summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--build-ant-macros.xml4
-rw-r--r--build.examples.xml256
-rwxr-xr-xbuild.xml253
-rw-r--r--dbuild-meta.json30
-rw-r--r--docs/LICENSE36
-rw-r--r--docs/README58
-rw-r--r--docs/examples/actors/auction.scala131
-rw-r--r--docs/examples/actors/boundedbuffer.scala37
-rw-r--r--docs/examples/actors/channels.scala32
-rw-r--r--docs/examples/actors/fringe.scala82
-rw-r--r--docs/examples/actors/links.scala47
-rw-r--r--docs/examples/actors/looping.scala26
-rw-r--r--docs/examples/actors/message.scala40
-rw-r--r--docs/examples/actors/pingpong.scala61
-rw-r--r--docs/examples/actors/producers.scala114
-rw-r--r--docs/examples/actors/seq.scala15
-rw-r--r--docs/examples/boundedbuffer.scala46
-rw-r--r--docs/examples/computeserver.scala54
-rw-r--r--docs/examples/expressions/expressions-current.scala68
-rw-r--r--docs/examples/fors.scala112
-rw-r--r--docs/examples/futures.scala17
-rw-r--r--docs/examples/gadts.scala22
-rw-r--r--docs/examples/iterators.scala28
-rw-r--r--docs/examples/jolib/Ref.scala55
-rw-r--r--docs/examples/jolib/parallelOr.scala58
-rw-r--r--docs/examples/maps.scala187
-rw-r--r--docs/examples/monads/callccInterpreter.scala86
-rw-r--r--docs/examples/monads/directInterpreter.scala55
-rw-r--r--docs/examples/monads/errorInterpreter.scala86
-rw-r--r--docs/examples/monads/simpleInterpreter.scala75
-rw-r--r--docs/examples/monads/stateInterpreter.scala86
-rw-r--r--docs/examples/oneplacebuffer.scala64
-rw-r--r--docs/examples/parsing/ArithmeticParser.scala57
-rw-r--r--docs/examples/parsing/ArithmeticParsers.scala70
-rw-r--r--docs/examples/parsing/JSON.scala44
-rw-r--r--docs/examples/parsing/ListParser.scala33
-rw-r--r--docs/examples/parsing/ListParsers.scala30
-rw-r--r--docs/examples/parsing/MiniML.scala52
-rw-r--r--docs/examples/parsing/lambda/Main.scala34
-rw-r--r--docs/examples/parsing/lambda/TestParser.scala68
-rw-r--r--docs/examples/parsing/lambda/TestSyntax.scala86
-rw-r--r--docs/examples/parsing/lambda/test/test-01.kwi1
-rw-r--r--docs/examples/parsing/lambda/test/test-02.kwi1
-rw-r--r--docs/examples/parsing/lambda/test/test-03.kwi1
-rw-r--r--docs/examples/parsing/lambda/test/test-04.kwi1
-rw-r--r--docs/examples/parsing/lambda/test/test-05.kwi1
-rw-r--r--docs/examples/parsing/lambda/test/test-06.kwi1
-rw-r--r--docs/examples/parsing/lambda/test/test-07.kwi1
-rw-r--r--docs/examples/parsing/lambda/test/test-08.kwi1
-rw-r--r--docs/examples/patterns.scala36
-rw-r--r--docs/examples/pilib/elasticBuffer.scala77
-rw-r--r--docs/examples/pilib/handover.scala186
-rw-r--r--docs/examples/pilib/mobilePhoneProtocol.scala172
-rw-r--r--docs/examples/pilib/piNat.scala89
-rw-r--r--docs/examples/pilib/rwlock.scala329
-rw-r--r--docs/examples/pilib/scheduler.scala150
-rw-r--r--docs/examples/pilib/semaphore.scala72
-rw-r--r--docs/examples/pilib/twoPlaceBuffer.scala67
-rw-r--r--docs/examples/plugintemplate/build.xml265
-rw-r--r--docs/examples/plugintemplate/doc/README68
-rw-r--r--docs/examples/plugintemplate/doc/examples/plugintemplate/examples/BasicExample.scala8
-rw-r--r--docs/examples/plugintemplate/lib/scalatest.jar.desired.sha11
-rw-r--r--docs/examples/plugintemplate/misc/scalac-plugin.xml4
-rw-r--r--docs/examples/plugintemplate/plugin.properties10
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/PluginProperties.scala61
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/TemplateAnnotationChecker.scala20
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/TemplateComponent.scala35
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/TemplateInfoTransformComponent.scala79
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/TemplatePlugin.scala52
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/TemplateTransformComponent.scala58
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/TemplateTraverseComponent.scala32
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala44
-rw-r--r--docs/examples/plugintemplate/src/plugintemplate/standalone/PluginRunner.scala36
-rw-r--r--docs/examples/plugintemplate/test/plugintemplate/PluginPropertiesSuite.scala14
-rw-r--r--docs/examples/plugintemplate/test/plugintemplate/TemplatePluginSuite.scala22
-rw-r--r--docs/examples/sort.scala48
-rw-r--r--docs/examples/sort1.scala22
-rw-r--r--docs/examples/sort2.scala25
-rw-r--r--docs/examples/swing/ButtonApp.scala24
-rw-r--r--docs/examples/swing/CelsiusConverter.scala42
-rw-r--r--docs/examples/swing/CelsiusConverter2.scala36
-rw-r--r--docs/examples/swing/ComboBoxes.scala86
-rw-r--r--docs/examples/swing/CountButton.scala30
-rw-r--r--docs/examples/swing/Dialogs.scala176
-rw-r--r--docs/examples/swing/GridBagDemo.scala64
-rw-r--r--docs/examples/swing/HelloWorld.scala13
-rw-r--r--docs/examples/swing/LabelTest.scala19
-rw-r--r--docs/examples/swing/LinePainting.scala53
-rw-r--r--docs/examples/swing/ListViewDemo.scala17
-rw-r--r--docs/examples/swing/SimpleApplet.scala18
-rw-r--r--docs/examples/swing/SwingApp.scala29
-rw-r--r--docs/examples/swing/TableSelection.scala96
-rw-r--r--docs/examples/swing/UIDemo.scala147
-rw-r--r--docs/examples/swing/images/banana.jpgbin6000 -> 0 bytes
-rw-r--r--docs/examples/swing/images/margarita1.jpgbin14770 -> 0 bytes
-rw-r--r--docs/examples/swing/images/margarita2.jpgbin17310 -> 0 bytes
-rw-r--r--docs/examples/swing/images/rose.jpgbin13808 -> 0 bytes
-rw-r--r--docs/examples/tcpoly/collection/HOSeq.scala167
-rw-r--r--docs/examples/tcpoly/monads/Monads.scala69
-rw-r--r--docs/examples/typeinf.scala253
-rw-r--r--docs/examples/xml/phonebook/embeddedBook.scala26
-rw-r--r--docs/examples/xml/phonebook/phonebook.scala38
-rw-r--r--docs/examples/xml/phonebook/phonebook1.scala21
-rw-r--r--docs/examples/xml/phonebook/phonebook2.scala25
-rw-r--r--docs/examples/xml/phonebook/phonebook3.scala81
-rw-r--r--docs/examples/xml/phonebook/verboseBook.scala24
-rw-r--r--docs/licenses/apache_android.txt16
-rw-r--r--docs/licenses/apache_ant.txt16
-rw-r--r--docs/licenses/apache_jansi.txt203
-rw-r--r--docs/licenses/bsd_asm.txt31
-rw-r--r--docs/licenses/bsd_jline.txt2
-rw-r--r--src/build/bnd/continuations.bnd5
-rw-r--r--src/build/bnd/scala-continuations-library.bnd5
-rw-r--r--src/build/bnd/scala-continuations-plugin.bnd5
-rw-r--r--src/build/bnd/scala-swing.bnd2
-rw-r--r--src/build/dbuild-meta-json-gen.scala7
-rw-r--r--src/build/maven/maven-deploy.xml2
-rw-r--r--src/build/maven/plugins/continuations-pom.xml59
-rw-r--r--src/build/maven/scala-swing-pom.xml62
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Validators.scala2
-rw-r--r--src/compiler/scala/reflect/macros/contexts/Typers.scala8
-rw-r--r--src/compiler/scala/reflect/macros/util/Helpers.scala8
-rw-r--r--src/compiler/scala/reflect/reify/Taggers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala19
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala5
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala6
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala93
-rw-r--r--src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala15
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugins.scala21
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala44
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala26
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala22
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala13
-rw-r--r--src/compiler/scala/tools/nsc/transform/Flatten.scala28
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala16
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Statics.scala52
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala76
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala73
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala343
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala18
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala56
-rw-r--r--src/compiler/scala/tools/reflect/FastTrack.scala24
-rw-r--r--src/compiler/scala/tools/reflect/ToolBox.scala12
-rw-r--r--src/compiler/scala/tools/reflect/ToolBoxFactory.scala6
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Holes.scala280
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala7
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala41
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala212
-rw-r--r--src/continuations/library/scala/util/continuations/ControlContext.scala249
-rw-r--r--src/continuations/library/scala/util/continuations/package.scala187
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala520
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala137
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala545
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala56
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala383
-rw-r--r--src/continuations/plugin/scalac-plugin.xml5
-rw-r--r--src/eclipse/continuations-library/.classpath8
-rw-r--r--src/eclipse/continuations-library/.project30
-rw-r--r--src/eclipse/continuations-library/.settings/org.scala-ide.sdt.core.prefs2
-rw-r--r--src/eclipse/reflect/.classpath1
-rw-r--r--src/eclipse/scala-compiler/.classpath1
-rw-r--r--src/eclipse/test-junit/.classpath1
-rw-r--r--src/intellij/continuations-library.iml.SAMPLE23
-rw-r--r--src/intellij/continuations-plugin.iml.SAMPLE25
-rw-r--r--src/intellij/parser-combinators.iml.SAMPLE22
-rw-r--r--src/intellij/partest.iml.SAMPLE24
-rw-r--r--src/intellij/scala-lang.ipr.SAMPLE6
-rw-r--r--src/intellij/swing.iml.SAMPLE24
-rw-r--r--src/intellij/xml.iml.SAMPLE22
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala18
-rw-r--r--src/library/scala/MatchError.scala10
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala51
-rw-r--r--src/library/scala/collection/immutable/HashSet.scala22
-rw-r--r--src/library/scala/collection/immutable/List.scala58
-rw-r--r--src/library/scala/collection/immutable/Queue.scala17
-rw-r--r--src/library/scala/collection/immutable/Stream.scala2
-rw-r--r--src/library/scala/concurrent/SyncVar.scala16
-rw-r--r--src/reflect/scala/reflect/api/BuildUtils.scala59
-rw-r--r--src/reflect/scala/reflect/api/Liftable.scala32
-rw-r--r--src/reflect/scala/reflect/api/Liftables.scala30
-rw-r--r--src/reflect/scala/reflect/api/Printers.scala2
-rw-r--r--src/reflect/scala/reflect/api/StandardLiftables.scala234
-rw-r--r--src/reflect/scala/reflect/api/Universe.scala1
-rw-r--r--src/reflect/scala/reflect/internal/BuildUtils.scala137
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala3
-rw-r--r--src/reflect/scala/reflect/internal/Mirrors.scala3
-rw-r--r--src/reflect/scala/reflect/internal/StdAttachments.scala3
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala15
-rw-r--r--src/reflect/scala/reflect/internal/SymbolTable.scala3
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala21
-rw-r--r--src/reflect/scala/reflect/internal/TreeGen.scala5
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala13
-rw-r--r--src/reflect/scala/reflect/internal/util/StringOps.scala16
-rw-r--r--src/reflect/scala/reflect/macros/Typers.scala12
-rw-r--r--src/reflect/scala/reflect/runtime/JavaUniverseForce.scala5
-rw-r--r--src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala5
-rw-r--r--src/swing/doc/README39
-rw-r--r--src/swing/doc/build.xml83
-rw-r--r--src/swing/scala/swing/AbstractButton.scala87
-rw-r--r--src/swing/scala/swing/Action.scala162
-rw-r--r--src/swing/scala/swing/Adjustable.scala53
-rw-r--r--src/swing/scala/swing/Alignment.scala32
-rw-r--r--src/swing/scala/swing/Applet.scala46
-rw-r--r--src/swing/scala/swing/BorderPanel.scala60
-rw-r--r--src/swing/scala/swing/BoxPanel.scala26
-rw-r--r--src/swing/scala/swing/BufferWrapper.scala34
-rw-r--r--src/swing/scala/swing/Button.scala34
-rw-r--r--src/swing/scala/swing/ButtonGroup.scala38
-rw-r--r--src/swing/scala/swing/CheckBox.scala26
-rw-r--r--src/swing/scala/swing/ColorChooser.scala45
-rw-r--r--src/swing/scala/swing/ComboBox.scala209
-rw-r--r--src/swing/scala/swing/Component.scala295
-rw-r--r--src/swing/scala/swing/Container.scala64
-rw-r--r--src/swing/scala/swing/EditorPane.scala28
-rw-r--r--src/swing/scala/swing/FileChooser.scala111
-rw-r--r--src/swing/scala/swing/FlowPanel.scala46
-rw-r--r--src/swing/scala/swing/FormattedTextField.scala40
-rw-r--r--src/swing/scala/swing/GridBagPanel.scala114
-rw-r--r--src/swing/scala/swing/GridPanel.scala51
-rw-r--r--src/swing/scala/swing/Label.scala62
-rw-r--r--src/swing/scala/swing/LayoutContainer.scala73
-rw-r--r--src/swing/scala/swing/ListView.scala246
-rw-r--r--src/swing/scala/swing/MainFrame.scala17
-rw-r--r--src/swing/scala/swing/Menu.scala70
-rw-r--r--src/swing/scala/swing/Orientable.scala27
-rw-r--r--src/swing/scala/swing/Orientation.scala19
-rw-r--r--src/swing/scala/swing/Oriented.scala35
-rw-r--r--src/swing/scala/swing/Panel.scala20
-rw-r--r--src/swing/scala/swing/PasswordField.scala34
-rw-r--r--src/swing/scala/swing/PopupMenu.scala65
-rw-r--r--src/swing/scala/swing/ProgressBar.scala40
-rw-r--r--src/swing/scala/swing/Publisher.scala2
-rw-r--r--src/swing/scala/swing/RadioButton.scala25
-rw-r--r--src/swing/scala/swing/Reactions.scala54
-rw-r--r--src/swing/scala/swing/Reactor.scala30
-rw-r--r--src/swing/scala/swing/RichWindow.scala195
-rw-r--r--src/swing/scala/swing/RootPanel.scala38
-rw-r--r--src/swing/scala/swing/ScrollBar.scala39
-rw-r--r--src/swing/scala/swing/ScrollPane.scala88
-rw-r--r--src/swing/scala/swing/Scrollable.scala43
-rw-r--r--src/swing/scala/swing/Separator.scala23
-rw-r--r--src/swing/scala/swing/SequentialContainer.scala36
-rw-r--r--src/swing/scala/swing/SimpleSwingApplication.scala36
-rw-r--r--src/swing/scala/swing/Slider.scala71
-rw-r--r--src/swing/scala/swing/SplitPane.scala63
-rw-r--r--src/swing/scala/swing/Swing.scala141
-rw-r--r--src/swing/scala/swing/SwingApplication.scala17
-rw-r--r--src/swing/scala/swing/TabbedPane.scala131
-rw-r--r--src/swing/scala/swing/Table.scala320
-rw-r--r--src/swing/scala/swing/TextArea.scala43
-rw-r--r--src/swing/scala/swing/TextComponent.scala75
-rw-r--r--src/swing/scala/swing/TextField.scala79
-rw-r--r--src/swing/scala/swing/ToggleButton.scala22
-rw-r--r--src/swing/scala/swing/UIElement.scala133
-rw-r--r--src/swing/scala/swing/Window.scala78
-rw-r--r--src/swing/scala/swing/event/ActionEvent.scala18
-rw-r--r--src/swing/scala/swing/event/AdjustingEvent.scala24
-rw-r--r--src/swing/scala/swing/event/BackgroundChanged.scala14
-rw-r--r--src/swing/scala/swing/event/ButtonClicked.scala15
-rw-r--r--src/swing/scala/swing/event/CaretUpdate.scala14
-rw-r--r--src/swing/scala/swing/event/ColorChanged.scala14
-rw-r--r--src/swing/scala/swing/event/ComponentEvent.scala16
-rw-r--r--src/swing/scala/swing/event/ContainerEvent.scala17
-rw-r--r--src/swing/scala/swing/event/EditDone.scala14
-rw-r--r--src/swing/scala/swing/event/Event.scala14
-rw-r--r--src/swing/scala/swing/event/FocusEvent.scala23
-rw-r--r--src/swing/scala/swing/event/FontChanged.scala14
-rw-r--r--src/swing/scala/swing/event/ForegroundChanged.scala14
-rw-r--r--src/swing/scala/swing/event/InputEvent.scala20
-rw-r--r--src/swing/scala/swing/event/Key.scala232
-rw-r--r--src/swing/scala/swing/event/KeyEvent.scala43
-rw-r--r--src/swing/scala/swing/event/ListEvent.scala43
-rw-r--r--src/swing/scala/swing/event/MouseEvent.scala79
-rw-r--r--src/swing/scala/swing/event/PopupMenuEvent.scala18
-rw-r--r--src/swing/scala/swing/event/SelectionEvent.scala34
-rw-r--r--src/swing/scala/swing/event/TableEvent.scala46
-rw-r--r--src/swing/scala/swing/event/UIEvent.scala21
-rw-r--r--src/swing/scala/swing/event/ValueChanged.scala18
-rw-r--r--src/swing/scala/swing/event/WindowActivated.scala14
-rw-r--r--src/swing/scala/swing/event/WindowClosed.scala4
-rw-r--r--src/swing/scala/swing/event/WindowClosing.scala14
-rw-r--r--src/swing/scala/swing/event/WindowDeactivated.scala14
-rw-r--r--src/swing/scala/swing/event/WindowDeiconified.scala14
-rw-r--r--src/swing/scala/swing/event/WindowEvent.scala14
-rw-r--r--src/swing/scala/swing/event/WindowIconified.scala14
-rw-r--r--src/swing/scala/swing/event/WindowOpened.scala14
-rw-r--r--src/swing/scala/swing/model/Matrix.scala121
-rw-r--r--src/swing/scala/swing/package.scala20
-rw-r--r--src/swing/swing.version.properties2
-rw-r--r--test/disabled/continuations-neg/infer0.check4
-rw-r--r--test/disabled/continuations-neg/infer0.scala12
-rw-r--r--test/files/continuations-neg/function0.check6
-rw-r--r--test/files/continuations-neg/function0.scala16
-rw-r--r--test/files/continuations-neg/function2.check6
-rw-r--r--test/files/continuations-neg/function2.scala16
-rw-r--r--test/files/continuations-neg/function3.check6
-rw-r--r--test/files/continuations-neg/function3.scala15
-rw-r--r--test/files/continuations-neg/infer2.check4
-rw-r--r--test/files/continuations-neg/infer2.scala19
-rw-r--r--test/files/continuations-neg/lazy.check4
-rw-r--r--test/files/continuations-neg/lazy.scala16
-rw-r--r--test/files/continuations-neg/t1929.check6
-rw-r--r--test/files/continuations-neg/t1929.scala17
-rw-r--r--test/files/continuations-neg/t2285.check6
-rw-r--r--test/files/continuations-neg/t2285.scala11
-rw-r--r--test/files/continuations-neg/t2949.check6
-rw-r--r--test/files/continuations-neg/t2949.scala15
-rw-r--r--test/files/continuations-neg/t3628.check4
-rw-r--r--test/files/continuations-neg/t3628.scala11
-rw-r--r--test/files/continuations-neg/t3718.check4
-rw-r--r--test/files/continuations-neg/t3718.scala3
-rw-r--r--test/files/continuations-neg/t5314-missing-result-type.check4
-rw-r--r--test/files/continuations-neg/t5314-missing-result-type.scala13
-rw-r--r--test/files/continuations-neg/t5314-npe.check4
-rw-r--r--test/files/continuations-neg/t5314-npe.scala3
-rw-r--r--test/files/continuations-neg/t5314-return-reset.check4
-rw-r--r--test/files/continuations-neg/t5314-return-reset.scala21
-rw-r--r--test/files/continuations-neg/t5314-type-error.check6
-rw-r--r--test/files/continuations-neg/t5314-type-error.scala17
-rw-r--r--test/files/continuations-neg/t5445.check4
-rw-r--r--test/files/continuations-neg/t5445.scala5
-rw-r--r--test/files/continuations-neg/trycatch2.check7
-rw-r--r--test/files/continuations-neg/trycatch2.scala33
-rwxr-xr-xtest/files/continuations-run/basics.check2
-rwxr-xr-xtest/files/continuations-run/basics.scala23
-rw-r--r--test/files/continuations-run/function1.check1
-rw-r--r--test/files/continuations-run/function1.scala16
-rw-r--r--test/files/continuations-run/function4.check1
-rw-r--r--test/files/continuations-run/function4.scala15
-rw-r--r--test/files/continuations-run/function5.check1
-rw-r--r--test/files/continuations-run/function5.scala15
-rw-r--r--test/files/continuations-run/function6.check1
-rw-r--r--test/files/continuations-run/function6.scala16
-rw-r--r--test/files/continuations-run/ifelse0.scala18
-rw-r--r--test/files/continuations-run/ifelse1.check4
-rw-r--r--test/files/continuations-run/ifelse1.scala25
-rw-r--r--test/files/continuations-run/ifelse2.check4
-rw-r--r--test/files/continuations-run/ifelse2.scala16
-rw-r--r--test/files/continuations-run/ifelse3.check2
-rw-r--r--test/files/continuations-run/ifelse3.scala21
-rw-r--r--test/files/continuations-run/ifelse4.check4
-rw-r--r--test/files/continuations-run/ifelse4.scala31
-rw-r--r--test/files/continuations-run/implicit-infer-annotations.check5
-rw-r--r--test/files/continuations-run/implicit-infer-annotations.scala59
-rw-r--r--test/files/continuations-run/infer1.scala33
-rw-r--r--test/files/continuations-run/match0.check2
-rw-r--r--test/files/continuations-run/match0.scala18
-rw-r--r--test/files/continuations-run/match1.check2
-rw-r--r--test/files/continuations-run/match1.scala18
-rw-r--r--test/files/continuations-run/match2.check2
-rw-r--r--test/files/continuations-run/match2.scala26
-rw-r--r--test/files/continuations-run/patvirt.check2
-rw-r--r--test/files/continuations-run/patvirt.scala32
-rw-r--r--test/files/continuations-run/shift-pct.check25
-rw-r--r--test/files/continuations-run/shift-pct.scala30
-rw-r--r--test/files/continuations-run/t1807.check1
-rw-r--r--test/files/continuations-run/t1807.scala14
-rw-r--r--test/files/continuations-run/t1808.scala10
-rw-r--r--test/files/continuations-run/t1820.scala14
-rw-r--r--test/files/continuations-run/t1821.check4
-rw-r--r--test/files/continuations-run/t1821.scala20
-rw-r--r--test/files/continuations-run/t2864.check1
-rw-r--r--test/files/continuations-run/t2864.scala30
-rw-r--r--test/files/continuations-run/t2934.check1
-rw-r--r--test/files/continuations-run/t2934.scala10
-rw-r--r--test/files/continuations-run/t3199.check1
-rw-r--r--test/files/continuations-run/t3199.scala20
-rw-r--r--test/files/continuations-run/t3223.check1
-rw-r--r--test/files/continuations-run/t3223.scala19
-rw-r--r--test/files/continuations-run/t3225.check12
-rw-r--r--test/files/continuations-run/t3225.scala56
-rw-r--r--test/files/continuations-run/t3501.check5
-rw-r--r--test/files/continuations-run/t3501.scala15
-rw-r--r--test/files/continuations-run/t5314-2.check5
-rw-r--r--test/files/continuations-run/t5314-2.scala44
-rw-r--r--test/files/continuations-run/t5314-3.check4
-rw-r--r--test/files/continuations-run/t5314-3.scala27
-rw-r--r--test/files/continuations-run/t5314-with-if.check1
-rw-r--r--test/files/continuations-run/t5314-with-if.scala17
-rw-r--r--test/files/continuations-run/t5314.check14
-rw-r--r--test/files/continuations-run/t5314.scala52
-rw-r--r--test/files/continuations-run/t5472.check25
-rw-r--r--test/files/continuations-run/t5472.scala91
-rw-r--r--test/files/continuations-run/t5506.check7
-rw-r--r--test/files/continuations-run/t5506.scala58
-rw-r--r--test/files/continuations-run/t5538.check2
-rw-r--r--test/files/continuations-run/t5538.scala52
-rw-r--r--test/files/continuations-run/trycatch0.check2
-rw-r--r--test/files/continuations-run/trycatch0.scala25
-rw-r--r--test/files/continuations-run/trycatch1.check10
-rw-r--r--test/files/continuations-run/trycatch1.scala48
-rw-r--r--test/files/continuations-run/while0.check1
-rw-r--r--test/files/continuations-run/while0.scala22
-rw-r--r--test/files/continuations-run/while1.check11
-rw-r--r--test/files/continuations-run/while1.scala22
-rw-r--r--test/files/continuations-run/while2.check19
-rw-r--r--test/files/continuations-run/while2.scala23
-rw-r--r--test/files/continuations-run/z1673.scala31
-rw-r--r--test/files/instrumented/InstrumentationTest.check4
-rw-r--r--test/files/instrumented/InstrumentationTest.scala27
-rw-r--r--test/files/instrumented/inline-in-constructors.check4
-rw-r--r--test/files/instrumented/inline-in-constructors/test_3.scala21
-rw-r--r--test/files/jvm/t5471.check (renamed from test/files/jvm/si5471.check)0
-rw-r--r--test/files/jvm/t5471.scala (renamed from test/files/jvm/si5471.scala)0
-rw-r--r--test/files/neg/checksensible.check17
-rw-r--r--test/files/neg/compile-time-only-a.check70
-rw-r--r--test/files/neg/compile-time-only-a.scala19
-rw-r--r--test/files/neg/compile-time-only-b.check8
-rw-r--r--test/files/neg/macro-blackbox-extractor/Macros_1.scala2
-rw-r--r--test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala2
-rw-r--r--test/files/neg/macro-bundle-object.check2
-rw-r--r--test/files/neg/macro-invalidret.check22
-rw-r--r--test/files/neg/macro-invalidret.flags4
-rw-r--r--test/files/neg/macro-invalidret/Impls_1.scala3
-rw-r--r--test/files/neg/macro-invalidret/Macros_Test_2.scala8
-rw-r--r--test/files/neg/macro-invalidsig-params-badtype.check2
-rw-r--r--test/files/neg/macro-invalidsig.check30
-rw-r--r--test/files/neg/macro-invalidsig/Macros_Test_2.scala6
-rw-r--r--test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala2
-rw-r--r--test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala2
-rw-r--r--test/files/neg/macro-invalidusage-badtargs.check10
-rw-r--r--test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala12
-rw-r--r--test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala2
-rw-r--r--test/files/neg/macro-override-macro-overrides-abstract-method-a.check2
-rw-r--r--test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala2
-rw-r--r--test/files/neg/macro-override-method-overrides-macro.check2
-rw-r--r--test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala14
-rw-r--r--test/files/neg/macro-quasiquotes.check6
-rw-r--r--test/files/neg/macro-quasiquotes/Macros_1.scala6
-rw-r--r--test/files/neg/macro-reify-splice-splice.check7
-rw-r--r--test/files/neg/macro-reify-splice-splice.flags (renamed from test/files/run/macro-reify-splice-splice.flags)0
-rw-r--r--test/files/neg/macro-reify-splice-splice/Macros_1.scala (renamed from test/files/run/macro-reify-splice-splice/Macros_1.scala)0
-rw-r--r--test/files/neg/macro-reify-splice-splice/Test_2.scala (renamed from test/files/run/macro-reify-splice-splice/Test_2.scala)0
-rw-r--r--test/files/neg/patmat-classtag-compound.check6
-rw-r--r--test/files/neg/patmat-classtag-compound.flags1
-rw-r--r--test/files/neg/patmat-classtag-compound.scala17
-rw-r--r--test/files/neg/quasiquotes-unliftable-not-found.check4
-rw-r--r--test/files/neg/quasiquotes-unliftable-not-found.scala5
-rw-r--r--test/files/neg/si7980.check4
-rw-r--r--test/files/neg/si7980.scala8
-rw-r--r--test/files/neg/t4928.check2
-rw-r--r--test/files/neg/t5426.check8
-rw-r--r--test/files/neg/t5663-badwarneq.check5
-rw-r--r--test/files/neg/t5753/Impls_Macros_1.scala2
-rw-r--r--test/files/neg/t5753/Test_2.scala2
-rw-r--r--test/files/neg/t5903a/Macros_1.scala2
-rw-r--r--test/files/neg/t5903b/Macros_1.scala2
-rw-r--r--test/files/neg/t5903c/Macros_1.scala2
-rw-r--r--test/files/neg/t5903d/Macros_1.scala2
-rw-r--r--test/files/neg/t5903e/Macros_1.scala2
-rw-r--r--test/files/neg/t6231.check6
-rw-r--r--test/files/neg/t6231.flags1
-rw-r--r--test/files/neg/t6355.check7
-rw-r--r--test/files/neg/t6355a.check7
-rw-r--r--test/files/neg/t6355a.scala (renamed from test/files/neg/t6355.scala)0
-rw-r--r--test/files/neg/t6355b.check11
-rw-r--r--test/files/neg/t6355b.scala17
-rwxr-xr-xtest/files/neg/t6446-missing.check2
-rw-r--r--test/files/neg/t6539.check8
-rw-r--r--test/files/neg/t6920.check6
-rw-r--r--test/files/neg/t6920.scala10
-rw-r--r--test/files/neg/t712.check1
-rw-r--r--test/files/neg/t7519-b.check2
-rw-r--r--test/files/neg/t7519-b/Use_2.scala2
-rw-r--r--test/files/neg/t7756b.check5
-rw-r--r--test/files/neg/t8006.check6
-rw-r--r--test/files/neg/t8006.scala8
-rw-r--r--test/files/neg/t8024.check6
-rw-r--r--test/files/neg/t8024.scala14
-rw-r--r--test/files/neg/t8024b.check6
-rw-r--r--test/files/neg/t8024b.scala17
-rw-r--r--test/files/neg/t8104.check4
-rw-r--r--test/files/neg/t8104/Macros_1.scala11
-rw-r--r--test/files/neg/t8104/Test_2.scala21
-rw-r--r--test/files/pos/attachments-typed-another-ident/Impls_1.scala2
-rw-r--r--test/files/pos/attachments-typed-ident/Impls_1.scala2
-rw-r--r--test/files/pos/macro-implicit-invalidate-on-error.scala17
-rw-r--r--test/files/pos/t5508-min-okay.scala6
-rw-r--r--test/files/pos/t5508-min-okay2.scala4
-rw-r--r--test/files/pos/t5508-min.scala6
-rw-r--r--test/files/pos/t5508.scala83
-rw-r--r--test/files/pos/t6231.scala (renamed from test/files/neg/t6231.scala)0
-rw-r--r--test/files/pos/t6231b.scala8
-rw-r--r--test/files/pos/t6780.scala20
-rw-r--r--test/files/pos/t7377/Macro_1.scala2
-rw-r--r--test/files/pos/t7461/Macros_1.scala2
-rw-r--r--test/files/pos/t8001/Macros_1.scala2
-rw-r--r--test/files/pos/t8013.flags1
-rw-r--r--test/files/pos/t8013/inpervolated_2.scala11
-rw-r--r--test/files/pos/t8013/inpervolator_1.scala33
-rw-r--r--test/files/pos/t8054.scala31
-rw-r--r--test/files/pos/t8060.scala11
-rw-r--r--test/files/presentation/ide-t1001326.check4
-rw-r--r--test/files/presentation/ide-t1001326/src/a/A.scala5
-rw-r--r--test/files/presentation/parse-invariants.check5
-rw-r--r--test/files/presentation/parse-invariants/Test.scala (renamed from test/files/presentation/ide-t1001326/Test.scala)32
-rw-r--r--test/files/presentation/parse-invariants/src/a/A.scala138
-rw-r--r--test/files/presentation/scope-completion-2.check16
-rw-r--r--test/files/presentation/scope-completion-2/src/Completions.scala16
-rw-r--r--test/files/presentation/scope-completion-3.check16
-rw-r--r--test/files/presentation/scope-completion-import.check114
-rw-r--r--test/files/presentation/scope-completion-import/src/Completions.scala8
-rw-r--r--test/files/run/idempotency-case-classes.scala2
-rw-r--r--test/files/run/idempotency-extractors.scala2
-rw-r--r--test/files/run/idempotency-labels.scala2
-rw-r--r--test/files/run/idempotency-lazy-vals.scala2
-rw-r--r--test/files/run/idempotency-this.scala2
-rw-r--r--test/files/run/iq.check4
-rw-r--r--test/files/run/iq.scala17
-rw-r--r--test/files/run/literals.check17
-rw-r--r--test/files/run/literals.scala23
-rw-r--r--test/files/run/macro-bodyexpandstoimpl/Impls_1.scala2
-rw-r--r--test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-bundle-repl.check4
-rw-r--r--test/files/run/macro-bundle-repl.scala4
-rw-r--r--test/files/run/macro-def-infer-return-type.check8
-rw-r--r--test/files/run/macro-def-infer-return-type.flags1
-rw-r--r--test/files/run/macro-def-infer-return-type/Impls_1.scala14
-rw-r--r--test/files/run/macro-def-infer-return-type/Macros_Test_2.scala24
-rw-r--r--test/files/run/macro-def-path-dependent/Test_1.scala48
-rw-r--r--test/files/run/macro-def-path-dependent/Test_2.scala2
-rw-r--r--test/files/run/macro-def-path-dependent/Test_4.scala2
-rw-r--r--test/files/run/macro-def-path-dependent/Test_6.scala2
-rw-r--r--test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala8
-rw-r--r--test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala8
-rw-r--r--test/files/run/macro-expand-overload/Macros_Test_2.scala12
-rw-r--r--test/files/run/macro-expand-override/Macros_Test_2.scala14
-rw-r--r--test/files/run/macro-expand-recursive/Macros_Test_2.scala4
-rw-r--r--test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala4
-rw-r--r--test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala8
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-quasiquotes/Macros_1.scala6
-rw-r--r--test/files/run/macro-reflective-mamd-normal-mi.check1
-rw-r--r--test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala4
-rw-r--r--test/files/run/macro-reify-nested-a/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-reify-nested-b/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-reify-ref-to-packageless/Test_2.scala2
-rw-r--r--test/files/run/macro-reify-splice-splice.check1
-rw-r--r--test/files/run/macro-reify-unreify/Macros_1.scala2
-rw-r--r--test/files/run/macro-repl-dontexpand.check4
-rw-r--r--test/files/run/macro-subpatterns.check3
-rw-r--r--test/files/run/macro-subpatterns/Macro_1.scala18
-rw-r--r--test/files/run/macro-subpatterns/Test_2.scala5
-rw-r--r--test/files/run/macro-system-properties.check2
-rw-r--r--test/files/run/macro-system-properties.scala2
-rw-r--r--test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-block/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-class/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-method/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-object/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala3
-rw-r--r--test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala2
-rw-r--r--test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled.check4
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2.check4
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala4
-rw-r--r--test/files/run/macro-vampire-false-warning/Macros_1.scala4
-rw-r--r--test/files/run/macro-whitebox-extractor/Macros_1.scala2
-rw-r--r--test/files/run/macro-whitebox-structural/Impls_Macros_1.scala2
-rw-r--r--test/files/run/reflection-mem-typecheck.scala2
-rw-r--r--test/files/run/reify_ann1a.scala2
-rw-r--r--test/files/run/reify_ann1b.scala2
-rw-r--r--test/files/run/reify_ann2a.scala2
-rw-r--r--test/files/run/reify_ann3.scala2
-rw-r--r--test/files/run/reify_ann4.scala2
-rw-r--r--test/files/run/reify_ann5.scala2
-rw-r--r--test/files/run/reify_classfileann_a.scala2
-rw-r--r--test/files/run/reify_classfileann_b.scala2
-rw-r--r--test/files/run/reify_renamed_term_t5841.check (renamed from test/files/run/reify_renamed_term_si5841.check)0
-rw-r--r--test/files/run/reify_renamed_term_t5841.scala (renamed from test/files/run/reify_renamed_term_si5841.scala)0
-rw-r--r--test/files/run/repl-term-macros.check6
-rw-r--r--test/files/run/repl-term-macros.scala6
-rw-r--r--test/files/run/resetattrs-this.scala2
-rw-r--r--test/files/run/showraw_aliases.scala2
-rw-r--r--test/files/run/showraw_tree_types_ids.scala4
-rw-r--r--test/files/run/showraw_tree_types_typed.scala4
-rw-r--r--test/files/run/showraw_tree_ultimate.scala4
-rw-r--r--test/files/run/t3199b.check (renamed from test/files/continuations-run/t3199b.check)0
-rw-r--r--test/files/run/t3199b.scala (renamed from test/files/continuations-run/t3199b.scala)0
-rw-r--r--test/files/run/t4750.check (renamed from test/files/run/si4750.check)0
-rw-r--r--test/files/run/t4750.scala (renamed from test/files/run/si4750.scala)0
-rw-r--r--test/files/run/t4841-isolate-plugins.check2
-rw-r--r--test/files/run/t4841-isolate-plugins/ploogin.scala30
-rw-r--r--test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala39
-rw-r--r--test/files/run/t4841-no-plugin.check1
-rw-r--r--test/files/run/t4841-no-plugin.scala17
-rw-r--r--test/files/run/t5045.check (renamed from test/files/run/si5045.check)0
-rw-r--r--test/files/run/t5045.scala (renamed from test/files/run/si5045.scala)0
-rw-r--r--test/files/run/t5415.scala2
-rw-r--r--test/files/run/t5418b.scala2
-rw-r--r--test/files/run/t5704.scala2
-rw-r--r--test/files/run/t5816.scala2
-rw-r--r--test/files/run/t5894.scala2
-rw-r--r--test/files/run/t5903a/Macros_1.scala2
-rw-r--r--test/files/run/t5903b/Macros_1.scala2
-rw-r--r--test/files/run/t5903c/Macros_1.scala2
-rw-r--r--test/files/run/t5903d/Macros_1.scala2
-rw-r--r--test/files/run/t5912.scala2
-rw-r--r--test/files/run/t5940.scala2
-rw-r--r--test/files/run/t5943a1.scala2
-rw-r--r--test/files/run/t6023.scala2
-rw-r--r--test/files/run/t6355.check2
-rw-r--r--test/files/run/t6355.scala17
-rw-r--r--test/files/run/t6381.check2
-rw-r--r--test/files/run/t6381.scala2
-rw-r--r--test/files/run/t6392b.scala2
-rw-r--r--test/files/run/t6992.check3
-rw-r--r--test/files/run/t6992/Macros_1.scala75
-rw-r--r--test/files/run/t6992/Test_2.scala12
-rw-r--r--test/files/run/t7185.check2
-rw-r--r--test/files/run/t7185.scala2
-rw-r--r--test/files/run/t7406.check (renamed from test/files/continuations-run/ifelse0.check)1
-rw-r--r--test/files/run/t7406.scala14
-rw-r--r--test/files/run/t7617b/Test_2.scala2
-rw-r--r--test/files/run/t7777.check7
-rw-r--r--test/files/run/t7777/Macros_1.scala17
-rw-r--r--test/files/run/t7777/Test_2.scala6
-rw-r--r--test/files/run/t7871/Macros_1.scala2
-rw-r--r--test/files/run/t7912.scala16
-rw-r--r--test/files/run/t8010.scala22
-rw-r--r--test/files/run/t8017.flags1
-rw-r--r--test/files/run/t8017/value-class-lambda.scala40
-rw-r--r--test/files/run/t8017/value-class.scala3
-rw-r--r--test/files/run/t8029.scala57
-rw-r--r--test/files/run/t8047.check7
-rw-r--r--test/files/run/t8047.scala31
-rw-r--r--test/files/run/t8048a.check1
-rw-r--r--test/files/run/t8048a/Macros_1.scala11
-rw-r--r--test/files/run/t8048a/Test_2.scala4
-rw-r--r--test/files/run/t8048b.check3
-rw-r--r--test/files/run/t8048b/Macros_1.scala37
-rw-r--r--test/files/run/t8048b/Test_2.scala5
-rw-r--r--test/files/run/t8091.check1
-rw-r--r--test/files/run/t8091.scala4
-rw-r--r--test/files/run/t8104.check1
-rw-r--r--test/files/run/t8104/Macros_1.scala11
-rw-r--r--test/files/run/t8104/Test_2.scala16
-rw-r--r--test/files/run/toolbox_current_run_compiles.scala2
-rw-r--r--test/files/run/toolbox_typecheck_implicitsdisabled.scala4
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled.check4
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled.scala4
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled2.check4
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled2.scala4
-rw-r--r--test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala11
-rw-r--r--test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala27
-rw-r--r--test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala16
-rw-r--r--test/files/scalacheck/quasiquotes/ErrorProps.scala21
-rw-r--r--test/files/scalacheck/quasiquotes/LiftableProps.scala35
-rw-r--r--test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala6
-rw-r--r--test/files/scalacheck/quasiquotes/RuntimeErrorProps.scala75
-rw-r--r--test/files/scalacheck/quasiquotes/TermConstructionProps.scala21
-rw-r--r--test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala6
-rw-r--r--test/files/scalacheck/quasiquotes/Test.scala2
-rw-r--r--test/files/scalacheck/quasiquotes/TypecheckedProps.scala25
-rw-r--r--test/files/scalacheck/quasiquotes/UnliftableProps.scala160
-rw-r--r--test/files/scalacheck/t4147.scala (renamed from test/files/scalacheck/si4147.scala)0
-rw-r--r--test/junit/scala/collection/QueueTest.scala28
-rw-r--r--test/junit/scala/reflect/internal/MirrorsTest.scala18
-rw-r--r--test/junit/scala/reflect/internal/util/StringOpsTest.scala52
-rw-r--r--test/pending/continuations-pos/t3620.scala73
-rw-r--r--test/pending/continuations-run/example0.scala9
-rw-r--r--test/pending/continuations-run/example1.scala9
-rw-r--r--test/pending/continuations-run/example16.scala9
-rw-r--r--test/pending/continuations-run/example2.scala9
-rw-r--r--test/pending/continuations-run/example3.scala9
-rw-r--r--test/pending/continuations-run/example4.scala9
-rw-r--r--test/pending/continuations-run/example5.scala9
-rw-r--r--test/pending/continuations-run/example6.scala9
-rw-r--r--test/pending/continuations-run/example7.scala9
-rw-r--r--test/pending/continuations-run/example8.scala9
-rw-r--r--test/pending/continuations-run/example9.scala9
-rw-r--r--test/pending/continuations-run/foreach.check4
-rw-r--r--test/pending/continuations-run/foreach.scala33
-rw-r--r--test/pending/run/idempotency-partial-functions.scala2
-rw-r--r--test/pending/run/t5943b1.scala2
-rw-r--r--test/scaladoc/run/SI-6812.scala6
-rwxr-xr-xtools/partest-ack29
-rwxr-xr-xtools/partest-paths27
-rw-r--r--versions.properties9
701 files changed, 3993 insertions, 17281 deletions
diff --git a/.gitignore b/.gitignore
index 766095fa4d..32a1665721 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,7 @@
/out/
/bin/
/sandbox/
+/.ant-targets-build.xml
# eclipse, intellij
/.classpath
diff --git a/build-ant-macros.xml b/build-ant-macros.xml
index 735e91ba7b..593f93b784 100644
--- a/build-ant-macros.xml
+++ b/build-ant-macros.xml
@@ -190,10 +190,6 @@
<and>
<available file="tools/zinc"/>
<equals arg1="@{stage}" arg2="quick"/>
- <not>
- <equals arg1="@{project}" arg2="continuations-plugins"/>
- </not>
- <!-- doesn't work in zinc because it requires the quick compiler, which isn't jarred up-->
</and>
<then>
<zinc taskname="Z.@{stage}.@{project}" compilerpathref="@{with}.compiler.path" destdir="${build-@{stage}.dir}/classes/@{destproject}" srcdir="${src.dir}/@{srcdir}" srcpath="@{srcpath}" buildpathref="@{stage}.@{project}.build.path" params="${scalac.args.@{stage}} @{args}" java-excludes="@{java-excludes}"/>
diff --git a/build.examples.xml b/build.examples.xml
deleted file mode 100644
index 82432121ca..0000000000
--- a/build.examples.xml
+++ /dev/null
@@ -1,256 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<project name="scala-examples" default="build">
-
- <description>
- I am SABBUS for ${ant.project.name}, the build system for the Scala compiler
- and core library. Please check the 'docs/README' file for more information
- about me.
- </description>
-
- <echo level="info" message="Running SABBUS for ${ant.project.name}..."/>
-
-<!-- ===========================================================================
-PROPERTIES
-============================================================================ -->
-
- <property environment="env"/>
-
- <!-- Prevents system classpath from being used -->
- <property name="build.sysclasspath" value="ignore"/>
-
- <!-- Base properties -->
- <property name="src.dir" value="${basedir}/docs"/>
- <property name="src.examples.dir" value="${src.dir}/examples"/>
- <property name="lib.dir" value="${basedir}/lib"/>
- <!-- User properties -->
- <property file="${basedir}/build.examples.properties"/>
- <!-- Location of pre-compiled libraries properties -->
- <property name="scala.lib.jar" value="${lib.dir}/scala-library.jar"/>
- <property name="scala.comp.jar" value="${lib.dir}/scala-compiler.jar"/>
- <property name="ant.jar" value="${ant.home}/lib/ant.jar"/>
- <property name="ant-contrib.jar" value="${lib.dir}/ant/ant-contrib.jar"/>
- <!-- -->
- <property name="build.dir" value="${basedir}/build"/>
- <property name="build.examples.dir" value="${build.dir}/examples"/>
- <!-- tbd -->
- <property name="excludes.compile"
- value="**/*current.*,**/parsers2.*,**/typeinf.*"/>
- <property name="excludes.run"
- value="**/Parsers.*"/>
-
-<!-- ===========================================================================
-INITIALISATION
-============================================================================ -->
-
- <target name="init" unless="init.avail">
- <tstamp prefix="start">
- <format
- property="human-time"
- pattern="EEEE, d MMMM yyyy, HH:mm:ss (zz)"
- />
- </tstamp>
- <!-- Testing if everything is in place -->
- <echo level="verbose" message="scala.lib.jar=${scala.lib.jar}"/>
- <fail message="Scala library in '${lib.dir}/' is not available">
- <condition><not><and>
- <available
- classname="scala.Predef"
- classpath="${scala.lib.jar}"
- />
- <available
- classname="scala.collection.immutable.List"
- classpath="${scala.lib.jar}"
- />
- <available
- classname="scala.runtime.ObjectRef"
- classpath="${scala.lib.jar}"
- />
- </and></not></condition>
- </fail>
- <echo level="verbose" message="scala.comp.jar=${scala.comp.jar}"/>
- <fail message="Scala compiler in '${lib.dir}/' is not available">
- <condition><not>
- <available
- classname="scala.tools.ant.Scalac"
- classpath="${scala.comp.jar}:${scala.lib.jar}"
- />
- </not></condition>
- </fail>
- <echo level="verbose" message="ant.jar=${ant.jar}"/>
- <echo level="verbose" message="ant-contrib.jar=${ant-contrib.jar}"/>
- <fail message="Additional Ant tasks in '${lib.dir}/' is not available">
- <condition><not>
- <available
- classname="net.sf.antcontrib.AntContribVersion"
- classpath="${ant-contrib.jar}"
- />
- </not></condition>
- </fail>
- <!-- Creating class-pathes -->
- <path id="scala.classpath">
- <pathelement location="${scala.lib.jar}"/>
- <pathelement location="${scala.comp.jar}"/>
- </path>
- <!-- Creating boot-level tasks -->
- <taskdef resource="net/sf/antcontrib/antlib.xml">
- <classpath>
- <pathelement location="${ant-contrib.jar}"/>
- </classpath>
- </taskdef>
- <!-- Finding out what system architecture is being used -->
- <condition property="os.win">
- <os family="windows"/>
- </condition>
- <if><isset property="os.win"/>
- <then>
- <exec
- executable="cygpath"
- vmlauncher="no"
- errorproperty="cygpath.err"
- outputproperty="cygpath.out"
- >
- <arg value="--windir"/>
- </exec>
- <condition property="os.cygwin">
- <equals arg1="${cygpath.err}" arg2=""/>
- </condition>
- </then>
- </if>
- <condition property="os.unix">
- <or>
- <os family="unix"/>
- <os family="mac"/>
- <isset property="os.cygwin"/>
- </or>
- </condition>
- <if><isset property="os.cygwin"/>
- <then><property name="os.type" value="Cygwin"/></then>
- <elseif><isset property="os.win"/>
- <then><property name="os.type" value="Windows"/></then>
- </elseif>
- <elseif><isset property="os.unix"/>
- <then><property name="os.type" value="UNIX"/></then>
- </elseif>
- <else>
- <fail>System environment could not be determined</fail>
- </else>
- </if>
- <echo
- level="info"
- message="OS: ${os.type} (${os.name} ${os.arch} ${os.version});"
- />
- <echo
- level="info"
- message="Java: ${java.version} ('${java.home}');"
- />
- <echo
- level="info"
- message="JVM: ${java.vm.name} ${java.vm.version};"
- />
- <echo
- level="info"
- message="Ant: ${ant.version}."
- />
- <property name="init.avail" value="yes"/>
- </target>
-
- <target name="setup" depends="init">
- <!-- Creating boot-level tasks -->
- <taskdef
- name="scalac"
- classname="scala.tools.ant.Scalac"
- classpathref="scala.classpath"
- />
- <property name="init.avail" value="yes"/>
- </target>
-
-<!-- ===========================================================================
-BUILD
-============================================================================ -->
-
- <target name="build" depends="setup">
- <mkdir dir="${build.dir}"/>
- <echo level="verbose">src.dir=${src.dir}</echo>
- <pathconvert property="list" pathsep=",">
- <path>
- <fileset
- dir="${src.dir}"
- includes="examples/*.scala"
- excludes="${excludes.compile}"
- />
- </path>
- <mapper>
- <globmapper from="${src.dir}/*" to="*"/>
- </mapper>
- </pathconvert>
- <for list="${list}" param="file">
- <sequential>
- <scalac srcdir="${src.dir}"
- destdir="${build.dir}" deprecation="true">
- <classpath>
- <pathelement location="${scala.lib.jar}"/>
- <pathelement location="${build.dir}"/>
- </classpath>
- <include name="@{file}"/>
- </scalac>
- </sequential>
- </for>
- </target>
-
-<!-- ===========================================================================
-RUN
-============================================================================ -->
-
- <target name="run" depends="build">
- <pathconvert property="list" pathsep=",">
- <path>
- <fileset
- dir="${src.dir}"
- includes="examples/*.scala"
- excludes="${excludes.run}"
- />
- </path>
- <mapper>
- <globmapper from="${src.dir}/*" to="*"/>
- </mapper>
- </pathconvert>
- <for list="${list}" param="file">
- <sequential>
- <var name="classname" unset="true"/>
- <basename property="classname" file="@{file}" suffix=".scala"/>
- <echo>Executing Scala program examples.${classname}..</echo>
- <java classname="examples.${classname}" fork="true"
- output="${build.examples.dir}/${classname}.log"
- error="${build.examples.dir}/${classname}.log"
- append="true">
- <classpath>
- <pathelement location="${scala.lib.jar}"/>
- <pathelement location="${build.dir}"/>
- </classpath>
- </java>
- </sequential>
- </for>
- </target>
-
-<!-- ===========================================================================
-CLEAN
-============================================================================ -->
-
- <macrodef name="remove">
- <attribute name="dir"/>
- <sequential>
- <delete
- dir="@{dir}"
- includeemptydirs="yes"
- quiet="yes"
- failonerror="no"
- />
- </sequential>
- </macrodef>
-
- <target name="clean" description="Removes all build examples">
- <remove dir="${build.examples.dir}"/>
- </target>
-
-</project>
diff --git a/build.xml b/build.xml
index 2fd6491510..53cd998f2d 100755
--- a/build.xml
+++ b/build.xml
@@ -107,6 +107,10 @@ TODO:
<target name="distclean" depends="dist.clean" description="Removes all distributions. Binaries and documentation are untouched."/>
+ <target name="test.continuations.suite">
+ <echo message="DEPRECATED: the continuations have moved to https://github.com/scala/scala-continuations"/>
+ </target>
+
<!-- ===========================================================================
PROPERTIES
============================================================================ -->
@@ -303,6 +307,9 @@ TODO:
<artifact:remoteRepository refid="extra-repo"/>
<dependency groupId="org.scala-lang.modules" artifactId="scala-xml_${scala.binary.version}" version="${scala-xml.version.number}"/>
<dependency groupId="org.scala-lang.modules" artifactId="scala-parser-combinators_${scala.binary.version}" version="${scala-parser-combinators.version.number}"/>
+ <dependency groupId="org.scala-lang.plugins" artifactId="scala-continuations-plugin_${scala.binary.version}" version="${scala-continuations-plugin.version.number}"/>
+ <dependency groupId="org.scala-lang.plugins" artifactId="scala-continuations-library_${scala.binary.version}" version="${scala-continuations-library.version.number}"/>
+ <dependency groupId="org.scala-lang.modules" artifactId="scala-swing_${scala.binary.version}" version="${scala-swing.version.number}"/>
</artifact:dependencies>
<!-- External modules, excluding the core -->
@@ -320,6 +327,9 @@ TODO:
<propertyForCrossedArtifact name="scala-parser-combinators" jar="org.scala-lang.modules:scala-parser-combinators"/>
<propertyForCrossedArtifact name="scala-xml" jar="org.scala-lang.modules:scala-xml"/>
+ <propertyForCrossedArtifact name="scala-continuations-plugin" jar="org.scala-lang.plugins:scala-continuations-plugin"/>
+ <propertyForCrossedArtifact name="scala-continuations-library" jar="org.scala-lang.plugins:scala-continuations-library"/>
+ <propertyForCrossedArtifact name="scala-swing" jar="org.scala-lang.modules:scala-swing"/>
<!-- BND support -->
<typedef resource="aQute/bnd/ant/taskdef.properties" classpathref="extra.tasks.classpath" />
@@ -406,13 +416,6 @@ TODO:
<fail if="has.unsupported.jdk" message="JDK ${ant.java.version} is not supported by this build!"/>
- <if><isset property="has.java7"/><then>
- <echo level="warning"> You are using JDK7 for this build.
- While this will be able to build most of Scala, it will not build the Swing project.
- You will be unable to create a distribution.
- </echo>
- </then></if>
-
<!-- Allow this to be overridden simply -->
<property name="sbt.latest.version" value="0.12.4"/>
@@ -560,17 +563,23 @@ TODO:
<property name="actors.description" value="Scala Actors Library"/>
- <property name="continuations-plugin.description" value="Scala Delimited Continuations Compiler Plugin"/>
- <property name="continuations-plugin.package" value="plugins." />
- <property name="continuations-plugin.dir" value="plugins/"/>
- <property name="continuations-plugin.name" value="continuations"/>
- <property name="continuations-plugin.targetdir" value="misc/scala-devel/plugins"/>
- <property name="continuations-plugin.srcdir" value="continuations/plugin"/>
+ <property name="swing.description" value="Scala Swing Library"/>
+ <property name="swing.package" value="modules."/>
+ <property name="swing.jar" value="${scala-swing}"/>
+ <property name="swing.src" value="false"/>
+ <property name="swing.srcjar" value="${scala-swing-sources}"/>
- <property name="continuations-library.description" value="Scala Delimited Continuations Library"/>
- <property name="continuations-library.srcdir" value="continuations/library"/>
+ <property name="continuations-plugin.description" value="Scala Delimited Continuations Compiler Plugin"/>
+ <property name="continuations-plugin.package" value="plugins." />
+ <property name="continuations-plugin.jar" value="${scala-continuations-plugin}"/>
+ <property name="continuations-plugin.src" value="false"/>
+ <property name="continuations-plugin.srcjar" value="${scala-continuations-plugin-sources}"/>
- <property name="swing.description" value="Scala Swing Library"/>
+ <property name="continuations-library.description" value="Scala Delimited Continuations Library"/>
+ <property name="continuations-library.package" value="plugins." />
+ <property name="continuations-library.jar" value="${scala-continuations-library}"/>
+ <property name="continuations-library.src" value="false"/>
+ <property name="continuations-library.srcjar" value="${scala-continuations-library-sources}"/>
<property name="parser-combinators.description" value="Scala Parser Combinators Library"/>
<property name="parser-combinators.package" value="modules."/>
@@ -592,12 +601,12 @@ TODO:
<property name="partest-javaagent.description" value="Scala Compiler Testing Tool (compiler-specific java agent)"/>
<!-- projects without project-specific options: asm, forkjoin, manual, bin, repl -->
- <for list="actors,compiler,interactive,scaladoc,continuations-library,continuations-plugin,library,parser-combinators,partest,partest-extras,partest-javaagent,reflect,scalap,swing,xml" param="project">
+ <for list="actors,compiler,interactive,scaladoc,library,parser-combinators,partest,partest-extras,partest-javaagent,reflect,scalap,swing,xml,continuations-plugin,continuations-library" param="project">
<sequential>
<!-- description is mandatory -->
- <init-project-prop project="@{project}" name="package" default=""/>
- <init-project-prop project="@{project}" name="dir" default=""/>
- <init-project-prop project="@{project}" name="name" default="scala-@{project}"/>
+ <init-project-prop project="@{project}" name="package" default=""/> <!-- used by mvn-package, copy-bundle, make-bundle -->
+ <init-project-prop project="@{project}" name="dir" default=""/> <!-- used by mvn-package -->
+ <init-project-prop project="@{project}" name="name" default="scala-@{project}"/> <!-- used for defaults in this block and by mvn-package, copy-bundle, make-bundle -->
<init-project-prop project="@{project}" name="namesuffix" default=""/>
<init-project-prop project="@{project}" name="version" default="${osgi.version.number}"/>
<init-project-prop project="@{project}" name="targetdir" default="lib"/>
@@ -641,7 +650,7 @@ TODO:
There must be a variable of the shape @{stage}.@{project}.build.path
for all @{stage} in locker, quick, strap
and all @{project} in library, reflect, compiler
- when stage is quick, @{project} also includes: actors, repl, swing, continuations-plugin, continuations-library, scalap
+ when stage is quick, @{project} also includes: actors, repl, scalap
NOTE: interactive, scaladoc, are only used upto quick; they are still packed into the compiler jar
-->
@@ -696,19 +705,6 @@ TODO:
<path refid="repl.deps.classpath"/>
</path>
- <path id="quick.swing.build.path">
- <path refid="quick.library.build.path"/>
- <pathelement location="${build-quick.dir}/classes/swing"/>
- </path>
-
- <path id="quick.continuations-plugin.build.path">
- <!-- plugins are run by locker compiler during quick stage,
- so must compile against the same classes the locker was compiled to
- -->
- <path refid="locker.compiler.build.path"/>
- <pathelement location="${build-quick.dir}/classes/continuations-plugin"/>
- </path>
-
<path id="quick.scalap.build.path">
<path refid="quick.compiler.build.path"/>
<pathelement location="${build-quick.dir}/classes/scalap"/>
@@ -743,7 +739,6 @@ TODO:
<path refid="quick.repl.build.path"/>
<path refid="quick.actors.build.path"/>
<pathelement location="${build-quick.dir}/classes/scalap"/>
- <pathelement location="${build-quick.dir}/classes/continuations-library"/>
<path refid="external-modules-nocore"/>
</path>
@@ -772,7 +767,6 @@ TODO:
<path id="pack.library.files">
<fileset dir="${build-quick.dir}/classes/library"/>
- <fileset dir="${build-quick.dir}/classes/continuations-library"/>
<fileset dir="${forkjoin-classes}"/>
</path>
@@ -795,9 +789,7 @@ TODO:
<path id="pack.interactive.files"><fileset dir="${build-quick.dir}/classes/interactive"/> </path>
-->
- <path id="pack.swing.files"> <fileset dir="${build-quick.dir}/classes/swing"/> </path>
<path id="pack.reflect.files"> <fileset dir="${build-quick.dir}/classes/reflect"/> </path>
- <path id="pack.continuations-plugin.files"> <fileset dir="${build-quick.dir}/classes/continuations-plugin"/> </path>
<path id="pack.scalap.files"> <fileset dir="${build-quick.dir}/classes/scalap"/>
<fileset file="${src.dir}/scalap/decoder.properties"/> </path>
@@ -829,10 +821,7 @@ TODO:
<path id="docs.scaladoc.build.path"> <path refid="quick.scaladoc.build.path"/> </path>
<path id="docs.interactive.build.path"> <path refid="quick.interactive.build.path"/> </path>
<path id="docs.scalap.build.path"> <path refid="quick.scalap.build.path"/> </path>
- <path id="docs.continuations-plugin.build.path"> <path refid="quick.continuations-plugin.build.path"/> </path>
- <path id="docs.continuations-library.build.path"> <path refid="quick.continuations-plugin.build.path"/> </path>
<path id="docs.actors.build.path"> <path refid="quick.actors.build.path"/> </path>
- <path id="docs.swing.build.path"> <path refid="quick.swing.build.path"/> </path>
<!-- run-time classpath for scaladoc TODO: resolve through maven -->
<path id="scaladoc.classpath">
@@ -905,6 +894,7 @@ TODO:
</restrict>
<pathelement location="${scala-xml}"/>
<pathelement location="${scala-parser-combinators}"/>
+ <!-- <pathelement location="${scala-swing}"/> -->
<restrict>
<path refid="scalacheck.classpath"/>
@@ -1071,38 +1061,9 @@ TODO:
<target name="quick.actors" depends="quick.lib">
<staged-build with="locker" stage="quick" project="actors"/> </target>
- <target name="quick.swing" depends="quick.actors, quick.lib" if="has.java6">
- <staged-build with="locker" stage="quick" project="swing"/> </target>
-
- <target name="quick.plugins" depends="quick.comp">
- <staged-uptodate stage="quick" project="continuations-plugin">
- <check><srcfiles dir="${src.dir}/continuations"/></check>
- <do>
- <stopwatch name="quick.continuations-plugin.timer"/>
-
- <mkdir dir="${build-quick.dir}/classes/continuations-plugin"/>
- <staged-scalac with="locker" stage="quick" project="continuations-plugin" srcdir="${continuations-plugin.srcdir}"/>
- <copy
- file="${src.dir}/${continuations-plugin.srcdir}/scalac-plugin.xml"
- todir="${build-quick.dir}/classes/continuations-plugin"/>
-
- <!-- not very nice to create jar here but needed to load plugin -->
- <mkdir dir="${build-quick.dir}/${continuations-plugin.targetdir}"/>
- <jar whenmanifestonly="fail" destfile="${build-quick.dir}/${continuations-plugin.targetdir}/continuations.jar" basedir="${build-quick.dir}/classes/continuations-plugin"/>
-
- <!-- might split off library part into its own ant target -->
- <mkdir dir="${build-quick.dir}/classes/continuations-library"/>
- <staged-scalac with="locker" stage="quick" project="continuations-plugin"
- srcdir="continuations/library" destproject="continuations-library"
- args="-Xplugin-require:continuations -P:continuations:enable -Xpluginsdir ${build-quick.dir}/${continuations-plugin.targetdir}"/>
-
- <stopwatch name="quick.continuations-plugin.timer" action="total"/>
- </do>
- </staged-uptodate>
- </target>
- <target name="quick.modules" depends="quick.repl, quick.scaladoc, quick.interactive, quick.scalap, quick.swing, quick.plugins"/>
+ <target name="quick.modules" depends="quick.repl, quick.scaladoc, quick.interactive, quick.scalap"/>
<target name="quick.bin" depends="quick.lib, quick.reflect, quick.comp, quick.modules">
<staged-bin stage="quick" classpathref="quick.bin.tool.path"/>
@@ -1115,7 +1076,7 @@ TODO:
<!-- ===========================================================================
PACKED QUICK BUILD (PACK)
============================================================================ -->
- <target name="pack.lib" depends="quick.lib, quick.plugins, forkjoin.done"> <staged-pack project="library"/></target>
+ <target name="pack.lib" depends="quick.lib, forkjoin.done"> <staged-pack project="library"/></target>
<target name="pack.reflect" depends="quick.reflect"> <staged-pack project="reflect"/> </target>
@@ -1152,16 +1113,13 @@ TODO:
-->
<target name="pack.actors" depends="quick.actors"> <staged-pack project="actors"/> </target>
- <target name="pack.swing" if="has.java6" depends="quick.swing"> <staged-pack project="swing"/> </target>
-
- <target name="pack.plugins" depends="quick.plugins"> <staged-pack project="continuations-plugin"/> </target>
<target name="pack.scalap" depends="quick.scalap"> <staged-pack project="scalap"/> </target>
<target name="pack.core" depends="pack.reflect, pack.comp, pack.lib"/>
<!-- TODO modularize compiler: pack.scaladoc, pack.interactive, -->
- <target name="pack.modules" depends="pack.actors, pack.swing, pack.plugins, pack.scalap">
+ <target name="pack.modules" depends="pack.actors, pack.scalap">
<copy todir="${build-pack.dir}/lib">
<path refid="external-modules-nocore" />
<mapper type="flatten" />
@@ -1217,20 +1175,24 @@ TODO:
<mkdir dir="${build-osgi.dir}"/>
<uptodate property="osgi.bundles.available" targetfile="${build-osgi.dir}/bundles.core.complete">
- <srcfiles dir="${basedir}">
- <include name="build.xml"/>
- <include name="src/build/bnd/*.bnd"/>
- <include name="${library.jar}"/>
- <include name="${reflect.jar}"/>
- <include name="${compiler.jar}"/>
- </srcfiles>
+ <srcresources>
+ <fileset dir="${basedir}">
+ <include name="build.xml"/>
+ <include name="build-ant-macros.xml"/>
+ <include name="src/build/bnd/*.bnd"/>
+ </fileset>
+ <filelist>
+ <file name="${library.jar}"/>
+ <file name="${reflect.jar}"/>
+ <file name="${compiler.jar}"/>
+ </filelist>
+ </srcresources>
</uptodate>
<if><not><isset property="osgi.bundles.available"/></not><then>
<stopwatch name="osgi.core.timer"/>
<make-bundle project="library">
<fileset dir="${src.dir}/library"/>
- <fileset dir="${src.dir}/continuations/library"/>
</make-bundle>
<make-bundle project="reflect">
@@ -1252,21 +1214,27 @@ TODO:
<target name="osgi.done" depends="pack.done, osgi.core">
<uptodate property="osgi.all.bundles.available" targetfile="${build-osgi.dir}/bundles.all.complete">
- <srcfiles dir="${basedir}">
- <include name="build.xml"/>
- <include name="src/build/bnd/*.bnd"/>
-
- <!-- TODO modularize compiler
- <include name="${interactive.jar}"/>
- <include name="${scaladoc.jar}"/>
- -->
-
- <include name="${actors.jar}"/>
- <include name="${continuations-plugin.jar}"/>
- <include name="${swing.jar}"/>
- <include name="${parser-combinators.jar}"/>
- <include name="${xml.jar}"/>
- </srcfiles>
+ <srcresources>
+ <fileset dir="${basedir}">
+ <include name="build.xml"/>
+ <include name="build-ant-macros.xml"/>
+ <include name="src/build/bnd/*.bnd"/>
+ </fileset>
+ <filelist>
+ <!-- TODO modularize compiler
+ <include name="${interactive.jar}"/>
+ <include name="${scaladoc.jar}"/>
+ -->
+
+ <file name="${actors.jar}"/>
+
+ <file name="${continuations-plugin.jar}"/>
+ <file name="${continuations-library.jar}"/>
+ <file name="${parser-combinators.jar}"/>
+ <file name="${xml.jar}"/>
+ <file name="${swing.jar}"/>
+ </filelist>
+ </srcresources>
</uptodate>
<if><not><isset property="osgi.all.bundles.available"/></not><then>
@@ -1290,18 +1258,12 @@ TODO:
<fileset dir="${src.dir}/actors"/>
</make-bundle>
- <make-bundle project="continuations-plugin">
- <fileset dir="${src.dir}/${continuations-plugin.srcdir}"/>
- </make-bundle>
-
- <if><isset property="has.java6"/><then>
- <make-bundle project="swing">
- <fileset dir="${src.dir}/swing"/>
- </make-bundle>
- </then></if>
+ <make-bundle project="continuations-plugin"/>
+ <make-bundle project="continuations-library"/>
<make-bundle project="parser-combinators"/>
<make-bundle project="xml"/>
+ <make-bundle project="swing"/>
<touch file="${build-osgi.dir}/bundles.all.complete" verbose="no"/>
<stopwatch name="osgi.all.timer" action="total"/>
@@ -1477,12 +1439,6 @@ TODO:
<testSuite kinds="run jvm"/>
</target>
- <target name="test.continuations.suite" depends="test.suite.init">
- <testSuite kinds="continuations-neg continuations-run"
- scalacOpts="${scalac.args.optimise} -Xpluginsdir ${build-quick.dir}/${continuations-plugin.targetdir} -Xplugin-require:continuations -P:continuations:enable"
- />
- </target>
-
<target name="test.scaladoc" depends="test.suite.init">
<testSuite kinds="run scalacheck" srcdir="scaladoc"/>
</target>
@@ -1493,7 +1449,7 @@ TODO:
<!-- for use in PR validation, where stability is rarely broken, so we're going to use starr for locker,
and skip test.stability (which requires locker == quick) -->
- <target name="test.core" depends="test.osgi, test.sbt, test.bc, test.junit, test.interactive, test.continuations.suite, test.scaladoc, test.suite"/>
+ <target name="test.core" depends="test.osgi, test.sbt, test.bc, test.junit, test.interactive, test.scaladoc, test.suite"/>
<target name="test.done" depends="test.core, test.stability"/>
<!-- ===========================================================================
@@ -1510,7 +1466,6 @@ TODO:
<dependency groupId="com.typesafe" artifactId="mima-reporter_2.9.2" version="0.1.5"/>
</artifact:dependencies>
<artifact:dependencies pathId="old.bc.classpath">
- <dependency groupId="org.scala-lang" artifactId="scala-swing" version="${bc-reference-version}"/>
<dependency groupId="org.scala-lang" artifactId="scala-library" version="${bc-reference-version}"/>
<dependency groupId="org.scala-lang" artifactId="scala-reflect" version="${bc-reference-version}"/>
</artifact:dependencies>
@@ -1523,10 +1478,9 @@ TODO:
<!-- Enable after the release of the 2.11.0 or a prior RC that estabilishes the new baseline. -->
<target name="test.bc"></target>
- <target name="test.bc.disabled" depends="bc.init, pack.lib, pack.reflect, pack.swing">
+ <target name="test.bc.disabled" depends="bc.init, pack.lib, pack.reflect">
<bc.check project="library"/>
<bc.check project="reflect"/>
- <bc.check project="swing"/>
</target>
<!-- ===========================================================================
@@ -1599,30 +1553,12 @@ TODO:
</staged-docs>
</target>
- <target name="docs.swing" depends="docs.start" unless="docs.skip">
- <staged-docs project="swing">
- <include name="**/*.scala"/>
- </staged-docs>
- </target>
-
<target name="docs.scalap" depends="docs.start" unless="docs.skip">
<staged-docs project="scalap">
<include name="**/*.scala"/>
</staged-docs>
</target>
- <target name="docs.continuations-plugin" depends="docs.start" unless="docs.skip">
- <staged-docs project="continuations-plugin">
- <include name="**/*.scala"/>
- </staged-docs>
- </target>
-
- <target name="docs.continuations-library" depends="docs.start" unless="docs.skip">
- <staged-docs project="continuations-library">
- <include name="**/*.scala"/>
- </staged-docs>
- </target>
-
<target name="docs.man" depends="docs.start">
<staged-uptodate stage="docs" project="manual">
<check><srcfiles dir="${src.dir}/manual"/></check>
@@ -1662,7 +1598,7 @@ TODO:
<target name="docs.core" depends="docs.lib, docs.reflect, docs.comp" unless="docs.skip"/>
<!-- TODO modularize compiler: docs.scaladoc, docs.interactive, -->
- <target name="docs.done" depends="docs.core, docs.actors, docs.swing, docs.scalap, docs.continuations-plugin, docs.continuations-library" unless="docs.skip"/>
+ <target name="docs.done" depends="docs.core, docs.actors, docs.scalap" unless="docs.skip"/>
<!-- ===========================================================================
DISTRIBUTION
@@ -1673,7 +1609,6 @@ TODO:
<mkdir dir="${dist.dir}/lib"/>
- <mkdir dir="${dist.dir}/${continuations-plugin.targetdir}"/>
<mkdir dir="${dist.dir}/src"/>
<copy todir="${dist.dir}/lib" overwrite="true">
@@ -1687,12 +1622,13 @@ TODO:
<copy-bundle project="reflect"/>
<copy-bundle project="compiler"/>
- <copy-bundle project="swing"/>
<copy-bundle project="actors"/>
- <copy-bundle project="xml"/>
- <copy-bundle project="parser-combinators"/>
<copy-bundle project="continuations-plugin"/>
+ <copy-bundle project="continuations-library"/>
+ <copy-bundle project="parser-combinators"/>
+ <copy-bundle project="xml"/>
+ <copy-bundle project="swing"/>
<!-- scalap -->
<copy toDir="${dist.dir}/lib" overwrite="true">
@@ -1715,29 +1651,30 @@ TODO:
<target name="dist.doc" depends="dist.base, docs.done">
- <mkdir dir="${dist.dir}/doc/scala-devel-docs"/>
- <copy toDir="${dist.dir}/doc/scala-devel-docs" overwrite="true" flatten="true">
- <file file="${scala-xml-javadoc}"/>
- <file file="${scala-parser-combinators-javadoc}"/>
+ <mkdir dir="${dist.dir}/doc"/>
+ <mkdir dir="${dist.dir}/doc/licenses"/>
+ <mkdir dir="${dist.dir}/doc/tools"/>
+ <copy file="${docs.dir}/LICENSE" toDir="${dist.dir}/doc" overwrite="true"/>
+ <copy file="${docs.dir}/README" toDir="${dist.dir}/doc" overwrite="true"/>
+ <copy toDir="${dist.dir}/doc/licenses" overwrite="true">
+ <fileset dir="${docs.dir}/licenses"/>
</copy>
- <copy file="${docs.dir}/LICENSE" toDir="${dist.dir}/doc" overwrite="true"/>
- <copy file="${docs.dir}/README" toDir="${dist.dir}/doc" overwrite="true"/>
- <mkdir dir="${dist.dir}/doc/scala-devel-docs/api"/>
- <copy toDir="${dist.dir}/doc/scala-devel-docs/api" overwrite="true">
+ <mkdir dir="${dist.dir}/api"/>
+ <copy toDir="${dist.dir}/api" overwrite="true">
<fileset dir="${build-docs.dir}/library"/>
</copy>
- <mkdir dir="${dist.dir}/doc/scala-devel-docs/examples"/>
- <copy toDir="${dist.dir}/doc/scala-devel-docs/examples" overwrite="true">
- <fileset dir="${docs.dir}/examples">
- <exclude name="**/*.desired.sha1"/>
- </fileset>
+
+ <copy toDir="${dist.dir}/doc/api" overwrite="true" flatten="true">
+ <file file="${scala-xml-javadoc}"/>
+ <file file="${scala-parser-combinators-javadoc}"/>
+ <file file="${scala-continuations-plugin-javadoc}"/>
+ <file file="${scala-continuations-library-javadoc}"/>
+ <file file="${scala-swing-javadoc}"/>
</copy>
- <copy file="${src.dir}/swing/doc/README"
- toFile="${dist.dir}/doc/scala-devel-docs/README.scala-swing"
- overwrite="true"/>
</target>
+
<target name="dist.man" depends="dist.base, docs.man">
<mkdir dir="${dist.dir}/man"/>
<copy toDir="${dist.dir}/man" overwrite="true">
@@ -1846,9 +1783,7 @@ MAIN DISTRIBUTION PACKAGING
<mvn-package project="scaladoc"/>
-->
- <mvn-package project="swing"/>
<mvn-package project="actors"/>
- <mvn-package project="continuations-plugin"/>
<!-- don't bother fitting scalap into the mould: it will move out soon -->
<copy tofile="${maven-base}/scalap/scalap-pom.xml" file="${src.dir}/build/maven/scalap-pom.xml" overwrite="true"/>
diff --git a/dbuild-meta.json b/dbuild-meta.json
index 8d3b65afd0..90d0104ec1 100644
--- a/dbuild-meta.json
+++ b/dbuild-meta.json
@@ -64,24 +64,6 @@
"artifacts": [
{
"extension": "jar",
- "name": "scala-swing",
- "organization": "org.scala-lang"
- }
- ],
- "dependencies": [
- {
- "extension": "jar",
- "name": "scala-library",
- "organization": "org.scala-lang"
- }
- ],
- "name": "scala-swing",
- "organization": "org.scala-lang"
- },
- {
- "artifacts": [
- {
- "extension": "jar",
"name": "scala-actors",
"organization": "org.scala-lang"
}
@@ -113,18 +95,6 @@
],
"name": "scalap",
"organization": "org.scala-lang"
- },
- {
- "artifacts": [
- {
- "extension": "jar",
- "name": "continuations",
- "organization": "org.scala-lang.plugins"
- }
- ],
- "dependencies": [],
- "name": "continuations",
- "organization": "org.scala-lang.plugins"
}
]
}
diff --git a/docs/LICENSE b/docs/LICENSE
index 446a1a350b..4daedef581 100644
--- a/docs/LICENSE
+++ b/docs/LICENSE
@@ -1,5 +1,11 @@
+Scala is licensed under the [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause).
+
+## Scala License
+
Copyright (c) 2002-2013 EPFL
+Copyright (c) 2011-2013 Typesafe, Inc.
+
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
@@ -25,3 +31,33 @@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Other Licenses
+
+This software includes projects with the following licenses,
+which are also included in the `licenses/` directory:
+
+### [Apache License](http://www.apache.org/licenses/LICENSE-2.0.html)
+This license is used by the following third-party libraries:
+ * jansi
+
+### [BSD License](http://www.opensource.org/licenses/bsd-license.php)
+This license is used by the following third-party libraries:
+ * jline
+
+### [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause)
+This license is used by the following third-party libraries:
+ * asm
+
+### [MIT License](http://www.opensource.org/licenses/MIT)
+This license is used by the following third-party libraries:
+ * jquery
+ * jquery-ui
+ * jquery-layout
+ * sizzle
+ * tools tooltip
+
+### Public Domain
+The following libraries are freely available in the public domain:
+ * forkjoin
+
diff --git a/docs/README b/docs/README
index 6af633444d..1d5f553d2e 100644
--- a/docs/README
+++ b/docs/README
@@ -1,58 +1,36 @@
+Scala Distribution
+------------------
-Scala Software Distributions
-----------------------------
-
-- scala-<major>.<minor>.<patch>.tgz Unix distribution
-- scala-<major>.<minor>.<patch>.zip Windows distribution
-
-The standard distributions require Java 1.5 or above. If you don't
-know which version of Java you have, run the command "java -version".
+The Scala distribution requires Java 1.6 or above.
+Please report bugs at https://issues.scala-lang.org/.
+We welcome contributions at https://github.com/scala/scala!
Scala Tools
-----------
-- fsc Scala offline compiler
+- scala Scala interactive interpreter
- scalac Scala compiler
+- fsc Scala resident compiler
- scaladoc Scala API documentation generator
-- scala Scala interactive interpreter
- scalap Scala classfile decoder
Run the command "scalac -help" to display the list of available
compiler options.
-Unix Installation
------------------
-
-Untar the archive. All Scala tools are located in the "bin" directory.
-Adding that directory to the PATH variable will make the Scala commands
-directly accessible.
-
-You may test the distribution by running the following commands:
-
-$ ./bin/scala
-scala> Array(4,3,2,1).sorted
-res0: Array[Int] = Array(1, 2, 3, 4)
-
-scala>:quit
-$
-
-
-Windows Installation
---------------------
-
-Unzip the archive. All Scala tools are located in the "bin" directory.
-Adding that directory to the PATH variable will make the Scala commands
-directly accessible.
+Installation
+------------
-On Windows 95/98/Me, you must define the environment variable SCALA_HOME
-to point to the home directory of the Scala distribution to run any of
-these tools. This can be done by adding the following command to your
-AUTOEXEC.BAT file and then rebooting your machine.
+Decompress the archive and run the above commands directly from `bin` directory.
+We recommend adding the full path of the `bin` directory to the `PATH`
+environment variable.
-set SCALA_HOME=<install-directory>\scala-<major>.<minor>.<patch>
-On Windows NT/2000/XP, you do not need to define any variable in order
-for the Scala commands to run correctly.
+Licenses
+--------
+Scala is licensed under the standard 3-clause BSD license,
+included in the distribution as the file `doc/LICENSE`.
+The licenses of the software included in the Scala distribution can
+be found in the `doc/licenses` directory. \ No newline at end of file
diff --git a/docs/examples/actors/auction.scala b/docs/examples/actors/auction.scala
deleted file mode 100644
index c3124c67a9..0000000000
--- a/docs/examples/actors/auction.scala
+++ /dev/null
@@ -1,131 +0,0 @@
-package examples.actors
-
-import java.util.Date
-
-import scala.actors._
-import scala.actors.Actor._
-
-/** A simple demonstrator program implementing an online auction service
- * The example uses the actor abstraction defined in the API of
- * package scala.actors.
- */
-
-trait AuctionMessage
-case class Offer(bid: Int, client: Actor) extends AuctionMessage // make a bid
-case class Inquire(client: Actor) extends AuctionMessage // inquire status
-
-trait AuctionReply
-case class Status(asked: Int, expiration: Date) // asked sum, expiration date
- extends AuctionReply
-case object BestOffer extends AuctionReply // yours is the best offer
-case class BeatenOffer(maxBid: Int) extends AuctionReply // offer beaten by maxBid
-case class AuctionConcluded(seller: Actor, client: Actor) // auction concluded
- extends AuctionReply
-case object AuctionFailed extends AuctionReply // failed with no bids
-case object AuctionOver extends AuctionReply // bidding is closed
-
-class AuctionActor(seller: Actor, minBid: Int, closing: Date) extends Actor {
- val timeToShutdown = 3000 // msec
- val bidIncrement = 10
-
- def act() {
- var maxBid = minBid - bidIncrement
- var maxBidder: Actor = null
-
- loop {
- reactWithin (closing.getTime() - new Date().getTime()) {
-
- case Offer(bid, client) =>
- if (bid >= maxBid + bidIncrement) {
- if (maxBid >= minBid)
- maxBidder ! BeatenOffer(bid)
- maxBid = bid
- maxBidder = client
- client ! BestOffer
- }
- else
- client ! BeatenOffer(maxBid)
-
- case Inquire(client) =>
- client ! Status(maxBid, closing)
-
- case TIMEOUT =>
- if (maxBid >= minBid) {
- val reply = AuctionConcluded(seller, maxBidder)
- maxBidder ! reply
- seller ! reply
- } else {
- seller ! AuctionFailed
- }
- reactWithin(timeToShutdown) {
- case Offer(_, client) => client ! AuctionOver
- case TIMEOUT => exit()
- }
-
- }
- }
- }
-}
-
-object auction {
-
- val random = new scala.util.Random
-
- val minBid = 100
- val closing = new Date(new Date().getTime() + 4000)
-
- val seller = Actor.actor { }
- val auction = new AuctionActor(seller, minBid, closing)
-
- def client(i: Int, increment: Int, top: Int) = new Actor {
- val name = "Client " + i
- def log(msg: String) = Console.println(name + ": " + msg)
- var max: Int = _
- var current: Int = 0
- def act() {
- log("started")
- auction ! Inquire(this)
- receive {
- case Status(maxBid, _) =>
- log("status(" + maxBid + ")")
- max = maxBid
- }
- loop {
- if (max >= top) {
- log("too high for me")
- }
- else if (current < max) {
- current = max + increment
- Thread.sleep(1 + random.nextInt(1000))
- auction ! Offer(current, this)
- }
-
- reactWithin(3000) {
- case BestOffer =>
- log("bestOffer(" + current + ")")
-
- case BeatenOffer(maxBid) =>
- log("beatenOffer(" + maxBid + ")")
- max = maxBid
-
- case AuctionConcluded(seller, maxBidder) =>
- log("auctionConcluded"); exit()
-
- case AuctionOver =>
- log("auctionOver"); exit()
-
- case TIMEOUT =>
- exit()
- }
- }
- }
- }
-
- def main(args: Array[String]) {
- seller.start()
- auction.start()
- client(1, 20, 200).start()
- client(2, 10, 300).start()
- }
-
-}
diff --git a/docs/examples/actors/boundedbuffer.scala b/docs/examples/actors/boundedbuffer.scala
deleted file mode 100644
index c65bb7719c..0000000000
--- a/docs/examples/actors/boundedbuffer.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-package examples.actors
-
-import scala.actors.Actor._
-
-object boundedbuffer {
- class BoundedBuffer[T](N: Int)(implicit m: Manifest[T]) {
- private case class Put(x: T)
- private case object Get
- private case object Stop
-
- private val buffer = actor {
- val buf = new Array[T](N)
- var in, out, n = 0
- loop {
- react {
- case Put(x) if n < N =>
- buf(in) = x; in = (in + 1) % N; n += 1; reply()
- case Get if n > 0 =>
- val r = buf(out); out = (out + 1) % N; n -= 1; reply(r)
- case Stop =>
- reply(); exit("stopped")
- }
- }
- }
-
- def put(x: T) { buffer !? Put(x) }
- def get: T = (buffer !? Get).asInstanceOf[T]
- def stop() { buffer !? Stop }
- }
-
- def main(args: Array[String]) {
- val buf = new BoundedBuffer[Int](1)
- buf.put(42)
- println("" + buf.get)
- buf.stop()
- }
-}
diff --git a/docs/examples/actors/channels.scala b/docs/examples/actors/channels.scala
deleted file mode 100644
index 3c0dbf232d..0000000000
--- a/docs/examples/actors/channels.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-package examples.actors
-
-import scala.actors._
-import scala.actors.Actor._
-
-object channels extends Application {
- case class Msg(ch1: Channel[Int], ch2: Channel[String])
-
- val a = actor {
- val Ch1 = new Channel[Int]
- val Ch2 = new Channel[String]
-
- b ! Msg(Ch1, Ch2)
-
- val ICh1 = Ch1.asInstanceOf[InputChannel[Int]]
- val ICh2 = Ch2.asInstanceOf[InputChannel[String]]
-
- react {
- case ICh1 ! (x: Int) =>
- val r = x + 21
- println("result: "+r)
- case ICh2 ! y =>
- println("received: "+y)
- }
- }
-
- val b = actor {
- react {
- case Msg(ch1, ch2) => ch1 ! 21
- }
- }
-}
diff --git a/docs/examples/actors/fringe.scala b/docs/examples/actors/fringe.scala
deleted file mode 100644
index 2026628cb3..0000000000
--- a/docs/examples/actors/fringe.scala
+++ /dev/null
@@ -1,82 +0,0 @@
-package examples.actors
-
-import scala.actors.Actor._
-import scala.actors.{Channel, OutputChannel}
-
-/**
- @author Philipp Haller
- @version 1.1, 09/21/2007
- */
-object fringe extends Application {
-
- abstract class Tree
- case class Node(left: Tree, right: Tree) extends Tree
- case class Leaf(v: Int) extends Tree
-
- case class CompareFringe(t1: Tree, t2: Tree)
- case class ComputeFringe(t1: Tree, atoms: OutputChannel[Option[Leaf]])
- case class Equal(atom1: Option[Leaf], atom2: Option[Leaf])
- case class Extract(tree: Tree)
-
- val comparator = actor {
- val extractor1 = actor(extractorBehavior())
- val extractor2 = actor(extractorBehavior())
- val ch1 = new Channel[Option[Leaf]]
- val ch2 = new Channel[Option[Leaf]]
- loop {
- react {
- case CompareFringe(tree1, tree2) =>
- extractor1 ! ComputeFringe(tree1, ch1)
- extractor2 ! ComputeFringe(tree2, ch2)
- self ! Equal(ch1.?, ch2.?)
-
- case Equal(atom1, atom2) =>
- if (atom1 == atom2) atom1 match {
- case None =>
- println("same fringe")
- exit()
- case _ =>
- self ! Equal(ch1.?, ch2.?)
- } else {
- println("fringes differ")
- exit()
- }
- }
- }
- }
-
- val extractorBehavior = () => {
- var output: OutputChannel[Option[Leaf]] = null
- loop {
- react {
- case ComputeFringe(tree, leafSink) =>
- output = leafSink
- self ! Extract(tree)
-
- case Extract(tree) => tree match {
- case atom @ Leaf(_) =>
- output ! Some(atom)
- sender ! 'Continue
-
- case Node(left, right) =>
- val outer = self
- val outerCont = sender
- val cont = actor {
- react {
- case 'Continue =>
- outer.send(Extract(right), outerCont)
- }
- }
- self.send(Extract(left), cont)
- }
-
- case 'Continue =>
- output ! None
- exit()
- }
- }
- }
-
- comparator ! CompareFringe(Node(Leaf(5), Node(Leaf(7), Leaf(3))),
- Node(Leaf(5), Node(Leaf(7), Leaf(3))))
-}
diff --git a/docs/examples/actors/links.scala b/docs/examples/actors/links.scala
deleted file mode 100644
index 373e6b07ce..0000000000
--- a/docs/examples/actors/links.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-package examples.actors
-
-import scala.actors.{Actor, Exit}
-import scala.actors.Actor._
-
-object links extends Application {
-
- case object Stop
-
- actor {
- val start = link(p(2))
- start ! Stop
- }
-
- def p(n: Int): Actor =
- if (n == 0) top1()
- else top(p(n-1), n)
-
- def top(a: Actor, n: Int): Actor = actor {
- println("starting actor " + n + " (" + self + ")")
- self.trapExit = true
- link(a)
- loop {
- receive {
- case ex @ Exit(from, reason) =>
- println("Actor " + n + " received " + ex)
- exit('finished)
- case any => {
- println("Actor " + n + " received " + any)
- a ! any
- }
- }
- }
- }
-
- def top1(): Actor = actor {
- println("starting last actor" + " (" + self + ")")
- receive {
- case Stop =>
- println("Last actor now exiting")
- exit('abnormal)
- case any =>
- println("Last actor received " + any)
- top1()
- }
- }
-}
diff --git a/docs/examples/actors/looping.scala b/docs/examples/actors/looping.scala
deleted file mode 100644
index 1ce2e2e5e8..0000000000
--- a/docs/examples/actors/looping.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-package examples.actors
-
-import scala.actors.Actor._
-
-object looping extends Application {
- case object A
-
- val a = actor {
- var cnt = 0
- loop {
- react {
- case A =>
- cnt += 1
- if (cnt % 2 != 0) continue
- if (cnt < 10)
- println("received A")
- else {
- println("received last A")
- exit()
- }
- }
- }
- }
-
- for (i <- 0 until 10) a ! A
-}
diff --git a/docs/examples/actors/message.scala b/docs/examples/actors/message.scala
deleted file mode 100644
index d385543470..0000000000
--- a/docs/examples/actors/message.scala
+++ /dev/null
@@ -1,40 +0,0 @@
-package examples.actors
-
-import scala.actors.{Actor, Scheduler}
-import scala.actors.Actor._
-import scala.actors.scheduler.SingleThreadedScheduler
-
-object message {
- def main(args: Array[String]) {
- val n = try { args(0).toInt }
- catch {
- case _ =>
- println("Usage: examples.actors.message <n>")
- Predef.exit
- }
- val nActors = 500
- val finalSum = n * nActors
- Scheduler.impl = new SingleThreadedScheduler
-
- def beh(next: Actor, sum: Int) {
- react {
- case value: Int =>
- val j = value + 1; val nsum = sum + j
- if (next == null && nsum >= n * j)
- println(nsum)
- else {
- if (next != null) next ! j
- if (nsum < n * j) beh(next, nsum)
- }
- }
- }
-
- def actorChain(i: Int, a: Actor): Actor =
- if (i > 0) actorChain(i-1, actor(beh(a, 0))) else a
-
- val firstActor = actorChain(nActors, null)
- var i = n; while (i > 0) { firstActor ! 0; i -= 1 }
-
- Scheduler.shutdown()
- }
-}
diff --git a/docs/examples/actors/pingpong.scala b/docs/examples/actors/pingpong.scala
deleted file mode 100644
index c355bee244..0000000000
--- a/docs/examples/actors/pingpong.scala
+++ /dev/null
@@ -1,61 +0,0 @@
-package examples.actors
-
-import scala.actors.Actor
-import scala.actors.Actor._
-
-case object Ping
-case object Pong
-case object Stop
-
-/**
- * Ping pong example.
- *
- * @author Philipp Haller
- * @version 1.1
- */
-object pingpong extends App {
- val pong = new Pong
- val ping = new Ping(100000, pong)
- ping.start
- pong.start
-}
-
-class Ping(count: Int, pong: Actor) extends Actor {
- def act() {
- var pingsLeft = count - 1
- pong ! Ping
- loop {
- react {
- case Pong =>
- if (pingsLeft % 1000 == 0)
- println("Ping: pong")
- if (pingsLeft > 0) {
- pong ! Ping
- pingsLeft -= 1
- } else {
- println("Ping: stop")
- pong ! Stop
- exit()
- }
- }
- }
- }
-}
-
-class Pong extends Actor {
- def act() {
- var pongCount = 0
- loop {
- react {
- case Ping =>
- if (pongCount % 1000 == 0)
- println("Pong: ping "+pongCount)
- sender ! Pong
- pongCount += 1
- case Stop =>
- println("Pong: stop")
- exit()
- }
- }
- }
-}
diff --git a/docs/examples/actors/producers.scala b/docs/examples/actors/producers.scala
deleted file mode 100644
index 80e5ae33d3..0000000000
--- a/docs/examples/actors/producers.scala
+++ /dev/null
@@ -1,114 +0,0 @@
-package examples.actors
-
-import scala.actors.Actor
-import scala.actors.Actor._
-
-abstract class Producer[T] {
-
- /** A signal that the next value should be produced. */
- private val Next = new Object
-
- /** A label for an undefined state of the iterators. */
- private val Undefined = new Object
-
- /** A signal to stop the coordinator. */
- private val Stop = new Object
-
- protected def produce(x: T) {
- coordinator ! Some(x)
- receive { case Next => }
- }
-
- protected def produceValues: Unit
-
- def iterator = new Iterator[T] {
- private var current: Any = Undefined
- private def lookAhead = {
- if (current == Undefined) current = coordinator !? Next
- current
- }
-
- def hasNext: Boolean = lookAhead match {
- case Some(x) => true
- case None => { coordinator ! Stop; false }
- }
-
- def next: T = lookAhead match {
- case Some(x) => current = Undefined; x.asInstanceOf[T]
- }
- }
-
- private val coordinator: Actor = actor {
- loop {
- react {
- case Next =>
- producer ! Next
- reply {
- receive { case x: Option[_] => x }
- }
- case Stop =>
- exit('stop)
- }
- }
- }
-
- private val producer: Actor = actor {
- receive {
- case Next =>
- produceValues
- coordinator ! None
- }
- }
-}
-
-object producers extends Application {
-
- class Tree(val left: Tree, val elem: Int, val right: Tree)
- def node(left: Tree, elem: Int, right: Tree): Tree = new Tree(left, elem, right)
- def node(elem: Int): Tree = node(null, elem, null)
-
- def tree = node(node(node(3), 4, node(6)), 8, node(node(9), 10, node(11)))
-
- class PreOrder(n: Tree) extends Producer[Int] {
- def produceValues = traverse(n)
- def traverse(n: Tree) {
- if (n != null) {
- produce(n.elem)
- traverse(n.left)
- traverse(n.right)
- }
- }
- }
-
- class PostOrder(n: Tree) extends Producer[Int] {
- def produceValues = traverse(n)
- def traverse(n: Tree) {
- if (n != null) {
- traverse(n.left)
- traverse(n.right)
- produce(n.elem)
- }
- }
- }
-
- class InOrder(n: Tree) extends Producer[Int] {
- def produceValues = traverse(n)
- def traverse(n: Tree) {
- if (n != null) {
- traverse(n.left)
- produce(n.elem)
- traverse(n.right)
- }
- }
- }
-
- actor {
- print("PreOrder:")
- for (x <- new PreOrder(tree).iterator) print(" "+x)
- print("\nPostOrder:")
- for (x <- new PostOrder(tree).iterator) print(" "+x)
- print("\nInOrder:")
- for (x <- new InOrder(tree).iterator) print(" "+x)
- print("\n")
- }
-}
diff --git a/docs/examples/actors/seq.scala b/docs/examples/actors/seq.scala
deleted file mode 100644
index 816c969cb6..0000000000
--- a/docs/examples/actors/seq.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-package examples.actors
-
-object seq extends Application {
- import scala.actors.Actor._
- val a = actor {
- { react {
- case 'A => println("received 1st message")
- }; ()
- } andThen react {
- case 'A => println("received 2nd message")
- }
- }
- a ! 'A
- a ! 'A
-}
diff --git a/docs/examples/boundedbuffer.scala b/docs/examples/boundedbuffer.scala
deleted file mode 100644
index 359bfd8d06..0000000000
--- a/docs/examples/boundedbuffer.scala
+++ /dev/null
@@ -1,46 +0,0 @@
-package examples
-
-object boundedbuffer {
-
- import concurrent.ops._
-
- class BoundedBuffer[A](N: Int)(implicit m: ClassManifest[A]) {
- var in, out, n = 0
- val elems = new Array[A](N)
-
- def await(cond: => Boolean) = while (!cond) { wait() }
-
- def put(x: A) = synchronized {
- await (n < N)
- elems(in) = x; in = (in + 1) % N; n += 1
- if (n == 1) notifyAll()
- }
-
- def get: A = synchronized {
- await (n != 0)
- val x = elems(out); out = (out + 1) % N ; n -= 1
- if (n == N - 1) notifyAll()
- x
- }
- }
-
- def kill(delay: Int) = new java.util.Timer().schedule(
- new java.util.TimerTask {
- override def run() = {
- println("[killed]")
- System.exit(0)
- }
- },
- delay) // in milliseconds
-
- def main(args: Array[String]) {
- val buf = new BoundedBuffer[String](10)
- var cnt = 0
- def produceString = { cnt += 1; cnt.toString() }
- def consumeString(ss: String) = println(ss)
- spawn { while (true) { val ssss = produceString; buf.put(ssss) } }
- spawn { while (true) { val s = buf.get; consumeString(s) } }
- kill(1000)
- }
-
-}
diff --git a/docs/examples/computeserver.scala b/docs/examples/computeserver.scala
deleted file mode 100644
index 788be284d1..0000000000
--- a/docs/examples/computeserver.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-package examples
-
-import concurrent._, concurrent.ops._
-
-class ComputeServer(n: Int) {
-
- private trait Job {
- type t
- def task: t
- def ret(x: t): Unit
- }
-
- private val openJobs = new Channel[Job]()
-
- private def processor(i: Int) {
- while (true) {
- val job = openJobs.read
- println("read a job")
- job.ret(job.task)
- }
- }
-
- def future[a](p: => a): () => a = {
- val reply = new SyncVar[a]()
- openJobs.write{
- new Job {
- type t = a
- def task = p
- def ret(x: a) = reply.set(x)
- }
- }
- () => reply.get
- }
-
- //spawn(replicate(0, n) { processor })
- spawn((0 until n).par foreach { processor })
-}
-
-object computeserver extends App {
-
- def kill(delay: Int) = new java.util.Timer().schedule(
- new java.util.TimerTask {
- override def run() = {
- println("[killed]")
- sys exit 0
- }
- },
- delay) // in milliseconds
-
- val server = new ComputeServer(1)
- val f = server.future(42)
- println(f())
- kill(10000)
-}
diff --git a/docs/examples/expressions/expressions-current.scala b/docs/examples/expressions/expressions-current.scala
deleted file mode 100644
index 660a417c11..0000000000
--- a/docs/examples/expressions/expressions-current.scala
+++ /dev/null
@@ -1,68 +0,0 @@
-package examples.expressions
-
-class Ref[a](var elem:a) {}
-
-abstract class Lang {
- trait Visitor {
- def caseNum(n: int): unit
- }
-
- abstract class Exp {
- def visit(v: visitor): unit
- }
-
- type visitor <: Visitor
-
- class Num(n: int) extends Exp {
- def visit(v: visitor): unit = v.caseNum(n)
- }
-
- class Eval(result: Ref[int]) requires visitor extends Visitor {
- def caseNum(n: int) = result.elem = n
- }
-}
-
-abstract class Lang2 extends Lang {
- trait Visitor2 extends Visitor {
- def casePlus(left: Exp, right: Exp): unit
- }
-
- type visitor <: Visitor2
-
- class Plus(l: Exp, r: Exp) extends Exp {
- def visit(v: visitor): unit = v.casePlus(l, r)
- }
-
- // class Eval2(result: Ref[int]): visitor extends Eval(result) with Visitor2 {
- class Eval2(result: Ref[int]) requires visitor extends Eval(result) with Visitor2 {
- def casePlus(l: Exp, r: Exp) =
- result.elem = { l.visit(this); result.elem } + { r.visit(this); result.elem }
- }
-
- class Show2(result: Ref[String]) requires visitor extends Visitor2 {
- def caseNum(n: int) = result.elem = n.toString()
- def casePlus(l: Exp, r: Exp) =
- result.elem =
- "(" + { l.visit(this); result.elem } +
- "+" + { r.visit(this); result.elem } + ")"
- }
-}
-
-object Main {
- def main(args: Array[String]): unit = {
- //val l1 = new Lang { type visitor = Visitor } // not yet implemented
- object l1 extends Lang { type visitor = Visitor } // workaround
- val e1: l1.Exp = new l1.Num(42)
- val iref = new Ref(0)
- Console.println("eval: " + { e1.visit(new l1.Eval(iref)); iref.elem })
-
- //val l2 = new Lang2 { type visitor = Visitor2 } // not yet implemented
- object l2 extends Lang2 { type visitor = Visitor2 } // workaround
- val e2: l2.Exp = new l2.Plus(new l2.Num(5), new l2.Num(37))
- val sref = new Ref("")
- Console.println("eval: " + { e2.visit(new l2.Eval2(iref)); iref.elem })
- Console.println("show: " + { e2.visit(new l2.Show2(sref)); sref.elem })
- e1.visit(new l1.Eval(iref))
- e2.visit(new l2.Show2(sref))
- }
-}
diff --git a/docs/examples/fors.scala b/docs/examples/fors.scala
deleted file mode 100644
index 29616b61b1..0000000000
--- a/docs/examples/fors.scala
+++ /dev/null
@@ -1,112 +0,0 @@
-package examples
-
-import scala.xml._
-
-
-object fors {
-
- val e = Node.NoAttributes
-
- class Person(_name: String, _age: Int) {
- val name = _name
- val age = _age
- }
-
- def printOlderThan20(xs: Seq[Person]): Iterator[String] =
- printOlderThan20(xs.iterator)
-
- def printOlderThan20(xs: Iterator[Person]): Iterator[String] =
- for (p <- xs if p.age > 20) yield p.name
-
- val persons = List(
- new Person("John", 40),
- new Person("Richard", 68)
- )
-
- def divisors(n: Int): List[Int] =
- for (i <- List.range(1, n+1) if n % i == 0) yield i
-
- def isPrime(n: Int) = divisors(n).length == 2
-
- def findNums(n: Int): Iterable[(Int, Int)] =
- for (i <- 1 until n;
- j <- 1 until (i-1);
- if isPrime(i+j)) yield (i, j)
-
- def sum(xs: List[Double]): Double =
- xs.foldLeft(0.0) { (x, y) => x + y }
-
- def scalProd(xs: List[Double], ys: List[Double]) =
- sum(for((x, y) <- xs zip ys) yield x * y)
-
- type Lst = List[Any]
-
- val prefix = null
- val scope = TopScope
-
- val books = List(
- Elem(prefix, "book", e, scope,
- Elem(prefix, "title", e, scope,
- Text("Structure and Interpretation of Computer Programs")),
- Elem(prefix, "author", e, scope,
- Text("Abelson, Harald")),
- Elem(prefix, "author", e, scope,
- Text("Sussman, Gerald J."))),
- Elem(prefix, "book", e, scope,
- Elem(prefix, "title", e, scope,
- Text("Principles of Compiler Design")),
- Elem(prefix, "author", e, scope,
- Text("Aho, Alfred")),
- Elem(prefix, "author", e, scope,
- Text("Ullman, Jeffrey"))),
- Elem(prefix, "book", e, scope,
- Elem(prefix, "title", e, scope,
- Text("Programming in Modula-2")),
- Elem(prefix, "author", e, scope,
- Text("Wirth, Niklaus")))
- )
-
- def findAuthor(books: Lst) =
- for (Elem(_, "book", _, _, book @ _*) <- books;
- Elem(_, "title", _, _, Text(title)) <- book.toList;
- if (title indexOf "Program") >= 0;
- Elem(_, "author", _, _, Text(author)) <- List(book)) yield author
-
- for (Elem(_, "book", _, _, book @ _*) <- books;
- Elem(_, "author", _, _, Text(author)) <- book.toList;
- if author startsWith "Ullman";
- Elem(_, "title", _, _, Text(title)) <- List(book)) yield title
-
- removeDuplicates(
- for (Elem(_, "book", _, _, b1 @ _* ) <- books;
- Elem(_, "book", _, _, b2 @ _*) <- books;
- if b1 != b2;
- Elem(_, "author", _, _, Text(a1)) <- b1.toList;
- Elem(_, "author", _, _, Text(a2)) <- b2.toList;
- if a1 == a2) yield (a1, a2))
-
- def removeDuplicates[a](xs: List[a]): List[a] =
- if (xs.isEmpty)
- xs
- else
- xs.head :: removeDuplicates(for (x <- xs.tail if x != xs.head) yield x)
-
- def main(args: Array[String]) {
- print("Persons over 20:")
- printOlderThan20(persons) foreach { x => print(" " + x) }
- println
-
- println("divisors(34) = " + divisors(34))
-
- print("findNums(15) =");
- findNums(15) foreach { x => print(" " + x); }
- println
-
- val xs = List(3.5, 5.0, 4.5)
- println("average(" + xs + ") = " + sum(xs) / xs.length)
-
- val ys = List(2.0, 1.0, 3.0)
- println("scalProd(" + xs + ", " + ys +") = " + scalProd(xs, ys))
- }
-
-}
diff --git a/docs/examples/futures.scala b/docs/examples/futures.scala
deleted file mode 100644
index e05b6b330e..0000000000
--- a/docs/examples/futures.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-package examples
-
-import concurrent.ops._
-
-object futures {
- def someLengthyComputation = 1
- def anotherLengthyComputation = 2
- def f(x: Int) = x + x
- def g(x: Int) = x * x
-
- def main(args: Array[String]) {
- val x = future(someLengthyComputation)
- anotherLengthyComputation
- val y = f(x()) + g(x())
- println(y)
- }
-}
diff --git a/docs/examples/gadts.scala b/docs/examples/gadts.scala
deleted file mode 100644
index d2792f4ada..0000000000
--- a/docs/examples/gadts.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-package examples
-
-object gadts extends Application {
-
- abstract class Term[T]
- case class Lit(x: Int) extends Term[Int]
- case class Succ(t: Term[Int]) extends Term[Int]
- case class IsZero(t: Term[Int]) extends Term[Boolean]
- case class If[T](c: Term[Boolean],
- t1: Term[T],
- t2: Term[T]) extends Term[T]
-
- def eval[T](t: Term[T]): T = t match {
- case Lit(n) => n
- case Succ(u) => eval(u) + 1
- case IsZero(u) => eval(u) == 0
- case If(c, u1, u2) => eval(if (eval(c)) u1 else u2)
- }
- println(
- eval(If(IsZero(Lit(1)), Lit(41), Succ(Lit(41)))))
-}
-
diff --git a/docs/examples/iterators.scala b/docs/examples/iterators.scala
deleted file mode 100644
index 9ddb141d61..0000000000
--- a/docs/examples/iterators.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-package examples
-
-object iterators {
-
- def Array(elems: Double*): Array[Double] = {
- val ar = new Array[Double](elems.length)
- for (i <- 0 until elems.length)
- ar(i) = elems(i)
- ar
- }
-
- def printArray(xs: Array[Double]) =
- xs.iterator foreach { x => println(x) }
-
- def findGreater(xs: Array[Double], limit: Double) =
- xs.iterator
- .zip(Iterator.from(0))
- .filter{case (x, i) => x > limit }
- .map{case (x, i) => i}
-
- def main(args: Array[String]) {
- val ar = Array/*[Double]*/(6, 2, 8, 5, 1)
- printArray(ar)
- println("Elements greater than 3.0:")
- findGreater(ar, 3.0) foreach { x => Console.println(ar(x)) }
- }
-
-}
diff --git a/docs/examples/jolib/Ref.scala b/docs/examples/jolib/Ref.scala
deleted file mode 100644
index 099a3c2df2..0000000000
--- a/docs/examples/jolib/Ref.scala
+++ /dev/null
@@ -1,55 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package examples.jolib;
-/*
-import concurrent.SyncVar;
-import concurrent.jolib._;
-
-class Ref[a](init: a) extends Join {
-
- object get extends Synchr[a](this) { case class C() extends SyncVar[a]; }
- object set extends Synchr[unit](this) { case class C(x: a) extends SyncVar[unit]; }
- object state extends Asynchr(this) { case class C(x: a); }
-
- rules (
- (List(get, state), { case List(g @ get.C(), state.C(x) ) =>
- { g.set(x); state(state.C(x)) } }),
- (List(set, state), { case List(s @ set.C(x), state.C(y) ) =>
- { s.set(()); state(state.C(x)) } })
- );
-
- state(state.C(init));
-
- def Get: a = get(get.C());
- def Set(x: a): unit = set(set.C(x));
-}
-*/
-object RefTest {
-
- def main(args: Array[String]) = {
- System.out.println("Started.");
-/*
- concurrent.ops.spawn({
- val r1 = new Ref(0);
- System.out.println("Reference r1 created.");
- System.out.println("Value r1 (first time) = " + r1.Get);
- r1.Set(42);
- System.out.println("Value r1 (second time) = " + r1.Get);
- });
- concurrent.ops.spawn({
- val r2 = new Ref(100);
- System.out.println("Reference r2 created.");
- System.out.println("Value r2 (first time) = " + r2.Get);
- r2.Set(89);
- System.out.println("Value r2 (second time) = " + r2.Get);
- });
-*/
- }
-
-}
diff --git a/docs/examples/jolib/parallelOr.scala b/docs/examples/jolib/parallelOr.scala
deleted file mode 100644
index a0305c56bf..0000000000
--- a/docs/examples/jolib/parallelOr.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package examples.jolib;
-/*
-import concurrent.jolib._;
-import concurrent.SyncVar;
-
-/** Implementation in the join-calculus of a parallel OR. */
-object or extends Join {
-
- object res extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
- object res1 extends Asynchr(this) { case class C(b: boolean); }
- object res2 extends Asynchr(this) { case class C(b: boolean); }
- object res1False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
- object res2False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
-
- rules(
- (List(res, res1), { case List(r @ res.C(), res1.C(b)) =>
- if (b) r.set(b) else r.set(res1False(res1False.C())) }),
-
- (List(res, res2), { case List(r @ res.C(), res2.C(b)) =>
- if (b) r.set(b) else r.set(res2False(res2False.C())) }),
-
- (List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) =>
- r.set(b) }),
-
- (List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) =>
- r.set(b) })
- );
-
- def apply(b1: => boolean, b2: => boolean): boolean = {
- concurrent.ops.spawn(res1(res1.C(b1)));
- concurrent.ops.spawn(res2(res2.C(b2)));
- res(res.C())
- }
-}
-*/
-object parallelOr {
-
- def main(args: Array[String]): unit = {
- def loop: boolean = { while (true) {}; true };
-/*
- System.out.println("true || true = " + or(true, true));
- System.out.println("false || false = " + or(false, false));
- System.out.println("false || true = " + or(false, true));
- System.out.println("true || false = " + or(true, false));
- System.out.println("true || loop = " + or(true, loop));
- System.out.println("loop || true = " + or(loop, true));
-*/
- }
-
-}
diff --git a/docs/examples/maps.scala b/docs/examples/maps.scala
deleted file mode 100644
index d545b50ab9..0000000000
--- a/docs/examples/maps.scala
+++ /dev/null
@@ -1,187 +0,0 @@
-package examples
-
-object maps {
-
- import scala.collection.immutable._
-
- trait MapStruct[kt, vt] {
- trait Map extends Function1[kt, vt] {
- def extend(key: kt, value: vt): Map
- def remove(key: kt): Map
- def domain: Stream[kt]
- def range: Stream[vt]
- }
- type map <: Map
- val empty: map
- }
-
- class AlgBinTree[kt >: Null <: Ordered[kt], vt >: Null <: AnyRef]() extends MapStruct[kt, vt] {
- type map = AlgMap
-
- val empty: AlgMap = Empty()
-
- private case class Empty() extends AlgMap {}
- private case class Node(key: kt, value: vt, l: map, r: map) extends AlgMap {}
-
- trait AlgMap extends Map {
- def apply(key: kt): vt = this match {
- case Empty() => null
- case Node(k, v, l, r) =>
- if (key < k) l.apply(key)
- else if (key > k) r.apply(key)
- else v
- }
-
- def extend(key: kt, value: vt): map = this match {
- case Empty()=> Node(key, value, empty, empty)
- case Node(k, v, l, r) =>
- if (key < k) Node(k, v, l.extend(key, value), r)
- else if (key > k) Node(k, v, l, r.extend(key, value))
- else Node(k, value, l, r)
- }
-
- def remove(key: kt): map = this match {
- case Empty()=> empty
- case Node(k, v, l, r) =>
- if (key < k) Node(k, v, l.remove(key), r)
- else if (key > k) Node(k, v, l, r.remove(key))
- else if (l == empty) r
- else if (r == empty) l
- else {
- val midKey = r.domain.head
- Node(midKey, r.apply(midKey), l, r.remove(midKey))
- }
- }
-
- def domain: Stream[kt] = this match {
- case Empty()=> Stream.empty
- case Node(k, v, l, r) => l.domain append Stream.cons(k, r.domain)
- }
-
- def range: Stream[vt] = this match {
- case Empty()=> Stream.empty
- case Node(k, v, l, r) => l.range append Stream.cons(v, r.range)
- }
- }
- }
-
- class OOBinTree[kt >: Null <: Ordered[kt], vt >: Null <: AnyRef]() extends MapStruct[kt, vt] {
- type map = OOMap
-
- trait OOMap extends Map {
- def apply(key: kt): vt
- def extend(key: kt, value: vt): map
- def remove(key: kt): map
- def domain: Stream[kt]
- def range: Stream[vt]
- }
- val empty: OOMap = new OOMap {
- def apply(key: kt): vt = null
- def extend(key: kt, value: vt) = new Node(key, value, empty, empty)
- def remove(key: kt) = empty
- def domain: Stream[kt] = Stream.empty
- def range: Stream[vt] = Stream.empty
- }
- private class Node(k: kt, v: vt, l: map, r: map) extends OOMap {
- def apply(key: kt): vt =
- if (key < k) l.apply(key)
- else if (key > k) r.apply(key)
- else v;
- def extend(key: kt, value: vt): map =
- if (key < k) new Node(k, v, l.extend(key, value), r)
- else if (key > k) new Node(k, v, l, r.extend(key, value))
- else new Node(k, value, l, r)
- def remove(key: kt): map =
- if (key < k) new Node(k, v, l.remove(key), r)
- else if (key > k) new Node(k, v, l, r.remove(key))
- else if (l == empty) r
- else if (r == empty) l
- else {
- val midKey = r.domain.head
- new Node(midKey, r(midKey), l, r.remove(midKey))
- }
- def domain: Stream[kt] = l.domain append Stream.cons(k, r.domain)
- def range: Stream[vt] = l.range append Stream.cons(v, r.range)
- }
- }
-
- class MutBinTree[kt >: Null <: Ordered[kt], vt >: Null <: AnyRef]() extends MapStruct[kt, vt] {
- type map = MutMap
- class MutMap(key: kt, value: vt) extends Map {
- val k = key
- var v = value
- var l, r = empty
-
- def apply(key: kt): vt =
- if (this == empty) null
- else if (key < k) l.apply(key)
- else if (key > k) r.apply(key)
- else v
-
- def extend(key: kt, value: vt): map =
- if (this == empty) new MutMap(key, value)
- else {
- if (key < k) l = l.extend(key, value)
- else if (key > k) r = r.extend(key, value)
- else v = value
- this
- }
-
- def remove(key: kt): map =
- if (this == empty) this
- else if (key < k) { l = l.remove(key); this }
- else if (key > k) { r = r.remove(key); this }
- else if (l == empty) r
- else if (r == empty) l
- else {
- var mid = r
- while (!(mid.l == empty)) { mid = mid.l }
- mid.r = r.remove(mid.k)
- mid.l = l
- mid
- }
-
- def domain: Stream[kt] =
- if (this == empty) Stream.empty
- else l.domain append Stream.cons(k, r.domain)
-
- def range: Stream[vt] =
- if (this == empty) Stream.empty
- else l.range append Stream.cons(v, r.range)
- }
- val empty = new MutMap(null, null)
- }
-
- class Date(y: Int, m: Int, d: Int) extends Ordered[Date] {
- def year = y
- def month = m
- def day = d
-
- def compare(other: Date): Int =
- if (year == other.year &&
- month == other.month &&
- day == other.day)
- 0
- else if (year < other.year ||
- year == other.year && month < other.month ||
- month == other.month && day < other.day)
- -1
- else
- 1
-
- override def equals(that: Any): Boolean =
- that.isInstanceOf[Date] && {
- val o = that.asInstanceOf[Date];
- day == o.day && month == o.month && year == o.year
- }
- }
-
- def main(args: Array[String]) {
- val t = new OOBinTree[Date, String]()
- ()
- }
-
-}
-
-
-
diff --git a/docs/examples/monads/callccInterpreter.scala b/docs/examples/monads/callccInterpreter.scala
deleted file mode 100644
index b5008c4c1b..0000000000
--- a/docs/examples/monads/callccInterpreter.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-object callccInterpreter {
-
- def id[a](x: a) = x
-
- type Answer = Value;
-
- case class M[A](in: (A => Answer) => Answer) {
- def bind[B](k: A => M[B]) = M[B](c => in (a => k(a) in c));
- def map[B](f: A => B): M[B] = bind(x => unitM(f(x)));
- def flatMap[B](f: A => M[B]): M[B] = bind(f);
- }
-
- def unitM[A](a: A) = M[A](c => c(a));
-
- def showM(m: M[Value]): String = (m in id).toString();
-
- def callCC[A](h: (A => M[A]) => M[A]) =
- M[A](c => h(a => M[A](d => c(a))) in c);
-
- type Name = String;
-
- trait Term;
- case class Var(x: Name) extends Term;
- case class Con(n: Int) extends Term;
- case class Add(l: Term, r: Term) extends Term;
- case class Lam(x: Name, body: Term) extends Term;
- case class App(fun: Term, arg: Term) extends Term;
- case class Ccc(x: Name, t: Term) extends Term;
-
- trait Value;
- case object Wrong extends Value {
- override def toString() = "wrong"
- }
- case class Num(n: Int) extends Value {
- override def toString() = n.toString();
- }
- case class Fun(f: Value => M[Value]) extends Value {
- override def toString() = "<function>"
- }
-
- type Environment = List[Tuple2[Name, Value]];
-
- def lookup(x: Name, e: Environment): M[Value] = e match {
- case List() => unitM(Wrong)
- case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
- }
-
- def add(a: Value, b: Value): M[Value] = (a, b) match {
- case (Num(m), Num(n)) => unitM(Num(m + n))
- case _ => unitM(Wrong)
- }
-
- def apply(a: Value, b: Value): M[Value] = a match {
- case Fun(k) => k(b)
- case _ => unitM(Wrong)
- }
-
- def interp(t: Term, e: Environment): M[Value] = t match {
- case Var(x) => lookup(x, e)
- case Con(n) => unitM(Num(n))
- case Add(l, r) => for (a <- interp(l, e);
- b <- interp(r, e);
- c <- add(a, b))
- yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
- case App(f, t) => for (a <- interp(f, e);
- b <- interp(t, e);
- c <- apply(a, b))
- yield c
- case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e))
- }
-
- def test(t: Term): String =
- showM(interp(t, List()));
-
- val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
- val term1 = App(Con(1), Con(2));
- val term2 = Add(Con(1), Ccc("k", Add(Con(2), App(Var("k"), Con(4)))));
-
- def main(args: Array[String]) = {
- System.out.println(test(term0));
- System.out.println(test(term1));
- System.out.println(test(term2));
- }
-}
-
diff --git a/docs/examples/monads/directInterpreter.scala b/docs/examples/monads/directInterpreter.scala
deleted file mode 100644
index d8ca8ccfa7..0000000000
--- a/docs/examples/monads/directInterpreter.scala
+++ /dev/null
@@ -1,55 +0,0 @@
-object directInterpreter {
-
- type Name = String;
-
- trait Term;
- case class Var(x: Name) extends Term;
- case class Con(n: Int) extends Term;
- case class Add(l: Term, r: Term) extends Term;
- case class Lam(x: Name, body: Term) extends Term;
- case class App(fun: Term, arg: Term) extends Term;
-
- trait Value;
- case object Wrong extends Value;
- case class Num(n: Int) extends Value;
- case class Fun(f: Value => Value)extends Value;
-
- def showval(v: Value): String = v match {
- case Wrong => "<wrong>"
- case Num(n) => n.toString()
- case Fun(f) => "<function>"
- }
-
- type Environment = List[Tuple2[Name, Value]];
-
- def lookup(x: Name, e: Environment): Value = e match {
- case List() => Wrong
- case (y, b) :: e1 => if (x == y) b else lookup(x, e1)
- }
-
- def add(a: Value, b: Value): Value = (a, b) match {
- case (Num(m), Num(n)) => Num(m + n)
- case _ => Wrong
- }
-
- def apply(a: Value, b: Value) = a match {
- case Fun(k) => k(b)
- case _ => Wrong
- }
-
- def interp(t: Term, e: Environment): Value = t match {
- case Var(x) => lookup(x, e)
- case Con(n) => Num(n)
- case Add(l, r) => add(interp(l, e), interp(r, e))
- case Lam(x, t) => Fun(a => interp(t, (x, a) :: e))
- case App(f, t) => apply(interp(f, e), interp(t, e))
- }
-
- def test(t: Term): String =
- showval(interp(t, List()));
-
- val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
-
- def main(args: Array[String]) =
- System.out.println(test(term0));
-}
diff --git a/docs/examples/monads/errorInterpreter.scala b/docs/examples/monads/errorInterpreter.scala
deleted file mode 100644
index c15e1041e2..0000000000
--- a/docs/examples/monads/errorInterpreter.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-object errorInterpreter {
-
- trait M[A] {
- def show: String
- def bind[B](k: A => M[B]): M[B]
- def map[B](f: A => B): M[B] = bind(x => unitM(f(x)))
- def flatMap[B](f: A => M[B]): M[B] = bind(f)
- }
-
- def unitM[A](a: A): M[A] = new Suc(a)
- def errorM[A](msg: String): M[A] = new Err(msg)
-
- def showM(m: M[Value]): String = m.show
-
- class Suc[A](x: A) extends M[A] {
- def bind[B](k: A => M[B]): M[B] = k(x)
- def show: String = "Success: " + x
- }
- class Err[A](msg: String) extends M[A] {
- def bind[B](k: A => M[B]): M[B] = new Err(msg)
- def show: String = "Error: " + msg
- }
-
- type Name = String
-
- trait Term
- case class Var(x: Name) extends Term
- case class Con(n: Int) extends Term
- case class Add(l: Term, r: Term) extends Term
- case class Lam(x: Name, body: Term) extends Term
- case class App(fun: Term, arg: Term) extends Term
-
- trait Value
- case object Wrong extends Value {
- override def toString() = "wrong"
- }
- case class Num(n: Int) extends Value {
- override def toString() = n.toString()
- }
- case class Fun(f: Value => M[Value]) extends Value {
- override def toString() = "<function>"
- }
-
- type Environment = List[Tuple2[Name, Value]]
-
- def lookup(x: Name, e: Environment): M[Value] = e match {
- case List() => errorM("unbound variable: " + x);
- case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
- }
-
- def add(a: Value, b: Value): M[Value] = (a, b) match {
- case (Num(m), Num(n)) => unitM(Num(m + n))
- case _ => errorM("should be numbers: " + a + "," + b)
- }
-
- def apply(a: Value, b: Value): M[Value] = a match {
- case Fun(k) => k(b)
- case _ => errorM("should be function: " + a)
- }
-
- def interp(t: Term, e: Environment): M[Value] = t match {
- case Var(x) => lookup(x, e)
- case Con(n) => unitM(Num(n))
- case Add(l, r) => for (a <- interp(l, e);
- b <- interp(r, e);
- c <- add(a, b))
- yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
- case App(f, t) => for (a <- interp(f, e);
- b <- interp(t, e);
- c <- apply(a, b))
- yield c
- }
-
- def test(t: Term): String =
- showM(interp(t, List()))
-
- val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)))
- val term1 = App(Con(1), Con(2))
-
- def main(args: Array[String]) = {
- System.out.println(test(term0))
- System.out.println(test(term1))
- }
-}
-
diff --git a/docs/examples/monads/simpleInterpreter.scala b/docs/examples/monads/simpleInterpreter.scala
deleted file mode 100644
index 64636749ff..0000000000
--- a/docs/examples/monads/simpleInterpreter.scala
+++ /dev/null
@@ -1,75 +0,0 @@
-object simpleInterpreter {
-
- case class M[A](value: A) {
- def bind[B](k: A => M[B]): M[B] = k(value);
- def map[B](f: A => B): M[B] = bind(x => unitM(f(x)));
- def flatMap[B](f: A => M[B]): M[B] = bind(f);
- }
-
- def unitM[A](a: A): M[A] = M(a);
-
- def showM(m: M[Value]): String = m.value.toString();
-
- type Name = String;
-
- trait Term;
- case class Var(x: Name) extends Term;
- case class Con(n: Int) extends Term;
- case class Add(l: Term, r: Term) extends Term;
- case class Lam(x: Name, body: Term) extends Term;
- case class App(fun: Term, arg: Term) extends Term;
-
- trait Value;
- case object Wrong extends Value {
- override def toString() = "wrong"
- }
- case class Num(n: Int) extends Value {
- override def toString() = n.toString();
- }
- case class Fun(f: Value => M[Value]) extends Value {
- override def toString() = "<function>"
- }
-
- type Environment = List[Tuple2[Name, Value]];
-
- def lookup(x: Name, e: Environment): M[Value] = e match {
- case List() => unitM(Wrong)
- case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
- }
-
- def add(a: Value, b: Value): M[Value] = (a, b) match {
- case (Num(m), Num(n)) => unitM(Num(m + n))
- case _ => unitM(Wrong)
- }
-
- def apply(a: Value, b: Value): M[Value] = a match {
- case Fun(k) => k(b)
- case _ => unitM(Wrong)
- }
-
- def interp(t: Term, e: Environment): M[Value] = t match {
- case Var(x) => lookup(x, e)
- case Con(n) => unitM(Num(n))
- case Add(l, r) => for (a <- interp(l, e);
- b <- interp(r, e);
- c <- add(a, b))
- yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
- case App(f, t) => for (a <- interp(f, e);
- b <- interp(t, e);
- c <- apply(a, b))
- yield c
- }
-
- def test(t: Term): String =
- showM(interp(t, List()));
-
- val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
- val term1 = App(Con(1), Con(2));
-
- def main(args: Array[String]) = {
- System.out.println(test(term0));
- System.out.println(test(term1));
- }
-}
-
diff --git a/docs/examples/monads/stateInterpreter.scala b/docs/examples/monads/stateInterpreter.scala
deleted file mode 100644
index e13e9049da..0000000000
--- a/docs/examples/monads/stateInterpreter.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-package examples.monads;
-
-object stateInterpreter {
-
- type State = Int;
-
- val tickS = new M(s => ((), s + 1));
-
- case class M[A](in: State => Tuple2[A, State]) {
- def bind[B](k: A => M[B]) = M[B]{ s0 =>
- val (a, s1) = this in s0; k(a) in s1
- }
- def map[B](f: A => B): M[B] = bind(x => unitM(f(x)));
- def flatMap[B](f: A => M[B]): M[B] = bind(f);
- }
-
- def unitM[A](a: A) = M[A](s => (a, s));
-
- def showM(m: M[Value]): String = {
- val (a, s1) = m in 0;
- "Value: " + a + "; Count: " + s1
- }
-
- type Name = String;
-
- trait Term;
- case class Var(x: Name) extends Term;
- case class Con(n: Int) extends Term;
- case class Add(l: Term, r: Term) extends Term;
- case class Lam(x: Name, body: Term) extends Term;
- case class App(fun: Term, arg: Term) extends Term;
-
- trait Value;
- case object Wrong extends Value {
- override def toString() = "wrong"
- }
- case class Num(n: Int) extends Value {
- override def toString() = n.toString();
- }
- case class Fun(f: Value => M[Value]) extends Value {
- override def toString() = "<function>"
- }
-
- type Environment = List[Tuple2[Name, Value]];
-
- def lookup(x: Name, e: Environment): M[Value] = e match {
- case List() => unitM(Wrong)
- case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1)
- }
-
- def add(a: Value, b: Value): M[Value] = (a, b) match {
- case (Num(m), Num(n)) => for (_ <- tickS) yield Num(m + n)
- case _ => unitM(Wrong)
- }
-
- def apply(a: Value, b: Value): M[Value] = a match {
- case Fun(k) => for (_ <- tickS; c <- k(b)) yield c
- case _ => unitM(Wrong)
- }
-
- def interp(t: Term, e: Environment): M[Value] = t match {
- case Var(x) => lookup(x, e)
- case Con(n) => unitM(Num(n))
- case Add(l, r) => for (a <- interp(l, e);
- b <- interp(r, e);
- c <- add(a, b))
- yield c
- case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e)))
- case App(f, t) => for (a <- interp(f, e);
- b <- interp(t, e);
- c <- apply(a, b))
- yield c
- }
-
- def test(t: Term): String =
- showM(interp(t, List()));
-
- val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
- val term1 = App(Con(1), Con(2));
-
- def main(args: Array[String]) = {
- System.out.println(test(term0));
- System.out.println(test(term1));
- }
-}
-
diff --git a/docs/examples/oneplacebuffer.scala b/docs/examples/oneplacebuffer.scala
deleted file mode 100644
index f7047a1c92..0000000000
--- a/docs/examples/oneplacebuffer.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-package examples
-
-object oneplacebuffer {
-
- import scala.actors.Actor._
- import scala.concurrent.ops
-
- class OnePlaceBuffer {
- private case class Put(x: Int)
- private case object Get
-
- private val m = actor {
- var buf: Option[Int] = None
- loop {
- react {
- case Put(x) if buf.isEmpty =>
- println("put "+x);
- buf = Some(x); reply()
- case Get if !buf.isEmpty =>
- val x = buf.get
- println("get "+x)
- buf = None; reply(x)
- }
- }
- }
- m.start()
-
- def write(x: Int) { m !? Put(x) }
-
- def read(): Int = (m !? Get).asInstanceOf[Int]
- }
-
- def kill(delay: Int) = new java.util.Timer().schedule(
- new java.util.TimerTask {
- override def run() {
- println("[killed]")
- sys exit 0
- }
- },
- delay) // in milliseconds
-
- def main(args: Array[String]) {
- val buf = new OnePlaceBuffer
- val random = new java.util.Random()
-
- def producer(n: Int) {
- Thread.sleep(random nextInt 1000)
- buf write n
- producer(n + 1)
- }
-
- def consumer {
- Thread.sleep(random nextInt 1000)
- val n = buf.read()
- consumer
- }
-
- ops spawn producer(0)
- ops spawn consumer
- kill(10000)
- }
-
-}
-
diff --git a/docs/examples/parsing/ArithmeticParser.scala b/docs/examples/parsing/ArithmeticParser.scala
deleted file mode 100644
index c272fa0ba0..0000000000
--- a/docs/examples/parsing/ArithmeticParser.scala
+++ /dev/null
@@ -1,57 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package examples.parsing
-
-import scala.util.parsing.combinator.lexical.StdLexical
-import scala.util.parsing.combinator.syntactical.StdTokenParsers
-
-/** Parse and evaluate a numeric expression as a sequence of terms, separated by + or -
- * a term is a sequence of factors, separated by * or /
- * a factor is a parenthesized expression or a number
- *
- * @author Adriaan Moors
- */
-object arithmeticParser extends StdTokenParsers {
- type Tokens = StdLexical ; val lexical = new StdLexical
- lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
-
- lazy val expr = term*("+" ^^^ {(x: int, y: int) => x + y} | "-" ^^^ {(x: int, y: int) => x - y})
- lazy val term = factor*("*" ^^^ {(x: int, y: int) => x * y} | "/" ^^^ {(x: int, y: int) => x / y})
- lazy val factor: Parser[int] = "(" ~> expr <~ ")" | numericLit ^^ (_.toInt)
-
- def main(args: Array[String]) {
- println(
- if (args.length == 1) {
- expr(new lexical.Scanner(args(0)))
- }
- else
- "usage: scala examples.parsing.arithmeticParser <expr-string>"
- )
- }
-}
-
-
-object arithmeticParserDesugared extends StdTokenParsers {
- type Tokens = StdLexical ; val lexical = new StdLexical
- lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
-
- lazy val expr = chainl1(term, (keyword("+").^^^{(x: int, y: int) => x + y}).|(keyword("-").^^^{(x: int, y: int) => x - y}))
- lazy val term = chainl1(factor, (keyword("*").^^^{(x: int, y: int) => x * y}).|(keyword("/").^^^{(x: int, y: int) => x / y}))
- lazy val factor: Parser[int] = keyword("(").~>(expr.<~(keyword(")"))).|(numericLit.^^(x => x.toInt))
-
- def main(args: Array[String]) {
- println(
- if (args.length == 1) {
- expr(new lexical.Scanner(args(0)))
- }
- else
- "usage: scala examples.parsing.arithmeticParser <expr-string>"
- )
- }
-}
diff --git a/docs/examples/parsing/ArithmeticParsers.scala b/docs/examples/parsing/ArithmeticParsers.scala
deleted file mode 100644
index 62d7a61862..0000000000
--- a/docs/examples/parsing/ArithmeticParsers.scala
+++ /dev/null
@@ -1,70 +0,0 @@
-package examples.parsing
-
-import scala.util.parsing.combinator1.syntactical.StandardTokenParsers
-
-object ArithmeticParsers extends StandardTokenParsers {
- lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
-
- def expr: Parser[Any] = term ~ rep("+" ~ term | "-" ~ term)
- def term = factor ~ rep("*" ~ factor | "/" ~ factor)
- def factor: Parser[Any] = "(" ~ expr ~ ")" | numericLit
-
- def main(args: Array[String]) {
- val tokens = new lexical.Scanner(args(0))
- println(args(0))
- println(phrase(expr)(tokens))
- }
-}
-
-object ArithmeticParsers1 extends StandardTokenParsers {
- lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
-
- val reduceList: Int ~ List[String ~ Int] => Int = {
- case i ~ ps => (i /: ps)(reduce)
- }
-
- def reduce(x: Int, r: String ~ Int) = (r: @unchecked) match {
- case "+" ~ y => x + y
- case "-" ~ y => x - y
- case "*" ~ y => x * y
- case "/" ~ y => x / y
- }
-
- def expr : Parser[Int] = term ~ rep ("+" ~ term | "-" ~ term) ^^ reduceList
- def term : Parser[Int] = factor ~ rep ("*" ~ factor | "/" ~ factor) ^^ reduceList
- def factor: Parser[Int] = "(" ~> expr <~ ")" | numericLit ^^ (_.toInt)
-
- def main(args: Array[String]) {
- val tokens = new lexical.Scanner(args(0))
- println(args(0))
- println(phrase(expr)(tokens))
- }
-}
-
-class Expr
-case class BinOp(op: String, l: Expr, r: Expr) extends Expr
-case class Num(n: Int) extends Expr
-
-object ArithmeticParsers2 extends StandardTokenParsers {
- lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
-
- val reduceList: Expr ~ List[String ~ Expr] => Expr = {
- case i ~ ps => (i /: ps)(reduce)
- }
-
- def reduce(l: Expr, r: String ~ Expr) = BinOp(r._1, l, r._2)
- def mkNum(s: String) = Num(s.toInt)
-
- def expr : Parser[Expr] = term ~ rep ("+" ~ term | "-" ~ term) ^^ reduceList
- def term : Parser[Expr] = factor ~ rep ("*" ~ factor | "/" ~ factor) ^^ reduceList
- def factor: Parser[Expr] = "(" ~> expr <~ ")" | numericLit ^^ ((s: String) => Num(s.toInt))
-
- def main(args: Array[String]) {
- val parse = phrase(expr)
- val tokens = new lexical.Scanner(args(0))
- println(args(0))
- println(parse(tokens))
- }
-}
-
-
diff --git a/docs/examples/parsing/JSON.scala b/docs/examples/parsing/JSON.scala
deleted file mode 100644
index abfa242e9f..0000000000
--- a/docs/examples/parsing/JSON.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-package examples.parsing
-
-import scala.util.parsing.combinator1.syntactical.StandardTokenParsers
-
-object JSON extends StandardTokenParsers {
- lexical.delimiters += ("{", "}", "[", "]", ":", ",")
- lexical.reserved += ("null", "true", "false")
-
- def obj : Parser[Any] = "{" ~ repsep(member, ",") ~ "}"
- def arr : Parser[Any] = "[" ~ repsep(value, ",") ~ "]"
- def member: Parser[Any] = ident ~ ":" ~ value
- def value : Parser[Any] = ident | numericLit | obj | arr |
- "null" | "true" | "false"
-
- def main(args: Array[String]) {
- val tokens = new lexical.Scanner(args(0))
- println(args(0))
- println(phrase(value)(tokens))
- }
-}
-object JSON1 extends StandardTokenParsers {
- lexical.delimiters += ("{", "}", "[", "]", ":", ",")
- lexical.reserved += ("null", "true", "false")
-
- def obj: Parser[Map[String, Any]] =
- "{" ~> repsep(member, ",") <~ "}" ^^ (Map() ++ _)
-
- def arr: Parser[List[Any]] =
- "[" ~> repsep(value, ",") <~ "]"
-
- def member: Parser[(String, Any)] =
- ident ~ ":" ~ value ^^ { case name ~ ":" ~ value => (name -> value) }
-
- def value: Parser[Any] =
- ident | numericLit ^^ (_.toInt) | obj | arr |
- "null" ^^^ null | "true" ^^^ true | "false" ^^^ false
-
- def main(args: Array[String]) {
- val tokens = new lexical.Scanner(args(0))
- println(args(0))
- println(phrase(value)(tokens))
- }
-}
-
diff --git a/docs/examples/parsing/ListParser.scala b/docs/examples/parsing/ListParser.scala
deleted file mode 100644
index 59fc292c1d..0000000000
--- a/docs/examples/parsing/ListParser.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-package examples.parsing
-
-import scala.util.parsing.combinator.{Parsers, ImplicitConversions, ~, mkTilde}
-import scala.util.parsing.input.CharArrayReader
-
-object listParser {
- abstract class Tree
- case class Id(s: String) extends Tree
- case class Num(n: Int) extends Tree
- case class Lst(elems: List[Tree]) extends Tree
-
- import Character.{isLetter, isLetterOrDigit, isDigit}
- def mkString(cs: List[Any]) = cs.mkString("")
-
- class ListParsers extends Parsers {
- type Elem = Char
-
- lazy val ident = rep1(elem("letter", isLetter), elem("letter or digit", isLetterOrDigit)) ^^ {cs => Id(mkString(cs))}
- lazy val number = chainl1(elem("digit", isDigit) ^^ (_ - '0'), success{(accum: Int, d: Int) => accum * 10 + d}) ^^ Num
- lazy val list = '(' ~> repsep(expr, ',') <~ ')' ^^ Lst
- lazy val expr: Parser[Tree] = list | ident | number
- }
-
- def main(args: Array[String]) {
- println(
- if (args.length == 1) {
- (new ListParsers).expr(new CharArrayReader(args(0).toCharArray()))
- }
- else
- "usage: scala examples.parsing.listParser <list-string>"
- )
- }
-}
diff --git a/docs/examples/parsing/ListParsers.scala b/docs/examples/parsing/ListParsers.scala
deleted file mode 100644
index b449c4a641..0000000000
--- a/docs/examples/parsing/ListParsers.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-package examples.parsing
-
-import scala.util.parsing.combinator1.syntactical.StandardTokenParsers
-
-object ListParsers extends StandardTokenParsers {
- lexical.delimiters ++= List("(", ")", ",")
-
- def expr: Parser[Any] = "(" ~ exprs ~ ")" | ident | numericLit
- def exprs: Parser[Any] = expr ~ rep ("," ~ expr)
-
- def main(args: Array[String]) {
- val tokens = new lexical.Scanner(args(0))
- println(args(0))
- println(phrase(expr)(tokens))
- }
-}
-
-object ListParsers1 extends StandardTokenParsers {
- lexical.delimiters ++= List("(", ")", ",")
-
- def expr: Parser[Any] = "(" ~> exprs <~ ")" | ident | numericLit
-
- def exprs: Parser[List[Any]] = expr ~ rep ("," ~> expr) ^^ { case x ~ y => x :: y }
-
- def main(args: Array[String]) {
- val tokens = new lexical.Scanner(args(0))
- println(args(0))
- println(phrase(expr)(tokens))
- }
-}
diff --git a/docs/examples/parsing/MiniML.scala b/docs/examples/parsing/MiniML.scala
deleted file mode 100644
index f7f7172e8d..0000000000
--- a/docs/examples/parsing/MiniML.scala
+++ /dev/null
@@ -1,52 +0,0 @@
-package examples.parsing
-
-import scala.util.parsing.combinator1.syntactical.StandardTokenParsers
-import scala.util.parsing.combinator1.syntactical.StandardTokenParsers
-
-object MiniML extends StandardTokenParsers {
- lexical.delimiters += ("(", ")", ".", "=")
- lexical.reserved += ("lambda", "let", "in")
-
- def expr: Parser[Any] = (
- "let" ~ ident ~ "=" ~ expr ~ "in" ~ expr
- | "lambda" ~ ident ~ "." ~ expr
- | simpleExpr ~ rep(expr)
- )
- def simpleExpr: Parser[Any] = (
- ident
- | "(" ~ expr ~ ")"
- )
-
- def main(args: Array[String]) {
- val tokens = new lexical.Scanner(args(0))
- println(args(0))
- println(phrase(expr)(tokens))
- }
-}
-
-class Expr
-case class Let(x: String, expr: Expr, body: Expr) extends Expr
-case class Lambda(x: String, expr: Expr) extends Expr
-case class Apply(fun: Expr, arg: Expr) extends Expr
-case class Var(x: String) extends Expr
-
-object MiniML1 extends StandardTokenParsers {
- lexical.delimiters += ("(", ")", ".", "=")
- lexical.reserved += ("lambda", "let", "in")
-
- def expr: Parser[Expr] = (
- "let" ~ ident ~ "=" ~ expr ~ "in" ~ expr ^^ { case "let" ~ x ~ "=" ~ e ~ "in" ~ b => Let(x, e, b) }
- | "lambda" ~ ident ~ "." ~ expr ^^ { case "lambda" ~ x ~ "." ~ e => Lambda(x, e) }
- | simpleExpr ~ rep(expr) ^^ { case f ~ as => (f /: as) (Apply) }
- )
- def simpleExpr: Parser[Expr] = (
- ident ^^ { Var }
- | "(" ~> expr <~ ")"
- )
-
- def main(args: Array[String]) {
- val tokens = new lexical.Scanner(args(0))
- println(args(0))
- println(phrase(expr)(tokens))
- }
-}
diff --git a/docs/examples/parsing/lambda/Main.scala b/docs/examples/parsing/lambda/Main.scala
deleted file mode 100644
index 165e82b670..0000000000
--- a/docs/examples/parsing/lambda/Main.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-package examples.parsing.lambda
-
-import scala.util.parsing.combinator.Parsers
-import scala.util.parsing.input.StreamReader
-
-import java.io.File
-import java.io.FileInputStream
-import java.io.InputStreamReader
-
-/**
- * Parser for an untyped lambda calculus
- *
- * Usage: scala examples.parsing.lambda.Main <file>
- *
- * (example files: see test/ *.kwi)
- *
- * @author Miles Sabin (adapted slightly by Adriaan Moors)
- */
-object Main extends Application with TestParser
-{
- override def main(args: Array[String]) =
- {
- val in = StreamReader(new InputStreamReader(new FileInputStream(new File(args(0))), "ISO-8859-1"))
- parse(in) match
- {
- case Success(term, _) =>
- {
- Console.println("Term: \n"+term)
- }
- case Failure(msg, remainder) => Console.println("Failure: "+msg+"\n"+"Remainder: \n"+remainder.pos.longString)
- case Error(msg, remainder) => Console.println("Error: "+msg+"\n"+"Remainder: \n"+remainder.pos.longString)
- }
- }
-}
diff --git a/docs/examples/parsing/lambda/TestParser.scala b/docs/examples/parsing/lambda/TestParser.scala
deleted file mode 100644
index d26589da1b..0000000000
--- a/docs/examples/parsing/lambda/TestParser.scala
+++ /dev/null
@@ -1,68 +0,0 @@
-package examples.parsing.lambda
-
-import scala.util.parsing.input.Reader
-import scala.util.parsing.combinator.lexical.StdLexical
-import scala.util.parsing.combinator.syntactical.StdTokenParsers
-import scala.util.parsing.combinator.ImplicitConversions
-
-/**
- * Parser for an untyped lambda calculus
- *
- * @author Miles Sabin (adapted slightly by Adriaan Moors)
- */
-trait TestParser extends StdTokenParsers with ImplicitConversions with TestSyntax
-{
- type Tokens = StdLexical
- val lexical = new StdLexical
- lexical.reserved ++= List("unit", "let", "in", "if", "then", "else")
- lexical.delimiters ++= List("=>", "->", "==", "(", ")", "=", "\\", "+", "-", "*", "/")
-
-
- def name : Parser[Name] = ident ^^ Name
-
- // meaning of the arguments to the closure during subsequent iterations
- // (...(expr2 op1 expr1) ... op1 expr1)
- // ^a^^^ ^o^ ^b^^^
- // ^^^^^^^a^^^^^^^ ^o^ ^^b^^
- def expr1 : Parser[Term] =
- chainl1(expr2, expr1, op1 ^^ {o => (a: Term, b: Term) => App(App(o, a), b)})
-
- def expr2 : Parser[Term] =
- chainl1(expr3, expr2, op2 ^^ {o => (a: Term, b: Term) => App(App(o, a), b)})
-
- def expr3 : Parser[Term] =
- chainl1(expr4, expr3, op3 ^^ {o => (a: Term, b: Term) => App(App(o, a), b)})
-
- def expr4 : Parser[Term] =
- ( "\\" ~> lambdas
- | ("let" ~> name) ~ ("=" ~> expr1) ~ ("in" ~> expr1) ^^ flatten3(Let)
- | ("if" ~> expr1) ~ ("then" ~> expr1) ~ ("else" ~> expr1) ^^ flatten3(If)
- | chainl1(aexpr, success(App(_: Term, _: Term)))
- )
-
- def lambdas : Parser[Term] =
- name ~ ("->" ~> expr1 | lambdas) ^^ flatten2(Lam)
-
- def aexpr : Parser[Term] =
- ( numericLit ^^ (_.toInt) ^^ Lit
- | name ^^ Ref
- | "unit" ^^^ Unit()
- | "(" ~> expr1 <~ ")"
- )
-
- def op1 : Parser[Term] =
- "==" ^^^ Ref(Name("=="))
-
- def op2 : Parser[Term] =
- ( "+" ^^^ Ref(Name("+"))
- | "-" ^^^ Ref(Name("-"))
- )
-
- def op3 : Parser[Term] =
- ( "*" ^^^ Ref(Name("*"))
- | "/" ^^^ Ref(Name("/"))
- )
-
- def parse(r: Reader[char]) : ParseResult[Term] =
- phrase(expr1)(new lexical.Scanner(r))
-}
diff --git a/docs/examples/parsing/lambda/TestSyntax.scala b/docs/examples/parsing/lambda/TestSyntax.scala
deleted file mode 100644
index 7edca6ccdc..0000000000
--- a/docs/examples/parsing/lambda/TestSyntax.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-package examples.parsing.lambda
-
-/**
- * Parser for an untyped lambda calculus: abstract syntax tree
- *
- * @author Miles Sabin (adapted slightly by Adriaan Moors)
- */
-trait TestSyntax
-{
- trait Term
-
- case class Unit extends Term
- {
- override def toString = "unit"
- }
-
- case class Lit(n: int) extends Term
- {
- override def toString = n.toString
- }
-
- case class Bool(b: boolean) extends Term
- {
- override def toString = b.toString
- }
-
- case class Name(name: String) extends Term
- {
- override def toString = name
- }
-
- case class Ref(n: Name) extends Term
- {
- def value = n
- }
-
- case class Lam(n: Name, l: Term) extends Term
- {
- override def toString = "(\\ "+n+" -> "+l+")"
- }
-
- case class App(t1: Term, t2: Term) extends Term
- {
- override def toString = "("+t1+" "+t2+")"
- }
-
- case class Let(n: Name, t1: Term, t2: Term) extends Term
- {
- override def toString = "let "+n+" = "+t1+" in "+t2
- }
-
- case class If(c: Term, t1: Term, t2: Term) extends Term
- {
- override def toString = "if "+c+" then "+t1+" else "+t2
- }
-
- trait PrimTerm extends Term
- {
- def apply(n: Lit) : Term
- }
-
- case class PrimPlus extends PrimTerm
- {
- def apply(x: Lit) = new PrimTerm { def apply(y: Lit) = Lit(x.n+y.n) }
- }
-
- case class PrimMinus extends PrimTerm
- {
- def apply(x: Lit) = new PrimTerm { def apply(y: Lit) = Lit(x.n-y.n) }
- }
-
- case class PrimMultiply extends PrimTerm
- {
- def apply(x: Lit) = new PrimTerm { def apply(y: Lit) = Lit(x.n*y.n) }
- }
-
- case class PrimDivide extends PrimTerm
- {
- def apply(x: Lit) = new PrimTerm { def apply(y: Lit) = Lit(x.n/y.n) }
- }
-
- case class PrimEquals extends PrimTerm
- {
- def apply(x: Lit) = new PrimTerm { def apply(y: Lit) = Bool(x.n == y.n) }
- }
-}
diff --git a/docs/examples/parsing/lambda/test/test-01.kwi b/docs/examples/parsing/lambda/test/test-01.kwi
deleted file mode 100644
index 9833d10673..0000000000
--- a/docs/examples/parsing/lambda/test/test-01.kwi
+++ /dev/null
@@ -1 +0,0 @@
-let x = 23 in (\y z -> x+y+z) 1 2
diff --git a/docs/examples/parsing/lambda/test/test-02.kwi b/docs/examples/parsing/lambda/test/test-02.kwi
deleted file mode 100644
index 11198c6fc9..0000000000
--- a/docs/examples/parsing/lambda/test/test-02.kwi
+++ /dev/null
@@ -1 +0,0 @@
-let f = (\x y -> x*y) in f 2 3
diff --git a/docs/examples/parsing/lambda/test/test-03.kwi b/docs/examples/parsing/lambda/test/test-03.kwi
deleted file mode 100644
index d4515d7297..0000000000
--- a/docs/examples/parsing/lambda/test/test-03.kwi
+++ /dev/null
@@ -1 +0,0 @@
-let f = (\x y -> x*y) in f (f 1 2) 3
diff --git a/docs/examples/parsing/lambda/test/test-04.kwi b/docs/examples/parsing/lambda/test/test-04.kwi
deleted file mode 100644
index e54c45457a..0000000000
--- a/docs/examples/parsing/lambda/test/test-04.kwi
+++ /dev/null
@@ -1 +0,0 @@
-let fact = \x -> if x == 0 then 1 else x*(fact (x-1)) in unit
diff --git a/docs/examples/parsing/lambda/test/test-05.kwi b/docs/examples/parsing/lambda/test/test-05.kwi
deleted file mode 100644
index 0b95d67846..0000000000
--- a/docs/examples/parsing/lambda/test/test-05.kwi
+++ /dev/null
@@ -1 +0,0 @@
-let fact = \x -> if x == 0 then 1 else x*(fact (x-1)) in fact 6
diff --git a/docs/examples/parsing/lambda/test/test-06.kwi b/docs/examples/parsing/lambda/test/test-06.kwi
deleted file mode 100644
index 47723dc998..0000000000
--- a/docs/examples/parsing/lambda/test/test-06.kwi
+++ /dev/null
@@ -1 +0,0 @@
-2*3+4*5 == 26
diff --git a/docs/examples/parsing/lambda/test/test-07.kwi b/docs/examples/parsing/lambda/test/test-07.kwi
deleted file mode 100644
index 14fba0d66a..0000000000
--- a/docs/examples/parsing/lambda/test/test-07.kwi
+++ /dev/null
@@ -1 +0,0 @@
-let fix = \f -> f(fix f) in unit
diff --git a/docs/examples/parsing/lambda/test/test-08.kwi b/docs/examples/parsing/lambda/test/test-08.kwi
deleted file mode 100644
index 7166d154f0..0000000000
--- a/docs/examples/parsing/lambda/test/test-08.kwi
+++ /dev/null
@@ -1 +0,0 @@
-let fix = (\f -> f(fix f)) in (fix (\g n -> if n == 0 then 1 else n*(g(n-1)))) 5
diff --git a/docs/examples/patterns.scala b/docs/examples/patterns.scala
deleted file mode 100644
index d082fcc3de..0000000000
--- a/docs/examples/patterns.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package examples
-
-object patterns {
-
- trait Tree
- case class Branch(left: Tree, right: Tree) extends Tree
- case class Leaf(x: Int) extends Tree
-
- val tree1 = Branch(Branch(Leaf(1), Leaf(2)), Branch(Leaf(3), Leaf(4)))
-
- def sumLeaves(t: Tree): Int = t match {
- case Branch(l, r) => sumLeaves(l) + sumLeaves(r)
- case Leaf(x) => x
- }
-
- def find[a,b](it: Iterator[Tuple2[a, b]], x: a): Option[b] = {
- var result: Option[b] = None
- var found = false
- while (it.hasNext && !found) {
- val (x1, y) = it.next
- if (x == x1) { found = true; result = Some(y) }
- }
- result
- }
-
- def printFinds[a](xs: List[Tuple2[a, String]], x: a) =
- find(xs.iterator, x) match {
- case Some(y) => System.out.println(y)
- case None => System.out.println("no match")
- }
-
- def main(args: Array[String]) {
- println("sum of leafs=" + sumLeaves(tree1))
- printFinds(List((3, "three"), (4, "four")), 4)
- }
-}
diff --git a/docs/examples/pilib/elasticBuffer.scala b/docs/examples/pilib/elasticBuffer.scala
deleted file mode 100644
index c173735dbb..0000000000
--- a/docs/examples/pilib/elasticBuffer.scala
+++ /dev/null
@@ -1,77 +0,0 @@
-package examples.pilib
-
-object elasticBuffer {
-
- import scala.concurrent.pilib._
-
- /**
- * Recursive type for channels that carry a "String" channel and
- * an object of the type we define.
- */
- class MetaChan extends Chan[Tuple2[Chan[String], MetaChan]]
-
- def Buffer(put: Chan[String], get: Chan[String]): Unit = {
-
- /**
- * An empty buffer cell, ready to pass on (o,r) to the left.
- */
- def Bl(i:Chan[String], l: MetaChan,
- o: Chan[String], r: MetaChan): unit =
- choice (
- l((o,r)) * (System.out.println("Removed one cell.")),
- i * (inp => Cl(i, l, o, r, inp))
- )
-
- /**
- * A buffer cell containing a value, ready to receive (o,r) from the right.
- */
- def Cl(i: Chan[String], l: MetaChan,
- o: Chan[String], r: MetaChan, content: String): Unit =
- choice (
- o(content) * (Bl(i,l,o,r)),
- i * (inp => Dl(i,l,o,r,content, inp)),
- r * ( { case (newo, newr) => Cl(i,l,newo,newr,content) })
- )
-
- /**
- * Two joined buffer cells, of type Cl
- */
- def Dl(i: Chan[String], l: MetaChan,
- o: Chan[String], r: MetaChan,
- content: String, inp: String): Unit = {
- val newlr = new MetaChan
- val newio = new Chan[String]
- spawn < Cl(i, l, newio, newlr, inp) | Cl(newio, newlr, o, r, content) >
- }
-
- // l and r channels for the leftmost and rightmost cell, respectively.
- val unused1 = new MetaChan
- val unused2 = new MetaChan
-
- Bl(put, unused1, get, unused2)
- }
-
- val random = new java.util.Random()
-
- def Producer(n: int, put: Chan[String]): Unit = {
- Thread.sleep(1 + random.nextInt(1000))
- val msg = "object " + n
- put.write(msg)
- System.out.println("Producer gave " + msg)
- Producer(n + 1, put)
- }
-
- def Consumer(get: Chan[String]): Unit = {
- Thread.sleep(1 + random.nextInt(1000))
- val msg = get.read
- System.out.println("Consumer took " + msg)
- Consumer(get)
- }
-
- def main(args: Array[String]): Unit = {
- val put = new Chan[String]
- val get = new Chan[String]
- spawn < Producer(0, put) | Consumer(get) | Buffer(put, get) >
- }
-
-}
diff --git a/docs/examples/pilib/handover.scala b/docs/examples/pilib/handover.scala
deleted file mode 100644
index 4e9a5670a0..0000000000
--- a/docs/examples/pilib/handover.scala
+++ /dev/null
@@ -1,186 +0,0 @@
-package examples.pilib
-
-/**
- * Handover example with recursive types for channels.
- */
-object handoverRecursive {
-
- import concurrent.pilib._
-
- val random = new java.util.Random()
-
- /**
- * Recursive type for channels that carry a channel "unit" and
- * an object of the type we define.
- */
- class Switch extends Chan[Tuple2[Chan[unit], Switch]]
-
- /**
- * Car.
- */
- def Car(talk: Chan[unit], switch: Switch): unit =
- choice (
- switch * ({ case (t,s) => Car(t, s) }),
- talk(()) * ( {
- Thread.sleep(1 + random.nextInt(1000));
- System.out.println("Car emitted a message.");
- Car(talk, switch)
- })
- );
-
- /**
- * Control center.
- */
- def Control(talk1: Chan[unit], switch1: Switch,
- gain1: Switch, lose1: Switch,
- talk2: Chan[unit], switch2: Switch,
- gain2: Switch, lose2: Switch): unit
- = {
- def Control1: unit= {
- Thread.sleep(1 + random.nextInt(1000));
- lose1.write((talk2, switch2));
- gain2.write((talk2, switch2));
- Control2
- }
- def Control2: unit = {
- Thread.sleep(1 + random.nextInt(1000));
- lose2.write((talk1, switch1));
- gain1.write((talk1, switch1));
- Control1
- }
- Control1
- }
-
- /**
- * Active transmitter.
- */
- def ActiveTransmitter(id: String, talk: Chan[unit], switch: Switch,
- gain: Switch, lose: Switch): unit
- =
- choice (
- talk * (x => {
- System.out.println(id + " received a message.")
- ActiveTransmitter(id, talk, switch, gain, lose)
- }),
- lose * ({ case (t, s) => {
- switch.write((t, s))
- IdleTransmitter(id, gain, lose)
- }})
- );
-
- /**
- * Idle transmitter.
- */
- def IdleTransmitter(id: String, gain: Switch, lose: Switch): unit = {
- val (t, s) = gain.read;
- ActiveTransmitter(id, t, s, gain, lose)
- }
-
- def main(args: Array[String]): unit = {
- val talk1 = new Chan[unit]
- val switch1 = new Switch
- val gain1 = new Switch
- val lose1 = new Switch
- val talk2 = new Chan[unit]
- val switch2 = new Switch
- val gain2 = new Switch
- val lose2 = new Switch
- spawn <
- Car(talk1, switch1) |
- ActiveTransmitter("Transmitter 1", talk1, switch1, gain1, lose1) |
- IdleTransmitter("Transmitter 2", gain2, lose2) |
- Control(talk1, switch1, gain1, lose1, talk2, switch2, gain2, lose2) >
- }
-}
-
-/**
-* Handover example with type casts.
-*/
-object handoverCast {
-
- import concurrent.pilib._;
-
- val random = new java.util.Random();
-
- /**
- * Car.
- */
- def Car(talk: Chan[Any], switch: Chan[Any]): unit =
- choice (
- switch * (o => {
- val (t,s) = o.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]];
- Car(t, s)
- }),
- talk(()) * ( {
- Thread.sleep(1 + random.nextInt(1000));
- System.out.println("Car emitted a message.");
- Car(talk, switch)
- })
- );
-
- /**
- * Control center.
- */
- def Control(talk1: Chan[Any], switch1: Chan[Any],
- gain1: Chan[Any], lose1: Chan[Any],
- talk2: Chan[Any], switch2: Chan[Any],
- gain2: Chan[Any], lose2: Chan[Any]): unit
- = {
- def Control1: unit = {
- Thread.sleep(1 + random.nextInt(1000));
- lose1.write((talk2, switch2));
- gain2.write((talk2, switch2));
- Control2
- }
- def Control2: unit = {
- Thread.sleep(1 + random.nextInt(1000));
- lose2.write((talk1, switch1));
- gain1.write((talk1, switch1));
- Control1
- }
- Control1
- }
-
- /**
- * Active transmitter.
- */
- def ActiveTransmitter(id: String, talk: Chan[Any], switch: Chan[Any],
- gain: Chan[Any], lose: Chan[Any]): unit
- =
- choice (
- talk * (x => {
- System.out.println(id + " received a message.")
- ActiveTransmitter(id, talk, switch, gain, lose)
- }),
- lose * (o => {
- val (t, s) = o.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]]
- switch.write((t, s))
- IdleTransmitter(id, gain, lose)
- })
- )
-
- /**
- * Idle transmitter.
- */
- def IdleTransmitter(id: String, gain: Chan[Any], lose: Chan[Any]): unit = {
- val (t, s) = gain.read.asInstanceOf[Tuple2[Chan[Any],Chan[Any]]]
- ActiveTransmitter(id, t, s, gain, lose)
- }
-
- def main(args: Array[String]): unit = {
- val talk1 = new Chan[Any]
- val switch1 = new Chan[Any]
- val gain1 = new Chan[Any]
- val lose1 = new Chan[Any]
- val talk2 = new Chan[Any]
- val switch2 = new Chan[Any]
- val gain2 = new Chan[Any]
- val lose2 = new Chan[Any]
- spawn <
- Car(talk1, switch1) |
- ActiveTransmitter("Transmitter 1", talk1, switch1, gain1, lose1) |
- IdleTransmitter("Transmitter 2", gain2, lose2) |
- Control(talk1, switch1, gain1, lose1, talk2, switch2, gain2, lose2) >
- }
-
-}
diff --git a/docs/examples/pilib/mobilePhoneProtocol.scala b/docs/examples/pilib/mobilePhoneProtocol.scala
deleted file mode 100644
index e8c0ac1dc4..0000000000
--- a/docs/examples/pilib/mobilePhoneProtocol.scala
+++ /dev/null
@@ -1,172 +0,0 @@
-package examples.pilib
-
-/**
-* Mobile phone protocol.
-* Equivalent to a three-place buffer.
-* @see Bjoern Victor "A verification tool for the polyadic pi-calculus".
-*/
-object mobilePhoneProtocol {
-
- import concurrent.pilib._
-
- val random = new java.util.Random()
-
- // Internal messages exchanged by the protocol.
- trait Message
-
- // Predefined messages used by the protocol.
- case class Data() extends Message;
- case class HoCmd() extends Message; // handover command
- case class HoAcc() extends Message; // handover access
- case class HoCom() extends Message; // handover complete
- case class HoFail() extends Message; // handover fail
- case class ChRel() extends Message; // release
- case class Voice(s: String) extends Message; // voice
- case class Channel(n: Chan[Message]) extends Message; // channel
-
- def MobileSystem(in: Chan[String], out: Chan[String]): unit = {
-
- def CC(fa: Chan[Message], fp: Chan[Message], l: Chan[Channel]): unit =
- choice (
- in * (v => { fa.write(Data()); fa.write(Voice(v)); CC(fa, fp, l) })
- ,
- l * (m_new => {
- fa.write(HoCmd());
- fa.write(m_new);
- choice (
- fp * ({ case HoCom() => {
- System.out.println("Mobile has moved from one cell to another");
- fa.write(ChRel());
- val Channel(m_old) = fa.read;
- l.write(Channel(m_old));
- CC(fp, fa, l)
- }})
- ,
- fa * ({ case HoFail() => {
- System.out.println("Mobile has failed to move from one cell to another");
- l.write(m_new);
- CC(fa, fp, l)
- }})
- )
- })
- );
-
- /*
- * Continuously orders the MSC to switch the MS to the non-used BS.
- */
- def HC(l: Chan[Channel], m: Chan[Message]): unit = {
- Thread.sleep(1 + random.nextInt(1000));
- l.write(Channel(m));
- val Channel(m_new) = l.read;
- HC(l, m_new)
- }
-
- /**
- * Mobile switching center.
- */
- def MSC(fa: Chan[Message], fp: Chan[Message], m: Chan[Message]): unit = {
- val l = new Chan[Channel];
- spawn < HC(l, m) | CC(fa, fp, l) >
- }
-
- /**
- * Active base station.
- */
- def BSa(f: Chan[Message], m: Chan[Message]): unit =
- (f.read) match {
- case Data() => {
- val v = f.read;
- m.write(Data());
- m.write(v);
- BSa(f, m)
- }
- case HoCmd() => {
- val v = f.read;
- m.write(HoCmd());
- m.write(v);
- choice (
- f * ({ case ChRel() => {
- f.write(Channel(m));
- BSp(f, m)
- }})
- ,
- m * ({ case HoFail() => {
- f.write(HoFail());
- BSa(f, m)
- }})
- )
- }
- };
-
- /**
- * Passive base station.
- */
- def BSp(f: Chan[Message], m: Chan[Message]): unit = {
- val HoAcc = m.read
- f.write(HoCom())
- BSa(f, m)
- }
-
- /**
- * Mobile station.
- */
- def MS(m: Chan[Message]): unit =
- (m.read) match {
- case Data() => {
- val Voice(v) = m.read;
- out.write(v);
- MS(m)
- }
- case HoCmd() =>
- (m.read) match {
- case Channel(m_new) => {
- if (random.nextInt(1) == 0)
- choice ( m_new(HoAcc()) * (MS(m_new)) );
- else
- choice ( m(HoFail()) * (MS(m)) );
- }
- }
- };
-
- def P(fa: Chan[Message], fp: Chan[Message]): unit = {
- val m = new Chan[Message];
- spawn < MSC(fa, fp, m) | BSp(fp, m) >
- }
-
- def Q(fa: Chan[Message]): unit = {
- val m = new Chan[Message];
- spawn < BSa(fa, m) | MS(m) >
- }
-
- val fa = new Chan[Message];
- val fp = new Chan[Message];
- spawn < Q(fa) | P(fa, fp) >;
- }
-
- //***************** Entry function ******************//
-
- def main(args: Array[String]): unit = {
-
- def Producer(n: Int, put: Chan[String]): unit = {
- Thread.sleep(1 + random.nextInt(1000));
- val msg = "object " + n;
- put.write(msg);
- System.out.println("Producer gave " + msg);
- Producer(n + 1, put)
- }
-
- def Consumer(get: Chan[String]): unit = {
- Thread.sleep(1 + random.nextInt(1000));
- val msg = get.read;
- System.out.println("Consumer took " + msg);
- Consumer(get)
- }
-
- val put = new Chan[String];
- val get = new Chan[String];
- spawn < Producer(0, put) | Consumer(get) | MobileSystem(put, get) >
- }
-
-}
-
-
diff --git a/docs/examples/pilib/piNat.scala b/docs/examples/pilib/piNat.scala
deleted file mode 100644
index c6d9bdaf5c..0000000000
--- a/docs/examples/pilib/piNat.scala
+++ /dev/null
@@ -1,89 +0,0 @@
-package examples.pilib
-
-import scala.concurrent.pilib._
-
-/** Church encoding of naturals in the Pi-calculus */
-object piNat extends Application {
-
- /** Locations of Pi-calculus natural */
- class NatChan extends Chan[Tuple3[Chan[Unit], Chan[NatChan], Chan[NatChan]]]
-
- /** Zero */
- def Z(l: NatChan): Unit = choice (
- l * { case (z, sd, d) => z.write(()) }
- )
-
- /** Successor of Double */
- def SD(n: NatChan, l: NatChan): Unit = choice (
- l * { case (z, sd, d) => sd.write(n) }
- )
-
- /** Double */
- def D(n: NatChan, l: NatChan): Unit = choice (
- l * { case (z, sd, d) => d.write(n) }
- )
-
- /** Make "l" a location representing the natural "n" */
- def make(n: Int, l: NatChan): Unit =
- if (n == 0) Z(l)
- else if (n % 2 == 0) { val l1 = new NatChan; spawn < D(l1, l) >; make(n/2, l1) }
- else { val l1 = new NatChan; spawn < SD(l1, l) >; make(n/2, l1) }
-
- /** Consume the natural "m" and put it successor at location "n" */
- def Succ(m: NatChan, n: NatChan) {
- val z = new Chan[Unit]
- val sd = new Chan[NatChan]
- val d = new Chan[NatChan]
- spawn < m.write((z, sd, d)) >;
- choice (
- z * { x => make(1, n) },
- sd * { m1 => { val n1 = new NatChan; spawn < D(n1, n) >; Succ(m1, n1) } },
- d * { m1 => SD(m1, n) }
- )
- }
-
- /** Consume the natural "l" and put two copies at locations "m" and "n" */
- def Copy(l: NatChan, m: NatChan, n: NatChan) {
- val z = new Chan[Unit]
- val sd = new Chan[NatChan]
- val d = new Chan[NatChan]
- spawn < l.write((z, sd, d)) >;
- choice (
- z * { x => spawn < Z(m) >; Z(n) },
- sd * { l1 => { val m1 = new NatChan; val n1 = new NatChan;
- spawn < SD(m1, m) | SD(n1, n) >;
- Copy(l1, m1, n1) } },
- d * { l1 => { val m1 = new NatChan; val n1 = new NatChan;
- spawn < D(m1, m) | D(n1, n) >;
- Copy(l1, m1, n1) } }
- )
- }
-
- /** Consume the natural at location "n" and return its value */
- def value(n: NatChan): Int = {
- val z = new Chan[Unit]
- val sd = new Chan[NatChan]
- val d = new Chan[NatChan]
- spawn < n.write((z, sd, d)) >;
- choice (
- z * { x => 0 },
- sd * { n1 => 2 * value(n1) + 1 },
- d * { n1 => 2 * value(n1) }
- )
- }
-
- // Test
- val i = 42
- val l = new NatChan
- val l1 = new NatChan
- val l2 = new NatChan
- val l3 = new NatChan
-
- spawn <
- make(i, l) |
- Copy(l, l1, l2) |
- Succ(l2, l3) |
- println("" + i + " = " + value(l1)) |
- println("succ " + i + " = " + value(l3)) >
-
-}
diff --git a/docs/examples/pilib/rwlock.scala b/docs/examples/pilib/rwlock.scala
deleted file mode 100644
index bb1c26bdf2..0000000000
--- a/docs/examples/pilib/rwlock.scala
+++ /dev/null
@@ -1,329 +0,0 @@
-package examples.pilib
-
-/**
-* From Pi to Scala: Semaphores, monitors, read/write locks.
-* Readers/writers locks.
-*/
-object rwlock {
-
- import scala.concurrent.pilib._
-
- class Signal extends Chan[unit] {
- def send = write(())
- def receive = read
- }
-
- class CountLock {
- private val busy = new Signal
- def get = busy.send
- def release = busy.receive
- spawn < release >
- }
-
- /** A binary semaphore
- */
- class Lock {
- private val busy = new Signal;
- private val free = new Signal;
- def get = busy.send;
- def release = free.send;
- spawn < (while (true) {
- choice (
- busy * (x => free.receive),
- free * (x => ())
- )
- }) >
- }
-
- /** A monitor a la Java
- */
- class JavaMonitor {
-
- private val lock = new Lock
-
- private var waiting: List[Signal] = Nil
-
- def Wait = {
- val s = new Signal
- waiting = s :: waiting
- lock.release
- s.receive
- lock.get
- }
-
- def Notify =
- if (!waiting.isEmpty) {
- waiting.head.send
- waiting = waiting.tail
- }
-
- def NotifyAll =
- while (!waiting.isEmpty) {
- waiting.head.send
- waiting = waiting.tail
- }
-
- def await(cond: => boolean): unit =
- while (false == cond) (Wait)
- }
-
- /*
- class Buffer[a](size: Int) extends JavaMonitor with {
- var in = 0, out = 0, n = 0;
- val elems = new Array[a](size);
- def put(x: a) = synchronized {
- await(n < size);
- elems(out) = x;
- out = (out + 1) % size;
- }
- def get: a = synchronized {
- await(n > 0);
- val x = elems(in);
- in = (in + 1) % size;
- x
- }
- }
- */
-
- /** A readers/writers lock. */
- trait ReadWriteLock {
- def startRead: unit
- def startWrite: unit
- def endRead: unit
- def endWrite: unit
- }
-
- /**
- * A readers/writers lock, using monitor abstractions.
- */
- class ReadWriteLock1 extends JavaMonitor with ReadWriteLock {
-
- private var nactive: int = 0
- private var nwriters: int = 0
-
- def status =
- System.out.println(nactive + " active, " + nwriters + " writers");
-
- def startRead = synchronized {
- await(nwriters == 0)
- nactive = nactive + 1
- status
- }
-
- def startWrite = synchronized {
- nwriters = nwriters + 1
- await(nactive == 0)
- nactive = 1
- status
- }
-
- def endRead = synchronized {
- nactive = nactive - 1
- if (nactive == 0) NotifyAll
- status
- }
-
- def endWrite = synchronized {
- nwriters = nwriters - 1
- nactive = 0
- NotifyAll
- status
- }
- }
-
- /** A readers/writers lock, using semaphores
- */
- class ReadWriteLock2 extends ReadWriteLock {
-
- private var rc: int = 0 // reading readers
- private var wc: int = 0 // writing writers
- private var rwc: int = 0 // waiting readers
- private var wwc: int = 0 // waiting writers
- private val mutex = new Lock
- private val rsem = new Lock
- private val wsem = new Lock
-
- def startRead = {
- mutex.get;
- if (wwc > 0 || wc > 0) {
- rwc = rwc + 1;
- mutex.release;
- rsem.get;
- rwc = rwc - 1
- }
- rc = rc + 1;
- if (rwc > 0) rsem.release;
- mutex.release
- }
-
- def startWrite = {
- mutex.get;
- if (rc > 0 || wc > 0) {
- wwc = wwc + 1;
- mutex.release;
- wsem.get;
- wwc = wwc - 1
- }
- wc = wc + 1;
- mutex.release
- }
-
- def endRead = {
- mutex.get;
- rc = rc - 1;
- if (rc == 0 && wwc > 0) wsem.release;
- mutex.release
- }
-
- def endWrite = {
- mutex.get;
- wc = wc - 1;
- if (rwc > 0)
- rsem.release
- else if (wwc > 0) wsem.release;
- mutex.release
- }
- }
-
- /** A readers/writers lock, using channels, without priortities
- */
- class ReadWriteLock3 extends ReadWriteLock {
-
- private val sr = new Signal
- private val er = new Signal
- private val sw = new Signal
- private val ew = new Signal
-
- def startRead = sr.send
- def startWrite = sw.send
- def endRead = er.send
- def endWrite = ew.send
-
- private def rwlock: unit = choice (
- sr * (x => reading(1)),
- sw * (x => { ew.receive; rwlock })
- )
-
- private def reading(n: int): unit = choice (
- sr * (x => reading(n+1)),
- er * (x => if (n == 1) rwlock else reading(n-1))
- )
-
- spawn < rwlock >
- }
-
- /** Same, with sequencing
- */
- class ReadWriteLock4 extends ReadWriteLock {
-
- private val rwlock = new ReadWriteLock3
-
- private val sr = new Signal
- private val ww = new Signal
- private val sw = new Signal
-
- def startRead = sr.send
- def startWrite = { ww.send; sw.send }
- def endRead = rwlock.endRead
- def endWrite = rwlock.endWrite
-
- private def queue: unit = choice (
- sr * (x => { rwlock.startRead ; queue }),
- ww * (x => { rwlock.startWrite; sw.receive; queue })
- )
-
- spawn < queue >;
- }
-
- /** Readwritelock where writers always have priority over readers
- */
- class ReadWriteLock5 extends ReadWriteLock {
-
- private val sr = new Signal
- private val er = new Signal
- private val ww = new Signal
- private val sw = new Signal
- private val ew = new Signal
-
- def startRead = sr.send
- def startWrite = { ww.send; sw.send }
- def endRead = er.send
- def endWrite = ew.send
-
- private def Reading(nr: int, nw: int): unit =
- if (nr == 0 && nw == 0)
- choice (
- sr * (x => Reading(1, 0)),
- ww * (x => Reading(0, 1))
- )
- else if (nr == 0 && nw != 0) {
- sw.receive;
- Writing(nw);
- }
- else if (nr != 0 && nw == 0)
- choice (
- sr * (x => Reading(nr + 1, 0)),
- er * (x => Reading(nr - 1, 0)),
- ww * (x => Reading(nr, 1))
- )
- else if (nr != 0 && nw != 0)
- choice (
- ww * (x => Reading(nr, nw + 1)),
- er * (x => Reading(nr - 1, nw))
- );
-
- private def Writing(nw: int): unit = choice (
- ew * (x => Reading(0, nw - 1)),
- ww * (x => Writing(nw + 1))
- );
-
- spawn < Reading(0, 0) >;
-
- }
-
- /**
- * Main function.
- */
- def main(args: Array[String]): unit = {
- val random = new java.util.Random()
-
- def reader(i: int, rwlock: ReadWriteLock): unit = {
- Thread.sleep(1 + random.nextInt(100))
- System.err.println("Reader " + i + " wants to read.")
- rwlock.startRead
- System.err.println("Reader " + i + " is reading.")
- Thread.sleep(1 + random.nextInt(100))
- rwlock.endRead
- System.err.println("Reader " + i + " has read.")
- reader(i, rwlock)
- }
-
- def writer(i: int, rwlock: ReadWriteLock): unit = {
- Thread.sleep(1 + random.nextInt(100))
- System.err.println("Writer " + i + " wants to write.")
- rwlock.startWrite
- System.err.println("Writer " + i + " is writing.")
- Thread.sleep(1 + random.nextInt(100))
- rwlock.endWrite
- System.err.println("Writer " + i + " has written.")
- writer(i, rwlock)
- }
-
- val n = try { Integer.parseInt(args(0)) } catch { case _ => 0 }
- if (n < 1 || 5 < n) {
- Console.println("Usage: scala examples.pilib.rwlock <n> (n=1..5)")
- exit
- }
- val rwlock = n match {
- case 1 => new ReadWriteLock1
- case 2 => new ReadWriteLock2
- case 3 => new ReadWriteLock3
- case 4 => new ReadWriteLock4
- case 5 => new ReadWriteLock5
- }
- List.range(0, 5) foreach (i => spawn < reader(i, rwlock) >)
- List.range(0, 5) foreach (i => spawn < writer(i, rwlock) >)
- }
-
-}
-
diff --git a/docs/examples/pilib/scheduler.scala b/docs/examples/pilib/scheduler.scala
deleted file mode 100644
index fd8fd52600..0000000000
--- a/docs/examples/pilib/scheduler.scala
+++ /dev/null
@@ -1,150 +0,0 @@
-package examples.pilib
-
-import scala.concurrent.pilib._
-
-object scheduler {
-
- /**
- * Random number generator.
- */
- val random = new util.Random()
-
- //***************** Scheduler ******************//
-
- /**
- * A cell of the scheduler whose attached agent is allowed to start.
- */
- def A(a: Chan[Unit], b: Chan[Unit])(d: Chan[Unit], c: Chan[Unit]) {
- ///- ... complete here ...
- choice ( a * { x => C(a, b)(d, c) })
- ///+
- }
-
- /**
- * A cell of the scheduler in another intermediate state.
- */
- def C(a: Chan[Unit], b: Chan[Unit])(d: Chan[Unit], c: Chan[Unit]) {
- ///- ... complete here ...
- choice (c * { x => B(a, b)(d, c) })
- ///+
- }
-
- /**
- * A cell of the scheduler whose attached agent is allowed to finish.
- */
- def B(a: Chan[Unit], b: Chan[Unit])(d: Chan[Unit], c: Chan[Unit]) {
- ///- ... complete here ...
- // choice (b * { x => D(a, b)(d, c) }) // incorrect naive solution
- choice (
- b * { x => choice ( d(()) * A(a, b)(d, c) ) }, // b.'d.A
- d(()) * (choice (b * { x => A(a, b)(d, c) })) // 'd.b.A
- )
- ///+
- }
-
- /**
- * A cell of the scheduler whose attached agent is not yet allowed to start.
- */
- def D(a: Chan[Unit], b: Chan[Unit])(d: Chan[Unit], c: Chan[Unit]) {
- ///- ... complete here ...
- choice (d(()) * A(a, b)(d, c))
- ///+
- }
-
- //***************** Agents ******************//
-
- def agent(i: Int)(a: Chan[Unit], b: Chan[Unit]) {
- // 50% chance that we sleep forever
- if (i == 0 && random.nextInt(10) < 5) {
- a.attach(x => println("Start and sleeps ----> " + i))
- Thread.sleep(random.nextInt(1000))
- a.write(())
- }
- else {
- a.attach(x => println("Start ----> " + i))
- b.attach(x => println("Stop -> " + i))
- Thread.sleep(random.nextInt(1000))
- a.write(())
- Thread.sleep(random.nextInt(1000))
- b.write(())
- agent(i)(a, b)
- }
- }
-
- //***************** Entry function ******************//
-
- /**
- * Creates a scheduler for five agents (programs).
- */
-
- def main(args: Array[String]) {
- val agentNb = 5
- val agents = List.range(0, agentNb) map agent
- scheduleAgents(agents)
- }
-
- //***************** Infrastructure *****************//
-
- /**
- * A cell is modelled as a function that takes as parameters
- * input and output channels and which returns nothing.
- */
- type Cell = (Chan[Unit], Chan[Unit]) => Unit
-
- /**
- * Creates a cell composed of two cells linked together.
- */
- def join(cell1: Cell, cell2: Cell): Cell =
- (l: Chan[Unit], r: Chan[Unit]) => {
- val link = new Chan[Unit];
- spawn < cell1(l, link) | cell2(link, r) >
- };
-
- /**
- * Links the output of a cell to its input.
- */
- def close(cell: Cell) {
- val a = new Chan[Unit]
- cell(a, a)
- }
-
- /**
- * Creates a cell consisting of a chain of cells.
- */
- def chain(cells: List[Cell]): Cell =
- cells reduceLeft join
-
- /**
- * Creates a cell consisting of a chain of cells.
- */
- def makeRing(cells: List[Cell]): Unit =
- close(chain(cells))
-
- /**
- * An agent is modelled as a function that takes as parameters channels to
- * signal that it has started or finished.
- */
- type Agent = (Chan[Unit], Chan[Unit]) => Unit
-
- /**
- * Takes a list of agents and schedules them.
- */
- def scheduleAgents(agents: List[Agent]) {
- var firstAgent = true;
- val cells = agents map (ag => {
- val a = new Chan[Unit];
- val b = new Chan[Unit];
- spawn < ag(a, b) >;
- (d: Chan[Unit], c: Chan[Unit]) => if (firstAgent) {
- firstAgent = false;
- A(a, b)(d, c)
- }
- else
- D(a, b)(d, c)
- });
- makeRing(cells)
- }
-
-}
-
-
diff --git a/docs/examples/pilib/semaphore.scala b/docs/examples/pilib/semaphore.scala
deleted file mode 100644
index 951c90e8d4..0000000000
--- a/docs/examples/pilib/semaphore.scala
+++ /dev/null
@@ -1,72 +0,0 @@
-package examples.pilib
-
-import scala.concurrent.pilib._
-
-/** Solution of exercise session 6 (first question). */
-object semaphore {
-
- class Signal extends Chan[Unit] {
- def send = write(())
- def receive = read
- }
-
- /** Interface. */
- trait Semaphore {
- def get: Unit
- def release: Unit
- }
-
- /** First implementation. */
- class Sem1 extends Semaphore {
-
- private val g = new Signal
- private val r = new Signal
-
- def get: Unit = g.send
- def release: Unit = r.send
-
- private def Sched: Unit = choice (
- g * (x => { r.receive; Sched }),
- r * (x => Sched)
- )
- spawn< Sched >
- }
-
- /** Second implementation. */
- class Sem2 extends Semaphore {
-
- private val a = new Signal
- private val na = new Signal
-
- def get { a.receive; spawn< na.send > }
- def release: Unit = choice (
- a * (x => spawn< a.send >),
- na * (x => spawn< a.send >)
- )
- spawn< a.send >
- }
-
- /** Test program. */
- def main(args: Array[String]) {
- val random = new util.Random()
- val sem = new Sem2
- def mutex(p: => Unit) { sem.get; p; sem.release }
-
- spawn< {
- Thread.sleep(1 + random.nextInt(100));
- mutex( {
- println("a1");
- Thread.sleep(1 + random.nextInt(100));
- println("a2")
- } )
- } | {
- Thread.sleep(1 + random.nextInt(100));
- mutex( {
- println("b1");
- Thread.sleep(1 + random.nextInt(100));
- println("b2")
- } )
- } >;
- }
-}
-
diff --git a/docs/examples/pilib/twoPlaceBuffer.scala b/docs/examples/pilib/twoPlaceBuffer.scala
deleted file mode 100644
index 255f70ca06..0000000000
--- a/docs/examples/pilib/twoPlaceBuffer.scala
+++ /dev/null
@@ -1,67 +0,0 @@
-package examples.pilib
-
-import scala.concurrent.pilib._
-
-/** Two-place buffer specification and implementation. */
-object twoPlaceBuffer extends Application {
-
- /**
- * Specification.
- */
- def Spec[A](in: Chan[A], out: Chan[A]) {
-
- def B0: Unit = choice (
- in * (x => B1(x))
- )
-
- def B1(x: A): Unit = choice (
- out(x) * (B0),
- in * (y => B2(x, y))
- )
-
- def B2(x: A, y: A): Unit = choice (
- out(x) * (B1(y))
- )
-
- B0
- }
-
- /**
- * Implementation using two one-place buffers.
- */
- def Impl[A](in: Chan[A], out: Chan[A]) {
- ///- ... complete here ...
- // one-place buffer
- def OnePlaceBuffer[A](in: Chan[A], out: Chan[A]) {
- def B0: Unit = choice ( in * (x => B1(x)) )
- def B1(x: A): Unit = choice ( out(x) * (B0))
- B0
- }
- val hidden = new Chan[A]
- spawn < OnePlaceBuffer(in, hidden) | OnePlaceBuffer(hidden, out) >
- ///+
- }
-
- val random = new util.Random()
-
- def Producer(n: Int, in: Chan[String]) {
- Thread.sleep(random.nextInt(1000))
- val msg = "" + n
- choice (in(msg) * {})
- Producer(n + 1, in)
- }
-
- def Consumer(out: Chan[String]) {
- Thread.sleep(random.nextInt(1000))
- choice (out * { msg => () })
- Consumer(out)
- }
-
- val in = new Chan[String]
- in.attach(s => println("put " + s))
- val out = new Chan[String]
- out.attach(s => println("get " + s))
- //spawn < Producer(0, in) | Consumer(out) | Spec(in, out) >
- spawn < Producer(0, in) | Consumer(out) | Impl(in, out) >
-
-}
diff --git a/docs/examples/plugintemplate/build.xml b/docs/examples/plugintemplate/build.xml
deleted file mode 100644
index 37c8441ce3..0000000000
--- a/docs/examples/plugintemplate/build.xml
+++ /dev/null
@@ -1,265 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<project name="plugintemplate" default="pack">
- <!-- Edit the file plugin.properties to set
- - scala.home
- - plugin.name
- - plugin.commandname
- - plugin.description
- - plugin.mainclass
- - version numbers
- -->
- <property file="${basedir}/plugin.properties"/>
-
- <property name="version" value="${version.major}.${version.minor}"/>
-
- <taskdef resource="scala/tools/ant/antlib.xml">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-compiler.jar"/>
- <pathelement location="${scala.home}/lib/scala-library.jar"/>
- </classpath>
- </taskdef>
-
-
- <!-- =================================================================
- End-user targets
- ================================================================== -->
-
- <target name="build" depends="build.main"/>
- <target name="build.all" depends="build.done"/>
- <target name="test" depends="test.all"/>
- <target name="guitest" depends="guitest.all"/>
- <target name="doc" depends="doc.done"/>
- <target name="pack" depends="pack.done"/>
- <target name="dist" depends="dist.done"/>
- <target name="clean" depends="clean.all"/>
-
- <!-- =================================================================
- Build targets
- ================================================================== -->
-
- <target name="build.main">
- <mkdir dir="build/build.main"/>
- <scalac srcdir="src"
- destdir="build/build.main"
- includes="**/*.scala">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-library.jar"/>
- <pathelement location="${scala.home}/lib/scala-compiler.jar"/>
- </classpath>
- </scalac>
- </target>
-
- <target name="build.test" depends="build.main">
- <mkdir dir="build/build.test"/>
- <scalac srcdir="test"
- destdir="build/build.test"
- includes="**/*.scala">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-library.jar"/>
- <pathelement location="${scala.home}/lib/scala-compiler.jar"/>
- <pathelement location="lib/scalatest.jar"/>
- <pathelement location="build/build.main"/>
- </classpath>
- </scalac>
- </target>
-
- <target name="build.examples" depends="build.test">
- <mkdir dir="build/build.examples"/>
- <scalac srcdir="doc/examples"
- destdir="build/build.examples"
- includes="**/*.scala">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-library.jar"/>
- <pathelement location="${scala.home}/lib/scala-compiler.jar"/>
- <pathelement location="build/build.main"/>
- </classpath>
- </scalac>
- </target>
-
- <target name="build.done" depends="build.examples"/>
-
- <!-- =================================================================
- Test targets
- ================================================================== -->
-
- <target name="test.all" depends="build.done">
- <!-- fork="true" is good for running the graphical mode -->
- <java classname="org.scalatest.tools.Runner" fork="true">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-compiler.jar" />
- <pathelement location="${scala.home}/lib/scala-library.jar" />
- <pathelement location="lib/scalatest.jar" />
- <pathelement location="build/build.main" />
- <pathelement location="build/build.test" />
- </classpath>
-
- <arg value="-p" />
- <arg value="build/build.test" />
-
- <arg value="-o" />
- </java>
- </target>
-
- <target name="guitest.all" depends="build.done">
- <!-- fork="true" is good for running the graphical mode -->
- <java classname="org.scalatest.tools.Runner" fork="true">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-compiler.jar" />
- <pathelement location="${scala.home}/lib/scala-library.jar" />
- <pathelement location="lib/scalatest.jar" />
- <pathelement location="build/build.main" />
- <pathelement location="build/build.test" />
- </classpath>
-
- <arg value="-p" />
- <arg value="build/build.test" />
-
- <arg value="-g" />
- </java>
- </target>
-
- <!-- =================================================================
- Doc targets
- ================================================================== -->
-
- <target name="doc.main">
- <mkdir dir="doc/api"/>
- <scaladoc srcdir="src"
- destdir="doc/api"
- includes="**/*.scala">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-library.jar"/>
- <pathelement location="${scala.home}/lib/scala-compiler.jar"/>
- </classpath>
- </scaladoc>
- </target>
-
- <target name="doc.done" depends="doc.main"/>
-
- <!-- =================================================================
- Pack targets
- ================================================================== -->
-
- <target name="pack.main" depends="build.done">
- <mkdir dir="build/pack"/>
- <jar destfile="build/pack/${plugin.name}.jar">
- <fileset dir="build/build.main"/>
- <fileset file="plugin.properties"/>
- <fileset file="misc/scalac-plugin.xml"/>
- </jar>
- </target>
-
- <target name="pack.src" depends="pack.main">
- <jar destfile="build/pack/${plugin.name}-src.jar"
- basedir="src"
- includes="**/*.scala"/>
- </target>
-
- <target name="pack.done" depends="pack.src"/>
-
- <!-- =================================================================
- Dist targets
- ================================================================== -->
-
- <target name="dist.bin" depends="test.all,pack.done,doc.done">
- <mkdir dir="build/toolscript"/>
- <scalascript
- file="build/toolscript/${plugin.commandname}"
- class="${plugin.mainclass}"/>
- <chmod dir="build/toolscript" perm="a+rx" excludes="*.bat"/>
- </target>
-
- <target name="dist.archive" depends="dist.bin">
- <mkdir dir="build/dist"/>
- <tar destfile="build/dist/${plugin.name}-${version}.tgz"
- compression="gzip">
- <tarfileset prefix="lib" dir="build/pack"
- includes="${plugin.name}.jar"/>
- <tarfileset prefix="src" dir="build/pack"
- includes="${plugin.name}-src.jar"/>
- <tarfileset prefix="doc/${plugin.name}" dir="doc"
- includes="README"/>
- <tarfileset prefix="doc/${plugin.name}" dir="doc"
- includes="examples/**"/>
- <tarfileset prefix="doc/${plugin.name}" dir="doc"
- includes="api/**"/>
- <tarfileset prefix="bin" dir="build/toolscript"
- includes="${plugin.commandname}" mode="755"/>
- <tarfileset prefix="bin" dir="build/toolscript"
- includes="${plugin.commandname}.bat"/>
- <tarfileset prefix="misc/scala-devel/plugins" dir="build/pack"
- includes="${plugin.name}.jar"/>
- </tar>
- </target>
-
- <target name="dist.sbaz" depends="dist.archive">
- <sbaz file="build/dist/${plugin.name}-${version}.sbp"
- adfile="build/dist/${plugin.name}-${version}.advert"
- name="${plugin.name}"
- version="${version}"
- depends="scala-devel"
- desc="${plugin.description}"
- link="${plugin.sbazbaseurl}/${plugin.name}-${version}.sbp">
- <libset dir="build/pack" includes="${plugin.name}.jar"/>
- <srcset dir="build/pack" includes="${plugin.name}-src.jar"/>
- <docset dir="doc" includes="README"/>
- <docset dir="doc" includes="examples/**"/>
- <docset dir="doc" includes="api/**"/>
- <binset dir="build/toolscript"/>
- <looseset destination="misc/scala-devel/plugins">
- <fileset file="build/pack/${plugin.name}.jar"/>
- </looseset>
- </sbaz>
- </target>
-
- <target name="dist.done" depends="dist.sbaz"/>
-
- <!-- =================================================================
- Local installation
- ================================================================== -->
-
- <target name="install" depends="dist.done">
- <exec executable="sbaz">
- <arg line="-v install -f build/dist/${plugin.name}-${version}.sbp"/>
- </exec>
- </target>
-
- <target name="uninstall">
- <exec executable="sbaz">
- <arg line="remove ${plugin.name}"/>
- </exec>
- </target>
-
- <!-- =================================================================
- Clean targets
- ================================================================== -->
-
- <target name="clean.build">
- <delete dir="build/build.main" includeemptydirs="yes"
- quiet="yes" failonerror="no"/>
- <delete dir="build/build.test" includeemptydirs="yes"
- quiet="yes" failonerror="no"/>
- <delete dir="build/build.examples" includeemptydirs="yes"
- quiet="yes" failonerror="no"/>
- </target>
-
- <target name="clean.pack" depends="clean.build">
- <delete dir="build/pack" includeemptydirs="yes"
- quiet="yes" failonerror="no"/>
- </target>
-
- <target name="clean.dist" depends="clean.pack">
- <delete dir="build/dist" includeemptydirs="yes"
- quiet="yes" failonerror="no"/>
- <delete dir="build/toolscript" includeemptydirs="yes"
- quiet="yes" failonerror="no"/>
- </target>
-
- <target name="clean.doc">
- <delete dir="doc/api" includeemptydirs="yes"
- quiet="yes" failonerror="no"/>
- </target>
-
- <target name="clean.all" depends="clean.dist,clean.doc"/>
-</project>
diff --git a/docs/examples/plugintemplate/doc/README b/docs/examples/plugintemplate/doc/README
deleted file mode 100644
index 958f71282b..0000000000
--- a/docs/examples/plugintemplate/doc/README
+++ /dev/null
@@ -1,68 +0,0 @@
-Scala compiler plugin template
-------------------------------
-
-This project is a template that can be used for creating compiler
-plugins for the Scala compiler.
-
-
-Installation
-------------
-To install the compiler plugin, run "ant install". This will create
-an sbaz package for the template plugin and install it in the scala
-installation available in your PATH.
-The install command will also create a script for running the plugin
-as standalone application. The command is called "runplugintemplate"
-and available in your scala installation as well.
-To uninstall the plugin again, run "and uninstall".
-
-Alternatively, copy the file build/pack/plugintemplate.jar, generated
-by "ant pack", to the directory misc/scala-devel/plugins of your
-scala distribution. The scala compiler will then find and integrate
-the new plugin.
-
-Customization
--------------
-The following files need to be edited when creating a new plugin
-- plugin.properties
-- misc/scalac-plugin.xml
-- src / test / doc/examples: The source files of the template plugin
- are located a package called "plugintemplate". This will most likely
- be changed for new plugins.
-
-When using eclipse for development, make sure "scala-compiler.jar" is
-in the Java Build Path: Right-Click the project and select "Properties".
-Then go to "Java Build Path" -> "Libraries" and add the jar file
-"eclipse/plugins/ch.epfl.lamp.sdt.core[..]/lib/scala-compiler.jar".
-
-Traverse, Transform, Check
---------------------------
-There are several pre-defined components that can be used to code
-the behavior of a plugin:
-- TemplateTraverseComponent: a template for tree traversers. Used
- to analyze and collect data about compiler trees.
- -> implement the "check" method
-
-- TemplateTransformComponent: a template for tree transformers.
- -> implement "preTransform" and / or "postTransform"
-
-- TemplateInfoTransformComponent: also a tree transformer, which
- additionally is an InfoTransformer. Allows changing the type
- of some symbols for later phases.
- -> implement "preTransform" and / or "postTransform", and the
- "apply" method of the "infoTransformer".
-
-- TemplateAnnotationChecker: a plugin for the typechecker, useful
- for pluggable type systems. Computes the subtyping between two
- annotated types, and allows providing inferred type information.
- -> implement "annotationsConform" and optionally "addAnnotations"
-
-- TemplateComponent: the most general component. Can do anything it
- likes with the CompilationUnits.
- -> implement the "run" method
-
-Ant tasks
----------
-"build.xml" defines Ant tasks for building, testing and packing a
-plugin. The tests are written using the ScalaTest framework
-(http://www.artima.com/scalatest/).
-Run the tests using "ant test", or "ant guitest".
diff --git a/docs/examples/plugintemplate/doc/examples/plugintemplate/examples/BasicExample.scala b/docs/examples/plugintemplate/doc/examples/plugintemplate/examples/BasicExample.scala
deleted file mode 100644
index d1f6c91cdc..0000000000
--- a/docs/examples/plugintemplate/doc/examples/plugintemplate/examples/BasicExample.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-package plugintemplate.examples
-
-/** An example demonstrating the fancy features of the new
- * compiler plugin.
- */
-class BasicExample {
- def foo = ()
-}
diff --git a/docs/examples/plugintemplate/lib/scalatest.jar.desired.sha1 b/docs/examples/plugintemplate/lib/scalatest.jar.desired.sha1
deleted file mode 100644
index 14c20f874f..0000000000
--- a/docs/examples/plugintemplate/lib/scalatest.jar.desired.sha1
+++ /dev/null
@@ -1 +0,0 @@
-8b6ba65c8146217333f0762087fe2340d572e832 ?scalatest.jar
diff --git a/docs/examples/plugintemplate/misc/scalac-plugin.xml b/docs/examples/plugintemplate/misc/scalac-plugin.xml
deleted file mode 100644
index bad4e87327..0000000000
--- a/docs/examples/plugintemplate/misc/scalac-plugin.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<plugin>
- <name>plugintemplate</name>
- <classname>plugintemplate.TemplatePlugin</classname>
-</plugin>
diff --git a/docs/examples/plugintemplate/plugin.properties b/docs/examples/plugintemplate/plugin.properties
deleted file mode 100644
index 131f96110f..0000000000
--- a/docs/examples/plugintemplate/plugin.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-scala.home=../../../build/pack
-
-plugin.name=plugintemplate
-plugin.commandname=runplugintemplate
-plugin.description=A template compiler plugin saying hello to the World
-plugin.mainclass=plugintemplate.standalone.Main
-plugin.sbazbaseurl=http://scala.epfl.ch/downloads/packages
-
-version.major=0
-version.minor=1
diff --git a/docs/examples/plugintemplate/src/plugintemplate/PluginProperties.scala b/docs/examples/plugintemplate/src/plugintemplate/PluginProperties.scala
deleted file mode 100644
index ed078a03d7..0000000000
--- a/docs/examples/plugintemplate/src/plugintemplate/PluginProperties.scala
+++ /dev/null
@@ -1,61 +0,0 @@
-package plugintemplate
-
-import java.util.Properties
-
-/** A utility to load properties of this plugin via the property
- * file "plugin.properties"
- */
-object PluginProperties {
- private val propFilename = "plugin.properties"
-
- val pluginName = getOrElse("plugin.name", "(name_unknown)")
- val pluginDescription = getOrElse("plugin.description", "(plugin description not found)")
- val pluginCommand = getOrElse("plugin.commandname", "(command_unknown)")
- val versionString = {
- val default = "(version_unknown)"
- props match {
- case Some(p) =>
- val major = p.getProperty("version.major")
- val minor = p.getProperty("version.minor")
- if ((major eq null) || (minor eq null)) default
- else major +"."+ minor
- case None => default
- }
- }
-
- private def getOrElse(property: String, default: String) = {
- props match {
- case Some(p) if (p.getProperty(property) != null) =>
- p.getProperty(property)
- case _ =>
- default
- }
- }
-
- private lazy val props: Option[Properties] = {
- /** Running from JAR file: the properties file should be in the
- * jar as well
- */
- var stream = this.getClass.getResourceAsStream("/"+ propFilename)
- if (stream == null) {
- /** Running from .class files: expect classfiles to be in
- * directory [...]/build/build.main, and [...] to contain
- * the properties file.
- */
- try {
- val current = this.getClass.getClassLoader.getResource(".")
- val dir = new java.io.File(current.toURI)
- // dir will be [...]/build/build.main/
- stream = new java.io.FileInputStream(dir.getParentFile.getParent +"/"+ propFilename)
- } catch {
- case _ => ()
- }
- }
- if (stream == null) None
- else {
- val p = new Properties
- p.load(stream)
- Some(p)
- }
- }
-}
diff --git a/docs/examples/plugintemplate/src/plugintemplate/TemplateAnnotationChecker.scala b/docs/examples/plugintemplate/src/plugintemplate/TemplateAnnotationChecker.scala
deleted file mode 100644
index 6cd3472675..0000000000
--- a/docs/examples/plugintemplate/src/plugintemplate/TemplateAnnotationChecker.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-package plugintemplate
-
-import scala.tools.nsc.Global
-
-abstract class TemplateAnnotationChecker {
- val global: Global
- import global._
-
- object checker extends AnnotationChecker {
- def annotationsConform(tpe1: Type, tpe2: Type): Boolean = {
- println("checking: "+ tpe1 +" <: "+ tpe2)
- true
- }
-
- override def addAnnotations(tree: Tree, tpe: Type): Type = {
- println("adding annot to "+ tree.symbol)
- tpe
- }
- }
-}
diff --git a/docs/examples/plugintemplate/src/plugintemplate/TemplateComponent.scala b/docs/examples/plugintemplate/src/plugintemplate/TemplateComponent.scala
deleted file mode 100644
index b63f3203b5..0000000000
--- a/docs/examples/plugintemplate/src/plugintemplate/TemplateComponent.scala
+++ /dev/null
@@ -1,35 +0,0 @@
-package plugintemplate
-
-import scala.tools.nsc._
-import scala.tools.nsc.plugins.PluginComponent
-
-/** This class shows how to implement a compiler component that
- * can be used in a compiler plugin. If the plugin uses a tree
- * transformer and / or an InfoTransformer, look at the two
- * classes <code>TemplateTransformComponent</code> and
- * <code>TemplateInfoTransformComponent</code>.
- *
- * @todo Adapt the name of this class to the plugin, and implement it.
- */
-class TemplateComponent(val global: Global) extends PluginComponent {
- import global._
-
- val runsAfter = List[String]("refchecks")
-
- /** The name of this plugin phase
- * @todo Adapt to specific plugin.
- */
- val phaseName = "plugintemplate"
-
- def newPhase(prev: Phase) = new Phase(prev) {
- def name = phaseName
-
- /** The implementation of this Phase's behavior
- *
- * @todo Implementation.
- */
- def run {
- println("Hello from phase "+ name)
- }
- }
-}
diff --git a/docs/examples/plugintemplate/src/plugintemplate/TemplateInfoTransformComponent.scala b/docs/examples/plugintemplate/src/plugintemplate/TemplateInfoTransformComponent.scala
deleted file mode 100644
index 71069aed6f..0000000000
--- a/docs/examples/plugintemplate/src/plugintemplate/TemplateInfoTransformComponent.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-package plugintemplate
-
-import scala.tools.nsc._
-import scala.tools.nsc.plugins.PluginComponent
-import scala.tools.nsc.transform.InfoTransform
-// import scala.tools.nsc.transform.TypingTransformers
-
-/** This class implements a plugin component using tree transformers and
- * InfoTransformer. An InfoTransformer will be automatically created
- * and registered in <code>SymbolTable.infoTransformers</code>. If
- * a <code>Typer</code> is needed during transformation, the component
- * should mix in <code>TypingTransformers</code>. This provides a local
- * variable <code>localTyper: Typer</code> that is always updated to
- * the current context.
- *
- * @todo Adapt the name of this class to the plugin, and implement it.
- */
-class TemplateInfoTransformComponent(val global: Global) extends PluginComponent
- // with TypingTransformers
- with InfoTransform {
-
- import global._
- import global.definitions._
-
- val runsAfter = List[String]("refchecks")
- /** The phase name of the compiler plugin
- * @todo Adapt to specific plugin.
- */
- val phaseName = "plugintemplateinfotransform"
-
- def transformInfo(sym: Symbol, tp: Type): Type = infoTransformer.mapOver(tp)
-
- def newTransformer(unit: CompilationUnit) = new TemplateTransformer
-
- /** The type transformation applied by this component. The trait InfoTransform
- * will create an instance of InfoTransformer applying this TypeMap. The type
- * map will be applied when computing a symbol's type in all phases
- * <em>after</em> "plugintemplateinfotransform".
- *
- * @todo Implement.
- */
- private val infoTransformer = new TypeMap {
- def apply(tp: Type): Type = tp match {
- case MethodType(pts, rt) =>
- println("methodType (_, _, ..) => "+ rt)
- tp
- case _ => mapOver(tp)
- }
- }
-
- /** The tree transformer that implements the behavior of this
- * component. Change the superclass to <code>TypingTransformer</code>
- * to make a local typechecker <code>localTyper</code> available.
- *
- * @todo Implement.
- */
- class TemplateTransformer extends /*Typing*/ Transformer {
- /** When using <code>preTransform</code>, each node is
- * visited before its children.
- */
- def preTransform(tree: Tree): Tree = tree match {
- case ValDef(_, name, _, _) =>
- println("pre-info-transforming valdef "+ name)
- tree
- case _ => tree
- }
-
- /** When using <code>postTransform</code>, each node is
- * visited after its children.
- */
- def postTransform(tree: Tree): Tree = tree match {
- case _ => tree
- }
-
- override def transform(tree: Tree): Tree = {
- postTransform(super.transform(preTransform(tree)))
- }
- }
-}
diff --git a/docs/examples/plugintemplate/src/plugintemplate/TemplatePlugin.scala b/docs/examples/plugintemplate/src/plugintemplate/TemplatePlugin.scala
deleted file mode 100644
index 6cda37d4e3..0000000000
--- a/docs/examples/plugintemplate/src/plugintemplate/TemplatePlugin.scala
+++ /dev/null
@@ -1,52 +0,0 @@
-package plugintemplate
-
-import scala.tools.nsc.Global
-import scala.tools.nsc.plugins.Plugin
-
-/** A class describing the compiler plugin
- *
- * @todo Adapt the name of this class to the plugin being
- * implemented
- */
-class TemplatePlugin(val global: Global) extends Plugin {
- /** The name of this plugin. Extracted from the properties file. */
- val name = PluginProperties.pluginName
-
- val runsAfter = List[String]("refchecks")
-
- /** A short description of the plugin, read from the properties file */
- val description = PluginProperties.pluginDescription
-
- /** @todo A description of the plugin's options */
- override val optionsHelp = Some(
- " -P:"+ name +":option sets some option for this plugin")
-
- /** @todo Implement parsing of plugin options */
- override def processOptions(options: List[String], error: String => Unit) {
- super.processOptions(options, error)
- }
-
- /** The compiler components that will be applied when running
- * this plugin
- *
- * @todo Adapt to the plugin being implemented
- */
- val components = TemplatePlugin.components(global)
-
- val checker = new TemplateAnnotationChecker {
- val global: TemplatePlugin.this.global.type = TemplatePlugin.this.global
- }
- global.addAnnotationChecker(checker.checker)
-}
-
-object TemplatePlugin {
- /** Yields the list of Components to be executed in this plugin
- *
- * @todo: Adapt to specific implementation.
- */
- def components(global: Global) =
- List(new TemplateComponent(global),
- new TemplateTraverseComponent(global),
- new TemplateTransformComponent(global),
- new TemplateInfoTransformComponent(global))
-}
diff --git a/docs/examples/plugintemplate/src/plugintemplate/TemplateTransformComponent.scala b/docs/examples/plugintemplate/src/plugintemplate/TemplateTransformComponent.scala
deleted file mode 100644
index 7c2630dc16..0000000000
--- a/docs/examples/plugintemplate/src/plugintemplate/TemplateTransformComponent.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-package plugintemplate
-
-import scala.tools.nsc._
-import scala.tools.nsc.plugins.PluginComponent
-import scala.tools.nsc.transform.Transform
-// import scala.tools.nsc.transform.TypingTransformers
-
-/** This class implements a plugin component using tree transformers. If
- * a <code>Typer</code> is needed during transformation, the component
- * should mix in <code>TypingTransformers</code>. This provides a local
- * variable <code>localTyper: Typer</code> that is always updated to
- * the current context.
- *
- * @todo Adapt the name of this class to the plugin, and implement it.
- */
-class TemplateTransformComponent(val global: Global) extends PluginComponent
- // with TypingTransformers
- with Transform {
- import global._
- import global.definitions._
-
- val runsAfter = List[String]("refchecks")
- /** The phase name of the compiler plugin
- * @todo Adapt to specific plugin.
- */
- val phaseName = "plugintemplatetransform"
-
- def newTransformer(unit: CompilationUnit) = new TemplateTransformer
-
- /** The tree transformer that implements the behavior of this
- * component. Change the superclass to <code>TypingTransformer</code>
- * to make a local typechecker <code>localTyper</code> available.
- *
- * @todo Implement.
- */
- class TemplateTransformer extends /*Typing*/ Transformer {
- /** When using <code>preTransform</code>, each node is
- * visited before its children.
- */
- def preTransform(tree: Tree): Tree = tree match {
- case _ => tree
- }
-
- /** When using <code>postTransform</code>, each node is
- * visited after its children.
- */
- def postTransform(tree: Tree): Tree = tree match {
- case New(tpt) =>
- println("post-transforming new "+ tpt)
- tree
- case _ => tree
- }
-
- override def transform(tree: Tree): Tree = {
- postTransform(super.transform(preTransform(tree)))
- }
- }
-}
diff --git a/docs/examples/plugintemplate/src/plugintemplate/TemplateTraverseComponent.scala b/docs/examples/plugintemplate/src/plugintemplate/TemplateTraverseComponent.scala
deleted file mode 100644
index 400daf7437..0000000000
--- a/docs/examples/plugintemplate/src/plugintemplate/TemplateTraverseComponent.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-package plugintemplate
-
-import scala.tools.nsc._
-import scala.tools.nsc.plugins.PluginComponent
-
-/** This class implements a plugin component using a tree
- * traverser */
-class TemplateTraverseComponent (val global: Global) extends PluginComponent {
- import global._
- import global.definitions._
-
- val runsAfter = List[String]("refchecks")
- /** The phase name of the compiler plugin
- * @todo Adapt to specific plugin.
- */
- val phaseName = "plugintemplatetraverse"
-
- def newPhase(prev: Phase): Phase = new TraverserPhase(prev)
- class TraverserPhase(prev: Phase) extends StdPhase(prev) {
- def apply(unit: CompilationUnit) {
- newTraverser().traverse(unit.body)
- }
- }
-
- def newTraverser(): Traverser = new ForeachTreeTraverser(check)
-
- def check(tree: Tree): Unit = tree match {
- case Apply(fun, args) =>
- println("traversing application of "+ fun)
- case _ => ()
- }
-}
diff --git a/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala b/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala
deleted file mode 100644
index 0bfcbf53c7..0000000000
--- a/docs/examples/plugintemplate/src/plugintemplate/standalone/Main.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-package plugintemplate.standalone
-
-import plugintemplate.PluginProperties
-import scala.tools.nsc.CompilerCommand
-import scala.tools.nsc.Settings
-
-/** An object for running the plugin as standalone application.
- *
- * @todo: print, parse and apply plugin options !!!
- * ideally re-use the TemplatePlugin (-> runsAfter, optionsHelp,
- * processOptions, components, annotationChecker) instead of
- * duplicating it here and in PluginRunner.
- */
-object Main {
- def main(args: Array[String]) {
- val settings = new Settings
-
- val command = new CompilerCommand(args.toList, settings) {
- /** The command name that will be printed in the usage message.
- * This is automatically set to the value of 'plugin.commandname' in the
- * file build.properties.
- */
- override val cmdName = PluginProperties.pluginCommand
- }
-
- if (!command.ok)
- return()
-
- /** The version number of this plugin is read from the properties file
- */
- if (settings.version.value) {
- println(command.cmdName +" version "+ PluginProperties.versionString)
- return()
- }
- if (settings.help.value) {
- println(command.usageMsg)
- return()
- }
-
- val runner = new PluginRunner(settings)
- val run = new runner.Run
- run.compile(command.files)
- }
-}
diff --git a/docs/examples/plugintemplate/src/plugintemplate/standalone/PluginRunner.scala b/docs/examples/plugintemplate/src/plugintemplate/standalone/PluginRunner.scala
deleted file mode 100644
index 06fe669cbd..0000000000
--- a/docs/examples/plugintemplate/src/plugintemplate/standalone/PluginRunner.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package plugintemplate.standalone
-
-import plugintemplate.{TemplateAnnotationChecker, TemplatePlugin}
-import scala.tools.nsc.{Global, Settings, SubComponent}
-import scala.tools.nsc.reporters.{ConsoleReporter, Reporter}
-
-/** This class is a compiler that will be used for running
- * the plugin in standalone mode.
- */
-class PluginRunner(settings: Settings, reporter: Reporter)
-extends Global(settings, reporter) {
- def this(settings: Settings) = this(settings, new ConsoleReporter(settings))
-
- val annotChecker = new TemplateAnnotationChecker {
- val global: PluginRunner.this.type = PluginRunner.this
- }
- addAnnotationChecker(annotChecker.checker)
-
- /** The phases to be run.
- *
- * @todo: Adapt to specific plugin implementation
- */
- override protected def computeInternalPhases() {
- phasesSet += syntaxAnalyzer
- phasesSet += analyzer.namerFactory
- phasesSet += analyzer.typerFactory
- phasesSet += superAccessors // add super accessors
- phasesSet += pickler // serialize symbol tables
- phasesSet += refChecks // perform reference and override checking, translate nested objects
-
- for (phase <- TemplatePlugin.components(this)) {
- phasesSet += phase
- }
- }
-
-}
diff --git a/docs/examples/plugintemplate/test/plugintemplate/PluginPropertiesSuite.scala b/docs/examples/plugintemplate/test/plugintemplate/PluginPropertiesSuite.scala
deleted file mode 100644
index a07796a7f2..0000000000
--- a/docs/examples/plugintemplate/test/plugintemplate/PluginPropertiesSuite.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-package plugintemplate
-
-import org.scalatest.Suite
-
-class PluginPropertiesSuite extends Suite {
- def testProperties() {
- expect("A template compiler plugin saying hello to the World") {
- PluginProperties.pluginDescription
- }
- expect("0.1") {
- PluginProperties.versionString
- }
- }
-}
diff --git a/docs/examples/plugintemplate/test/plugintemplate/TemplatePluginSuite.scala b/docs/examples/plugintemplate/test/plugintemplate/TemplatePluginSuite.scala
deleted file mode 100644
index 06916f9dd3..0000000000
--- a/docs/examples/plugintemplate/test/plugintemplate/TemplatePluginSuite.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-package plugintemplate
-
-import org.scalatest.Suite
-import org.scalatest.Ignore
-
-class TemplatePluginSuite extends Suite {
- def testName() {
- import scala.tools.nsc.{Global, Settings}
- import scala.tools.nsc.reporters.ConsoleReporter
- val settings = new Settings
- val compiler = new Global(settings, new ConsoleReporter(settings))
- val plugin = new TemplatePlugin(compiler)
- expect("plugintemplate") {
- plugin.name
- }
- }
-
- @Ignore
- def testFail() {
- expect(1) { 2 }
- }
-}
diff --git a/docs/examples/sort.scala b/docs/examples/sort.scala
deleted file mode 100644
index 9a928f1107..0000000000
--- a/docs/examples/sort.scala
+++ /dev/null
@@ -1,48 +0,0 @@
-package examples
-
-object sort {
-
- def sort(a: Array[Int]) {
-
- def swap(i: Int, j: Int) {
- val t = a(i); a(i) = a(j); a(j) = t
- }
-
- def sort1(l: Int, r: Int) {
- val pivot = a((l + r) / 2)
- var i = l
- var j = r
- while (i <= j) {
- while (a(i) < pivot) { i += 1 }
- while (a(j) > pivot) { j -= 1 }
- if (i <= j) {
- swap(i, j)
- i += 1
- j -= 1
- }
- }
- if (l < j) sort1(l, j)
- if (j < r) sort1(i, r)
- }
-
- if (a.length > 0)
- sort1(0, a.length - 1)
- }
-
- def println(ar: Array[Int]) {
- def print1 = {
- def iter(i: Int): String =
- ar(i) + (if (i < ar.length-1) "," + iter(i+1) else "")
- if (ar.length == 0) "" else iter(0)
- }
- Console.println("[" + print1 + "]")
- }
-
- def main(args: Array[String]) {
- val ar = Array(6, 2, 8, 5, 1)
- println(ar)
- sort(ar)
- println(ar)
- }
-
-}
diff --git a/docs/examples/sort1.scala b/docs/examples/sort1.scala
deleted file mode 100644
index 39e5519fe0..0000000000
--- a/docs/examples/sort1.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-package examples
-
-object sort1 {
-
- def sort(a: List[Int]): List[Int] = {
- if (a.length < 2)
- a
- else {
- val pivot = a(a.length / 2)
- sort(a.filter(x => x < pivot)) :::
- a.filter(x => x == pivot) :::
- sort(a.filter(x => x > pivot))
- }
- }
-
- def main(args: Array[String]) {
- val xs = List(6, 2, 8, 5, 1)
- println(xs)
- println(sort(xs))
- }
-
-}
diff --git a/docs/examples/sort2.scala b/docs/examples/sort2.scala
deleted file mode 100644
index e0016088bb..0000000000
--- a/docs/examples/sort2.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-package examples
-
-object sort2 {
-
- def sort(a: List[Int]): List[Int] = {
- if (a.length < 2)
- a
- else {
- val pivot = a(a.length / 2)
- def lePivot(x: Int) = x < pivot
- def gtPivot(x: Int) = x > pivot
- def eqPivot(x: Int) = x == pivot
- sort(a filter lePivot) :::
- (a filter eqPivot) :::
- sort(a filter gtPivot)
- }
- }
-
- def main(args: Array[String]) {
- val xs = List(6, 2, 8, 5, 1, 8)
- println(xs)
- println(sort(xs))
- }
-
-}
diff --git a/docs/examples/swing/ButtonApp.scala b/docs/examples/swing/ButtonApp.scala
deleted file mode 100644
index 96799b24f2..0000000000
--- a/docs/examples/swing/ButtonApp.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-package examples.swing
-
-import java.awt.Dimension
-
-import swing._
-import swing.event._
-
-object ButtonApp extends SimpleSwingApplication {
- def top = new MainFrame {
- title = "My Frame"
- contents = new GridPanel(2, 2) {
- hGap = 3
- vGap = 3
- contents += new Button {
- text = "Press Me!"
- reactions += {
- case ButtonClicked(_) => text = "Hello Scala"
- }
- }
- }
- size = new Dimension(300, 80)
- }
-}
-
diff --git a/docs/examples/swing/CelsiusConverter.scala b/docs/examples/swing/CelsiusConverter.scala
deleted file mode 100644
index b4a62fb366..0000000000
--- a/docs/examples/swing/CelsiusConverter.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-package examples.swing
-
-import swing._
-import event._
-
-/** A GUI app to convert celsius to centigrade
- */
-object CelsiusConverter extends SimpleSwingApplication {
- def top = new MainFrame {
- title = "Convert Celsius to Fahrenheit"
- val tempCelsius = new TextField
- val celsiusLabel = new Label {
- text = "Celsius"
- border = Swing.EmptyBorder(5, 5, 5, 5)
- }
- val convertButton = new Button {
- text = "Convert"//new javax.swing.ImageIcon("c:\\workspace\\gui\\images\\convert.gif")
- //border = Border.Empty(5, 5, 5, 5)
- }
- val fahrenheitLabel = new Label {
- text = "Fahrenheit "
- border = Swing.EmptyBorder(5, 5, 5, 5)
- listenTo(convertButton, tempCelsius)
-
- def convert() {
- val c = Integer.parseInt(tempCelsius.text)
- val f = c * 9 / 5 + 32
- text = "<html><font color = red>"+f+"</font> Fahrenheit</html>"
- }
-
- reactions += {
- case ButtonClicked(_) | EditDone(_) => convert()
- }
- }
- contents = new GridPanel(2,2) {
- contents.append(tempCelsius, celsiusLabel, convertButton, fahrenheitLabel)
- border = Swing.EmptyBorder(10, 10, 10, 10)
- }
- //defaultButton = Some(convertButton)
- }
-}
-
diff --git a/docs/examples/swing/CelsiusConverter2.scala b/docs/examples/swing/CelsiusConverter2.scala
deleted file mode 100644
index 3630d61b61..0000000000
--- a/docs/examples/swing/CelsiusConverter2.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package examples.swing
-
-import swing._
-import event._
-
-object CelsiusConverter2 extends SimpleSwingApplication {
- def newField = new TextField {
- text = "0"
- columns = 5
- horizontalAlignment = Alignment.Right
- }
- val celsius = newField
- val fahrenheit = newField
-
- listenTo(fahrenheit, celsius)
- reactions += {
- case EditDone(`fahrenheit`) =>
- val f = Integer.parseInt(fahrenheit.text)
- val c = (f - 32) * 5 / 9
- celsius.text = c.toString
- case EditDone(`celsius`) =>
- val c = Integer.parseInt(celsius.text)
- val f = c * 9 / 5 + 32
- fahrenheit.text = f.toString
- }
-
- lazy val ui = new FlowPanel(celsius, new Label(" Celsius = "),
- fahrenheit, new Label(" Fahrenheit")) {
- border = Swing.EmptyBorder(15, 10, 10, 10)
- }
- def top = new MainFrame {
- title = "Convert Celsius / Fahrenheit"
- contents = ui
- }
-}
-
diff --git a/docs/examples/swing/ComboBoxes.scala b/docs/examples/swing/ComboBoxes.scala
deleted file mode 100644
index c6ee19013a..0000000000
--- a/docs/examples/swing/ComboBoxes.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-package examples.swing
-
-import swing._
-import event._
-import java.util.Date
-import java.awt.Color
-import java.text.SimpleDateFormat
-import javax.swing.{Icon, ImageIcon}
-
-/**
- * Demonstrates how to use combo boxes and custom item renderers.
- *
- * TODO: clean up layout
- */
-object ComboBoxes extends SimpleSwingApplication {
- import ComboBox._
- lazy val ui = new FlowPanel {
- contents += new ComboBox(List(1,2,3,4))
-
- val patterns = List("dd MMMMM yyyy",
- "dd.MM.yy",
- "MM/dd/yy",
- "yyyy.MM.dd G 'at' hh:mm:ss z",
- "EEE, MMM d, ''yy",
- "h:mm a",
- "H:mm:ss:SSS",
- "K:mm a,z",
- "yyyy.MMMMM.dd GGG hh:mm aaa")
- val dateBox = new ComboBox(patterns) { makeEditable() }
- contents += dateBox
- val field = new TextField(20) { editable = false }
- contents += field
-
- reactions += {
- case SelectionChanged(`dateBox`) => reformat()
- }
- listenTo(dateBox.selection)
-
- def reformat() {
- try {
- val today = new Date
- val formatter = new SimpleDateFormat(dateBox.selection.item)
- val dateString = formatter.format(today)
- field.foreground = Color.black
- field.text = dateString
- } catch {
- case e: IllegalArgumentException =>
- field.foreground = Color.red
- field.text = "Error: " + e.getMessage
- }
- }
-
-
- val icons = try {
- List(new ImageIcon(resourceFromClassloader("images/margarita1.jpg")),
- new ImageIcon(resourceFromClassloader("images/margarita2.jpg")),
- new ImageIcon(resourceFromClassloader("images/rose.jpg")),
- new ImageIcon(resourceFromClassloader("images/banana.jpg")))
- } catch {
- case _ =>
- println("Couldn't load images for combo box")
- List(Swing.EmptyIcon)
- }
-
- val iconBox = new ComboBox(icons) {
- renderer = new ListView.AbstractRenderer[Icon, Label](new Label) {
- def configure(list: ListView[_], isSelected: Boolean, focused: Boolean, icon: Icon, index: Int) {
- component.icon = icon
- component.xAlignment = Alignment.Center
- if(isSelected) {
- component.border = Swing.LineBorder(list.selectionBackground, 3)
- } else {
- component.border = Swing.EmptyBorder(3)
- }
- }
- }
- }
- contents += iconBox
- }
-
- def top = new MainFrame {
- title = "ComboBoxes Demo"
- contents = ui
- }
-}
-
diff --git a/docs/examples/swing/CountButton.scala b/docs/examples/swing/CountButton.scala
deleted file mode 100644
index 5fb14681d6..0000000000
--- a/docs/examples/swing/CountButton.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-package examples.swing
-
-import scala.swing._
-import scala.swing.event._
-
-object CountButton extends SimpleSwingApplication {
- def top = new MainFrame {
- title = "My Frame"
- contents = new GridPanel(2, 2) {
- hGap = 3
- vGap = 3
- val button = new Button {
- text = "Press Me!"
- }
- contents += button
- val label = new Label {
- text = "No button clicks registered"
- }
- contents += label
-
- listenTo(button)
- var nclicks = 0
- reactions += {
- case ButtonClicked(b) =>
- nclicks += 1
- label.text = "Number of button clicks: "+nclicks
- }
- }
- }
-}
diff --git a/docs/examples/swing/Dialogs.scala b/docs/examples/swing/Dialogs.scala
deleted file mode 100644
index 0b4ac258cf..0000000000
--- a/docs/examples/swing/Dialogs.scala
+++ /dev/null
@@ -1,176 +0,0 @@
-package examples.swing
-
-import swing._
-import swing.event._
-
-object Dialogs extends SimpleSwingApplication {
- import TabbedPane._
-
- lazy val label = new Label("No Result yet")
- lazy val tabs = new TabbedPane {
- pages += new Page("File", new GridBagPanel { grid =>
- import GridBagPanel._
- val buttonText = new TextField("Click Me")
-
- val c = new Constraints
- c.fill = Fill.Horizontal
- c.grid = (1,1)
-
- val chooser = new FileChooser
- layout(new Button(Action("Open") {
- chooser.showOpenDialog(grid)
- })) = c
-
- c.grid = (1,2)
- layout(new Button(Action("Save") {
- chooser.showSaveDialog(grid)
- })) = c
-
- c.grid = (1,3)
- layout(new Button(Action("Custom") {
- chooser.showDialog(grid, buttonText.text)
- })) = c
-
- c.grid = (2,3)
- layout(new Label(" with Text ")) = c
-
- c.grid = (3,3)
- c.ipadx = 50
- layout(buttonText) = c
-
- border = Swing.EmptyBorder(5, 5, 5, 5)
- })
- pages += new Page("Simple Modal Dialogs", new BorderPanel {
- import BorderPanel._
- val mutex = new ButtonGroup
- val ok = new RadioButton("OK (in the L&F's words)")
- val ynlf = new RadioButton("Yes/No (in the L&F's words)")
- val ynp = new RadioButton("Yes/No (in the programmer's words)")
- val yncp = new RadioButton("Yes/No/Cancel (in the programmer's words)")
- val radios = List(ok, ynlf, ynp, yncp)
- mutex.buttons ++= radios
- mutex.select(ok)
- val buttons = new BoxPanel(Orientation.Vertical) {
- contents ++= radios
- }
- layout(buttons) = Position.North
- layout(new Button(Action("Show It!") {
- import Dialog._
- mutex.selected.get match {
- case `ok` =>
- showMessage(buttons, "Eggs aren't supposed to be green.")
- case `ynlf` =>
- label.text = showConfirmation(buttons,
- "Would you like green eggs and ham?",
- "An Inane Question") match {
- case Result.Yes => "Ewww!"
- case Result.No => "Me neither!"
- case _ => "Come on -- tell me!"
- }
- case `ynp` =>
- val options = List("Yes, please",
- "No, thanks",
- "No eggs, no ham!")
- label.text = showOptions(buttons,
- "Would you like some green eggs to go with that ham?",
- "A Silly Question",
- entries = options,
- initial = 2) match {
- case Result.Yes => "You're kidding!"
- case Result.No => "I don't like them, either."
- case _ => "Come on -- 'fess up!"
- }
- case `yncp` =>
- val options = List("Yes, please",
- "No, thanks",
- "No eggs, no ham!")
- label.text = showOptions(buttons,
- message = "Would you like some green eggs to go with that ham?",
- title = "A Silly Question",
- entries = options,
- initial = 2) match {
- case Result.Yes => "Here you go: green eggs and ham!"
- case Result.No => "OK, just the ham, then."
- case Result.Cancel => "Well, I'm certainly not going to eat them!"
- case _ => "Please tell me what you want!"
- }
- }
- })) = Position.South
- })
- pages += new Page("More Dialogs", new BorderPanel {
- import BorderPanel._
- val mutex = new ButtonGroup
- val pick = new RadioButton("Pick one of several choices")
- val enter = new RadioButton("Enter some text")
- val custom = new RadioButton("Custom")
- val customUndec = new RadioButton("Custom undecorated")
- val custom2 = new RadioButton("2 custom dialogs")
- val radios = List(pick, enter, custom, customUndec, custom2)
- mutex.buttons ++= radios
- mutex.select(pick)
- val buttons = new BoxPanel(Orientation.Vertical) {
- contents ++= radios
- }
- layout(buttons) = Position.North
- layout(new Button(Action("Show It!") {
- import Dialog._
- mutex.selected.get match {
- case `pick` =>
- val possibilities = List("ham", "spam", "yam")
- val s = showInput(buttons,
- "Complete the sentence:\n\"Green eggs and...\"",
- "Customized Dialog",
- Message.Plain,
- Swing.EmptyIcon,
- possibilities, "ham")
-
- //If a string was returned, say so.
- label.text = if ((s != None) && (s.get.length > 0))
- "Green eggs and... " + s.get + "!"
- else
- "Come on, finish the sentence!"
- case `enter` =>
- val s = showInput(buttons,
- "Complete the sentence:\n\"Green eggs and...\"",
- "Customized Dialog",
- Message.Plain,
- Swing.EmptyIcon,
- Nil, "ham")
-
- //If a string was returned, say so.
- label.text = if ((s != None) && (s.get.length > 0))
- "Green eggs and... " + s.get + "!"
- else
- "Come on, finish the sentence!"
- case `custom` =>
- val dialog = new Dialog(top)
- dialog.open()
- dialog.contents = Button("Close Me!") { dialog.close() }
- case `customUndec` =>
- val dialog = new Dialog with RichWindow.Undecorated
- dialog.open()
- dialog.contents = Button("Close Me!") { dialog.close() }
- case `custom2` =>
- val d1 = new Dialog
- val d2 = new Dialog(d1)
- d1.open()
- d2.open()
- d1.contents = Button("Close Me! I am the owner and will automatically close the other one") { d1.close() }
- d2.contents = Button("Close Me!") { d2.close() }
- }
- })) = Position.South
- })
- }
-
- lazy val ui: Panel = new BorderPanel {
- layout(tabs) = BorderPanel.Position.Center
- layout(label) = BorderPanel.Position.South
- }
-
-
- lazy val top = new MainFrame {
- title = "Dialog Demo"
- contents = ui
- }
-}
-
diff --git a/docs/examples/swing/GridBagDemo.scala b/docs/examples/swing/GridBagDemo.scala
deleted file mode 100644
index 60cfc13acb..0000000000
--- a/docs/examples/swing/GridBagDemo.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-package examples.swing
-
-import swing._
-import swing.event._
-import GridBagPanel._
-import java.awt.Insets
-
-object GridBagDemo extends SimpleSwingApplication {
- lazy val ui = new GridBagPanel {
- val c = new Constraints
- val shouldFill = true
- if (shouldFill) {
- c.fill = Fill.Horizontal
- }
-
- val button1 = new Button("Button 1")
-
- c.weightx = 0.5
-
- c.fill = Fill.Horizontal
- c.gridx = 0;
- c.gridy = 0;
- layout(button1) = c
-
- val button2 = new Button("Button 2")
- c.fill = Fill.Horizontal
- c.weightx = 0.5;
- c.gridx = 1;
- c.gridy = 0;
- layout(button2) = c
-
- val button3 = new Button("Button 3")
- c.fill = Fill.Horizontal
- c.weightx = 0.5;
- c.gridx = 2;
- c.gridy = 0;
- layout(button3) = c
-
- val button4 = new Button("Long-Named Button 4")
- c.fill = Fill.Horizontal
- c.ipady = 40; //make this component tall
- c.weightx = 0.0;
- c.gridwidth = 3;
- c.gridx = 0;
- c.gridy = 1;
- layout(button4) = c
-
- val button5 = new Button("5")
- c.fill = Fill.Horizontal
- c.ipady = 0; //reset to default
- c.weighty = 1.0; //request any extra vertical space
- c.anchor = Anchor.PageEnd
- c.insets = new Insets(10,0,0,0); //top padding
- c.gridx = 1; //aligned with button 2
- c.gridwidth = 2; //2 columns wide
- c.gridy = 2; //third row
- layout(button5) = c
- }
-
- def top = new MainFrame {
- title = "GridBag Demo"
- contents = ui
- }
-}
diff --git a/docs/examples/swing/HelloWorld.scala b/docs/examples/swing/HelloWorld.scala
deleted file mode 100644
index e89bfedd8a..0000000000
--- a/docs/examples/swing/HelloWorld.scala
+++ /dev/null
@@ -1,13 +0,0 @@
-package examples.swing
-
-import swing._
-
-/**
- * A simple swing demo.
- */
-object HelloWorld extends SimpleSwingApplication {
- def top = new MainFrame {
- title = "Hello, World!"
- contents = new Button("Click Me!")
- }
-}
diff --git a/docs/examples/swing/LabelTest.scala b/docs/examples/swing/LabelTest.scala
deleted file mode 100644
index edd7a14634..0000000000
--- a/docs/examples/swing/LabelTest.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-package examples.swing
-
-import scala.swing._
-import scala.swing.event._
-
-object LabelTest extends SimpleSwingApplication {
- def top = new MainFrame{
- contents = new Label {
- text = "Hello"
- import java.awt.event._
- listenTo(mouse.clicks)
- reactions += {
- case MousePressed(_,_,_,_,_) =>
- println("Mouse pressed2")
- }
- }
- }
-}
-
diff --git a/docs/examples/swing/LinePainting.scala b/docs/examples/swing/LinePainting.scala
deleted file mode 100644
index f72f8701ed..0000000000
--- a/docs/examples/swing/LinePainting.scala
+++ /dev/null
@@ -1,53 +0,0 @@
-package examples.swing
-
-import scala.swing.Swing._
-import scala.swing.{MainFrame, Panel}
-import scala.swing.event._
-import java.awt.{Color, Graphics2D, Point, geom}
-
-/**
- * Dragging the mouse draws a simple graph
- *
- * @author Frank Teubler, Ingo Maier
- */
-object LinePainting extends SimpleSwingApplication {
- lazy val ui = new Panel {
- background = Color.white
- preferredSize = (200,200)
-
- focusable = true
- listenTo(mouse.clicks, mouse.moves, keys)
-
- reactions += {
- case e: MousePressed =>
- moveTo(e.point)
- requestFocusInWindow()
- case e: MouseDragged => lineTo(e.point)
- case e: MouseReleased => lineTo(e.point)
- case KeyTyped(_,'c',_,_) =>
- path = new geom.GeneralPath
- repaint()
- case _: FocusLost => repaint()
- }
-
- /* records the dragging */
- var path = new geom.GeneralPath
-
- def lineTo(p: Point) { path.lineTo(p.x, p.y); repaint() }
- def moveTo(p: Point) { path.moveTo(p.x, p.y); repaint() }
-
- override def paintComponent(g: Graphics2D) = {
- super.paintComponent(g)
- g.setColor(new Color(100,100,100))
- g.drawString("Press left mouse button and drag to paint." +
- (if(hasFocus) " Press 'c' to clear." else ""), 10, size.height-10)
- g.setColor(Color.black)
- g.draw(path)
- }
- }
-
- def top = new MainFrame {
- title = "Simple Line Painting Demo"
- contents = ui
- }
-}
diff --git a/docs/examples/swing/ListViewDemo.scala b/docs/examples/swing/ListViewDemo.scala
deleted file mode 100644
index 5630f2871d..0000000000
--- a/docs/examples/swing/ListViewDemo.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-package examples.swing
-
-object ListViewDemo extends SimpleSwingApplication {
- def top = new MainFrame {
- case class City(name: String, country: String, population: Int, capital: Boolean)
- val items = List(City("Lausanne", "Switzerland", 129273, false),
- City("Paris", "France", 2203817, true),
- City("New York", "USA", 8363710 , false),
- City("Berlin", "Germany", 3416300, true),
- City("Tokio", "Japan", 12787981, true))
- import ListView._
- contents = new FlowPanel(new ScrollPane(new ListView(items) {
- renderer = Renderer(_.name)
- }))
- //new ScrollPane(new Table(items)))
- }
-}
diff --git a/docs/examples/swing/SimpleApplet.scala b/docs/examples/swing/SimpleApplet.scala
deleted file mode 100644
index 502de537a3..0000000000
--- a/docs/examples/swing/SimpleApplet.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-package examples.swing
-
-import event._
-
-class SimpleApplet extends Applet {
- object ui extends UI with Reactor {
- def init() = {
- val button = new Button("Press here!")
- val text = new TextArea("Java Version: " + util.Properties.javaVersion + "\n")
- listenTo(button)
- reactions += {
- case ButtonClicked(_) => text.text += "Button Pressed!\n"
- case _ =>
- }
- contents = new BoxPanel(Orientation.Vertical) { contents.append(button, text) }
- }
- }
-}
diff --git a/docs/examples/swing/SwingApp.scala b/docs/examples/swing/SwingApp.scala
deleted file mode 100644
index b3fe7447ef..0000000000
--- a/docs/examples/swing/SwingApp.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-package examples.swing
-
-import swing._
-import swing.event._
-
-object SwingApp extends SimpleSwingApplication {
- def top = new MainFrame {
- title = "SwingApp"
- var numclicks = 0
- object label extends Label {
- val prefix = "Number of button clicks: "
- text = prefix + "0 "
- listenTo(button)
- reactions += {
- case ButtonClicked(button) =>
- numclicks = numclicks + 1
- text = prefix + numclicks
- }
- }
- object button extends Button {
- text = "I am a button"
- }
- contents = new FlowPanel {
- contents.append(button, label)
- border = Swing.EmptyBorder(5, 5, 5, 5)
- }
- }
-}
-
diff --git a/docs/examples/swing/TableSelection.scala b/docs/examples/swing/TableSelection.scala
deleted file mode 100644
index 8c8ea4ffcc..0000000000
--- a/docs/examples/swing/TableSelection.scala
+++ /dev/null
@@ -1,96 +0,0 @@
-package examples.swing
-
-import java.awt.Dimension
-import swing.event._
-
-object TableSelection extends SimpleSwingApplication {
- val model = Array(List("Mary", "Campione", "Snowboarding", 5, false).toArray,
- List("Alison", "Huml", "Rowing", 5, false).toArray,
- List("Kathy", "Walrath", "Knitting", 5, false).toArray,
- List("Sharon", "Zakhour", "Speed reading", 5, false).toArray,
- List("Philip", "Milne", "Pool", 5, false).toArray)
- /*val model = Array.tabulate(10000) { i =>
- List("Mary", "Campione", "Snowboarding", i, false).toArray
- }*/
-
- lazy val ui = new BoxPanel(Orientation.Vertical) {
- val table = new Table(model, Array("First Name", "Last Name", "Sport", "# of Years", "Vegetarian")) {
- preferredViewportSize = new Dimension(500, 70)
- }
- //1.6:table.fillsViewportHeight = true
- listenTo(table.selection)
-
- contents += new ScrollPane(table)
- contents += new Label("Selection Mode")
-
- def radio(mutex: ButtonGroup, text: String): RadioButton = {
- val b = new RadioButton(text)
- listenTo(b)
- mutex.buttons += b
- contents += b
- b
- }
-
- val intervalMutex = new ButtonGroup
- val multiInterval = radio(intervalMutex, "Multiple Interval Selection")
- val elementInterval = radio(intervalMutex, "Single Selection")
- val singleInterval = radio(intervalMutex, "Single Interval Selection")
- intervalMutex.select(multiInterval)
-
- contents += new Label("Selection Options")
- val elemMutex = new ButtonGroup
- val rowSelection = radio(elemMutex, "Row Selection")
- val columnSelection = radio(elemMutex, "Column Selection")
- val cellSelection = radio(elemMutex, "Cell Selection")
- elemMutex.select(rowSelection)
-
- val output = new TextArea(5, 40) { editable = false }
- contents += new ScrollPane(output)
-
- def outputSelection() {
- output.append("Lead: " + table.selection.rows.leadIndex + "," +
- table.selection.columns.leadIndex + ". ")
- output.append("Rows:")
- for (c <- table.selection.rows) output.append(" " + c)
- output.append(". Columns:")
- for (c <- table.selection.columns) output.append(" " + c)
- output.append(".\n")
- }
-
- reactions += {
- case ButtonClicked(`multiInterval`) =>
- table.selection.intervalMode = Table.IntervalMode.MultiInterval
- if (cellSelection.selected) {
- elemMutex.select(rowSelection)
- table.selection.elementMode = Table.ElementMode.None
- }
- cellSelection.enabled = false
- case ButtonClicked(`elementInterval`) =>
- table.selection.intervalMode = Table.IntervalMode.Single
- cellSelection.enabled = true
- case ButtonClicked(`singleInterval`) =>
- table.selection.intervalMode = Table.IntervalMode.SingleInterval
- cellSelection.enabled = true
- case ButtonClicked(`rowSelection`) =>
- if (rowSelection.selected)
- table.selection.elementMode = Table.ElementMode.Row
- case ButtonClicked(`columnSelection`) =>
- if (columnSelection.selected)
- table.selection.elementMode = Table.ElementMode.Column
- case ButtonClicked(`cellSelection`) =>
- if (cellSelection.selected)
- table.selection.elementMode = Table.ElementMode.Cell
- case TableRowsSelected(_, range, false) =>
- output.append("Rows selected, changes: " + range + "\n")
- outputSelection()
- case TableColumnsSelected(_, range, false) =>
- output.append("Columns selected, changes " + range + "\n")
- outputSelection()
- }
- }
-
- def top = new MainFrame {
- title = "Table Selection"
- contents = ui
- }
-}
diff --git a/docs/examples/swing/UIDemo.scala b/docs/examples/swing/UIDemo.scala
deleted file mode 100644
index 6d77c049e0..0000000000
--- a/docs/examples/swing/UIDemo.scala
+++ /dev/null
@@ -1,147 +0,0 @@
-package examples.swing
-
-import swing._
-import event._
-import Swing._
-import ListView._
-
-object UIDemo extends SimpleSwingApplication {
- def top = new MainFrame {
- title = "Scala Swing Demo"
-
- /*
- * Create a menu bar with a couple of menus and menu items and
- * set the result as this frame's menu bar.
- */
- menuBar = new MenuBar {
- contents += new Menu("A Menu") {
- contents += new MenuItem("An item")
- contents += new MenuItem(Action("An action item") {
- println("Action '"+ title +"' invoked")
- })
- contents += new Separator
- contents += new CheckMenuItem("Check me")
- contents += new CheckMenuItem("Me too!")
- contents += new Separator
- val a = new RadioMenuItem("a")
- val b = new RadioMenuItem("b")
- val c = new RadioMenuItem("c")
- val mutex = new ButtonGroup(a,b,c)
- contents ++= mutex.buttons
- }
- contents += new Menu("Empty Menu")
- }
-
- /*
- * The root component in this frame is a panel with a border layout.
- */
- contents = new BorderPanel {
- import BorderPanel.Position._
-
- var reactLive = false
-
- val tabs = new TabbedPane {
- import TabbedPane._
- val buttons = new FlowPanel {
- border = Swing.EmptyBorder(5,5,5,5)
-
- contents += new BoxPanel(Orientation.Vertical) {
- border = CompoundBorder(TitledBorder(EtchedBorder, "Radio Buttons"), EmptyBorder(5,5,5,10))
- val a = new RadioButton("Green Vegetables")
- val b = new RadioButton("Red Meat")
- val c = new RadioButton("White Tofu")
- val mutex = new ButtonGroup(a,b,c)
- contents ++= mutex.buttons
- }
- contents += new BoxPanel(Orientation.Vertical) {
- border = CompoundBorder(TitledBorder(EtchedBorder, "Check Boxes"), EmptyBorder(5,5,5,10))
- val paintLabels = new CheckBox("Paint Labels")
- val paintTicks = new CheckBox("Paint Ticks")
- val snapTicks = new CheckBox("Snap To Ticks")
- val live = new CheckBox("Live")
- contents.append(paintLabels, paintTicks, snapTicks, live)
- listenTo(paintLabels, paintTicks, snapTicks, live)
- reactions += {
- case ButtonClicked(`paintLabels`) =>
- slider.paintLabels = paintLabels.selected
- case ButtonClicked(`paintTicks`) =>
- slider.paintTicks = paintTicks.selected
- case ButtonClicked(`snapTicks`) =>
- slider.snapToTicks = snapTicks.selected
- case ButtonClicked(`live`) =>
- reactLive = live.selected
- }
- }
- contents += new Button(Action("Center Frame") { centerOnScreen() })
- }
- pages += new Page("Buttons", buttons)
- pages += new Page("GridBag", GridBagDemo.ui)
- pages += new Page("Converter", CelsiusConverter2.ui)
- pages += new Page("Tables", TableSelection.ui)
- pages += new Page("Dialogs", Dialogs.ui)
- pages += new Page("Combo Boxes", ComboBoxes.ui)
- pages += new Page("Split Panes",
- new SplitPane(Orientation.Vertical, new Button("Hello"), new Button("World")) {
- continuousLayout = true
- })
-
- val password = new FlowPanel {
- contents += new Label("Enter your secret password here ")
- val field = new PasswordField(10)
- contents += field
- val label = new Label(field.text)
- contents += label
- listenTo(field)
- reactions += {
- case EditDone(`field`) => label.text = field.password.mkString
- }
- }
-
- pages += new Page("Password", password)
- pages += new Page("Painting", LinePainting.ui)
- //pages += new Page("Text Editor", TextEditor.ui)
- }
-
- val list = new ListView(tabs.pages) {
- selectIndices(0)
- selection.intervalMode = ListView.IntervalMode.Single
- renderer = ListView.Renderer(_.title)
- }
- val center = new SplitPane(Orientation.Vertical, new ScrollPane(list), tabs) {
- oneTouchExpandable = true
- continuousLayout = true
- }
- layout(center) = Center
-
- /*
- * This slider is used above, so we need lazy initialization semantics.
- * Objects or lazy vals are the way to go, but objects give us better
- * type inference at times.
- */
- object slider extends Slider {
- min = 0
- value = tabs.selection.index
- max = tabs.pages.size-1
- majorTickSpacing = 1
- }
- layout(slider) = South
-
- /*
- * Establish connection between the tab pane, slider, and list view.
- */
- listenTo(slider)
- listenTo(tabs.selection)
- listenTo(list.selection)
- reactions += {
- case ValueChanged(`slider`) =>
- if(!slider.adjusting || reactLive) tabs.selection.index = slider.value
- case SelectionChanged(`tabs`) =>
- slider.value = tabs.selection.index
- list.selectIndices(tabs.selection.index)
- case SelectionChanged(`list`) =>
- if (list.selection.items.length == 1)
- tabs.selection.page = list.selection.items(0)
- }
- }
- }
-}
diff --git a/docs/examples/swing/images/banana.jpg b/docs/examples/swing/images/banana.jpg
deleted file mode 100644
index 62267a4325..0000000000
--- a/docs/examples/swing/images/banana.jpg
+++ /dev/null
Binary files differ
diff --git a/docs/examples/swing/images/margarita1.jpg b/docs/examples/swing/images/margarita1.jpg
deleted file mode 100644
index d315f7c79f..0000000000
--- a/docs/examples/swing/images/margarita1.jpg
+++ /dev/null
Binary files differ
diff --git a/docs/examples/swing/images/margarita2.jpg b/docs/examples/swing/images/margarita2.jpg
deleted file mode 100644
index c8b076e5f9..0000000000
--- a/docs/examples/swing/images/margarita2.jpg
+++ /dev/null
Binary files differ
diff --git a/docs/examples/swing/images/rose.jpg b/docs/examples/swing/images/rose.jpg
deleted file mode 100644
index d4a2b58062..0000000000
--- a/docs/examples/swing/images/rose.jpg
+++ /dev/null
Binary files differ
diff --git a/docs/examples/tcpoly/collection/HOSeq.scala b/docs/examples/tcpoly/collection/HOSeq.scala
deleted file mode 100644
index a6757b95ba..0000000000
--- a/docs/examples/tcpoly/collection/HOSeq.scala
+++ /dev/null
@@ -1,167 +0,0 @@
-package examples.tcpoly.collection;
-
-trait HOSeq {
- // an internal interface that encapsulates the accumulation of elements (of type elT) to produce
- // a structure of type coll[elT] -- different kinds of collections should provide different implicit
- // values implementing this interface, in order to provide more performant ways of building that structure
- trait Accumulator[+coll[x], elT] {
- def += (el: elT): Unit
- def result: coll[elT]
- }
-
-
- // Iterable abstracts over the type of its structure as well as its elements (see PolyP's Bifunctor)
- // m[x] is intentionally unbounded: fold can then be defined nicely
- // variance: if we write m[+x] instead of +m[+x], x is an invariant position because its enclosing type
- // is an invariant position -- should probably rule that out?
- trait Iterable[+m[+x], +t] {
- //def unit[a](orig: a): m[a]
- def iterator: Iterator[t]
-
- // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t
- def accumulator[t]: Accumulator[m, t]
-
- def filter(p: t => Boolean): m[t] = {
- val buf = accumulator[t]
- val elems = elements
- while (elems.hasNext) { val x = elems.next; if (p(x)) buf += x }
- buf.result
- }
-
- def map[s](f: t => s): m[s] = {
- val buf = accumulator[s]
- val elems = elements
- while (elems.hasNext) buf += f(elems.next)
- buf.result
- }
-
- // flatMap is a more specialized map, it only works if the mapped function produces Iterable values,
- // which are then added to the result one by one
- // the compiler should be able to find the right accumulator (implicit buf) to build the result
- // to get concat, resColl = SingletonIterable, f = unit for SingletonIterable
- def flatMap[resColl[x] <: Iterable[resColl, x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = {
- // TODO: would a viewbound for resColl[x] be better?
- // -- 2nd-order type params are not yet in scope in view bound
- val elems = elements
- while (elems.hasNext) {
- val elemss: Iterator[s] = f(elems.next).iterator
- while (elemss.hasNext) buf += elemss.next
- }
- buf.result
- }
- }
-
- final class ListBuffer[A] {
- private var start: List[A] = Nil
- private var last: ::[A] = _
- private var exported: boolean = false
-
- /** Appends a single element to this buffer.
- *
- * @param x the element to append.
- */
- def += (x: A): unit = {
- if (exported) copy
- if (start.isEmpty) {
- last = new HOSeq.this.:: (x, Nil)
- start = last
- } else {
- val last1 = last
- last = new HOSeq.this.:: (x, null) // hack: ::'s tail will actually be last
- //last1.tl = last
- }
- }
-
- /** Converts this buffer to a list
- */
- def toList: List[A] = {
- exported = !start.isEmpty
- start
- }
-
- /** Clears the buffer contents.
- */
- def clear: unit = {
- start = Nil
- exported = false
- }
-
- /** Copy contents of this buffer */
- private def copy = {
- var cursor = start
- val limit = last.tail
- clear
- while (cursor ne limit) {
- this += cursor.head
- cursor = cursor.tail
- }
- }
- }
-
- implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] {
- private[this] val buff = new ListBuffer[elT]
- def += (el: elT): Unit = buff += el
- def result: List[elT] = buff.toList
- }
-
- trait List[+t] extends Iterable[List, t] {
- def head: t
- def tail: List[t]
- def isEmpty: Boolean
- def iterator: Iterator[t] = error("TODO")
-
- // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t
- def accumulator[t]: Accumulator[List, t] = error("TODO")
- }
-
- // TODO: the var tl approach does not seem to work because subtyping isn't fully working yet
- final case class ::[+b](hd: b, private val tl: List[b]) extends List[b] {
- def head = hd
- def tail = if(tl==null) this else tl // hack
- override def isEmpty: boolean = false
- }
-
- case object Nil extends List[Nothing] {
- def isEmpty = true
- def head: Nothing =
- throw new NoSuchElementException("head of empty list")
- def tail: List[Nothing] =
- throw new NoSuchElementException("tail of empty list")
- }
-}
-
-
-
-// misc signatures collected from mailing list / library code:
- /*override def flatMap[B](f: A => Iterable[B]): Set[B]
- final override def flatMap[b](f: Any => Iterable[b]): Array[b]
- def flatMap[b](f: a => Parser[b]) = new Parser[b]
- override def flatMap[b](f: a => Iterable[b]): List[b]
-
-
- MapResult[K] <: Seq[K]
- FilterResult <: Seq[T]
- Concat <: Seq[T]
- Subseq <: Seq[T]
-
-
- def map[K](f: T=>K): MapResult[K]
- def filter(f: T=>Boolean): FilterResult
- def subseq(from: int, to: int): Subseq
- def flatMap[S <: Seq[K], K](f: T => S): S#Concat // legal?
- def concat(others: Seq[T]): Concat
- */
-
-/*trait Iterator[t] {
- // @post hasAdvanced implies hasNext
- // model def hasAdvanced: Boolean
-
- def hasNext: Boolean // pure
-
- // @pre hasAdvanced
- def current: t // pure
-
- // @pre hasNext
- // @post hasAdvanced
- def advance: Unit
-}*/
diff --git a/docs/examples/tcpoly/monads/Monads.scala b/docs/examples/tcpoly/monads/Monads.scala
deleted file mode 100644
index b6e3d5b9a8..0000000000
--- a/docs/examples/tcpoly/monads/Monads.scala
+++ /dev/null
@@ -1,69 +0,0 @@
-package examples.tcpoly.monad;
-
-trait Monads {
- /**
- * class Monad m where
- * (>>=) :: m a -> (a -> m b) -> m b
- * return :: a -> m a
- *
- * MonadTC encodes the above Haskell type class,
- * an instance of MonadTC corresponds to a method dictionary.
- * (see http://lampwww.epfl.ch/~odersky/talks/wg2.8-boston06.pdf)
- *
- * Note that the identity (`this') of the method dictionary does not really correspond
- * to the instance of m[x] (`self') that is `wrapped': e.g., unit does not use `self' (which
- * corresponds to the argument of the implicit conversion that encodes an instance of this type class)
- */
- // Option =:= [x] => Option[x] <: [x] => Any
-// trait MonadTC[m <: [x] => Any, a] {
- // MonadTC[m[x], a] x is a type parameter too -- should not write e.g., m[Int] here
- trait MonadTC[m[x], a] {
- def unit[a](orig: a): m[a]
-
- // >>='s first argument comes from the implicit definition constructing this "method dictionary"
- def >>=[b](fun: a => m[b]): m[b]
- }
-}
-
-/**
- * instance Monad Maybe where
- * (Just x) >>= k = k x
- * Nothing >>= _ = Nothing
- */
-trait OptionMonad extends Monads {
- // this implicit method encodes the Monad type class instance for Option
- implicit def OptionInstOfMonad[a](self: Option[a]): MonadTC[Option, a]
- = new MonadTC[Option, a] {
- def unit[a](orig: a) = Some(orig)
- def >>=[b](fun: a => Option[b]): Option[b] = self match {
- case Some(x) => fun(x)
- case None => None
- }
- }
-}
-
-object main extends OptionMonad with Application {
- Console.println(Some("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") >>= (x => Some(x.length)))
-}
-
-
-/*
-trait MonadTC[m[x], a] requires m[x] {
- def unit[a](orig: a): m[a]
-
- // >>='s first argument comes from the implicit definition constructing this "method dictionary"
- def >>=[b](fun: a => m[b]): m[b]
-}
-
-abstract class OptionIsMonad[t[x] <: Option[x], a] implicit extends MonadTC[t, a] {
- def unit[a](orig: a) = Some(orig) // TODO: problematic.. is a meta-member: not invoked on this
-}
-
-class SomeIsMonad[a] extends OptionIsMonad[Some, a] {
- def >>=[b](fun: a => Option[b]): Option[b] = fun(x)
-}
-
-class NoneIsMonad[a] extends OptionIsMonad[None, a] {
- def >>=[b](fun: a => Option[b]): Option[b] = None
-}
-*/
diff --git a/docs/examples/typeinf.scala b/docs/examples/typeinf.scala
deleted file mode 100644
index ac6cc35f6b..0000000000
--- a/docs/examples/typeinf.scala
+++ /dev/null
@@ -1,253 +0,0 @@
-package examples
-
-object typeinf {
-
-trait Term {}
-
-case class Var(x: String) extends Term {
- override def toString() = x
-}
-case class Lam(x: String, e: Term) extends Term {
- override def toString() = "(\\" + x + "." + e + ")"
-}
-case class App(f: Term, e: Term) extends Term {
- override def toString() = "(" + f + " " + e + ")"
-}
-case class Let(x: String, e: Term, f: Term) extends Term {
- override def toString() = "let " + x + " = " + e + " in " + f
-}
-
-sealed trait Type {}
-case class Tyvar(a: String) extends Type {
- override def toString() = a
-}
-case class Arrow(t1: Type, t2: Type) extends Type {
- override def toString() = "(" + t1 + "->" + t2 + ")"
-}
-case class Tycon(k: String, ts: List[Type]) extends Type {
- override def toString() =
- k + (if (ts.isEmpty) "" else ts.mkString("[", ",", "]"))
-}
-
-object typeInfer {
-
- private var n: Int = 0
- def newTyvar(): Type = { n += 1; Tyvar("a" + n) }
-
- trait Subst extends Function1[Type, Type] {
- def lookup(x: Tyvar): Type
- def apply(t: Type): Type = t match {
- case tv @ Tyvar(a) => val u = lookup(tv); if (t == u) t else apply(u)
- case Arrow(t1, t2) => Arrow(apply(t1), apply(t2))
- case Tycon(k, ts) => Tycon(k, ts map apply)
- }
- def extend(x: Tyvar, t: Type) = new Subst {
- def lookup(y: Tyvar): Type = if (x == y) t else Subst.this.lookup(y)
- }
- }
-
- val emptySubst = new Subst { def lookup(t: Tyvar): Type = t }
-
- case class TypeScheme(tyvars: List[Tyvar], tpe: Type) {
- def newInstance: Type =
- (emptySubst /: tyvars) ((s, tv) => s.extend(tv, newTyvar())) (tpe)
- }
-
- type Env = List[Tuple2[String, TypeScheme]]
-
- def lookup(env: Env, x: String): TypeScheme = env match {
- case List() => null
- case (y, t) :: env1 => if (x == y) t else lookup(env1, x)
- }
-
- def gen(env: Env, t: Type): TypeScheme =
- TypeScheme(tyvars(t) diff tyvars(env), t)
-
- def tyvars(t: Type): List[Tyvar] = t match {
- case tv @ Tyvar(a) => List(tv)
- case Arrow(t1, t2) => tyvars(t1) union tyvars(t2)
- case Tycon(k, ts) => (List[Tyvar]() /: ts) ((tvs, t) => tvs union tyvars(t))
- }
-
- def tyvars(ts: TypeScheme): List[Tyvar] =
- tyvars(ts.tpe) diff ts.tyvars;
-
- def tyvars(env: Env): List[Tyvar] =
- (List[Tyvar]() /: env) ((tvs, nt) => tvs union tyvars(nt._2))
-
- def mgu(t: Type, u: Type, s: Subst): Subst = (s(t), s(u)) match {
- case (Tyvar(a), Tyvar(b)) if (a == b) =>
- s
- case (Tyvar(a), _) if !(tyvars(u) contains a) =>
- s.extend(Tyvar(a), u)
- case (_, Tyvar(a)) =>
- mgu(u, t, s)
- case (Arrow(t1, t2), Arrow(u1, u2)) =>
- mgu(t1, u1, mgu(t2, u2, s))
- case (Tycon(k1, ts), Tycon(k2, us)) if (k1 == k2) =>
- (s /: (ts zip us)) ((s, tu) => mgu(tu._1, tu._2, s))
- case _ =>
- throw new TypeError("cannot unify " + s(t) + " with " + s(u))
- }
-
- case class TypeError(s: String) extends Exception(s) {}
-
- def tp(env: Env, e: Term, t: Type, s: Subst): Subst = {
- current = e
- e match {
- case Var(x) =>
- val u = lookup(env, x)
- if (u == null) throw new TypeError("undefined: " + x)
- else mgu(u.newInstance, t, s)
-
- case Lam(x, e1) =>
- val a, b = newTyvar()
- val s1 = mgu(t, Arrow(a, b), s)
- val env1 = (x, TypeScheme(List(), a)) :: env
- tp(env1, e1, b, s1)
-
- case App(e1, e2) =>
- val a = newTyvar()
- val s1 = tp(env, e1, Arrow(a, t), s)
- tp(env, e2, a, s1)
-
- case Let(x, e1, e2) =>
- val a = newTyvar()
- val s1 = tp(env, e1, a, s)
- tp((x, gen(env, s1(a))) :: env, e2, t, s1)
- }
- }
- var current: Term = null
-
- def typeOf(env: Env, e: Term): Type = {
- val a = newTyvar()
- tp(env, e, a, emptySubst)(a)
- }
-}
-
- object predefined {
- val booleanType = Tycon("Boolean", List())
- val intType = Tycon("Int", List())
- def listType(t: Type) = Tycon("List", List(t))
-
- private def gen(t: Type): typeInfer.TypeScheme = typeInfer.gen(List(), t)
- private val a = typeInfer.newTyvar()
- val env = List(
-/*
- ("true", gen(booleanType)),
- ("false", gen(booleanType)),
- ("if", gen(Arrow(booleanType, Arrow(a, Arrow(a, a))))),
- ("zero", gen(intType)),
- ("succ", gen(Arrow(intType, intType))),
- ("nil", gen(listType(a))),
- ("cons", gen(Arrow(a, Arrow(listType(a), listType(a))))),
- ("isEmpty", gen(Arrow(listType(a), booleanType))),
- ("head", gen(Arrow(listType(a), a))),
- ("tail", gen(Arrow(listType(a), listType(a)))),
-*/
- ("fix", gen(Arrow(Arrow(a, a), a)))
- )
- }
-
- trait MiniMLParsers extends CharParsers {
-
- /** whitespace */
- def whitespace = rep{chr(' ') ||| chr('\t') ||| chr('\n')}
-
- /** A given character, possible preceded by whitespace */
- def wschr(ch: char) = whitespace &&& chr(ch)
-
- def isLetter = (c: char) => Character.isLetter(c)
- def isLetterOrDigit: char => boolean = Character.isLetterOrDigit
-
- /** identifiers or keywords */
- def id: Parser[String] =
- for (
- c: char <- rep(chr(' ')) &&& chr(isLetter);
- cs: List[char] <- rep(chr(isLetterOrDigit))
- ) yield (c :: cs).mkString("", "", "")
-
- /** Non-keyword identifiers */
- def ident: Parser[String] =
- for (s <- id if s != "let" && s != "in") yield s
-
- /** term = '\' ident '.' term | term1 {term1} | let ident "=" term in term */
- def term: Parser[Term] = (
- ( for (
- _ <- wschr('\\');
- x <- ident;
- _ <- wschr('.');
- t <- term)
- yield Lam(x, t): Term )
- |||
- ( for (
- letid <- id if letid == "let";
- x <- ident;
- _ <- wschr('=');
- t <- term;
- inid <- id; if inid == "in";
- c <- term)
- yield Let(x, t, c) )
- |||
- ( for (
- t <- term1;
- ts <- rep(term1))
- yield (t /: ts)((f, arg) => App(f, arg)) )
- )
-
- /** term1 = ident | '(' term ')' */
- def term1: Parser[Term] = (
- ( for (s <- ident)
- yield Var(s): Term )
- |||
- ( for (
- _ <- wschr('(');
- t <- term;
- _ <- wschr(')'))
- yield t )
- )
-
- /** all = term ';' */
- def all: Parser[Term] =
- for (
- t <- term;
- _ <- wschr(';'))
- yield t
- }
-
- class ParseString(s: String) extends Parsers {
- type inputType = int
- val input = 0
- def any = new Parser[char] {
- def apply(in: int): Parser[char]#Result =
- if (in < s.length()) Some((s charAt in, in + 1)) else None
- }
- }
-
- def showType(e: Term): String =
- try {
- typeInfer.typeOf(predefined.env, e).toString()
- }
- catch {
- case typeInfer.TypeError(msg) =>
- "\n cannot type: " + typeInfer.current +
- "\n reason: " + msg
- }
-
- def main(args: Array[String]) {
- Console.println(
- if (args.length == 1) {
- val ps = new ParseString(args(0)) with MiniMLParsers
- ps.all(ps.input) match {
- case Some((term, _)) =>
- "" + term + ": " + showType(term)
- case None =>
- "syntax error"
- }
- }
- else
- "usage: java examples.typeinf <expr-string>"
- )
- }
-
-}
diff --git a/docs/examples/xml/phonebook/embeddedBook.scala b/docs/examples/xml/phonebook/embeddedBook.scala
deleted file mode 100644
index 3286485f0b..0000000000
--- a/docs/examples/xml/phonebook/embeddedBook.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-/* examples/phonebook/embeddedBook.scala */
-package phonebook
-
-object embeddedBook {
-
- val company = <a href="http://acme.org">ACME</a>
- val first = "Burak"
- val last = "Emir"
- val location = "work"
-
- val embBook =
- <phonebook>
- <descr>
- This is the <b>phonebook</b> of the
- {company} corporation.
- </descr>
- <entry>
- <name>{ first+" "+last }</name>
- <phone where={ location }>+41 21 693 68 {val x = 60 + 7; x}</phone>
- </entry>
- </phonebook>;
-
- def main(args: Array[String]) =
- Console.println( embBook )
-
-}
diff --git a/docs/examples/xml/phonebook/phonebook.scala b/docs/examples/xml/phonebook/phonebook.scala
deleted file mode 100644
index 3c0dfbd837..0000000000
--- a/docs/examples/xml/phonebook/phonebook.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-package phonebook ;
-
-object phonebook {
-
- val labPhoneBook =
- <phonebook>
- <descr>
- This is the <b>phonebook</b> of the
- <a href="http://acme.org">ACME</a> corporation.
- </descr>
- <entry>
- <name>Burak</name>
- <phone where="work"> +41 21 693 68 67</phone>
- <phone where="mobile">+41 79 602 23 23</phone>
- </entry>
- </phonebook>;
-
- Console.println( labPhoneBook );
-
- // XML is immutable - adding an element
-
- import scala.xml.{ Node, Text };
-
- def add( phonebook:Node, newEntry:Node ):Node = phonebook match {
- case <phonebook>{ ch @ _* }</phonebook> =>
- <phonebook>{ ch }{ newEntry }</phonebook>
- }
-
- val pb2 =
- add( labPhoneBook,
- <entry>
- <name>Kim</name>
- <phone where="work"> +41 21 111 11 11</phone>
- </entry> );
-
- def main(args:Array[String]) = Console.println( pb2 );
-
-}
diff --git a/docs/examples/xml/phonebook/phonebook1.scala b/docs/examples/xml/phonebook/phonebook1.scala
deleted file mode 100644
index 316c6c1995..0000000000
--- a/docs/examples/xml/phonebook/phonebook1.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-/* examples/phonebook/phonebook1.scala */
-package phonebook
-
-object phonebook1 {
-
- val labPhoneBook =
- <phonebook>
- <descr>
- This is the <b>phonebook</b> of the
- <a href="http://acme.org">ACME</a> corporation.
- </descr>
- <entry>
- <name>Burak Emir</name>
- <phone where="work">+41 21 693 68 67</phone>
- </entry>
- </phonebook>;
-
- def main(args: Array[String]) =
- Console.println( labPhoneBook )
-
-}
diff --git a/docs/examples/xml/phonebook/phonebook2.scala b/docs/examples/xml/phonebook/phonebook2.scala
deleted file mode 100644
index 2a708daf7c..0000000000
--- a/docs/examples/xml/phonebook/phonebook2.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* examples/xml/phonebook/phonebook2.scala */
-package phonebook;
-
-object phonebook2 {
-
- import scala.xml.Node
-
- /** adds an entry to a phonebook */
- def add( p: Node, newEntry: Node ): Node = p match {
-
- case <phonebook>{ ch @ _* }</phonebook> =>
-
- <phonebook>{ ch }{ newEntry }</phonebook>
- }
-
- val pb2 =
- add( phonebook1.labPhoneBook,
- <entry>
- <name>Kim</name>
- <phone where="work">+41 21 111 11 11</phone>
- </entry> );
-
- def main( args: Array[String] ) =
- Console.println( pb2 )
-}
diff --git a/docs/examples/xml/phonebook/phonebook3.scala b/docs/examples/xml/phonebook/phonebook3.scala
deleted file mode 100644
index 12f2deaa79..0000000000
--- a/docs/examples/xml/phonebook/phonebook3.scala
+++ /dev/null
@@ -1,81 +0,0 @@
-package phonebook;
-
-object phonebook3 {
-
- import scala.xml.{Elem, Node, Text} ;
- import scala.xml.PrettyPrinter ;
- import Node.NoAttributes ;
-
- /* this method "changes" (returns an updated copy) of the phonebook when the
- * entry for Name exists. If it has an attribute "where" whose value is equal to the
- * parameter Where, it is changed, otherwise, it is added.
- */
- def change ( phonebook:Node, Name:String, Where:String, newPhone:String ) = {
-
- /** this nested function walks through tree, and returns an updated copy of it */
- def copyOrChange ( ch: Iterator[Node] ) = {
-
- import xml.Utility.{trim,trimProper} //removes whitespace nodes, which are annoying in matches
-
- for( val c <- ch ) yield
- trimProper(c) match {
-
- // if the node is the particular entry we are looking for, return an updated copy
-
- case x @ <entry><name>{ Text(Name) }</name>{ ch1 @ _* }</entry> =>
-
- var updated = false;
- val ch2 = for(c <- ch1) yield c match { // does it have the phone number?
-
- case y @ <phone>{ _* }</phone> if y \ "@where" == Where =>
- updated = true
- <phone where={ Where }>{ newPhone }</phone>
-
- case y => y
-
- }
- if( !updated ) { // no, so we add as first entry
-
- <entry>
- <name>{ Name }</name>
- <phone where={ Where }>{ newPhone }</phone>
- { ch1 }
- </entry>
-
- } else { // yes, and we changed it as we should
-
- <entry>
- { ch2 }
- </entry>
-
- }
- // end case x @ <entry>...
-
- // other entries are copied without changing them
-
- case x =>
- x
-
- }
- } ; // for ... yield ... returns an Iterator[Node]
-
- // decompose phonebook, apply updates
- phonebook match {
- case <phonebook>{ ch @ _* }</phonebook> =>
- <phonebook>{ copyOrChange( ch.iterator ) }</phonebook>
- }
-
- }
-
- val pb2 =
- change( phonebook1.labPhoneBook, "John", "work", "+41 55 555 55 55" );
-
- val pp = new PrettyPrinter( 80, 5 );
-
- def main( args:Array[String] ) = {
- Console.println("---before---");
- Console.println( pp.format( phonebook1.labPhoneBook ));
- Console.println("---after---");
- Console.println( pp.format( pb2 ));
- }
-}
diff --git a/docs/examples/xml/phonebook/verboseBook.scala b/docs/examples/xml/phonebook/verboseBook.scala
deleted file mode 100644
index 2dcb155480..0000000000
--- a/docs/examples/xml/phonebook/verboseBook.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-/* examples/xml/phonebook/verboseBook.scala */
-package phonebook
-
-object verboseBook {
-
- import scala.xml.{ UnprefixedAttribute, Elem, Node, Null, Text, TopScope }
-
- val pbookVerbose =
- Elem(null, "phonebook", Null, TopScope,
- Elem(null, "descr", Null, TopScope,
- Text("This is a "),
- Elem(null, "b", Null, TopScope, Text("sample")),
- Text("description")
- ),
- Elem(null, "entry", Null, TopScope,
- Elem(null, "name", Null, TopScope, Text("Burak Emir")),
- Elem(null, "phone", new UnprefixedAttribute("where","work", Null), TopScope,
- Text("+41 21 693 68 67"))
- )
- )
-
- def main(args: Array[String]) =
- Console.println( pbookVerbose )
-}
diff --git a/docs/licenses/apache_android.txt b/docs/licenses/apache_android.txt
deleted file mode 100644
index 00f339625f..0000000000
--- a/docs/licenses/apache_android.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Scala includes various example files for Android:
-
-Copyright (c) 2005-2009, The Android Open Source Project
-Copyright (c) 2007, Steven Osborn
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License. \ No newline at end of file
diff --git a/docs/licenses/apache_ant.txt b/docs/licenses/apache_ant.txt
deleted file mode 100644
index ac637d760d..0000000000
--- a/docs/licenses/apache_ant.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Scala includes Ant as a library needed for build with sbt
-
-Copyright © 1999-2010, The Apache Software Foundation.
- http://ant.apache.org/
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/docs/licenses/apache_jansi.txt b/docs/licenses/apache_jansi.txt
new file mode 100644
index 0000000000..067a5a6a34
--- /dev/null
+++ b/docs/licenses/apache_jansi.txt
@@ -0,0 +1,203 @@
+Scala includes the JLine library, which includes the Jansi library.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/docs/licenses/bsd_asm.txt b/docs/licenses/bsd_asm.txt
new file mode 100644
index 0000000000..8613cd33a2
--- /dev/null
+++ b/docs/licenses/bsd_asm.txt
@@ -0,0 +1,31 @@
+Scala includes the ASM library.
+
+Copyright (c) 2000-2011 INRIA, France Telecom
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
diff --git a/docs/licenses/bsd_jline.txt b/docs/licenses/bsd_jline.txt
index 4ac4a378ed..3e5dba75da 100644
--- a/docs/licenses/bsd_jline.txt
+++ b/docs/licenses/bsd_jline.txt
@@ -1,4 +1,4 @@
-Scala includes the jLine library:
+Scala includes the JLine library:
Copyright (c) 2002-2006, Marc Prud'hommeaux <mwp1@cornell.edu>
All rights reserved.
diff --git a/src/build/bnd/continuations.bnd b/src/build/bnd/continuations.bnd
deleted file mode 100644
index 748502f653..0000000000
--- a/src/build/bnd/continuations.bnd
+++ /dev/null
@@ -1,5 +0,0 @@
-Bundle-Name: Scala Continuations Plugin
-Bundle-SymbolicName: org.scala-lang.plugins.continuations
-ver: @VERSION@
-Bundle-Version: ${ver}
-Export-Package: *;version=${ver}
diff --git a/src/build/bnd/scala-continuations-library.bnd b/src/build/bnd/scala-continuations-library.bnd
new file mode 100644
index 0000000000..bb505b60a9
--- /dev/null
+++ b/src/build/bnd/scala-continuations-library.bnd
@@ -0,0 +1,5 @@
+Bundle-Name: Scala Delimited Continuations Library
+Bundle-SymbolicName: org.scala-lang.plugins.scala-continuations-library
+ver: @VERSION@
+Bundle-Version: ${ver}
+Export-Package: *;version=${ver}
diff --git a/src/build/bnd/scala-continuations-plugin.bnd b/src/build/bnd/scala-continuations-plugin.bnd
new file mode 100644
index 0000000000..cd66614a22
--- /dev/null
+++ b/src/build/bnd/scala-continuations-plugin.bnd
@@ -0,0 +1,5 @@
+Bundle-Name: Scala Delimited Continuations Compiler Plugin
+Bundle-SymbolicName: org.scala-lang.plugins.scala-continuations-plugin
+ver: @VERSION@
+Bundle-Version: ${ver}
+Export-Package: *;version=${ver}
diff --git a/src/build/bnd/scala-swing.bnd b/src/build/bnd/scala-swing.bnd
index eeacb9bd3f..7cccb1343b 100644
--- a/src/build/bnd/scala-swing.bnd
+++ b/src/build/bnd/scala-swing.bnd
@@ -1,5 +1,5 @@
Bundle-Name: Scala Swing
-Bundle-SymbolicName: org.scala-lang.scala-swing
+Bundle-SymbolicName: org.scala-lang.modules.scala-swing
ver: @VERSION@
Bundle-Version: ${ver}
Export-Package: *;version=${ver}
diff --git a/src/build/dbuild-meta-json-gen.scala b/src/build/dbuild-meta-json-gen.scala
index ee1976ffa4..d1d4c12b3f 100644
--- a/src/build/dbuild-meta-json-gen.scala
+++ b/src/build/dbuild-meta-json-gen.scala
@@ -30,10 +30,6 @@ val meta =
// Seq(ProjectRef("scala-interactive", "org.scala-lang")),
// Seq(ProjectRef("scala-compiler", "org.scala-lang"), ProjectRef("scaladoc", "org.scala-lang"))),
- Project("scala-swing", "org.scala-lang",
- Seq(ProjectRef("scala-swing", "org.scala-lang")),
- Seq(ProjectRef("scala-library", "org.scala-lang"))),
-
Project("scala-actors", "org.scala-lang",
Seq(ProjectRef("scala-actors", "org.scala-lang")),
Seq(ProjectRef("scala-library", "org.scala-lang"))),
@@ -44,9 +40,8 @@ val meta =
Project("scalap", "org.scala-lang",
Seq(ProjectRef("scalap", "org.scala-lang")),
- Seq(ProjectRef("scala-compiler", "org.scala-lang"))),
+ Seq(ProjectRef("scala-compiler", "org.scala-lang")))
- Project("continuations", "org.scala-lang.plugins", Seq(ProjectRef("continuations", "org.scala-lang.plugins")), Seq.empty)
))
println(Utils.writeValue(meta))
diff --git a/src/build/maven/maven-deploy.xml b/src/build/maven/maven-deploy.xml
index 822cc1a25f..412d7caab6 100644
--- a/src/build/maven/maven-deploy.xml
+++ b/src/build/maven/maven-deploy.xml
@@ -124,9 +124,7 @@
-->
<deploy-one dir="@{dir}" name="scala-actors" local="@{local}" signed="@{signed}"/>
- <deploy-one dir="@{dir}" name="scala-swing" local="@{local}" signed="@{signed}"/>
<deploy-one dir="@{dir}" name="scalap" local="@{local}" signed="@{signed}"/>
- <deploy-one dir="@{dir}plugins/" name="continuations" local="@{local}" signed="@{signed}"/>
</sequential>
</macrodef>
diff --git a/src/build/maven/plugins/continuations-pom.xml b/src/build/maven/plugins/continuations-pom.xml
deleted file mode 100644
index 8dc79c8664..0000000000
--- a/src/build/maven/plugins/continuations-pom.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.scala-lang.plugins</groupId>
- <artifactId>continuations</artifactId>
- <packaging>jar</packaging>
- <version>@VERSION@</version>
- <name>Scala Continuations Plugin</name>
- <description>Delimited continuations compilation for Scala</description>
- <url>http://www.scala-lang.org/</url>
- <inceptionYear>2010</inceptionYear>
- <organization>
- <name>LAMP/EPFL</name>
- <url>http://lamp.epfl.ch/</url>
- </organization>
- <licenses>
- <license>
- <name>BSD 3-Clause</name>
- <url>http://www.scala-lang.org/license.html</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <scm>
- <connection>scm:git:git://github.com/scala/scala.git</connection>
- <url>https://github.com/scala/scala.git</url>
- </scm>
- <issueManagement>
- <system>JIRA</system>
- <url>https://issues.scala-lang.org/</url>
- </issueManagement>
- <dependencies>
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-compiler</artifactId>
- <version>@VERSION@</version>
- </dependency>
- </dependencies>
- <distributionManagement>
- <repository>
- <id>scala-tools.org</id>
- <url>@RELEASE_REPOSITORY@</url>
- </repository>
- <snapshotRepository>
- <id>scala-tools.org</id>
- <url>@SNAPSHOT_REPOSITORY@</url>
- <uniqueVersion>false</uniqueVersion>
- </snapshotRepository>
- </distributionManagement>
- <developers>
- <developer>
- <id>lamp</id>
- <name>EPFL LAMP</name>
- </developer>
- <developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
- </developer>
- </developers>
-</project>
diff --git a/src/build/maven/scala-swing-pom.xml b/src/build/maven/scala-swing-pom.xml
deleted file mode 100644
index 01c89f9bea..0000000000
--- a/src/build/maven/scala-swing-pom.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-swing</artifactId>
- <packaging>jar</packaging>
- <version>@VERSION@</version>
- <name>Scala Swing library</name>
- <description>Swing for Scala</description>
- <url>http://www.scala-lang.org/</url>
- <inceptionYear>2002</inceptionYear>
- <organization>
- <name>LAMP/EPFL</name>
- <url>http://lamp.epfl.ch/</url>
- </organization>
- <licenses>
- <license>
- <name>BSD 3-Clause</name>
- <url>http://www.scala-lang.org/license.html</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <scm>
- <connection>scm:git:git://github.com/scala/scala.git</connection>
- <url>https://github.com/scala/scala.git</url>
- </scm>
- <issueManagement>
- <system>JIRA</system>
- <url>https://issues.scala-lang.org/</url>
- </issueManagement>
- <properties>
- <info.apiURL>http://www.scala-lang.org/api/@VERSION@/</info.apiURL>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-library</artifactId>
- <version>@VERSION@</version>
- </dependency>
- </dependencies>
- <distributionManagement>
- <repository>
- <id>scala-tools.org</id>
- <url>@RELEASE_REPOSITORY@</url>
- </repository>
- <snapshotRepository>
- <id>scala-tools.org</id>
- <url>@SNAPSHOT_REPOSITORY@</url>
- <uniqueVersion>false</uniqueVersion>
- </snapshotRepository>
- </distributionManagement>
- <developers>
- <developer>
- <id>lamp</id>
- <name>EPFL LAMP</name>
- </developer>
- <developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
- </developer>
- </developers>
-</project>
diff --git a/src/compiler/scala/reflect/macros/compiler/Validators.scala b/src/compiler/scala/reflect/macros/compiler/Validators.scala
index 0a56aa45e3..5936b52890 100644
--- a/src/compiler/scala/reflect/macros/compiler/Validators.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Validators.scala
@@ -155,7 +155,7 @@ trait Validators {
else mmap(macroDdef.vparamss)(param)
val macroDefRet =
if (!macroDdef.tpt.isEmpty) typer.typedType(macroDdef.tpt).tpe
- else computeMacroDefTypeFromMacroImplRef(macroDdef, macroImplRef)
+ else computeMacroDefTypeFromMacroImplRef(macroDdef, macroImplRef) orElse AnyTpe
val implReturnType = sigma(increaseMetalevel(ctxPrefix, macroDefRet))
object SigmaTypeMap extends TypeMap {
diff --git a/src/compiler/scala/reflect/macros/contexts/Typers.scala b/src/compiler/scala/reflect/macros/contexts/Typers.scala
index 4a1122b913..85204d0f1b 100644
--- a/src/compiler/scala/reflect/macros/contexts/Typers.scala
+++ b/src/compiler/scala/reflect/macros/contexts/Typers.scala
@@ -13,7 +13,7 @@ trait Typers {
/**
* @see [[scala.tools.reflect.ToolBox.typeCheck]]
*/
- def typeCheck(tree: Tree, pt: Type = universe.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = {
+ def typecheck(tree: Tree, pt: Type = universe.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = {
macroLogVerbose("typechecking %s with expected type %s, implicit views = %s, macros = %s".format(tree, pt, !withImplicitViewsDisabled, !withMacrosDisabled))
val context = callsiteTyper.context
val wrapper1 = if (!withImplicitViewsDisabled) (context.withImplicitsEnabled[Tree] _) else (context.withImplicitsDisabled[Tree] _)
@@ -24,7 +24,7 @@ trait Typers {
// typechecking uses silent anyways (e.g. in typedSelect), so you'll only waste your time
// I'd advise fixing the root cause: finding why the context is not set to report errors
// (also see reflect.runtime.ToolBoxes.typeCheckExpr for a workaround that might work for you)
- wrapper(callsiteTyper.silent(_.typed(tree, pt), reportAmbiguousErrors = false) match {
+ wrapper(callsiteTyper.silent(_.typed(universe.duplicateAndKeepPositions(tree), pt), reportAmbiguousErrors = false) match {
case universe.analyzer.SilentResultValue(result) =>
macroLogVerbose(result)
result
@@ -46,7 +46,7 @@ trait Typers {
universe.analyzer.inferImplicit(tree, viewTpe, true, callsiteTyper.context, silent, withMacrosDisabled, pos, (pos, msg) => throw TypecheckException(pos, msg))
}
- def resetAllAttrs(tree: Tree): Tree = universe.resetAllAttrs(tree)
+ def resetAllAttrs(tree: Tree): Tree = universe.resetAllAttrs(universe.duplicateAndKeepPositions(tree))
- def resetLocalAttrs(tree: Tree): Tree = universe.resetLocalAttrs(tree)
+ def resetLocalAttrs(tree: Tree): Tree = universe.resetLocalAttrs(universe.duplicateAndKeepPositions(tree))
}
diff --git a/src/compiler/scala/reflect/macros/util/Helpers.scala b/src/compiler/scala/reflect/macros/util/Helpers.scala
index ff03696524..bddc42d1f9 100644
--- a/src/compiler/scala/reflect/macros/util/Helpers.scala
+++ b/src/compiler/scala/reflect/macros/util/Helpers.scala
@@ -77,7 +77,8 @@ trait Helpers {
/** Decreases metalevel of the type, i.e. transforms:
* * c.Expr[T] to T
- * * Anything else to Any
+ * * Nothing to Nothing
+ * * Anything else to NoType
*
* @see Metalevels.scala for more information and examples about metalevels
*/
@@ -86,7 +87,10 @@ trait Helpers {
import runDefinitions._
transparentShallowTransform(RepeatedParamClass, tp) {
case ExprClassOf(runtimeType) => runtimeType
- case _ => AnyTpe // so that macro impls with rhs = ??? don't screw up our inference
+ // special-casing Nothing here is a useful convention
+ // that enables no-hassle prototyping with `macro ???` and `macro { ...; ??? }`
+ case nothing if nothing =:= NothingTpe => NothingTpe
+ case _ => NoType
}
}
}
diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala
index 0c7831b592..093c2bee22 100644
--- a/src/compiler/scala/reflect/reify/Taggers.scala
+++ b/src/compiler/scala/reflect/reify/Taggers.scala
@@ -65,13 +65,13 @@ abstract class Taggers {
case _ =>
translatingReificationErrors(materializer)
}
- try c.typeCheck(result)
+ try c.typecheck(result)
catch { case terr @ TypecheckException(pos, msg) => failTag(result, terr) }
}
def materializeExpr(universe: Tree, mirror: Tree, expr: Tree): Tree = {
val result = translatingReificationErrors(c.reifyTree(universe, mirror, expr))
- try c.typeCheck(result)
+ try c.typecheck(result)
catch { case terr @ TypecheckException(pos, msg) => failExpr(result, terr) }
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index e488166169..87bd498ea1 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -460,15 +460,6 @@ trait Scanners extends ScannersCommon {
nextChar()
base = 16
} else {
- /*
- * What should leading 0 be in the future? It is potentially dangerous
- * to let it be base-10 because of history. Should it be an error? Is
- * there a realistic situation where one would need it?
- */
- if (isDigit(ch)) {
- if (settings.future) syntaxError("Non-zero numbers may not have a leading zero.")
- else deprecationWarning("Treating numbers with a leading zero as octal is deprecated.")
- }
base = 8
}
getNumber()
@@ -984,10 +975,15 @@ trait Scanners extends ScannersCommon {
*/
protected def getNumber() {
val base1 = if (base < 10) 10 else base
- // read 8,9's even if format is octal, produce a malformed number error afterwards.
+ // Read 8,9's even if format is octal, produce a malformed number error afterwards.
+ // At this point, we have already read the first digit, so to tell an innocent 0 apart
+ // from an octal literal 0123... (which we want to disallow), we check whether there
+ // are any additional digits coming after the first one we have already read.
+ var notSingleZero = false
while (digit2int(ch, base1) >= 0) {
putChar(ch)
nextChar()
+ notSingleZero = true
}
token = INTLIT
@@ -1004,6 +1000,9 @@ trait Scanners extends ScannersCommon {
if (base <= 10 && isEfd)
getFraction()
else {
+ // Checking for base == 8 is not enough, because base = 8 is set
+ // as soon as a 0 is read in `case '0'` of method fetchToken.
+ if (base == 8 && notSingleZero) syntaxError("Non-zero integral values may not have a leading zero.")
setStrVal()
if (isL) {
nextChar()
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
index f10d7cdc40..2e44c405cf 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
@@ -8,6 +8,7 @@ package tools.nsc
package backend.icode.analysis
import scala.collection.{mutable, immutable}
+import java.util.concurrent.TimeUnit
/** A data-flow analysis on types, that works on `ICode`.
*
@@ -709,14 +710,14 @@ abstract class TypeFlowAnalysis {
private var lastStart = 0L
def start() {
- lastStart = System.currentTimeMillis
+ lastStart = System.nanoTime()
}
/** Stop the timer and return the number of milliseconds since the last
* call to start. The 'millis' field is increased by the elapsed time.
*/
def stop: Long = {
- val elapsed = System.currentTimeMillis - lastStart
+ val elapsed = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStart)
millis += elapsed
elapsed
}
diff --git a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala
index f4e97a91d8..235e954f88 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala
@@ -5,6 +5,8 @@
package scala.tools.nsc
package backend.opt
+import java.util.concurrent.TimeUnit
+
/**
* This optimization phase inlines the exception handlers so that further phases can optimize the code better
*
@@ -91,12 +93,12 @@ abstract class InlineExceptionHandlers extends SubComponent {
/** Apply exception handler inlining to a class */
override def apply(c: IClass): Unit =
if (settings.inlineHandlers) {
- val startTime = System.currentTimeMillis
+ val startTime = System.nanoTime()
currentClass = c
debuglog("Starting InlineExceptionHandlers on " + c)
c.methods foreach applyMethod
- debuglog("Finished InlineExceptionHandlers on " + c + "... " + (System.currentTimeMillis - startTime) + "ms")
+ debuglog("Finished InlineExceptionHandlers on " + c + "... " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime) + "ms")
currentClass = null
}
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
index d194c095f8..183752d4a2 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -12,7 +12,8 @@ import scala.reflect.io.{ Directory, File, Path }
import java.io.InputStream
import java.util.zip.ZipException
-import scala.collection.mutable.ListBuffer
+import scala.collection.mutable
+import mutable.ListBuffer
import scala.util.{ Try, Success, Failure }
/** Information about a plugin loaded from a jar file.
@@ -99,7 +100,7 @@ object Plugin {
private def loadDescriptionFromJar(jarp: Path): Try[PluginDescription] = {
// XXX Return to this once we have more ARM support
def read(is: Option[InputStream]) = is match {
- case None => throw new RuntimeException(s"Missing $PluginXML in $jarp")
+ case None => throw new PluginLoadException(jarp.path, s"Missing $PluginXML in $jarp")
case Some(is) => PluginDescription.fromXML(is)
}
Try(new Jar(jarp.jfile).withEntryStream(PluginXML)(read))
@@ -113,11 +114,14 @@ object Plugin {
/** Use a class loader to load the plugin class.
*/
def load(classname: String, loader: ClassLoader): Try[AnyClass] = {
- Try[AnyClass] {
- loader loadClass classname
- } recoverWith {
- case _: Exception =>
- Failure(new RuntimeException(s"Warning: class not found: ${classname}"))
+ import scala.util.control.NonFatal
+ try {
+ Success[AnyClass](loader loadClass classname)
+ } catch {
+ case NonFatal(e) =>
+ Failure(new PluginLoadException(classname, s"Error: unable to load class: $classname"))
+ case e: NoClassDefFoundError =>
+ Failure(new PluginLoadException(classname, s"Error: class not found: ${e.getMessage} required by $classname"))
}
}
@@ -128,33 +132,54 @@ object Plugin {
* A single classloader is created and used to load all of them.
*/
def loadAllFrom(
- jars: List[Path],
+ paths: List[List[Path]],
dirs: List[Path],
ignoring: List[String]): List[Try[AnyClass]] =
{
- // List[(jar, Success(descriptor))] in dir
- def scan(d: Directory) = for {
- f <- d.files.toList sortBy (_.name)
- if Jar isJarOrZip f
- pd = loadDescriptionFromJar(f)
- if pd.isSuccess
- } yield (f, pd)
- // (dir, Try(descriptor))
- def explode(d: Directory) = d -> loadDescriptionFromFile(d / PluginXML)
- // (j, Try(descriptor))
- def required(j: Path) = j -> loadDescriptionFromJar(j)
-
- type Paired = Tuple2[Path, Try[PluginDescription]]
- val included: List[Paired] = (dirs flatMap (_ ifDirectory scan)).flatten
- val exploded: List[Paired] = jars flatMap (_ ifDirectory explode)
- val explicit: List[Paired] = jars flatMap (_ ifFile required)
- def ignored(p: Paired) = p match {
- case (path, Success(pd)) => ignoring contains pd.name
- case _ => false
+ // List[(jar, Try(descriptor))] in dir
+ def scan(d: Directory) =
+ d.files.toList sortBy (_.name) filter (Jar isJarOrZip _) map (j => (j, loadDescriptionFromJar(j)))
+
+ type PDResults = List[Try[(PluginDescription, ScalaClassLoader)]]
+
+ // scan plugin dirs for jars containing plugins, ignoring dirs with none and other jars
+ val fromDirs: PDResults = dirs filter (_.isDirectory) flatMap { d =>
+ scan(d.toDirectory) collect {
+ case (j, Success(pd)) => Success((pd, loaderFor(Seq(j))))
+ }
+ }
+
+ // scan jar paths for plugins, taking the first plugin you find.
+ // a path element can be either a plugin.jar or an exploded dir.
+ def findDescriptor(ps: List[Path]) = {
+ def loop(qs: List[Path]): Try[PluginDescription] = qs match {
+ case Nil => Failure(new MissingPluginException(ps))
+ case p :: rest =>
+ if (p.isDirectory) loadDescriptionFromFile(p.toDirectory / PluginXML)
+ else if (p.isFile) loadDescriptionFromJar(p.toFile)
+ else loop(rest)
+ }
+ loop(ps)
+ }
+ val fromPaths: PDResults = paths map (p => (p, findDescriptor(p))) map {
+ case (p, Success(pd)) => Success((pd, loaderFor(p)))
+ case (_, Failure(e)) => Failure(e)
}
- val (locs, pds) = ((explicit ::: exploded ::: included) filterNot ignored).unzip
- val loader = loaderFor(locs.distinct)
- (pds filter (_.isSuccess) map (_.get.classname)).distinct map (Plugin load (_, loader))
+
+ val seen = mutable.HashSet[String]()
+ val enabled = (fromPaths ::: fromDirs) map {
+ case Success((pd, loader)) if seen(pd.classname) =>
+ // a nod to SI-7494, take the plugin classes distinctly
+ Failure(new PluginLoadException(pd.name, s"Ignoring duplicate plugin ${pd.name} (${pd.classname})"))
+ case Success((pd, loader)) if ignoring contains pd.name =>
+ Failure(new PluginLoadException(pd.name, s"Disabling plugin ${pd.name}"))
+ case Success((pd, loader)) =>
+ seen += pd.classname
+ Plugin.load(pd.classname, loader)
+ case Failure(e) =>
+ Failure(e)
+ }
+ enabled // distinct and not disabled
}
/** Instantiate a plugin class, given the class and
@@ -164,3 +189,11 @@ object Plugin {
(clazz getConstructor classOf[Global] newInstance global).asInstanceOf[Plugin]
}
}
+
+class PluginLoadException(val path: String, message: String, cause: Exception) extends Exception(message, cause) {
+ def this(path: String, message: String) = this(path, message, null)
+}
+
+class MissingPluginException(path: String) extends PluginLoadException(path, s"No plugin in path $path") {
+ def this(paths: List[Path]) = this(paths mkString File.pathSeparator)
+}
diff --git a/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala b/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala
deleted file mode 100644
index c5da24993e..0000000000
--- a/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2007-2013 LAMP/EPFL
- * @author Lex Spoon
- */
-
-package scala.tools.nsc
-package plugins
-
-/** ...
- *
- * @author Lex Spoon
- * @version 1.0, 2007-5-21
- */
-class PluginLoadException(filename: String, cause: Exception)
-extends Exception(cause)
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
index 4769705404..12f9aeba27 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
@@ -8,6 +8,7 @@ package scala.tools.nsc
package plugins
import scala.reflect.io.{ File, Path }
+import scala.tools.nsc.util.ClassPath
import scala.tools.util.PathResolver.Defaults
/** Support for run-time loading of compiler plugins.
@@ -16,8 +17,7 @@ import scala.tools.util.PathResolver.Defaults
* @version 1.1, 2009/1/2
* Updated 2009/1/2 by Anders Bach Nielsen: Added features to implement SIP 00002
*/
-trait Plugins {
- self: Global =>
+trait Plugins { global: Global =>
/** Load a rough list of the plugins. For speed, it
* does not instantiate a compiler run. Therefore it cannot
@@ -25,13 +25,20 @@ trait Plugins {
* filtered from the final list of plugins.
*/
protected def loadRoughPluginsList(): List[Plugin] = {
- val jars = settings.plugin.value map Path.apply
- def injectDefault(s: String) = if (s.isEmpty) Defaults.scalaPluginPath else s
- val dirs = (settings.pluginsDir.value split File.pathSeparator).toList map injectDefault map Path.apply
- val maybes = Plugin.loadAllFrom(jars, dirs, settings.disable.value)
+ def asPath(p: String) = ClassPath split p
+ val paths = settings.plugin.value filter (_ != "") map (s => asPath(s) map Path.apply)
+ val dirs = {
+ def injectDefault(s: String) = if (s.isEmpty) Defaults.scalaPluginPath else s
+ asPath(settings.pluginsDir.value) map injectDefault map Path.apply
+ }
+ val maybes = Plugin.loadAllFrom(paths, dirs, settings.disable.value)
val (goods, errors) = maybes partition (_.isSuccess)
// Explicit parameterization of recover to suppress -Xlint warning about inferred Any
- errors foreach (_.recover[Any] { case e: Exception => inform(e.getMessage) })
+ errors foreach (_.recover[Any] {
+ // legacy behavior ignores altogether, so at least warn devs
+ case e: MissingPluginException => if (global.isDeveloper) warning(e.getMessage)
+ case e: Exception => inform(e.getMessage)
+ })
val classes = goods map (_.get) // flatten
// Each plugin must only be instantiated once. A common pattern
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index 3ecce8d7b1..9738769db9 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -11,7 +11,7 @@ import Flags._
import scala.collection._
import scala.language.postfixOps
-abstract class CleanUp extends Transform with ast.TreeDSL {
+abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
import global._
import definitions._
import CODE._
@@ -35,7 +35,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
protected def newTransformer(unit: CompilationUnit): Transformer =
new CleanUpTransformer(unit)
- class CleanUpTransformer(unit: CompilationUnit) extends Transformer {
+ class CleanUpTransformer(unit: CompilationUnit) extends StaticsTransformer {
private val newStaticMembers = mutable.Buffer.empty[Tree]
private val newStaticInits = mutable.Buffer.empty[Tree]
private val symbolsStoredAsStatic = mutable.Map.empty[String, Symbol]
@@ -49,7 +49,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
clearStatics()
val newBody = transformTrees(body)
val templ = deriveTemplate(tree)(_ => transformTrees(newStaticMembers.toList) ::: newBody)
- try addStaticInits(templ) // postprocess to include static ctors
+ try addStaticInits(templ, newStaticInits, localTyper) // postprocess to include static ctors
finally clearStatics()
}
private def mkTerm(prefix: String): TermName = unit.freshTermName(prefix)
@@ -557,44 +557,6 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
})
}
- /* finds the static ctor DefDef tree within the template if it exists. */
- private def findStaticCtor(template: Template): Option[Tree] =
- template.body find {
- case defdef @ DefDef(_, nme.CONSTRUCTOR, _, _, _, _) => defdef.symbol.hasStaticFlag
- case _ => false
- }
-
- /* changes the template for the class so that it contains a static constructor with symbol fields inits,
- * augments an existing static ctor if one already existed.
- */
- private def addStaticInits(template: Template): Template = {
- if (newStaticInits.isEmpty)
- template
- else {
- val newCtor = findStaticCtor(template) match {
- // in case there already were static ctors - augment existing ones
- // currently, however, static ctors aren't being generated anywhere else
- case Some(ctor @ DefDef(_,_,_,_,_,_)) =>
- // modify existing static ctor
- deriveDefDef(ctor) {
- case block @ Block(stats, expr) =>
- // need to add inits to existing block
- treeCopy.Block(block, newStaticInits.toList ::: stats, expr)
- case term: TermTree =>
- // need to create a new block with inits and the old term
- treeCopy.Block(term, newStaticInits.toList, term)
- }
- case _ =>
- // create new static ctor
- val staticCtorSym = currentClass.newStaticConstructor(template.pos)
- val rhs = Block(newStaticInits.toList, Literal(Constant(())))
-
- localTyper.typedPos(template.pos)(DefDef(staticCtorSym, rhs))
- }
- deriveTemplate(template)(newCtor :: _)
- }
- }
-
} // CleanUpTransformer
}
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index b97b1e3527..391bce5abb 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -13,7 +13,7 @@ import symtab.Flags._
/** This phase converts classes with parameters into Java-like classes with
* fields, which are assigned to from constructors.
*/
-abstract class Constructors extends Transform with ast.TreeDSL {
+abstract class Constructors extends Statics with Transform with ast.TreeDSL {
import global._
import definitions._
@@ -199,7 +199,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
detectUsages walk auxConstructorBuf
}
}
- def mustbeKept(sym: Symbol) = !omittables(sym)
+ def mustBeKept(sym: Symbol) = !omittables(sym)
} // OmittablesHelper
@@ -458,7 +458,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
} // GuardianOfCtorStmts
private class TemplateTransformer(val unit: CompilationUnit, val impl: Template)
- extends Transformer
+ extends StaticsTransformer
with DelayedInitHelper
with OmittablesHelper
with GuardianOfCtorStmts {
@@ -607,7 +607,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
// follow the primary constructor
val auxConstructorBuf = new ListBuffer[Tree]
- // The list of statements that go into constructor after and including the superclass constructor call
+ // The list of statements that go into the constructor after and including the superclass constructor call
val constrStatBuf = new ListBuffer[Tree]
// The list of early initializer statements that go into constructor before the superclass constructor call
@@ -616,6 +616,9 @@ abstract class Constructors extends Transform with ast.TreeDSL {
// The early initialized field definitions of the class (these are the class members)
val presupers = treeInfo.preSuperFields(stats)
+ // The list of statements that go into the class initializer
+ val classInitStatBuf = new ListBuffer[Tree]
+
// generate code to copy pre-initialized fields
for (stat <- constrBody.stats) {
constrStatBuf += stat
@@ -644,7 +647,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
else if (stat.symbol.isConstructor) auxConstructorBuf += stat
else defBuf += stat
}
- case ValDef(_, _, _, rhs) =>
+ case ValDef(mods, _, _, rhs) if !mods.hasStaticFlag =>
// val defs with constant right-hand sides are eliminated.
// for all other val defs, an empty valdef goes into the template and
// the initializer goes as an assignment into the constructor
@@ -659,6 +662,11 @@ abstract class Constructors extends Transform with ast.TreeDSL {
}
defBuf += deriveValDef(stat)(_ => EmptyTree)
}
+ case ValDef(_, _, _, rhs) =>
+ // Add static initializer statements to classInitStatBuf and remove the rhs from the val def.
+ classInitStatBuf += mkAssign(stat.symbol, rhs)
+ defBuf += deriveValDef(stat)(_ => EmptyTree)
+
case ClassDef(_, _, _, _) =>
// classes are treated recursively, and left in the template
defBuf += new ConstructorTransformer(unit).transform(stat)
@@ -670,7 +678,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
populateOmittables()
// Initialize all parameters fields that must be kept.
- val paramInits = paramAccessors filter mustbeKept map { acc =>
+ val paramInits = paramAccessors filter mustBeKept map { acc =>
// Check for conflicting symbol amongst parents: see bug #1960.
// It would be better to mangle the constructor parameter name since
// it can only be used internally, but I think we need more robust name
@@ -710,11 +718,13 @@ abstract class Constructors extends Transform with ast.TreeDSL {
defBuf ++= auxConstructorBuf
// Unlink all fields that can be dropped from class scope
- for (sym <- clazz.info.decls ; if !mustbeKept(sym))
+ for (sym <- clazz.info.decls ; if !mustBeKept(sym))
clazz.info.decls unlink sym
// Eliminate all field definitions that can be dropped from template
- val transformed: Template = deriveTemplate(impl)(_ => defBuf.toList filter (stat => mustbeKept(stat.symbol)))
+ val templateWithoutOmittables: Template = deriveTemplate(impl)(_ => defBuf.toList filter (stat => mustBeKept(stat.symbol)))
+ // Add the static initializers
+ val transformed: Template = addStaticInits(templateWithoutOmittables, classInitStatBuf, localTyper)
} // TemplateTransformer
diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
index c546c21d48..933a2f70a1 100644
--- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
+++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
@@ -340,7 +340,19 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
else (true, adaptToType(tree, expectedTpe))
}
+ def adaptAndPostErase(tree: Tree, pt: Type): (Boolean, Tree) = {
+ val (needsAdapt, adaptedTree) = adapt(tree, pt)
+ val trans = postErasure.newTransformer(unit)
+ val postErasedTree = trans.atOwner(currentOwner)(trans.transform(adaptedTree)) // SI-8017 elimnates ErasedValueTypes
+ (needsAdapt, postErasedTree)
+ }
+
enteringPhase(currentRun.posterasurePhase) {
+ // e.g, in:
+ // class C(val a: Int) extends AnyVal; (x: Int) => new C(x)
+ //
+ // This type is:
+ // (x: Int)ErasedValueType(class C, Int)
val liftedBodyDefTpe: MethodType = {
val liftedBodySymbol = {
val Apply(method, _) = originalFunction.body
@@ -349,8 +361,14 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
liftedBodySymbol.info.asInstanceOf[MethodType]
}
val (paramNeedsAdaptation, adaptedParams) = (bridgeSyms zip liftedBodyDefTpe.params map {case (bridgeSym, param) => adapt(Ident(bridgeSym) setType bridgeSym.tpe, param.tpe)}).unzip
- val body = Apply(gen.mkAttributedSelect(gen.mkAttributedThis(newClass), applyMethod.symbol), adaptedParams) setType applyMethod.symbol.tpe.resultType
- val (needsReturnAdaptation, adaptedBody) = adapt(typer.typed(body), ObjectTpe)
+ // SI-8017 Before, this code used `applyMethod.symbol.info.resultType`.
+ // But that symbol doesn't have a type history that goes back before `delambdafy`,
+ // so we just see a plain `Int`, rather than `ErasedValueType(C, Int)`.
+ // This triggered primitive boxing, rather than value class boxing.
+ val resTp = liftedBodyDefTpe.finalResultType
+ val body = Apply(gen.mkAttributedSelect(gen.mkAttributedThis(newClass), applyMethod.symbol), adaptedParams) setType resTp
+ val (needsReturnAdaptation, adaptedBody) = adaptAndPostErase(body, ObjectTpe)
+
val needsBridge = (paramNeedsAdaptation contains true) || needsReturnAdaptation
if (needsBridge) {
val methDef = DefDef(bridgeMethSym, List(bridgeParams), adaptedBody)
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index 6fe0f34105..6732900ef2 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -714,11 +714,24 @@ abstract class Erasure extends AddInterfaces
/** TODO - adapt SymbolPairs so it can be used here. */
private def checkNoDeclaredDoubleDefs(base: Symbol) {
val decls = base.info.decls
+
+ // SI-8010 force infos, otherwise makeNotPrivate in ExplicitOuter info transformer can trigger
+ // a scope rehash while were iterating and we can see the same entry twice!
+ // Inspection of SymbolPairs (the basis of OverridingPairs), suggests that it is immune
+ // from this sort of bug as it copies the symbols into a temporary scope *before* any calls to `.info`,
+ // ie, no variant of it calls `info` or `tpe` in `SymbolPair#exclude`.
+ //
+ // Why not just create a temporary scope here? We need to force the name changes in any case before
+ // we do these checks, so that we're comparing same-named methods based on the expanded names that actually
+ // end up in the bytecode.
+ exitingPostErasure(decls.foreach(_.info))
+
var e = decls.elems
while (e ne null) {
if (e.sym.isTerm) {
var e1 = decls lookupNextEntry e
while (e1 ne null) {
+ assert(e.sym ne e1.sym, s"Internal error: encountered ${e.sym.debugLocationString} twice during scope traversal. This might be related to SI-8010.")
if (sameTypeAfterErasure(e.sym, e1.sym))
doubleDefError(new SymbolPair(base, e.sym, e1.sym))
diff --git a/src/compiler/scala/tools/nsc/transform/Flatten.scala b/src/compiler/scala/tools/nsc/transform/Flatten.scala
index e31211d321..b4329965fc 100644
--- a/src/compiler/scala/tools/nsc/transform/Flatten.scala
+++ b/src/compiler/scala/tools/nsc/transform/Flatten.scala
@@ -100,23 +100,36 @@ abstract class Flatten extends InfoTransform {
/** Buffers for lifted out classes */
private val liftedDefs = perRunCaches.newMap[Symbol, ListBuffer[Tree]]()
- override def transform(tree: Tree): Tree = {
+ override def transform(tree: Tree): Tree = postTransform {
tree match {
case PackageDef(_, _) =>
liftedDefs(tree.symbol.moduleClass) = new ListBuffer
+ super.transform(tree)
case Template(_, _, _) if tree.symbol.isDefinedInPackage =>
liftedDefs(tree.symbol.owner) = new ListBuffer
+ super.transform(tree)
+ case ClassDef(_, _, _, _) if tree.symbol.isNestedClass =>
+ // SI-5508 Ordering important. In `object O { trait A { trait B } }`, we want `B` to appear after `A` in
+ // the sequence of lifted trees in the enclosing package. Why does this matter? Currently, mixin
+ // needs to transform `A` first to a chance to create accessors for private[this] trait fields
+ // *before* it transforms inner classes that refer to them. This also fixes SI-6231.
+ //
+ // Alternative solutions
+ // - create the private[this] accessors eagerly in Namer (but would this cover private[this] fields
+ // added later phases in compilation?)
+ // - move the accessor creation to the Mixin info transformer
+ val liftedBuffer = liftedDefs(tree.symbol.enclosingTopLevelClass.owner)
+ val index = liftedBuffer.length
+ liftedBuffer.insert(index, super.transform(tree))
+ EmptyTree
case _ =>
+ super.transform(tree)
}
- postTransform(super.transform(tree))
}
private def postTransform(tree: Tree): Tree = {
val sym = tree.symbol
val tree1 = tree match {
- case ClassDef(_, _, _, _) if sym.isNestedClass =>
- liftedDefs(sym.enclosingTopLevelClass.owner) += tree
- EmptyTree
case Select(qual, name) if sym.isStaticModule && !sym.isTopLevel =>
exitingFlatten {
atPos(tree.pos) {
@@ -134,7 +147,10 @@ abstract class Flatten extends InfoTransform {
/** Transform statements and add lifted definitions to them. */
override def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = {
val stats1 = super.transformStats(stats, exprOwner)
- if (currentOwner.isPackageClass) stats1 ::: liftedDefs(currentOwner).toList
+ if (currentOwner.isPackageClass) {
+ val lifted = liftedDefs(currentOwner).toList
+ stats1 ::: lifted
+ }
else stats1
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index 4eb8eb933c..89f9cb4b06 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -1207,21 +1207,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
val iface = toInterface(sym.owner.tpe).typeSymbol
val ifaceGetter = sym getter iface
- def si6231Restriction() {
- // See SI-6231 comments in LamdaLift for ideas on how to lift the restriction.
- val msg = sm"""Implementation restriction: local ${iface.fullLocationString} is unable to automatically capture the
- |free variable ${sym} on behalf of ${currentClass}. You can manually assign it to a val inside the trait,
- |and refer that that val in ${currentClass}. For more details, see SI-6231."""
- reporter.error(tree.pos, msg)
- }
-
- if (ifaceGetter == NoSymbol) {
- if (sym.isParamAccessor) {
- si6231Restriction()
- EmptyTree
- }
- else abort("No getter for " + sym + " in " + iface)
- }
+ if (ifaceGetter == NoSymbol) abort("No getter for " + sym + " in " + iface)
else typedPos(tree.pos)((qual DOT ifaceGetter)())
case Assign(Apply(lhs @ Select(qual, _), List()), rhs) =>
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index 1723c69180..c505d9dc5f 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -923,7 +923,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
/** Return the specialized overload of `m`, in the given environment. */
private def specializedOverload(owner: Symbol, sym: Symbol, env: TypeEnv, nameSymbol: Symbol = NoSymbol): Symbol = {
- val newFlags = (sym.flags | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR)
+ val newFlags = (sym.flags | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR | LAZY)
// this method properly duplicates the symbol's info
val specname = specializedName(nameSymbol orElse sym, env)
( sym.cloneSymbol(owner, newFlags, newName = specname)
diff --git a/src/compiler/scala/tools/nsc/transform/Statics.scala b/src/compiler/scala/tools/nsc/transform/Statics.scala
new file mode 100644
index 0000000000..e2508b8d08
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/transform/Statics.scala
@@ -0,0 +1,52 @@
+package scala.tools.nsc
+package transform
+
+import symtab._
+import Flags._
+
+import collection.mutable.Buffer
+
+abstract class Statics extends Transform with ast.TreeDSL {
+ import global._
+
+ class StaticsTransformer extends Transformer {
+
+ /** finds the static ctor DefDef tree within the template if it exists. */
+ def findStaticCtor(template: Template): Option[Tree] =
+ template.body find {
+ case defdef @ DefDef(_, nme.CONSTRUCTOR, _, _, _, _) => defdef.symbol.hasStaticFlag
+ case _ => false
+ }
+
+ /** changes the template for the class so that it contains a static constructor with symbol fields inits,
+ * augments an existing static ctor if one already existed.
+ */
+ def addStaticInits(template: Template, newStaticInits: Buffer[Tree], localTyper: analyzer.Typer): Template = {
+ if (newStaticInits.isEmpty)
+ template
+ else {
+ val newCtor = findStaticCtor(template) match {
+ // in case there already were static ctors - augment existing ones
+ // currently, however, static ctors aren't being generated anywhere else
+ case Some(ctor @ DefDef(_,_,_,_,_,_)) =>
+ // modify existing static ctor
+ deriveDefDef(ctor) {
+ case block @ Block(stats, expr) =>
+ // need to add inits to existing block
+ treeCopy.Block(block, newStaticInits.toList ::: stats, expr)
+ case term: TermTree =>
+ // need to create a new block with inits and the old term
+ treeCopy.Block(term, newStaticInits.toList, term)
+ }
+ case _ =>
+ // create new static ctor
+ val staticCtorSym = currentClass.newStaticConstructor(template.pos)
+ val rhs = Block(newStaticInits.toList, Literal(Constant(())))
+
+ localTyper.typedPos(template.pos)(DefDef(staticCtorSym, rhs))
+ }
+ deriveTemplate(template)(newCtor :: _)
+ }
+ }
+ }
+}
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 2472f63993..719d04a7f9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -1261,7 +1261,7 @@ trait ContextErrors {
def DoubleParamNamesDefaultError(arg: Tree, name: Name, pos: Int, otherName: Option[Name])(implicit context: Context) = {
val annex = otherName match {
- case Some(oName) => "\nNote that that '"+ oName +"' is not a parameter name of the invoked method."
+ case Some(oName) => "\nNote that '"+ oName +"' is not a parameter name of the invoked method."
case None => ""
}
issueNormalTypeError(arg, "parameter '"+ name +"' is already specified at parameter position "+ pos + annex)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 2be6d92ed0..53bc9a2772 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -773,7 +773,7 @@ trait Contexts { self: Analyzer =>
// Implicit collection
//
- private var implicitsCache: List[List[ImplicitInfo]] = null
+ private var implicitsCache: List[ImplicitInfo] = null
private var implicitsRunId = NoRunId
def resetCache() {
@@ -832,35 +832,53 @@ trait Contexts { self: Analyzer =>
* filtered out later by `eligibleInfos` (SI-4270 / 9129cfe9), as they don't type-check.
*/
def implicitss: List[List[ImplicitInfo]] = {
- val imports = this.imports
val nextOuter = this.nextOuter
- if (implicitsRunId != currentRunId) {
- implicitsRunId = currentRunId
- implicitsCache = List()
- val newImplicits: List[ImplicitInfo] =
- if (owner != nextOuter.owner && owner.isClass && !owner.isPackageClass && !inSelfSuperCall) {
- if (!owner.isInitialized) return nextOuter.implicitss
- // debuglog("collect member implicits " + owner + ", implicit members = " + owner.thisType.implicitMembers)//DEBUG
- savingEnclClass(this) {
- // !!! In the body of `class C(implicit a: A) { }`, `implicitss` returns `List(List(a), List(a), List(<predef..)))`
- // it handled correctly by implicit search, which considers the second `a` to be shadowed, but should be
- // remedied nonetheless.
- collectImplicits(owner.thisType.implicitMembers, owner.thisType)
- }
- } else if (scope != nextOuter.scope && !owner.isPackageClass) {
- debuglog("collect local implicits " + scope.toList)//DEBUG
- collectImplicits(scope, NoPrefix)
- } else if (firstImport != nextOuter.firstImport) {
- assert(imports.tail.headOption == nextOuter.firstImport, (imports, nextOuter.imports))
- collectImplicitImports(imports.head)
- } else if (owner.isPackageClass) {
- // the corresponding package object may contain implicit members.
- collectImplicits(owner.tpe.implicitMembers, owner.tpe)
- } else List()
- implicitsCache = if (newImplicits.isEmpty) nextOuter.implicitss
- else newImplicits :: nextOuter.implicitss
+ def withOuter(is: List[ImplicitInfo]): List[List[ImplicitInfo]] =
+ is match {
+ case Nil => nextOuter.implicitss
+ case _ => is :: nextOuter.implicitss
+ }
+
+ val CycleMarker = NoRunId - 1
+ if (implicitsRunId == CycleMarker) {
+ debuglog(s"cycle while collecting implicits at owner ${owner}, probably due to an implicit without an explicit return type. Continuing with implicits from enclosing contexts.")
+ withOuter(Nil)
+ } else if (implicitsRunId != currentRunId) {
+ implicitsRunId = CycleMarker
+ implicits(nextOuter) match {
+ case None =>
+ implicitsRunId = NoRunId
+ withOuter(Nil)
+ case Some(is) =>
+ implicitsRunId = currentRunId
+ implicitsCache = is
+ withOuter(is)
+ }
}
- implicitsCache
+ else withOuter(implicitsCache)
+ }
+
+ /** @return None if a cycle is detected, or Some(infos) containing the in-scope implicits at this context */
+ private def implicits(nextOuter: Context): Option[List[ImplicitInfo]] = {
+ val imports = this.imports
+ if (owner != nextOuter.owner && owner.isClass && !owner.isPackageClass && !inSelfSuperCall) {
+ if (!owner.isInitialized) None
+ else savingEnclClass(this) {
+ // !!! In the body of `class C(implicit a: A) { }`, `implicitss` returns `List(List(a), List(a), List(<predef..)))`
+ // it handled correctly by implicit search, which considers the second `a` to be shadowed, but should be
+ // remedied nonetheless.
+ Some(collectImplicits(owner.thisType.implicitMembers, owner.thisType))
+ }
+ } else if (scope != nextOuter.scope && !owner.isPackageClass) {
+ debuglog("collect local implicits " + scope.toList)//DEBUG
+ Some(collectImplicits(scope, NoPrefix))
+ } else if (firstImport != nextOuter.firstImport) {
+ assert(imports.tail.headOption == nextOuter.firstImport, (imports, nextOuter.imports))
+ Some(collectImplicitImports(imports.head))
+ } else if (owner.isPackageClass) {
+ // the corresponding package object may contain implicit members.
+ Some(collectImplicits(owner.tpe.implicitMembers, owner.tpe))
+ } else Some(Nil)
}
//
@@ -1108,7 +1126,7 @@ trait Contexts { self: Analyzer =>
impSym = NoSymbol
// Otherwise they are irreconcilably ambiguous
else
- return ambiguousDefnAndImport(defSym.owner, imp1)
+ return ambiguousDefnAndImport(defSym.alternatives.head.owner, imp1)
}
// At this point only one or the other of defSym and impSym might be set.
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index 27920dbd74..0d46a96b81 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -260,7 +260,11 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
}
def isBlackbox(expandee: Tree): Boolean = isBlackbox(dissectApplied(expandee).core.symbol)
- def isBlackbox(macroDef: Symbol): Boolean = loadMacroImplBinding(macroDef).map(_.isBlackbox).getOrElse(false)
+ def isBlackbox(macroDef: Symbol): Boolean = {
+ val fastTrackBoxity = fastTrack.get(macroDef).map(_.isBlackbox)
+ val bindingBoxity = loadMacroImplBinding(macroDef).map(_.isBlackbox)
+ fastTrackBoxity orElse bindingBoxity getOrElse false
+ }
def computeMacroDefTypeFromMacroImplRef(macroDdef: DefDef, macroImplRef: Tree): Type = {
macroImplRef match {
@@ -345,7 +349,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
new {
val universe: self.global.type = self.global
val callsiteTyper: universe.analyzer.Typer = typer.asInstanceOf[global.analyzer.Typer]
- val expandee = universe.analyzer.macroExpanderAttachment(expandeeTree).original orElse expandeeTree
+ val expandee = universe.analyzer.macroExpanderAttachment(expandeeTree).original orElse duplicateAndKeepPositions(expandeeTree)
val macroRole = universe.analyzer.macroExpanderAttachment(expandeeTree).role
} with UnaffiliatedMacroContext {
val prefix = Expr[Nothing](prefixTree)(TypeTag.Nothing)
@@ -403,8 +407,8 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
val wrappedArgs = mapWithIndex(args)((arg, j) => {
val fingerprint = implParams(min(j, implParams.length - 1))
fingerprint match {
- case LiftedTyped => context.Expr[Nothing](arg)(TypeTag.Nothing) // TODO: SI-5752
- case LiftedUntyped => arg
+ case LiftedTyped => context.Expr[Nothing](arg.duplicate)(TypeTag.Nothing) // TODO: SI-5752
+ case LiftedUntyped => arg.duplicate
case _ => abort(s"unexpected fingerprint $fingerprint in $binding with paramss being $paramss " +
s"corresponding to arg $arg in $argss")
}
@@ -600,39 +604,46 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
}
/** Expands a term macro used in apply role as `M(2)(3)` in `val x = M(2)(3)`.
+ * @param outerPt Expected type that comes from enclosing context (something that's traditionally called `pt`).
+ * @param innerPt Expected type that comes from the signature of a macro def, possibly wildcarded to help type inference.
* @see MacroExpander
*/
- def macroExpandApply(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Tree = {
- object expander extends TermMacroExpander(APPLY_ROLE, typer, expandee, mode, pt) {
- override def onSuccess(expanded0: Tree) = {
- def approximate(tp: Type) = {
+ def macroExpandApply(typer: Typer, expandee: Tree, mode: Mode, outerPt: Type): Tree = {
+ object expander extends TermMacroExpander(APPLY_ROLE, typer, expandee, mode, outerPt) {
+ lazy val innerPt = {
+ val tp = if (isNullaryInvocation(expandee)) expandee.tpe.finalResultType else expandee.tpe
+ if (isBlackbox(expandee)) tp
+ else {
// approximation is necessary for whitebox macros to guide type inference
// read more in the comments for onDelayed below
- if (isBlackbox(expandee)) tp
+ val undetparams = tp collect { case tp if tp.typeSymbol.isTypeParameter => tp.typeSymbol }
+ deriveTypeWithWildcards(undetparams)(tp)
+ }
+ }
+ override def onSuccess(expanded0: Tree) = {
+ // prematurely annotate the tree with a macro expansion attachment
+ // so that adapt called indirectly by typer.typed knows that it needs to apply the existential fixup
+ linkExpandeeAndExpanded(expandee, expanded0)
+
+ def typecheck(label: String, tree: Tree, pt: Type): Tree = {
+ if (tree.isErrorTyped) tree
else {
- val undetparams = tp collect { case tp if tp.typeSymbol.isTypeParameter => tp.typeSymbol }
- deriveTypeWithWildcards(undetparams)(tp)
+ if (macroDebugVerbose) println(s"$label (against pt = $pt): $tree")
+ // `macroExpandApply` is called from `adapt`, where implicit conversions are disabled
+ // therefore we need to re-enable the conversions back temporarily
+ val result = typer.context.withImplicitsEnabled(typer.typed(tree, mode, pt))
+ if (result.isErrorTyped && macroDebugVerbose) println(s"$label has failed: ${typer.context.reportBuffer.errors}")
+ result
}
}
- val macroPt = approximate(if (isNullaryInvocation(expandee)) expandee.tpe.finalResultType else expandee.tpe)
- val expanded = if (isBlackbox(expandee)) atPos(enclosingMacroPosition.focus)(Typed(expanded0, TypeTree(macroPt))) else expanded0
- // prematurely annotate the tree with a macro expansion attachment
- // so that adapt called indirectly by typer.typed knows that it needs to apply the existential fixup
- linkExpandeeAndExpanded(expandee, expanded)
-
- // `macroExpandApply` is called from `adapt`, where implicit conversions are disabled
- // therefore we need to re-enable the conversions back temporarily
- if (macroDebugVerbose) println(s"typecheck #1 (against macroPt = $macroPt): $expanded")
- val expanded1 = typer.context.withImplicitsEnabled(typer.typed(expanded, mode, macroPt))
- if (expanded1.isErrorTyped) {
- if (macroDebugVerbose) println(s"typecheck #1 has failed: ${typer.context.reportBuffer.errors}")
- expanded1
+ if (isBlackbox(expandee)) {
+ val expanded1 = atPos(enclosingMacroPosition.makeTransparent)(Typed(expanded0, TypeTree(innerPt)))
+ typecheck("blackbox typecheck", expanded1, outerPt)
} else {
- if (macroDebugVerbose) println(s"typecheck #2 (against pt = $pt): $expanded1")
- val expanded2 = typer.context.withImplicitsEnabled(super.onSuccess(expanded1))
- if (macroDebugVerbose && expanded2.isErrorTyped) println(s"typecheck #2 has failed: ${typer.context.reportBuffer.errors}")
- expanded2
+ val expanded1 = expanded0
+ val expanded2 = typecheck("whitebox typecheck #1", expanded1, outerPt)
+ typecheck("whitebox typecheck #2", expanded2, innerPt)
}
}
override def onDelayed(delayed: Tree) = {
@@ -686,11 +697,11 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
// Thanks to that the materializer can take a look at what's going on and react accordingly.
val shouldInstantiate = typer.context.undetparams.nonEmpty && !mode.inPolyMode
if (shouldInstantiate) {
- if (isBlackbox(expandee)) typer.instantiatePossiblyExpectingUnit(delayed, mode, pt)
+ if (isBlackbox(expandee)) typer.instantiatePossiblyExpectingUnit(delayed, mode, outerPt)
else {
forced += delayed
- typer.infer.inferExprInstance(delayed, typer.context.extractUndetparams(), pt, keepNothings = false)
- macroExpandApply(typer, delayed, mode, pt)
+ typer.infer.inferExprInstance(delayed, typer.context.extractUndetparams(), outerPt, keepNothings = false)
+ macroExpandApply(typer, delayed, mode, outerPt)
}
} else delayed
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
index ba135d7d25..069d6d5fb2 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala
@@ -391,8 +391,10 @@ trait PatternTypers {
else freshUnapplyArgType()
)
)
+ val unapplyArgTree = Ident(unapplyArg) updateAttachment SubpatternsAttachment(args)
+
// clearing the type is necessary so that ref will be stabilized; see bug 881
- val fun1 = typedPos(fun.pos)(Apply(Select(fun.clearType(), unapplyMethod), Ident(unapplyArg) :: Nil))
+ val fun1 = typedPos(fun.pos)(Apply(Select(fun.clearType(), unapplyMethod), unapplyArgTree :: Nil))
def makeTypedUnApply() = {
// the union of the expected type and the inferred type of the argument to unapply
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 38065d5ea8..95f2620061 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -954,162 +954,166 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
case Object_eq | Object_ne | Object_== | Object_!= | Any_== | Any_!= => true
case _ => false
}
- def checkSensible(pos: Position, fn: Tree, args: List[Tree]) = fn match {
- case Select(qual, name @ (nme.EQ | nme.NE | nme.eq | nme.ne)) if args.length == 1 && isObjectOrAnyComparisonMethod(fn.symbol) =>
- // Make sure the 'eq' or 'ne' method is the one in AnyRef.
- def isReferenceOp = fn.symbol == Object_eq || fn.symbol == Object_ne
- def isNew(tree: Tree) = tree match {
- case Function(_, _)
- | Apply(Select(New(_), nme.CONSTRUCTOR), _) => true
- case _ => false
- }
- def underlyingClass(tp: Type): Symbol = {
- val sym = tp.widen.typeSymbol
- if (sym.isAbstractType) underlyingClass(sym.info.bounds.hi)
- else sym
- }
- val actual = underlyingClass(args.head.tpe)
- val receiver = underlyingClass(qual.tpe)
- def onTrees[T](f: List[Tree] => T) = f(List(qual, args.head))
- def onSyms[T](f: List[Symbol] => T) = f(List(receiver, actual))
-
- // @MAT normalize for consistency in error message, otherwise only part is normalized due to use of `typeSymbol`
- def typesString = normalizeAll(qual.tpe.widen)+" and "+normalizeAll(args.head.tpe.widen)
-
- /* Symbols which limit the warnings we can issue since they may be value types */
- val isMaybeValue = Set[Symbol](AnyClass, AnyRefClass, AnyValClass, ObjectClass, ComparableClass, JavaSerializableClass)
-
- // Whether def equals(other: Any) has known behavior: it is the default
- // inherited from java.lang.Object, or it is a synthetically generated
- // case equals. TODO - more cases are warnable if the target is a synthetic
- // equals.
- def isUsingWarnableEquals = {
- val m = receiver.info.member(nme.equals_)
- ((m == Object_equals) || (m == Any_equals) || isMethodCaseEquals(m))
- }
- def isMethodCaseEquals(m: Symbol) = m.isSynthetic && m.owner.isCase
- def isCaseEquals = isMethodCaseEquals(receiver.info.member(nme.equals_))
- // Whether this == or != is one of those defined in Any/AnyRef or an overload from elsewhere.
- def isUsingDefaultScalaOp = {
- val s = fn.symbol
- (s == Object_==) || (s == Object_!=) || (s == Any_==) || (s == Any_!=)
- }
- def haveSubclassRelationship = (actual isSubClass receiver) || (receiver isSubClass actual)
-
- // Whether the operands+operator represent a warnable combo (assuming anyrefs)
- // Looking for comparisons performed with ==/!= in combination with either an
- // equals method inherited from Object or a case class synthetic equals (for
- // which we know the logic.)
- def isWarnable = isReferenceOp || (isUsingDefaultScalaOp && isUsingWarnableEquals)
- def isEitherNullable = (NullTpe <:< receiver.info) || (NullTpe <:< actual.info)
- def isEitherValueClass = actual.isDerivedValueClass || receiver.isDerivedValueClass
- def isBoolean(s: Symbol) = unboxedValueClass(s) == BooleanClass
- def isUnit(s: Symbol) = unboxedValueClass(s) == UnitClass
- def isNumeric(s: Symbol) = isNumericValueClass(unboxedValueClass(s)) || isAnyNumber(s)
- def isScalaNumber(s: Symbol) = s isSubClass ScalaNumberClass
- def isJavaNumber(s: Symbol) = s isSubClass JavaNumberClass
- // includes java.lang.Number if appropriate [SI-5779]
- def isAnyNumber(s: Symbol) = isScalaNumber(s) || isJavaNumber(s)
- def isMaybeAnyValue(s: Symbol) = isPrimitiveValueClass(unboxedValueClass(s)) || isMaybeValue(s)
- // used to short-circuit unrelatedTypes check if both sides are special
- def isSpecial(s: Symbol) = isMaybeAnyValue(s) || isAnyNumber(s)
- val nullCount = onSyms(_ filter (_ == NullClass) size)
- def isNonsenseValueClassCompare = (
- !haveSubclassRelationship
- && isUsingDefaultScalaOp
- && isEitherValueClass
- && !isCaseEquals
- )
+ /** Check the sensibility of using the given `equals` to compare `qual` and `other`. */
+ private def checkSensibleEquals(pos: Position, qual: Tree, name: Name, sym: Symbol, other: Tree) = {
+ def isReferenceOp = sym == Object_eq || sym == Object_ne
+ def isNew(tree: Tree) = tree match {
+ case Function(_, _) | Apply(Select(New(_), nme.CONSTRUCTOR), _) => true
+ case _ => false
+ }
+ def underlyingClass(tp: Type): Symbol = {
+ val sym = tp.widen.typeSymbol
+ if (sym.isAbstractType) underlyingClass(sym.info.bounds.hi)
+ else sym
+ }
+ val actual = underlyingClass(other.tpe)
+ val receiver = underlyingClass(qual.tpe)
+ def onTrees[T](f: List[Tree] => T) = f(List(qual, other))
+ def onSyms[T](f: List[Symbol] => T) = f(List(receiver, actual))
+
+ // @MAT normalize for consistency in error message, otherwise only part is normalized due to use of `typeSymbol`
+ def typesString = normalizeAll(qual.tpe.widen)+" and "+normalizeAll(other.tpe.widen)
+
+ /* Symbols which limit the warnings we can issue since they may be value types */
+ val isMaybeValue = Set[Symbol](AnyClass, AnyRefClass, AnyValClass, ObjectClass, ComparableClass, JavaSerializableClass)
+
+ // Whether def equals(other: Any) has known behavior: it is the default
+ // inherited from java.lang.Object, or it is a synthetically generated
+ // case equals. TODO - more cases are warnable if the target is a synthetic
+ // equals.
+ def isUsingWarnableEquals = {
+ val m = receiver.info.member(nme.equals_)
+ ((m == Object_equals) || (m == Any_equals) || isMethodCaseEquals(m))
+ }
+ def isMethodCaseEquals(m: Symbol) = m.isSynthetic && m.owner.isCase
+ def isCaseEquals = isMethodCaseEquals(receiver.info.member(nme.equals_))
+ // Whether this == or != is one of those defined in Any/AnyRef or an overload from elsewhere.
+ def isUsingDefaultScalaOp = sym == Object_== || sym == Object_!= || sym == Any_== || sym == Any_!=
+ def haveSubclassRelationship = (actual isSubClass receiver) || (receiver isSubClass actual)
+
+ // Whether the operands+operator represent a warnable combo (assuming anyrefs)
+ // Looking for comparisons performed with ==/!= in combination with either an
+ // equals method inherited from Object or a case class synthetic equals (for
+ // which we know the logic.)
+ def isWarnable = isReferenceOp || (isUsingDefaultScalaOp && isUsingWarnableEquals)
+ def isEitherNullable = (NullTpe <:< receiver.info) || (NullTpe <:< actual.info)
+ def isEitherValueClass = actual.isDerivedValueClass || receiver.isDerivedValueClass
+ def isBoolean(s: Symbol) = unboxedValueClass(s) == BooleanClass
+ def isUnit(s: Symbol) = unboxedValueClass(s) == UnitClass
+ def isNumeric(s: Symbol) = isNumericValueClass(unboxedValueClass(s)) || isAnyNumber(s)
+ def isScalaNumber(s: Symbol) = s isSubClass ScalaNumberClass
+ def isJavaNumber(s: Symbol) = s isSubClass JavaNumberClass
+ // includes java.lang.Number if appropriate [SI-5779]
+ def isAnyNumber(s: Symbol) = isScalaNumber(s) || isJavaNumber(s)
+ def isMaybeAnyValue(s: Symbol) = isPrimitiveValueClass(unboxedValueClass(s)) || isMaybeValue(s)
+ // used to short-circuit unrelatedTypes check if both sides are special
+ def isSpecial(s: Symbol) = isMaybeAnyValue(s) || isAnyNumber(s)
+ val nullCount = onSyms(_ filter (_ == NullClass) size)
+ def isNonsenseValueClassCompare = (
+ !haveSubclassRelationship
+ && isUsingDefaultScalaOp
+ && isEitherValueClass
+ && !isCaseEquals
+ )
- def nonSensibleWarning(what: String, alwaysEqual: Boolean) = {
- val msg = alwaysEqual == (name == nme.EQ || name == nme.eq)
- unit.warning(pos, "comparing "+what+" using `"+name.decode+"' will always yield " + msg)
- }
- def nonSensible(pre: String, alwaysEqual: Boolean) =
- nonSensibleWarning(pre+"values of types "+typesString, alwaysEqual)
- def nonSensiblyEq() = nonSensible("", true)
- def nonSensiblyNeq() = nonSensible("", false)
- def nonSensiblyNew() = nonSensibleWarning("a fresh object", false)
-
- def unrelatedMsg = name match {
- case nme.EQ | nme.eq => "never compare equal"
- case _ => "always compare unequal"
- }
- def unrelatedTypes() = {
- val weaselWord = if (isEitherValueClass) "" else " most likely"
- unit.warning(pos, s"$typesString are unrelated: they will$weaselWord $unrelatedMsg")
- }
+ // Have we already determined that the comparison is non-sensible? I mean, non-sensical?
+ var isNonSensible = false
- if (nullCount == 2) // null == null
+ def nonSensibleWarning(what: String, alwaysEqual: Boolean) = {
+ val msg = alwaysEqual == (name == nme.EQ || name == nme.eq)
+ unit.warning(pos, s"comparing $what using `${name.decode}' will always yield $msg")
+ isNonSensible = true
+ }
+ def nonSensible(pre: String, alwaysEqual: Boolean) =
+ nonSensibleWarning(s"${pre}values of types $typesString", alwaysEqual)
+ def nonSensiblyEq() = nonSensible("", alwaysEqual = true)
+ def nonSensiblyNeq() = nonSensible("", alwaysEqual = false)
+ def nonSensiblyNew() = nonSensibleWarning("a fresh object", alwaysEqual = false)
+
+ def unrelatedMsg = name match {
+ case nme.EQ | nme.eq => "never compare equal"
+ case _ => "always compare unequal"
+ }
+ def unrelatedTypes() = if (!isNonSensible) {
+ val weaselWord = if (isEitherValueClass) "" else " most likely"
+ unit.warning(pos, s"$typesString are unrelated: they will$weaselWord $unrelatedMsg")
+ }
+
+ if (nullCount == 2) // null == null
+ nonSensiblyEq()
+ else if (nullCount == 1) {
+ if (onSyms(_ exists isPrimitiveValueClass)) // null == 5
+ nonSensiblyNeq()
+ else if (onTrees( _ exists isNew)) // null == new AnyRef
+ nonSensiblyNew()
+ }
+ else if (isBoolean(receiver)) {
+ if (!isBoolean(actual) && !isMaybeValue(actual)) // true == 5
+ nonSensiblyNeq()
+ }
+ else if (isUnit(receiver)) {
+ if (isUnit(actual)) // () == ()
nonSensiblyEq()
- else if (nullCount == 1) {
- if (onSyms(_ exists isPrimitiveValueClass)) // null == 5
- nonSensiblyNeq()
- else if (onTrees( _ exists isNew)) // null == new AnyRef
- nonSensiblyNew()
- }
- else if (isBoolean(receiver)) {
- if (!isBoolean(actual) && !isMaybeValue(actual)) // true == 5
+ else if (!isUnit(actual) && !isMaybeValue(actual)) // () == "abc"
+ nonSensiblyNeq()
+ }
+ else if (isNumeric(receiver)) {
+ if (!isNumeric(actual))
+ if (isUnit(actual) || isBoolean(actual) || !isMaybeValue(actual)) // 5 == "abc"
nonSensiblyNeq()
- }
- else if (isUnit(receiver)) {
- if (isUnit(actual)) // () == ()
- nonSensiblyEq()
- else if (!isUnit(actual) && !isMaybeValue(actual)) // () == "abc"
+ }
+ else if (isWarnable && !isCaseEquals) {
+ if (isNew(qual)) // new X == y
+ nonSensiblyNew()
+ else if (isNew(other) && (receiver.isEffectivelyFinal || isReferenceOp)) // object X ; X == new Y
+ nonSensiblyNew()
+ else if (receiver.isEffectivelyFinal && !(receiver isSubClass actual) && !actual.isRefinementClass) { // object X, Y; X == Y
+ if (isEitherNullable)
+ nonSensible("non-null ", false)
+ else
nonSensiblyNeq()
}
- else if (isNumeric(receiver)) {
- if (!isNumeric(actual))
- if (isUnit(actual) || isBoolean(actual) || !isMaybeValue(actual)) // 5 == "abc"
- nonSensiblyNeq()
+ }
+
+ // warn if one but not the other is a derived value class
+ // this is especially important to enable transitioning from
+ // regular to value classes without silent failures.
+ if (isNonsenseValueClassCompare)
+ unrelatedTypes()
+ // possibleNumericCount is insufficient or this will warn on e.g. Boolean == j.l.Boolean
+ else if (isWarnable && nullCount == 0 && !(isSpecial(receiver) && isSpecial(actual))) {
+ // better to have lubbed and lost
+ def warnIfLubless(): Unit = {
+ val common = global.lub(List(actual.tpe, receiver.tpe))
+ if (ObjectTpe <:< common)
+ unrelatedTypes()
}
- else if (isWarnable && !isCaseEquals) {
- if (isNew(qual)) // new X == y
- nonSensiblyNew()
- else if (isNew(args.head) && (receiver.isEffectivelyFinal || isReferenceOp)) // object X ; X == new Y
- nonSensiblyNew()
- else if (receiver.isEffectivelyFinal && !(receiver isSubClass actual) && !actual.isRefinementClass) { // object X, Y; X == Y
- if (isEitherNullable)
- nonSensible("non-null ", false)
- else
- nonSensiblyNeq()
+ // warn if actual has a case parent that is not same as receiver's;
+ // if actual is not a case, then warn if no common supertype, as below
+ if (isCaseEquals) {
+ def thisCase = receiver.info.member(nme.equals_).owner
+ actual.info.baseClasses.find(_.isCase) match {
+ case Some(p) if p != thisCase => nonSensible("case class ", false)
+ case None =>
+ // stronger message on (Some(1) == None)
+ //if (receiver.isCase && receiver.isEffectivelyFinal && !(receiver isSubClass actual)) nonSensiblyNeq()
+ //else
+ // if a class, it must be super to thisCase (and receiver) since not <: thisCase
+ if (!actual.isTrait && !(receiver isSubClass actual)) nonSensiblyNeq()
+ else if (!haveSubclassRelationship) warnIfLubless()
+ case _ =>
}
}
-
- // warn if one but not the other is a derived value class
- // this is especially important to enable transitioning from
- // regular to value classes without silent failures.
- if (isNonsenseValueClassCompare)
- unrelatedTypes()
- // possibleNumericCount is insufficient or this will warn on e.g. Boolean == j.l.Boolean
- else if (isWarnable && nullCount == 0 && !(isSpecial(receiver) && isSpecial(actual))) {
- // better to have lubbed and lost
- def warnIfLubless(): Unit = {
- val common = global.lub(List(actual.tpe, receiver.tpe))
- if (ObjectTpe <:< common)
- unrelatedTypes()
- }
- // warn if actual has a case parent that is not same as receiver's;
- // if actual is not a case, then warn if no common supertype, as below
- if (isCaseEquals) {
- def thisCase = receiver.info.member(nme.equals_).owner
- actual.info.baseClasses.find(_.isCase) match {
- case Some(p) if p != thisCase => nonSensible("case class ", false)
- case None =>
- // stronger message on (Some(1) == None)
- //if (receiver.isCase && receiver.isEffectivelyFinal && !(receiver isSubClass actual)) nonSensiblyNeq()
- //else
- // if a class, it must be super to thisCase (and receiver) since not <: thisCase
- if (!actual.isTrait && !(receiver isSubClass actual)) nonSensiblyNeq()
- else if (!haveSubclassRelationship) warnIfLubless()
- case _ =>
- }
- }
- // warn only if they have no common supertype below Object
- else if (!haveSubclassRelationship) {
- warnIfLubless()
- }
+ // warn only if they have no common supertype below Object
+ else if (!haveSubclassRelationship) {
+ warnIfLubless()
}
+ }
+ }
+ /** Sensibility check examines flavors of equals. */
+ def checkSensible(pos: Position, fn: Tree, args: List[Tree]) = fn match {
+ case Select(qual, name @ (nme.EQ | nme.NE | nme.eq | nme.ne)) if args.length == 1 && isObjectOrAnyComparisonMethod(fn.symbol) =>
+ checkSensibleEquals(pos, qual, name, fn.symbol, args.head)
case _ =>
}
@@ -1265,22 +1269,22 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
false
}
- /** If symbol is deprecated, and the point of reference is not enclosed
- * in either a deprecated member or a scala bridge method, issue a warning.
- */
- private def checkDeprecated(sym: Symbol, pos: Position) {
+ // Note: if a symbol has both @deprecated and @migration annotations and both
+ // warnings are enabled, only the first one checked here will be emitted.
+ // I assume that's a consequence of some code trying to avoid noise by suppressing
+ // warnings after the first, but I think it'd be better if we didn't have to
+ // arbitrarily choose one as more important than the other.
+ private def checkUndesiredProperties(sym: Symbol, pos: Position) {
+ // If symbol is deprecated, and the point of reference is not enclosed
+ // in either a deprecated member or a scala bridge method, issue a warning.
if (sym.isDeprecated && !currentOwner.ownerChain.exists(x => x.isDeprecated || x.hasBridgeAnnotation)) {
unit.deprecationWarning(pos, "%s%s is deprecated%s".format(
sym, sym.locationString, sym.deprecationMessage map (": " + _) getOrElse "")
)
}
- }
-
- /** Similar to deprecation: check if the symbol is marked with @migration
- * indicating it has changed semantics between versions.
- */
- private def checkMigration(sym: Symbol, pos: Position) = {
- if (sym.hasMigrationAnnotation) {
+ // Similar to deprecation: check if the symbol is marked with @migration
+ // indicating it has changed semantics between versions.
+ if (sym.hasMigrationAnnotation && settings.Xmigration.value != NoScalaVersion) {
val changed = try
settings.Xmigration.value < ScalaVersion(sym.migrationVersion.get)
catch {
@@ -1292,9 +1296,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
if (changed)
unit.warning(pos, s"${sym.fullLocationString} has changed semantics in version ${sym.migrationVersion.get}:\n${sym.migrationMessage.get}")
}
- }
-
- private def checkCompileTimeOnly(sym: Symbol, pos: Position) = {
+ // See an explanation of compileTimeOnly in its scaladoc at scala.annotation.compileTimeOnly.
if (sym.isCompileTimeOnly) {
def defaultMsg =
sm"""Reference to ${sym.fullLocationString} should not have survived past type checking,
@@ -1416,8 +1418,8 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
case TypeRef(pre, sym, args) =>
tree match {
case tt: TypeTree if tt.original == null => // SI-7783 don't warn about inferred types
- case _ =>
- checkDeprecated(sym, tree.pos)
+ // FIXME: reconcile this check with one in resetAllAttrs
+ case _ => checkUndesiredProperties(sym, tree.pos)
}
if(sym.isJavaDefined)
sym.typeParams foreach (_.cookJavaRawInfo())
@@ -1449,7 +1451,6 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
private def applyRefchecksToAnnotations(tree: Tree): Unit = {
def applyChecks(annots: List[AnnotationInfo]) = {
- annots foreach (annot => checkCompileTimeOnly(annot.atp.typeSymbol, annot.pos))
checkAnnotations(annots map (_.atp), tree)
transformTrees(annots flatMap (_.args))
}
@@ -1529,7 +1530,8 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
transform(qual)
case Apply(fn, args) =>
- // sensicality should be subsumed by the unreachability/exhaustivity/irrefutability analyses in the pattern matcher
+ // sensicality should be subsumed by the unreachability/exhaustivity/irrefutability
+ // analyses in the pattern matcher
if (!inPattern) {
checkImplicitViewOptionApply(tree.pos, fn, args)
checkSensible(tree.pos, fn, args)
@@ -1541,16 +1543,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
val Select(qual, _) = tree
val sym = tree.symbol
- /* Note: if a symbol has both @deprecated and @migration annotations and both
- * warnings are enabled, only the first one checked here will be emitted.
- * I assume that's a consequence of some code trying to avoid noise by suppressing
- * warnings after the first, but I think it'd be better if we didn't have to
- * arbitrarily choose one as more important than the other.
- */
- checkDeprecated(sym, tree.pos)
- if(settings.Xmigration.value != NoScalaVersion)
- checkMigration(sym, tree.pos)
- checkCompileTimeOnly(sym, tree.pos)
+ checkUndesiredProperties(sym, tree.pos)
checkDelayedInitSelect(qual, sym, tree.pos)
if (!sym.exists)
@@ -1705,7 +1698,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
tree
case Ident(name) =>
- checkCompileTimeOnly(tree.symbol, tree.pos)
+ checkUndesiredProperties(sym, tree.pos)
transformCaseApply(tree,
if (name != nme.WILDCARD && name != tpnme.WILDCARD_STAR) {
assert(sym != NoSymbol, "transformCaseApply: name = " + name.debugString + " tree = " + tree + " / " + tree.getClass) //debug
diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
index 54c665fe56..14f47a00fd 100644
--- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
@@ -50,6 +50,10 @@ trait StdAttachments {
case _ => false
}
+ /** Returns the original tree of the macro expansion if the argument is a macro expansion or EmptyTree otherwise.
+ */
+ def macroExpandee(tree: Tree): Tree = tree.attachments.get[MacroExpansionAttachment].map(_.expandee).getOrElse(EmptyTree)
+
/** After macro expansion is completed, links the expandee and the expansion result by annotating them both with a `MacroExpansionAttachment`.
* The `expanded` parameter is of type `Any`, because macros can expand both into trees and into annotations.
*/
@@ -147,4 +151,18 @@ trait StdAttachments {
* because someone has put MacroImplRefAttachment on it.
*/
def isMacroImplRef(tree: Tree): Boolean = tree.attachments.get[MacroImplRefAttachment.type].isDefined
+
+ /** Since mkInvoke, the applyDynamic/selectDynamic/etc desugarer, is disconnected
+ * from typedNamedApply, the applyDynamicNamed argument rewriter, the latter
+ * doesn’t know whether it needs to apply the rewriting because the application
+ * has just been desugared or it needs to hold on because it’s already performed
+ * a desugaring on this tree. This has led to SI-8006.
+ *
+ * This attachment solves the problem by providing a means of communication
+ * between the two Dynamic desugarers, which solves the aforementioned issue.
+ */
+ case object DynamicRewriteAttachment
+ def markDynamicRewrite(tree: Tree): Tree = tree.updateAttachment(DynamicRewriteAttachment)
+ def unmarkDynamicRewrite(tree: Tree): Tree = tree.removeAttachment[DynamicRewriteAttachment.type]
+ def isDynamicRewrite(tree: Tree): Boolean = tree.attachments.get[DynamicRewriteAttachment.type].isDefined
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index fb252c3058..910da77ca8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3369,7 +3369,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
(args exists isNamedArg) || // uses a named argument
isNamedApplyBlock(fun)) { // fun was transformed to a named apply block =>
// integrate this application into the block
- if (dyna.isApplyDynamicNamed(fun)) dyna.typedNamedApply(tree, fun, args, mode, pt)
+ if (dyna.isApplyDynamicNamed(fun) && isDynamicRewrite(fun)) dyna.typedNamedApply(tree, fun, args, mode, pt)
else tryNamesDefaults
} else {
val tparams = context.extractUndetparams()
@@ -3746,7 +3746,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
val dealiasLocals = new TypeMap {
def apply(tp: Type): Type = tp match {
case TypeRef(pre, sym, args) =>
- if (sym.isAliasType && containsLocal(tp)) apply(tp.dealias)
+ if (sym.isAliasType && containsLocal(tp) && (tp.dealias ne tp)) apply(tp.dealias)
else {
if (pre.isVolatile)
InferTypeWithVolatileTypeSelectionError(tree, pre)
@@ -3927,7 +3927,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
gen.mkTuple(List(CODE.LIT(""), arg))
}
- val t = treeCopy.Apply(orig, fun, args map argToBinding)
+ val t = treeCopy.Apply(orig, unmarkDynamicRewrite(fun), args map argToBinding)
wrapErrors(t, _.typed(t, mode, pt))
}
@@ -3953,9 +3953,12 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
def mkInvoke(cxTree: Tree, tree: Tree, qual: Tree, name: Name): Option[Tree] = {
debuglog(s"dyna.mkInvoke($cxTree, $tree, $qual, $name)")
val treeInfo.Applied(treeSelection, _, _) = tree
- def isDesugaredApply = treeSelection match {
- case Select(`qual`, nme.apply) => true
- case _ => false
+ def isDesugaredApply = {
+ val protoQual = macroExpandee(qual) orElse qual
+ treeSelection match {
+ case Select(`protoQual`, nme.apply) => true
+ case _ => false
+ }
}
acceptsApplyDynamicWithType(qual, name) map { tp =>
// If tp == NoType, pass only explicit type arguments to applyXXX. Not used at all
@@ -3989,7 +3992,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
val nameStringLit = atPos(treeSelection.pos.withStart(treeSelection.pos.point).makeTransparent) {
Literal(Constant(name.decode))
}
- atPos(qual.pos)(Apply(fun, List(nameStringLit)))
+ markDynamicRewrite(atPos(qual.pos)(Apply(fun, List(nameStringLit))))
case _ =>
setError(tree)
}
@@ -5113,12 +5116,24 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
// Warn about likely interpolated strings which are missing their interpolators
def warnMissingInterpolator(lit: Literal): Unit = if (!isPastTyper) {
+ // attempt to avoid warning about trees munged by macros
+ def isMacroExpansion = {
+ // context.tree is not the expandee; it is plain new SC(ps).m(args)
+ //context.tree exists (t => (t.pos includes lit.pos) && hasMacroExpansionAttachment(t))
+ // testing pos works and may suffice
+ //openMacros exists (_.macroApplication.pos includes lit.pos)
+ // tests whether the lit belongs to the expandee of an open macro
+ openMacros exists (_.macroApplication.attachments.get[MacroExpansionAttachment] match {
+ case Some(MacroExpansionAttachment(_, t: Tree)) => t exists (_ == lit)
+ case _ => false
+ })
+ }
// attempt to avoid warning about the special interpolated message string
// for implicitNotFound or any standard interpolation (with embedded $$).
def isRecognizablyNotForInterpolation = context.enclosingApply.tree match {
case Apply(Select(Apply(RefTree(_, nme.StringContext), _), _), _) => true
case Apply(Select(New(RefTree(_, tpnme.implicitNotFound)), _), _) => true
- case _ => false
+ case _ => isMacroExpansion
}
def requiresNoArgs(tp: Type): Boolean = tp match {
case PolyType(_, restpe) => requiresNoArgs(restpe)
@@ -5149,12 +5164,9 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
def typedLiteral(tree: Literal) = {
- if (settings.lint)
- warnMissingInterpolator(tree)
+ if (settings.lint) warnMissingInterpolator(tree)
- tree setType (
- if (tree.value.tag == UnitTag) UnitTpe
- else ConstantType(tree.value))
+ tree setType (if (tree.value.tag == UnitTag) UnitTpe else ConstantType(tree.value))
}
def typedSingletonTypeTree(tree: SingletonTypeTree) = {
@@ -5508,7 +5520,23 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
val isMacroBodyOkay = !tree.symbol.isErroneous && !(tree1 exists (_.isErroneous)) && tree1 != EmptyTree
val shouldInheritMacroImplReturnType = ddef.tpt.isEmpty
- if (isMacroBodyOkay && shouldInheritMacroImplReturnType) computeMacroDefTypeFromMacroImplRef(ddef, tree1) else AnyTpe
+ if (isMacroBodyOkay && shouldInheritMacroImplReturnType) {
+ val commonMessage = "macro defs must have explicitly specified return types"
+ def reportFailure() = {
+ ddef.symbol.setFlag(IS_ERROR)
+ unit.error(ddef.pos, commonMessage)
+ }
+ def reportWarning(inferredType: Type) = {
+ val explanation = s"inference of $inferredType from macro impl's c.Expr[$inferredType] is deprecated and is going to stop working in 2.12"
+ unit.deprecationWarning(ddef.pos, s"$commonMessage ($explanation)")
+ }
+ computeMacroDefTypeFromMacroImplRef(ddef, tree1) match {
+ case ErrorType => ErrorType
+ case NothingTpe => NothingTpe
+ case NoType => reportFailure(); AnyTpe
+ case tpe => reportWarning(tpe); tpe
+ }
+ } else AnyTpe
}
def transformedOr(tree: Tree, op: => Tree): Tree = transformed remove tree match {
diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala
index dd92e14602..bb0bbd79a3 100644
--- a/src/compiler/scala/tools/reflect/FastTrack.scala
+++ b/src/compiler/scala/tools/reflect/FastTrack.scala
@@ -24,10 +24,12 @@ trait FastTrack {
new { val c: c0.type = c0 } with MacroImplementations
private implicit def context2quasiquote(c0: MacroContext): QuasiquoteImpls { val c: c0.type } =
new { val c: c0.type = c0 } with QuasiquoteImpls
- private def make(sym: Symbol)(pf: PartialFunction[Applied, MacroContext => Tree]) =
- sym -> new FastTrackEntry(pf)
+ private def makeBlackbox(sym: Symbol)(pf: PartialFunction[Applied, MacroContext => Tree]) =
+ sym -> new FastTrackEntry(pf, isBlackbox = true)
+ private def makeWhitebox(sym: Symbol)(pf: PartialFunction[Applied, MacroContext => Tree]) =
+ sym -> new FastTrackEntry(pf, isBlackbox = false)
- final class FastTrackEntry(pf: PartialFunction[Applied, MacroContext => Tree]) extends (MacroArgs => Any) {
+ final class FastTrackEntry(pf: PartialFunction[Applied, MacroContext => Tree], val isBlackbox: Boolean) extends (MacroArgs => Any) {
def validate(tree: Tree) = pf isDefinedAt Applied(tree)
def apply(margs: MacroArgs): margs.c.Expr[Nothing] = {
val MacroArgs(c, _) = margs
@@ -42,14 +44,14 @@ trait FastTrack {
val runDefinitions = currentRun.runDefinitions
import runDefinitions._
Map[Symbol, FastTrackEntry](
- make( materializeClassTag) { case Applied(_, ttag :: Nil, _) => _.materializeClassTag(ttag.tpe) },
- make( materializeWeakTypeTag) { case Applied(_, ttag :: Nil, (u :: _) :: _) => _.materializeTypeTag(u, EmptyTree, ttag.tpe, concrete = false) },
- make( materializeTypeTag) { case Applied(_, ttag :: Nil, (u :: _) :: _) => _.materializeTypeTag(u, EmptyTree, ttag.tpe, concrete = true) },
- make( ApiUniverseReify) { case Applied(_, ttag :: Nil, (expr :: _) :: _) => c => c.materializeExpr(c.prefix.tree, EmptyTree, expr) },
- make( StringContext_f) { case Applied(Select(Apply(_, ps), _), _, args) => c => c.macro_StringInterpolation_f(ps, args.flatten, c.expandee.pos) },
- make(ReflectRuntimeCurrentMirror) { case _ => c => currentMirror(c).tree },
- make( QuasiquoteClass_api_apply) { case _ => _.expandQuasiquote },
- make(QuasiquoteClass_api_unapply) { case _ => _.expandQuasiquote }
+ makeBlackbox( materializeClassTag) { case Applied(_, ttag :: Nil, _) => _.materializeClassTag(ttag.tpe) },
+ makeBlackbox( materializeWeakTypeTag) { case Applied(_, ttag :: Nil, (u :: _) :: _) => _.materializeTypeTag(u, EmptyTree, ttag.tpe, concrete = false) },
+ makeBlackbox( materializeTypeTag) { case Applied(_, ttag :: Nil, (u :: _) :: _) => _.materializeTypeTag(u, EmptyTree, ttag.tpe, concrete = true) },
+ makeBlackbox( ApiUniverseReify) { case Applied(_, ttag :: Nil, (expr :: _) :: _) => c => c.materializeExpr(c.prefix.tree, EmptyTree, expr) },
+ makeBlackbox( StringContext_f) { case Applied(Select(Apply(_, ps), _), _, args) => c => c.macro_StringInterpolation_f(ps, args.flatten, c.expandee.pos) },
+ makeBlackbox(ReflectRuntimeCurrentMirror) { case _ => c => currentMirror(c).tree },
+ makeWhitebox( QuasiquoteClass_api_apply) { case _ => _.expandQuasiquote },
+ makeWhitebox(QuasiquoteClass_api_unapply) { case _ => _.expandQuasiquote }
)
}
}
diff --git a/src/compiler/scala/tools/reflect/ToolBox.scala b/src/compiler/scala/tools/reflect/ToolBox.scala
index be22003114..236b868842 100644
--- a/src/compiler/scala/tools/reflect/ToolBox.scala
+++ b/src/compiler/scala/tools/reflect/ToolBox.scala
@@ -21,6 +21,12 @@ trait ToolBox[U <: scala.reflect.api.Universe] {
*/
def frontEnd: FrontEnd
+ /** @see `Typers.typecheck`
+ */
+ @deprecated("Use `tb.typecheck` instead", "2.11.0")
+ def typeCheck(tree: u.Tree, pt: u.Type = u.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree =
+ typecheck(tree, pt, silent, withImplicitViewsDisabled, withMacrosDisabled)
+
/** Typechecks a tree using this ToolBox.
* This populates symbols and types of the tree and possibly transforms it to reflect certain desugarings.
*
@@ -35,7 +41,7 @@ trait ToolBox[U <: scala.reflect.api.Universe] {
* `withImplicitViewsDisabled` recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
* `withMacrosDisabled` recursively prohibits macro expansions and macro-based implicits, default value is false
*/
- def typeCheck(tree: u.Tree, pt: u.Type = u.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree
+ def typecheck(tree: u.Tree, pt: u.Type = u.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree
/** Infers an implicit value of the expected type `pt` in top-level context.
* Optional `pos` parameter provides a position that will be associated with the implicit search.
@@ -47,7 +53,7 @@ trait ToolBox[U <: scala.reflect.api.Universe] {
* If `silent` is false, `TypeError` will be thrown in case of an inference error.
* If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in `typeCheck`, `silent` is true by default.
+ * Unlike in `typecheck`, `silent` is true by default.
*/
def inferImplicitValue(pt: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree
@@ -61,7 +67,7 @@ trait ToolBox[U <: scala.reflect.api.Universe] {
* If `silent` is false, `TypeError` will be thrown in case of an inference error.
* If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in `typeCheck`, `silent` is true by default.
+ * Unlike in `typecheck`, `silent` is true by default.
*/
def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree
diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
index e94b7725cd..af13b7d0ba 100644
--- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
+++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
@@ -171,7 +171,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
unwrapped
}
- def typeCheck(expr: Tree, pt: Type, silent: Boolean, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): Tree =
+ def typecheck(expr: Tree, pt: Type, silent: Boolean, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): Tree =
transformDuringTyper(expr, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled)(
(currentTyper, expr) => {
trace("typing (implicit views = %s, macros = %s): ".format(!withImplicitViewsDisabled, !withMacrosDisabled))(showAttributed(expr, true, true, settings.Yshowsymkinds.value))
@@ -348,7 +348,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
}
}
- def typeCheck(tree: u.Tree, expectedType: u.Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree = withCompilerApi { compilerApi =>
+ def typecheck(tree: u.Tree, expectedType: u.Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree = withCompilerApi { compilerApi =>
import compilerApi._
if (compiler.settings.verbose) println("importing "+tree+", expectedType = "+expectedType)
@@ -356,7 +356,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
val cexpectedType: compiler.Type = importer.importType(expectedType)
if (compiler.settings.verbose) println("typing "+ctree+", expectedType = "+expectedType)
- val ttree: compiler.Tree = compiler.typeCheck(ctree, cexpectedType, silent = silent, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled)
+ val ttree: compiler.Tree = compiler.typecheck(ctree, cexpectedType, silent = silent, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled)
val uttree = exporter.importTree(ttree)
uttree
}
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Holes.scala b/src/compiler/scala/tools/reflect/quasiquotes/Holes.scala
index f92c9aa845..f5bcaf68e0 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Holes.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Holes.scala
@@ -3,6 +3,7 @@ package quasiquotes
import scala.collection.{immutable, mutable}
import scala.reflect.internal.Flags._
+import scala.reflect.macros.TypecheckException
class Cardinality private[Cardinality](val value: Int) extends AnyVal {
def pred = { assert(value - 1 >= 0); new Cardinality(value - 1) }
@@ -30,158 +31,173 @@ trait Holes { self: Quasiquotes =>
import definitions._
import universeTypes._
- /** Location characterizes a kind of a non-terminal in Scala syntax where something is going to be spliced.
- * A location is typically associated with a type of the things that can be spliced there.
- * Associated type might be different from an actual tpe of a splicee due to lifting.
- * This is the first pillar of modularity in the quasiquote reifier.
- */
- sealed abstract class Location(val tpe: Type)
- case object UnknownLocation extends Location(NoType)
- case class TreeLocation(override val tpe: Type) extends Location(tpe)
- case object NameLocation extends Location(nameType)
- case object ModsLocation extends Location(modsType)
- case object FlagsLocation extends Location(flagsType)
- case object SymbolLocation extends Location(symbolType)
- case class IterableLocation(card: Cardinality, sublocation: TreeLocation) extends Location(NoType) {
- override val tpe = {
- def loop(n: Cardinality, tpe: Type): Type =
- if (n == NoDot) tpe
- else appliedType(IterableClass.toType, List(loop(n.pred, tpe)))
- loop(card, sublocation.tpe)
+ protected lazy val IterableTParam = IterableClass.typeParams(0).asType.toType
+ protected def inferParamImplicit(tfun: Type, targ: Type) = c.inferImplicitValue(appliedType(tfun, List(targ)), silent = true)
+ protected def inferLiftable(tpe: Type): Tree = inferParamImplicit(liftableType, tpe)
+ protected def inferUnliftable(tpe: Type): Tree = inferParamImplicit(unliftableType, tpe)
+ protected def isLiftableType(tpe: Type) = inferLiftable(tpe) != EmptyTree
+ protected def isNativeType(tpe: Type) =
+ (tpe <:< treeType) || (tpe <:< nameType) || (tpe <:< modsType) ||
+ (tpe <:< flagsType) || (tpe <:< symbolType)
+ protected def isBottomType(tpe: Type) =
+ tpe <:< NothingClass.tpe || tpe <:< NullClass.tpe
+ protected def stripIterable(tpe: Type, limit: Option[Cardinality] = None): (Cardinality, Type) =
+ if (limit.map { _ == NoDot }.getOrElse { false }) (NoDot, tpe)
+ else if (tpe != null && !isIterableType(tpe)) (NoDot, tpe)
+ else if (isBottomType(tpe)) (NoDot, tpe)
+ else {
+ val targ = IterableTParam.asSeenFrom(tpe, IterableClass)
+ val (card, innerTpe) = stripIterable(targ, limit.map { _.pred })
+ (card.succ, innerTpe)
}
+ protected def iterableTypeFromCard(n: Cardinality, tpe: Type): Type = {
+ if (n == NoDot) tpe
+ else appliedType(IterableClass.toType, List(iterableTypeFromCard(n.pred, tpe)))
}
- /** Hole type describes location, cardinality and a pre-reification routine associated with a hole.
- * An interesting thing about HoleType is that it can be completely inferred from the type of the splicee.
- * This is the second pillar of modularity in the quasiquote reifier.
+ /** Hole encapsulates information about splices in quasiquotes.
+ * It packs together a cardinality of a splice, pre-reified tree
+ * representation (possibly preprocessed) and position.
*/
- case class HoleType(preprocessor: Tree => Tree, location: Location, cardinality: Cardinality) {
- def makeHole(tree: Tree) = Hole(preprocessor(tree), location, cardinality)
+ abstract class Hole {
+ val tree: Tree
+ val pos: Position
+ val cardinality: Cardinality
}
- object HoleType {
- def unapply(tpe: Type): Option[HoleType] = tpe match {
- case NativeType(holeTpe) => Some(holeTpe)
- case LiftableType(holeTpe) => Some(holeTpe)
- case IterableTreeType(holeTpe) => Some(holeTpe)
- case IterableLiftableType(holeTpe) => Some(holeTpe)
- case _ => None
- }
- trait HoleTypeExtractor {
- def unapply(tpe: Type): Option[HoleType] = {
- for {
- preprocessor <- this.preprocessor(tpe)
- location <- this.location(tpe)
- cardinality <- Some(this.cardinality(tpe))
- } yield HoleType(preprocessor, location, cardinality)
- }
- def preprocessor(tpe: Type): Option[Tree => Tree]
- def location(tpe: Type): Option[Location]
- def cardinality(tpe: Type): Cardinality = parseCardinality(tpe)._1
-
- def lifter(tpe: Type): Option[Tree => Tree] = {
- val lifterTpe = appliedType(LiftableClass.toType, List(tpe))
- val lifter = c.inferImplicitValue(lifterTpe, silent = true)
- if (lifter != EmptyTree) Some(tree => {
- val lifted = Apply(lifter, List(u, tree))
- val targetType = Select(u, tpnme.Tree)
- atPos(tree.pos)(TypeApply(Select(lifted, nme.asInstanceOf_), List(targetType)))
- }) else None
- }
+ object Hole {
+ def apply(card: Cardinality, tree: Tree): Hole =
+ if (method != nme.unapply) new ApplyHole(card, tree)
+ else new UnapplyHole(card, tree)
+ def unapply(hole: Hole): Some[(Tree, Cardinality)] = Some((hole.tree, hole.cardinality))
+ }
- def iterator(tpe: Type)(elementTransform: Tree => Tree): Option[Tree => Tree] = {
- def reifyIterable(tree: Tree, n: Cardinality): Tree = {
- def loop(tree: Tree, n: Cardinality) =
- if (n == NoDot) elementTransform(tree)
- else {
- val x: TermName = c.freshName()
- val wrapped = reifyIterable(Ident(x), n.pred)
- val xToWrapped = Function(List(ValDef(Modifiers(PARAM), x, TypeTree(), EmptyTree)), wrapped)
- Select(Apply(Select(tree, nme.map), List(xToWrapped)), nme.toList)
- }
- if (tree.tpe != null && (tree.tpe <:< listTreeType || tree.tpe <:< listListTreeType)) tree
- else atPos(tree.pos)(loop(tree, n))
- }
- val card = parseCardinality(tpe)._1
- if (card != NoDot) Some(reifyIterable(_, card)) else None
- }
+ class ApplyHole(card: Cardinality, splicee: Tree) extends Hole {
+ val (strippedTpe, tpe): (Type, Type) = {
+ if (stripIterable(splicee.tpe)._1.value < card.value) cantSplice()
+ val (_, strippedTpe) = stripIterable(splicee.tpe, limit = Some(card))
+ if (isBottomType(strippedTpe)) cantSplice()
+ else if (isNativeType(strippedTpe)) (strippedTpe, iterableTypeFromCard(card, strippedTpe))
+ else if (isLiftableType(strippedTpe)) (strippedTpe, iterableTypeFromCard(card, treeType))
+ else cantSplice()
}
- object NativeType extends HoleTypeExtractor {
- def preprocessor(tpe: Type) = Some(identity)
- def location(tpe: Type) = {
- if (tpe <:< treeType) Some(TreeLocation(tpe))
- else if (tpe <:< nameType) Some(NameLocation)
- else if (tpe <:< modsType) Some(ModsLocation)
- else if (tpe <:< flagsType) Some(FlagsLocation)
- else if (tpe <:< symbolType) Some(SymbolLocation)
- else None
- }
+ val tree = {
+ def inner(itpe: Type)(tree: Tree) =
+ if (isNativeType(itpe)) tree
+ else if (isLiftableType(itpe)) lifted(itpe)(tree)
+ else global.abort("unreachable")
+ if (card == NoDot) inner(strippedTpe)(splicee)
+ else iterated(card, strippedTpe, inner(strippedTpe))(splicee)
}
- object LiftableType extends HoleTypeExtractor {
- def preprocessor(tpe: Type) = lifter(tpe)
- def location(tpe: Type) = Some(TreeLocation(treeType))
+ val pos = splicee.pos
+
+ val cardinality = stripIterable(tpe)._1
+
+ protected def cantSplice(): Nothing = {
+ val (iterableCard, iterableType) = stripIterable(splicee.tpe)
+ val holeCardMsg = if (card != NoDot) s" with $card" else ""
+ val action = "splice " + splicee.tpe + holeCardMsg
+ val suggestCard = card != iterableCard || card != NoDot
+ val spliceeCardMsg = if (card != iterableCard && iterableCard != NoDot) s"using $iterableCard" else "omitting the dots"
+ val cardSuggestion = if (suggestCard) spliceeCardMsg else ""
+ val suggestLifting = (card == NoDot || iterableCard != NoDot) && !(iterableType <:< treeType) && !isLiftableType(iterableType)
+ val liftedTpe = if (card != NoDot) iterableType else splicee.tpe
+ val liftSuggestion = if (suggestLifting) s"providing an implicit instance of Liftable[$liftedTpe]" else ""
+ val advice =
+ if (isBottomType(iterableType)) "bottom type values often indicate programmer mistake"
+ else "consider " + List(cardSuggestion, liftSuggestion).filter(_ != "").mkString(" or ")
+ c.abort(splicee.pos, s"Can't $action, $advice")
}
- object IterableTreeType extends HoleTypeExtractor {
- def preprocessor(tpe: Type) = iterator(tpe)(identity)
- def location(tpe: Type) = {
- val (card, elementTpe) = parseCardinality(tpe)
- if (card != NoDot && elementTpe <:< treeType) Some(IterableLocation(card, TreeLocation(elementTpe)))
- else None
- }
+ protected def lifted(tpe: Type)(tree: Tree): Tree = {
+ val lifter = inferLiftable(tpe)
+ assert(lifter != EmptyTree, s"couldnt find a liftable for $tpe")
+ val lifted = Apply(lifter, List(tree))
+ val targetType = Select(u, tpnme.Tree)
+ atPos(tree.pos)(TypeApply(Select(lifted, nme.asInstanceOf_), List(targetType)))
}
- object IterableLiftableType extends HoleTypeExtractor {
- def preprocessor(tpe: Type) = {
- val (_, elementTpe) = parseCardinality(tpe)
- for {
- lifter <- this.lifter(elementTpe)
- iterator <- this.iterator(tpe)(lifter)
- } yield iterator
+ protected def iterated(card: Cardinality, tpe: Type, elementTransform: Tree => Tree = identity)(tree: Tree): Tree = {
+ assert(card != NoDot)
+ def reifyIterable(tree: Tree, n: Cardinality): Tree = {
+ def loop(tree: Tree, n: Cardinality): Tree =
+ if (n == NoDot) elementTransform(tree)
+ else {
+ val x: TermName = c.freshName()
+ val wrapped = reifyIterable(Ident(x), n.pred)
+ val xToWrapped = Function(List(ValDef(Modifiers(PARAM), x, TypeTree(), EmptyTree)), wrapped)
+ Select(Apply(Select(tree, nme.map), List(xToWrapped)), nme.toList)
+ }
+ if (tree.tpe != null && (tree.tpe <:< listTreeType || tree.tpe <:< listListTreeType)) tree
+ else atPos(tree.pos)(loop(tree, n))
}
- def location(tpe: Type) = Some(IterableLocation(cardinality(tpe), TreeLocation(treeType)))
+ reifyIterable(tree, card)
}
}
- /** Hole encapsulates information about splices in quasiquotes.
- * It packs together a cardinality of a splice, a splicee (possibly preprocessed)
- * and the description of the location in Scala syntax where the splicee can be spliced.
- * This is the third pillar of modularity in the quasiquote reifier.
- */
- case class Hole(tree: Tree, location: Location, cardinality: Cardinality)
-
- object Hole {
- def apply(splicee: Tree, holeCard: Cardinality): Hole = {
- if (method == nme.unapply) return new Hole(splicee, UnknownLocation, holeCard)
- val (spliceeCard, elementTpe) = parseCardinality(splicee.tpe)
- def cantSplice() = {
- val holeCardMsg = if (holeCard != NoDot) s" with $holeCard" else ""
- val action = "splice " + splicee.tpe + holeCardMsg
- val suggestCard = holeCard != spliceeCard || holeCard != NoDot
- val spliceeCardMsg = if (holeCard != spliceeCard && spliceeCard != NoDot) s"using $spliceeCard" else "omitting the dots"
- val cardSuggestion = if (suggestCard) spliceeCardMsg else ""
- def canBeLifted(tpe: Type) = HoleType.LiftableType.unapply(tpe).nonEmpty
- val suggestLifting = (holeCard == NoDot || spliceeCard != NoDot) && !(elementTpe <:< treeType) && !canBeLifted(elementTpe)
- val liftedTpe = if (holeCard != NoDot) elementTpe else splicee.tpe
- val liftSuggestion = if (suggestLifting) s"providing an implicit instance of Liftable[$liftedTpe]" else ""
- val advice = List(cardSuggestion, liftSuggestion).filter(_ != "").mkString(" or ")
- c.abort(splicee.pos, s"Can't $action, consider $advice")
- }
- val holeTpe = splicee.tpe match {
- case _ if holeCard != spliceeCard => cantSplice()
- case HoleType(holeTpe) => holeTpe
- case _ => cantSplice()
- }
- holeTpe.makeHole(splicee)
+ class UnapplyHole(val cardinality: Cardinality, pat: Tree) extends Hole {
+ val (placeholderName, pos, tptopt) = pat match {
+ case Bind(pname, inner @ Bind(_, Typed(Ident(nme.WILDCARD), tpt))) => (pname, inner.pos, Some(tpt))
+ case Bind(pname, inner @ Typed(Ident(nme.WILDCARD), tpt)) => (pname, inner.pos, Some(tpt))
+ case Bind(pname, inner) => (pname, inner.pos, None)
}
+ val treeNoUnlift = Bind(placeholderName, Ident(nme.WILDCARD))
+ lazy val tree =
+ tptopt.map { tpt =>
+ val TypeDef(_, _, _, typedTpt) =
+ try c.typeCheck(TypeDef(NoMods, TypeName("T"), Nil, tpt))
+ catch { case TypecheckException(pos, msg) => c.abort(pos.asInstanceOf[c.Position], msg) }
+ val tpe = typedTpt.tpe
+ val (iterableCard, _) = stripIterable(tpe)
+ if (iterableCard.value < cardinality.value)
+ c.abort(pat.pos, s"Can't extract $tpe with $cardinality, consider using $iterableCard")
+ val (_, strippedTpe) = stripIterable(tpe, limit = Some(cardinality))
+ if (strippedTpe <:< treeType) treeNoUnlift
+ else
+ unlifters.spawn(strippedTpe, cardinality).map {
+ Apply(_, treeNoUnlift :: Nil)
+ }.getOrElse {
+ c.abort(pat.pos, s"Can't find $unliftableType[$strippedTpe], consider providing it")
+ }
+ }.getOrElse { treeNoUnlift }
}
- def parseCardinality(tpe: Type): (Cardinality, Type) = {
- if (tpe != null && isIterableType(tpe)) {
- val (card, innerTpe) = parseCardinality(tpe.typeArguments.head)
- (card.succ, innerTpe)
- } else (NoDot, tpe)
+ /** Full support for unliftable implies that it's possible to interleave
+ * deconstruction with higher cardinality and unlifting of the values.
+ * In particular extraction of List[Tree] as List[T: Unliftable] requires
+ * helper extractors that would do the job: UnliftHelper1[T]. Similarly
+ * List[List[Tree]] needs UnliftHelper2[T].
+ *
+ * See also "unlift list" tests in UnapplyProps.scala
+ */
+ object unlifters {
+ private var records = List.empty[(Type, Cardinality)]
+ // Request an UnliftHelperN[T] where n == card and T == tpe.
+ // If card == 0 then helper is not needed and plain instance
+ // of unliftable is returned.
+ def spawn(tpe: Type, card: Cardinality): Option[Tree] = {
+ val unlifter = inferUnliftable(tpe)
+ if (unlifter == EmptyTree) None
+ else if (card == NoDot) Some(unlifter)
+ else {
+ val idx = records.indexWhere { p => p._1 =:= tpe && p._2 == card }
+ val resIdx = if (idx != -1) idx else { records +:= (tpe, card); records.length - 1}
+ Some(Ident(TermName(nme.QUASIQUOTE_UNLIFT_HELPER + resIdx)))
+ }
+ }
+ // Returns a list of vals that will defined required unlifters
+ def preamble(): List[Tree] =
+ records.zipWithIndex.map { case ((tpe, card), idx) =>
+ val name = TermName(nme.QUASIQUOTE_UNLIFT_HELPER + idx)
+ val helperName = card match { case DotDot => nme.UnliftHelper1 case DotDotDot => nme.UnliftHelper2 }
+ val lifter = inferUnliftable(tpe)
+ assert(helperName.isTermName)
+ // q"val $name: $u.build.${helperName.toTypeName} = $u.build.$helperName($lifter)"
+ ValDef(NoMods, name,
+ AppliedTypeTree(Select(Select(u, nme.build), helperName.toTypeName), List(TypeTree(tpe))),
+ Apply(Select(Select(u, nme.build), helperName), lifter :: Nil))
+ }
}
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
index 126c14ac81..6e6b617e5c 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
@@ -161,7 +161,12 @@ trait Parsers { self: Quasiquotes =>
}
object TermParser extends Parser {
- def entryPoint = { parser => gen.mkTreeOrBlock(parser.templateOrTopStatSeq()) }
+ def entryPoint = { parser =>
+ parser.templateOrTopStatSeq() match {
+ case head :: Nil => Block(Nil, head)
+ case lst => gen.mkTreeOrBlock(lst)
+ }
+ }
}
object TypeParser extends Parser {
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala b/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala
index 54be9123c7..bdb44ad9a2 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala
@@ -13,6 +13,7 @@ import scala.collection.{immutable, mutable}
trait Placeholders { self: Quasiquotes =>
import global._
import Cardinality._
+ import universeTypes._
// Step 1: Transform Scala source with holes into vanilla Scala source
@@ -32,13 +33,17 @@ trait Placeholders { self: Quasiquotes =>
def appendHole(tree: Tree, cardinality: Cardinality) = {
val placeholderName = c.freshName(TermName(nme.QUASIQUOTE_PREFIX + sessionSuffix))
sb.append(placeholderName)
- val holeTree = if (method == nme.unapply) Bind(placeholderName, Ident(nme.WILDCARD)) else tree
- holeMap(placeholderName) = Hole(holeTree, cardinality)
+ val holeTree =
+ if (method != nme.unapply) tree
+ else Bind(placeholderName, tree)
+ holeMap(placeholderName) = Hole(cardinality, holeTree)
}
val iargs = method match {
case nme.apply => args
- case nme.unapply => List.fill(parts.length - 1)(EmptyTree)
+ case nme.unapply =>
+ val (dummy @ Ident(nme.SELECTOR_DUMMY)) :: Nil = args
+ dummy.attachments.get[SubpatternsAttachment].get.patterns
case _ => global.abort("unreachable")
}
@@ -78,9 +83,9 @@ trait Placeholders { self: Quasiquotes =>
trait HolePlaceholder {
def matching: PartialFunction[Any, Name]
- def unapply(scrutinee: Any): Option[(Tree, Location, Cardinality)] = {
+ def unapply(scrutinee: Any): Option[Hole] = {
val name = matching.lift(scrutinee)
- name.flatMap { holeMap.get(_).map { case Hole(repr, loc, card) => (repr, loc, card) } }
+ name.flatMap { holeMap.get(_) }
}
}
@@ -128,44 +133,44 @@ trait Placeholders { self: Quasiquotes =>
}
object SymbolPlaceholder {
- def unapply(scrutinee: Any): Option[Tree] = scrutinee match {
- case Placeholder(tree, SymbolLocation, _) => Some(tree)
+ def unapply(scrutinee: Any): Option[Hole] = scrutinee match {
+ case Placeholder(hole: ApplyHole) if hole.tpe <:< symbolType => Some(hole)
case _ => None
}
}
object CasePlaceholder {
- def unapply(tree: Tree): Option[(Tree, Location, Cardinality)] = tree match {
- case CaseDef(Apply(Ident(nme.QUASIQUOTE_CASE), List(Placeholder(tree, location, card))), EmptyTree, EmptyTree) => Some((tree, location, card))
+ def unapply(tree: Tree): Option[Hole] = tree match {
+ case CaseDef(Apply(Ident(nme.QUASIQUOTE_CASE), List(Placeholder(hole))), EmptyTree, EmptyTree) => Some(hole)
case _ => None
}
}
object RefineStatPlaceholder {
- def unapply(tree: Tree): Option[(Tree, Location, Cardinality)] = tree match {
- case ValDef(_, Placeholder(tree, location, card), Ident(tpnme.QUASIQUOTE_REFINE_STAT), _) => Some((tree, location, card))
+ def unapply(tree: Tree): Option[Hole] = tree match {
+ case ValDef(_, Placeholder(hole), Ident(tpnme.QUASIQUOTE_REFINE_STAT), _) => Some(hole)
case _ => None
}
}
object EarlyDefPlaceholder {
- def unapply(tree: Tree): Option[(Tree, Location, Cardinality)] = tree match {
- case ValDef(_, Placeholder(tree, location, card), Ident(tpnme.QUASIQUOTE_EARLY_DEF), _) => Some((tree, location, card))
+ def unapply(tree: Tree): Option[Hole] = tree match {
+ case ValDef(_, Placeholder(hole), Ident(tpnme.QUASIQUOTE_EARLY_DEF), _) => Some(hole)
case _ => None
}
}
object PackageStatPlaceholder {
- def unapply(tree: Tree): Option[(Tree, Location, Cardinality)] = tree match {
- case ValDef(NoMods, Placeholder(tree, location, card), Ident(tpnme.QUASIQUOTE_PACKAGE_STAT), EmptyTree) => Some((tree, location, card))
+ def unapply(tree: Tree): Option[Hole] = tree match {
+ case ValDef(NoMods, Placeholder(hole), Ident(tpnme.QUASIQUOTE_PACKAGE_STAT), EmptyTree) => Some(hole)
case _ => None
}
}
object ForEnumPlaceholder {
- def unapply(tree: Tree): Option[(Tree, Location, Cardinality)] = tree match {
- case build.SyntacticValFrom(Bind(Placeholder(tree, location, card), Ident(nme.WILDCARD)), Ident(nme.QUASIQUOTE_FOR_ENUM)) =>
- Some((tree, location, card))
+ def unapply(tree: Tree): Option[Hole] = tree match {
+ case build.SyntacticValFrom(Bind(Placeholder(hole), Ident(nme.WILDCARD)), Ident(nme.QUASIQUOTE_FOR_ENUM)) =>
+ Some(hole)
case _ => None
}
}
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
index b28c85cfc2..87ab52414c 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
@@ -13,7 +13,7 @@ trait Reifiers { self: Quasiquotes =>
import Cardinality._
import universeTypes._
- abstract class Reifier extends {
+ abstract class Reifier(val isReifyingExpressions: Boolean) extends {
val global: self.global.type = self.global
val universe = self.universe
val reifee = EmptyTree
@@ -22,7 +22,6 @@ trait Reifiers { self: Quasiquotes =>
} with ReflectReifier {
lazy val typer = throw new UnsupportedOperationException
- def isReifyingExpressions: Boolean
def isReifyingPatterns: Boolean = !isReifyingExpressions
def action = if (isReifyingExpressions) "splice" else "extract"
def holesHaveTypes = isReifyingExpressions
@@ -33,8 +32,16 @@ trait Reifiers { self: Quasiquotes =>
var nameMap = collection.mutable.HashMap.empty[Name, Set[TermName]].withDefault { _ => Set() }
/** Wraps expressions into:
- * a sequence of nested withFreshTermName/withFreshTypeName calls which are required
- * to force regeneration of randomly generated names on every evaluation of quasiquote.
+ * a block which starts with a sequence of vals that correspond
+ * to fresh names that has to be created at evaluation of the quasiquote
+ * and ends with reified tree:
+ *
+ * {
+ * val name$1: universe.TermName = universe.build.freshTermName(prefix1)
+ * ...
+ * val name$N: universe.TermName = universe.build.freshTermName(prefixN)
+ * tree
+ * }
*
* Wraps patterns into:
* a call into anonymous class' unapply method required by unapply macro expansion:
@@ -51,15 +58,18 @@ trait Reifiers { self: Quasiquotes =>
*/
def wrap(tree: Tree) =
if (isReifyingExpressions) {
- nameMap.foldLeft(tree) {
- case (t, (origname, names)) =>
+ val freshdefs = nameMap.iterator.map {
+ case (origname, names) =>
assert(names.size == 1)
val FreshName(prefix) = origname
- val ctor = TermName("withFresh" + (if (origname.isTermName) "TermName" else "TypeName"))
- // q"$u.build.$ctor($prefix) { ${names.head} => $t }"
- Apply(Apply(Select(Select(u, nme.build), ctor), List(Literal(Constant(prefix)))),
- List(Function(List(ValDef(Modifiers(PARAM), names.head, TypeTree(), EmptyTree)), t)))
- }
+ val nameTypeName = if (origname.isTermName) tpnme.TermName else tpnme.TypeName
+ val freshName = if (origname.isTermName) nme.freshTermName else nme.freshTypeName
+ // q"val ${names.head}: $u.$nameTypeName = $u.build.$freshName($prefix)"
+ ValDef(NoMods, names.head, Select(u, nameTypeName),
+ Apply(Select(Select(u, nme.build), freshName), Literal(Constant(prefix)) :: Nil))
+ }.toList
+ // q"..$freshdefs; $tree"
+ SyntacticBlock(freshdefs :+ tree)
} else {
val freevars = holeMap.toList.map { case (name, _) => Ident(name) }
val isVarPattern = tree match { case Bind(name, Ident(nme.WILDCARD)) => true case _ => false }
@@ -94,12 +104,12 @@ trait Reifiers { self: Quasiquotes =>
// cq"$tree if $guard => $succ" :: cq"_ => $fail" :: Nil
CaseDef(tree, guard, succ) :: CaseDef(Ident(nme.WILDCARD), EmptyTree, fail) :: Nil
}
- // q"new { def unapply(tree: $AnyClass) = tree match { case ..$cases } }.unapply(..$args)"
+ // q"new { def unapply(tree: $AnyClass) = { ..${unlifters.preamble()}; tree match { case ..$cases } } }.unapply(..$args)"
Apply(
Select(
SyntacticNew(Nil, Nil, noSelfType, List(
DefDef(NoMods, nme.unapply, Nil, List(List(ValDef(NoMods, nme.tree, TypeTree(AnyClass.toType), EmptyTree))), TypeTree(),
- Match(Ident(nme.tree), cases)))),
+ SyntacticBlock(unlifters.preamble() :+ Match(Ident(nme.tree), cases))))),
nme.unapply),
args)
}
@@ -107,7 +117,7 @@ trait Reifiers { self: Quasiquotes =>
def reifyFillingHoles(tree: Tree): Tree = {
val reified = reifyTree(tree)
holeMap.unused.foreach { hole =>
- c.abort(holeMap(hole).tree.pos, s"Don't know how to $action here")
+ c.abort(holeMap(hole).pos, s"Don't know how to $action here")
}
wrap(reified)
}
@@ -117,21 +127,27 @@ trait Reifiers { self: Quasiquotes =>
reifyTreeSyntactically(tree)
def reifyTreePlaceholder(tree: Tree): Tree = tree match {
- case Placeholder(tree, TreeLocation(_), _) if isReifyingExpressions => tree
- case Placeholder(tree, _, NoDot) if isReifyingPatterns => tree
- case Placeholder(tree, _, card @ Dot()) => c.abort(tree.pos, s"Can't $action with $card here")
+ case Placeholder(hole: ApplyHole) if hole.tpe <:< treeType => hole.tree
+ case Placeholder(Hole(tree, NoDot)) if isReifyingPatterns => tree
+ case Placeholder(hole @ Hole(_, card @ Dot())) => c.abort(hole.pos, s"Can't $action with $card here")
case TuplePlaceholder(args) => reifyTuple(args)
case TupleTypePlaceholder(args) => reifyTupleType(args)
case FunctionTypePlaceholder(argtpes, restpe) => reifyFunctionType(argtpes, restpe)
- case CasePlaceholder(tree, location, _) => reifyCase(tree, location)
- case RefineStatPlaceholder(tree, _, _) => reifyRefineStat(tree)
- case EarlyDefPlaceholder(tree, _, _) => reifyEarlyDef(tree)
- case PackageStatPlaceholder(tree, _, _) => reifyPackageStat(tree)
- case ForEnumPlaceholder(tree, _, _) => tree
+ case CasePlaceholder(hole) => hole.tree
+ case RefineStatPlaceholder(hole) => reifyRefineStat(hole)
+ case EarlyDefPlaceholder(hole) => reifyEarlyDef(hole)
+ case PackageStatPlaceholder(hole) => reifyPackageStat(hole)
+ // for enumerators are checked not during splicing but during
+ // desugaring of the for loop in SyntacticFor & SyntacticForYield
+ case ForEnumPlaceholder(hole) => hole.tree
case _ => EmptyTree
}
override def reifyTreeSyntactically(tree: Tree) = tree match {
+ case RefTree(qual, SymbolPlaceholder(Hole(tree, _))) if isReifyingExpressions =>
+ mirrorBuildCall(nme.RefTree, reify(qual), tree)
+ case This(SymbolPlaceholder(Hole(tree, _))) if isReifyingExpressions =>
+ mirrorCall(nme.This, tree)
case SyntacticTraitDef(mods, name, tparams, earlyDefs, parents, selfdef, body) =>
reifyBuildCall(nme.SyntacticTraitDef, mods, name, tparams, earlyDefs, parents, selfdef, body)
case SyntacticClassDef(mods, name, tparams, constrmods, vparamss, earlyDefs, parents, selfdef, body) =>
@@ -161,17 +177,24 @@ trait Reifiers { self: Quasiquotes =>
reifyBuildCall(nme.SyntacticForYield, enums, body)
case SyntacticAssign(lhs, rhs) =>
reifyBuildCall(nme.SyntacticAssign, lhs, rhs)
- case SyntacticApplied(fun, List(args))
- if args.forall { case Placeholder(_, _, DotDotDot) => false case _ => true } =>
- reifyBuildCall(nme.SyntacticApply, fun, args)
case SyntacticApplied(fun, argss) if argss.nonEmpty =>
reifyBuildCall(nme.SyntacticApplied, fun, argss)
case SyntacticTypeApplied(fun, targs) if targs.nonEmpty =>
reifyBuildCall(nme.SyntacticTypeApplied, fun, targs)
case SyntacticFunction(args, body) =>
reifyBuildCall(nme.SyntacticFunction, args, body)
+ case SyntacticIdent(name, isBackquoted) =>
+ reifyBuildCall(nme.SyntacticIdent, name, isBackquoted)
+ case Block(Nil, Placeholder(Hole(tree, DotDot))) =>
+ mirrorBuildCall(nme.SyntacticBlock, tree)
+ case Block(Nil, other) =>
+ reifyTree(other)
case Block(stats, last) =>
reifyBuildCall(nme.SyntacticBlock, stats :+ last)
+ case Try(block, catches, finalizer) =>
+ reifyBuildCall(nme.SyntacticTry, block, catches, finalizer)
+ case Match(selector, cases) =>
+ reifyBuildCall(nme.SyntacticMatch, selector, cases)
// parser emits trees with scala package symbol to ensure
// that some names hygienically point to various scala package
// members; we need to preserve this symbol to preserve
@@ -183,9 +206,10 @@ trait Reifiers { self: Quasiquotes =>
}
override def reifyName(name: Name): Tree = name match {
- case Placeholder(tree, location, _) =>
- if (holesHaveTypes && !(location.tpe <:< nameType)) c.abort(tree.pos, s"$nameType expected but ${location.tpe} found")
- tree
+ case Placeholder(hole: ApplyHole) =>
+ if (!(hole.tpe <:< nameType)) c.abort(hole.pos, s"$nameType expected but ${hole.tpe} found")
+ hole.tree
+ case Placeholder(hole: UnapplyHole) => hole.treeNoUnlift
case FreshName(prefix) if prefix != nme.QUASIQUOTE_NAME_PREFIX =>
def fresh() = c.freshName[TermName](nme.QUASIQUOTE_NAME_PREFIX)
def introduceName() = { val n = fresh(); nameMap(name) += n; n}
@@ -196,15 +220,10 @@ trait Reifiers { self: Quasiquotes =>
super.reifyName(name)
}
- def reifyCase(tree: Tree, location: Location) = {
- if (holesHaveTypes && !(location.tpe <:< caseDefType)) c.abort(tree.pos, s"$caseDefType expected but ${location.tpe} found")
- tree
- }
-
def reifyTuple(args: List[Tree]) = args match {
case Nil => reify(Literal(Constant(())))
- case List(hole @ Placeholder(_, _, NoDot)) => reify(hole)
- case List(Placeholder(_, _, _)) => reifyBuildCall(nme.SyntacticTuple, args)
+ case List(hole @ Placeholder(Hole(_, NoDot))) => reify(hole)
+ case List(Placeholder(_)) => reifyBuildCall(nme.SyntacticTuple, args)
// in a case we only have one element tuple without
// any cardinality annotations this means that this is
// just an expression wrapped in parentheses
@@ -214,8 +233,8 @@ trait Reifiers { self: Quasiquotes =>
def reifyTupleType(args: List[Tree]) = args match {
case Nil => reify(Select(Ident(nme.scala_), tpnme.Unit))
- case List(hole @ Placeholder(_, _, NoDot)) => reify(hole)
- case List(Placeholder(_, _, _)) => reifyBuildCall(nme.SyntacticTupleType, args)
+ case List(hole @ Placeholder(Hole(_, NoDot))) => reify(hole)
+ case List(Placeholder(_)) => reifyBuildCall(nme.SyntacticTupleType, args)
case List(other) => reify(other)
case _ => reifyBuildCall(nme.SyntacticTupleType, args)
}
@@ -223,13 +242,18 @@ trait Reifiers { self: Quasiquotes =>
def reifyFunctionType(argtpes: List[Tree], restpe: Tree) =
reifyBuildCall(nme.SyntacticFunctionType, argtpes, restpe)
- def reifyRefineStat(tree: Tree) = tree
+ def reifyConstructionCheck(name: TermName, hole: Hole) = hole match {
+ case _: UnapplyHole => hole.tree
+ case _: ApplyHole => mirrorBuildCall(name, hole.tree)
+ }
+
+ def reifyRefineStat(hole: Hole) = reifyConstructionCheck(nme.mkRefineStat, hole)
- def reifyEarlyDef(tree: Tree) = tree
+ def reifyEarlyDef(hole: Hole) = reifyConstructionCheck(nme.mkEarlyDef, hole)
- def reifyAnnotation(tree: Tree) = tree
+ def reifyAnnotation(hole: Hole) = reifyConstructionCheck(nme.mkAnnotation, hole)
- def reifyPackageStat(tree: Tree) = tree
+ def reifyPackageStat(hole: Hole) = reifyConstructionCheck(nme.mkPackageStat, hole)
/** Splits list into a list of groups where subsequent elements are considered
* similar by the corresponding function.
@@ -262,7 +286,7 @@ trait Reifiers { self: Quasiquotes =>
*
* reifyMultiCardinalityList(lst) {
* // first we define patterns that extract high-cardinality holeMap (currently ..)
- * case Placeholder(CorrespondsTo(tree, tpe)) if tpe <:< iterableTreeType => tree
+ * case Placeholder(IterableType(_, _)) => tree
* } {
* // in the end we define how single elements are reified, typically with default reify call
* reify(_)
@@ -281,21 +305,22 @@ trait Reifiers { self: Quasiquotes =>
* elements.
*/
override def reifyList(xs: List[Any]): Tree = reifyMultiCardinalityList(xs) {
- case Placeholder(tree, _, DotDot) => tree
- case CasePlaceholder(tree, _, DotDot) => tree
- case RefineStatPlaceholder(tree, _, DotDot) => reifyRefineStat(tree)
- case EarlyDefPlaceholder(tree, _, DotDot) => reifyEarlyDef(tree)
- case PackageStatPlaceholder(tree, _, DotDot) => reifyPackageStat(tree)
- case ForEnumPlaceholder(tree, _, DotDot) => tree
- case List(Placeholder(tree, _, DotDotDot)) => tree
+ case Placeholder(Hole(tree, DotDot)) => tree
+ case CasePlaceholder(Hole(tree, DotDot)) => tree
+ case RefineStatPlaceholder(h @ Hole(_, DotDot)) => reifyRefineStat(h)
+ case EarlyDefPlaceholder(h @ Hole(_, DotDot)) => reifyEarlyDef(h)
+ case PackageStatPlaceholder(h @ Hole(_, DotDot)) => reifyPackageStat(h)
+ case ForEnumPlaceholder(Hole(tree, DotDot)) => tree
+ case List(Placeholder(Hole(tree, DotDotDot))) => tree
} {
reify(_)
}
def reifyAnnotList(annots: List[Tree]): Tree = reifyMultiCardinalityList(annots) {
- case AnnotPlaceholder(tree, _, DotDot) => reifyAnnotation(tree)
+ case AnnotPlaceholder(h @ Hole(_, DotDot)) => reifyAnnotation(h)
} {
- case AnnotPlaceholder(tree, UnknownLocation | TreeLocation(_), NoDot) => reifyAnnotation(tree)
+ case AnnotPlaceholder(h: ApplyHole) if h.tpe <:< treeType => reifyAnnotation(h)
+ case AnnotPlaceholder(h: UnapplyHole) if h.cardinality == NoDot => reifyAnnotation(h)
case other => reify(other)
}
@@ -321,78 +346,55 @@ trait Reifiers { self: Quasiquotes =>
override def mirrorBuildCall(name: TermName, args: Tree*): Tree =
Apply(Select(Select(universe, nme.build), name), args.toList)
- }
-
- class ApplyReifier extends Reifier {
- def isReifyingExpressions = true
- override def reifyTreeSyntactically(tree: Tree): Tree = tree match {
- case RefTree(qual, SymbolPlaceholder(tree)) =>
- mirrorBuildCall(nme.RefTree, reify(qual), tree)
- case This(SymbolPlaceholder(tree)) =>
- mirrorCall(nme.This, tree)
- case _ =>
- super.reifyTreeSyntactically(tree)
- }
+ override def scalaFactoryCall(name: String, args: Tree*): Tree =
+ call("scala." + name, args: _*)
+ }
- override def reifyMultiCardinalityList[T](xs: List[T])(fill: PartialFunction[T, Tree])(fallback: T => Tree): Tree = xs match {
- case Nil => mkList(Nil)
- case _ =>
+ class ApplyReifier extends Reifier(isReifyingExpressions = true) {
+ def reifyMultiCardinalityList[T](xs: List[T])(fill: PartialFunction[T, Tree])(fallback: T => Tree): Tree =
+ if (xs.isEmpty) mkList(Nil)
+ else {
def reifyGroup(group: List[T]): Tree = group match {
case List(elem) if fill.isDefinedAt(elem) => fill(elem)
case elems => mkList(elems.map(fallback))
}
val head :: tail = group(xs) { (a, b) => !fill.isDefinedAt(a) && !fill.isDefinedAt(b) }
tail.foldLeft[Tree](reifyGroup(head)) { (tree, lst) => Apply(Select(tree, nme.PLUSPLUS), List(reifyGroup(lst))) }
- }
+ }
override def reifyModifiers(m: Modifiers) =
if (m == NoMods) super.reifyModifiers(m)
else {
val (modsPlaceholders, annots) = m.annotations.partition {
- case ModsPlaceholder(_, _, _) => true
+ case ModsPlaceholder(_) => true
case _ => false
}
val (mods, flags) = modsPlaceholders.map {
- case ModsPlaceholder(tree, location, card) => (tree, location)
- }.partition { case (tree, location) =>
- location match {
- case ModsLocation => true
- case FlagsLocation => false
- case _ => c.abort(tree.pos, s"$flagsType or $modsType expected but ${tree.tpe} found")
- }
+ case ModsPlaceholder(hole: ApplyHole) => hole
+ }.partition { hole =>
+ if (hole.tpe <:< modsType) true
+ else if (hole.tpe <:< flagsType) false
+ else c.abort(hole.pos, s"$flagsType or $modsType expected but ${hole.tpe} found")
}
mods match {
- case (tree, _) :: Nil =>
- if (flags.nonEmpty) c.abort(flags(0)._1.pos, "Can't splice flags together with modifiers, consider merging flags into modifiers")
- if (annots.nonEmpty) c.abort(tree.pos, "Can't splice modifiers together with annotations, consider merging annotations into modifiers")
- ensureNoExplicitFlags(m, tree.pos)
- tree
- case _ :: (second, _) :: Nil =>
- c.abort(second.pos, "Can't splice multiple modifiers, consider merging them into a single modifiers instance")
+ case hole :: Nil =>
+ if (flags.nonEmpty) c.abort(flags(0).pos, "Can't splice flags together with modifiers, consider merging flags into modifiers")
+ if (annots.nonEmpty) c.abort(hole.pos, "Can't splice modifiers together with annotations, consider merging annotations into modifiers")
+ ensureNoExplicitFlags(m, hole.pos)
+ hole.tree
+ case _ :: hole :: Nil =>
+ c.abort(hole.pos, "Can't splice multiple modifiers, consider merging them into a single modifiers instance")
case _ =>
val baseFlags = reifyFlags(m.flags)
- val reifiedFlags = flags.foldLeft[Tree](baseFlags) { case (flag, (tree, _)) => Apply(Select(flag, nme.OR), List(tree)) }
+ val reifiedFlags = flags.foldLeft[Tree](baseFlags) { case (flag, hole) => Apply(Select(flag, nme.OR), List(hole.tree)) }
mirrorFactoryCall(nme.Modifiers, reifiedFlags, reify(m.privateWithin), reifyAnnotList(annots))
}
}
- override def reifyRefineStat(tree: Tree) = mirrorBuildCall(nme.mkRefineStat, tree)
-
- override def reifyEarlyDef(tree: Tree) = mirrorBuildCall(nme.mkEarlyDef, tree)
-
- override def reifyAnnotation(tree: Tree) = mirrorBuildCall(nme.mkAnnotation, tree)
-
- override def reifyPackageStat(tree: Tree) = mirrorBuildCall(nme.mkPackageStat, tree)
}
-
- class UnapplyReifier extends Reifier {
- def isReifyingExpressions = false
-
- override def scalaFactoryCall(name: String, args: Tree*): Tree =
- call("scala." + name, args: _*)
-
- override def reifyMultiCardinalityList[T](xs: List[T])(fill: PartialFunction[T, Tree])(fallback: T => Tree) = xs match {
+ class UnapplyReifier extends Reifier(isReifyingExpressions = false) {
+ def reifyMultiCardinalityList[T](xs: List[T])(fill: PartialFunction[T, Tree])(fallback: T => Tree): Tree = xs match {
case init :+ last if fill.isDefinedAt(last) =>
init.foldRight[Tree](fill(last)) { (el, rest) =>
val cons = Select(Select(Select(Ident(nme.scala_), nme.collection), nme.immutable), nme.CONS)
@@ -405,14 +407,14 @@ trait Reifiers { self: Quasiquotes =>
override def reifyModifiers(m: Modifiers) =
if (m == NoMods) super.reifyModifiers(m)
else {
- val mods = m.annotations.collect { case ModsPlaceholder(tree, _, _) => tree }
+ val mods = m.annotations.collect { case ModsPlaceholder(hole: UnapplyHole) => hole }
mods match {
- case tree :: Nil =>
- if (m.annotations.length != 1) c.abort(tree.pos, "Can't extract modifiers together with annotations, consider extracting just modifiers")
- ensureNoExplicitFlags(m, tree.pos)
- tree
- case _ :: second :: rest =>
- c.abort(second.pos, "Can't extract multiple modifiers together, consider extracting a single modifiers instance")
+ case hole :: Nil =>
+ if (m.annotations.length != 1) c.abort(hole.pos, "Can't extract modifiers together with annotations, consider extracting just modifiers")
+ ensureNoExplicitFlags(m, hole.pos)
+ hole.treeNoUnlift
+ case _ :: hole :: _ =>
+ c.abort(hole.pos, "Can't extract multiple modifiers together, consider extracting a single modifiers instance")
case Nil =>
mirrorFactoryCall(nme.Modifiers, reifyFlags(m.flags), reify(m.privateWithin), reifyAnnotList(m.annotations))
}
diff --git a/src/continuations/library/scala/util/continuations/ControlContext.scala b/src/continuations/library/scala/util/continuations/ControlContext.scala
deleted file mode 100644
index c196809da9..0000000000
--- a/src/continuations/library/scala/util/continuations/ControlContext.scala
+++ /dev/null
@@ -1,249 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2010-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util.continuations
-
-import scala.annotation.{ Annotation, StaticAnnotation, TypeConstraint }
-
-/** This annotation is used to mark a parameter as part of a continuation
- * context.
- *
- * The type `A @cpsParam[B,C]` is desugared to `ControlContext[A,B,C]` at compile
- * time.
- *
- * @tparam B The type of computation state after computation has executed, and
- * before control is returned to the shift.
- * @tparam C The eventual return type of this delimited compuation.
- * @see scala.util.continuations.ControlContext
- */
-class cpsParam[-B,+C] extends StaticAnnotation with TypeConstraint
-
-private class cpsSym[B] extends Annotation // implementation detail
-
-private class cpsSynth extends Annotation // implementation detail
-
-private class cpsPlus extends StaticAnnotation with TypeConstraint // implementation detail
-private class cpsMinus extends Annotation // implementation detail
-
-
-/**
- * This class represent a portion of computation that has a 'hole' in it. The
- * class has the ability to compute state up until a certain point where the
- * state has the `A` type. If this context is given a function of type
- * `A => B` to move the state to the `B` type, then the entire computation can
- * be completed resulting in a value of type `C`.
- *
- * An Example: {{{
- * val cc = new ControlContext[String, String, String](
- * fun = { (f: String=>String, err: Exception => String) =>
- * val updatedState =
- * try f("State")
- * catch {
- * case e: Exception => err(e)
- * }
- * updatedState + "-Complete!"
- * },
- * x = null.asIntanceOf[String]
- * }
- * cc.foreach(_ + "-Continued") // Results in "State-Continued-Complete!"
- * }}}
- *
- * This class is used to transform calls to `shift` in the `continuations`
- * package. Direct use and instantiation is possible, but usually reserved
- * for advanced cases.
- *
- *
- * A context may either be ''trivial'' or ''non-trivial''. A ''trivial''
- * context '''just''' has a state of type `A`. When completing the computation,
- * it's only necessary to use the function of type `A => B` directly against
- * the trivial value. A ''non-trivial'' value stores a computation '''around'''
- * the state transformation of type `A => B` and cannot be short-circuited.
- *
- * @param fun The captured computation so far. The type
- * `(A => B, Exception => B) => C` is a function where:
- * - The first parameter `A=>B` represents the computation defined against
- * the current state held in the ControlContext.
- * - The second parameter `Exception => B` represents a computation to
- * perform if an exception is thrown from the first parameter's computation.
- * - The return value is the result of the entire computation contained in this
- * `ControlContext`.
- * @param x The current state stored in this context. Allowed to be null if
- * the context is non-trivial.
- * @tparam A The type of the state currently held in the context.
- * @tparam B The type of the transformed state needed to complete this computation.
- * @tparam C The return type of the entire computation stored in this context.
- * @note `fun` and `x` are allowed to be `null`.
- * @see scala.util.continutations.shiftR
- */
-final class ControlContext[+A,-B,+C](val fun: (A => B, Exception => B) => C, val x: A) extends Serializable {
-
- /*
- final def map[A1](f: A => A1): ControlContext[A1,B,C] = {
- new ControlContext((k:(A1 => B)) => fun((x:A) => k(f(x))), null.asInstanceOf[A1])
- }
-
- final def flatMap[A1,B1<:B](f: (A => ControlContext[A1,B1,B])): ControlContext[A1,B1,C] = {
- new ControlContext((k:(A1 => B1)) => fun((x:A) => f(x).fun(k)))
- }
- */
-
- /**
- * Modifies the currently captured state in this `ControlContext`.
- * @tparam A1 The new type of state in this context.
- * @param f A transformation function on the current state of the `ControlContext`.
- * @return The new `ControlContext`.
- */
- @noinline final def map[A1](f: A => A1): ControlContext[A1,B,C] = {
- if (fun eq null)
- try {
- new ControlContext[A1,B,C](null, f(x)) // TODO: only alloc if f(x) != x
- } catch {
- case ex: Exception =>
- new ControlContext((k: A1 => B, thr: Exception => B) => thr(ex).asInstanceOf[C], null.asInstanceOf[A1])
- }
- else
- new ControlContext({ (k: A1 => B, thr: Exception => B) =>
- fun( { (x:A) =>
- var done = false
- try {
- val res = f(x)
- done = true
- k(res)
- } catch {
- case ex: Exception if !done =>
- thr(ex)
- }
- }, thr)
- }, null.asInstanceOf[A1])
- }
-
-
- // it would be nice if @inline would turn the trivial path into a tail call.
- // unfortunately it doesn't, so we do it ourselves in SelectiveCPSTransform
-
- /**
- * Maps and flattens this `ControlContext` with another `ControlContext` generated from the current state.
- * @note The resulting comuptation is still the type `C`.
- * @tparam A1 The new type of the contained state.
- * @tparam B1 The new type of the state after the stored continuation has executed.
- * @tparam C1 The result type of the nested `ControlContext`. Because the nested `ControlContext` is executed within
- * the outer `ControlContext`, this type must `>: B` so that the resulting nested computation can be fed through
- * the current continuation.
- * @param f A transformation function from the current state to a nested `ControlContext`.
- * @return The transformed `ControlContext`.
- */
- @noinline final def flatMap[A1,B1,C1<:B](f: (A => ControlContext[A1,B1,C1])): ControlContext[A1,B1,C] = {
- if (fun eq null)
- try {
- f(x).asInstanceOf[ControlContext[A1,B1,C]]
- } catch {
- case ex: Exception =>
- new ControlContext((k: A1 => B1, thr: Exception => B1) => thr(ex).asInstanceOf[C], null.asInstanceOf[A1])
- }
- else
- new ControlContext({ (k: A1 => B1, thr: Exception => B1) =>
- fun( { (x:A) =>
- var done = false
- try {
- val ctxR = f(x)
- done = true
- val res: C1 = ctxR.foreachFull(k, thr) // => B1
- res
- } catch {
- case ex: Exception if !done =>
- thr(ex).asInstanceOf[B] // => B NOTE: in general this is unsafe!
- } // However, the plugin will not generate offending code
- }, thr.asInstanceOf[Exception=>B]) // => B
- }, null.asInstanceOf[A1])
- }
-
- /**
- * Runs the computation against the state stored in this `ControlContext`.
- * @param f the computation that modifies the current state of the context.
- * @note This method could throw exceptions from the computations.
- */
- final def foreach(f: A => B) = foreachFull(f, throw _)
-
- def foreachFull(f: A => B, g: Exception => B): C = {
- if (fun eq null)
- f(x).asInstanceOf[C]
- else
- fun(f, g)
- }
-
- /** @return true if this context only stores a state value and not any deferred computation. */
- final def isTrivial = fun eq null
- /** @return The current state value. */
- final def getTrivialValue = x.asInstanceOf[A]
-
- // need filter or other functions?
-
- final def flatMapCatch[A1>:A,B1<:B,C1>:C<:B1](pf: PartialFunction[Exception, ControlContext[A1,B1,C1]]): ControlContext[A1,B1,C1] = { // called by codegen from SelectiveCPSTransform
- if (fun eq null)
- this
- else {
- val fun1 = (ret1: A1 => B1, thr1: Exception => B1) => {
- val thr: Exception => B1 = { t: Exception =>
- var captureExceptions = true
- try {
- if (pf.isDefinedAt(t)) {
- val cc1 = pf(t)
- captureExceptions = false
- cc1.foreachFull(ret1, thr1) // Throw => B
- } else {
- captureExceptions = false
- thr1(t) // Throw => B1
- }
- } catch {
- case t1: Exception if captureExceptions => thr1(t1) // => E2
- }
- }
- fun(ret1, thr)// fun(ret1, thr) // => B
- }
- new ControlContext(fun1, null.asInstanceOf[A1])
- }
- }
-
- final def mapFinally(f: () => Unit): ControlContext[A,B,C] = { // called in code generated by SelectiveCPSTransform
- if (fun eq null) {
- try {
- f()
- this
- } catch {
- case ex: Exception =>
- new ControlContext((k: A => B, thr: Exception => B) => thr(ex).asInstanceOf[C], null.asInstanceOf[A])
- }
- } else {
- val fun1 = (ret1: A => B, thr1: Exception => B) => {
- val ret: A => B = { x: A =>
- var captureExceptions = true
- try {
- f()
- captureExceptions = false
- ret1(x)
- } catch {
- case t1: Exception if captureExceptions => thr1(t1)
- }
- }
- val thr: Exception => B = { t: Exception =>
- var captureExceptions = true
- try {
- f()
- captureExceptions = false
- thr1(t)
- } catch {
- case t1: Exception if captureExceptions => thr1(t1)
- }
- }
- fun(ret, thr1)
- }
- new ControlContext(fun1, null.asInstanceOf[A])
- }
- }
-
-}
diff --git a/src/continuations/library/scala/util/continuations/package.scala b/src/continuations/library/scala/util/continuations/package.scala
deleted file mode 100644
index 573fae85e7..0000000000
--- a/src/continuations/library/scala/util/continuations/package.scala
+++ /dev/null
@@ -1,187 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2010-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util
-
-/* TODO: better documentation of return-type modification.
- * (Especially what means "Illegal answer type modification: ... andThen ...")
- */
-
-/**
- * Delimited continuations are a feature for modifying the usual control flow
- * of a program. To use continuations, provide the option `-P:continuations:enable`
- * to the Scala compiler or REPL to activate the compiler plugin.
- *
- * Below is an example of using continuations to suspend execution while awaiting
- * user input. Similar facilities are used in so-called continuation-based web frameworks.
- *
- * {{{
- * def go =
- * reset {
- * println("Welcome!")
- * val first = ask("Please give me a number")
- * val second = ask("Please enter another number")
- * printf("The sum of your numbers is: %d\n", first + second)
- * }
- * }}}
- *
- * The `reset` is provided by this package and delimits the extent of the
- * transformation. The `ask` is a function that will be defined below. Its
- * effect is to issue a prompt and then suspend execution awaiting user input.
- * Once the user provides an input value, execution of the suspended block
- * resumes.
- *
- * {{{
- * val sessions = new HashMap[UUID, Int=>Unit]
- * def ask(prompt: String): Int @cps[Unit] =
- * shift {
- * k: (Int => Unit) => {
- * val id = uuidGen
- * printf("%s\nrespond with: submit(0x%x, ...)\n", prompt, id)
- * sessions += id -> k
- * }
- * }
- * }}}
- *
- * The type of `ask` includes a `@cps` annotation which drives the transformation.
- * The type signature `Int @cps[Unit]` means that `ask` should be used in a
- * context requiring an `Int`, but actually it will suspend and return `Unit`.
- *
- * The computation leading up to the first `ask` is executed normally. The
- * remainder of the reset block is wrapped into a closure that is passed as
- * the parameter `k` to the `shift` function, which can then decide whether
- * and how to execute the continuation. In this example, the continuation is
- * stored in a sessions map for later execution. This continuation includes a
- * second call to `ask`, which is treated likewise once the execution resumes.
- *
- * <h2>CPS Annotation</h2>
- *
- * The aforementioned `@cps[A]` annotation is an alias for the more general
- * `@cpsParam[B,C]` where `B=C`. The type `A @cpsParam[B,C]` describes a term
- * which yields a value of type `A` within an evaluation context producing a
- * value of type `B`. After the CPS transformation, this return type is
- * modified to `C`.
- *
- * The `@cpsParam` annotations are introduced by `shift` blocks, and propagate
- * via the return types to the dynamically enclosing context. The propagation
- * stops upon reaching a `reset` block.
- */
-
-package object continuations {
-
- /** An annotation that denotes a type is part of a continuation context.
- * `@cps[A]` is shorthand for `cpsParam[A,A]`.
- * @tparam A The return type of the continuation context.
- */
- type cps[A] = cpsParam[A,A]
-
- /** An annotation that denotes a type is part of a side effecting continuation context.
- * `@suspendable` is shorthand notation for `@cpsParam[Unit,Unit]` or `@cps[Unit]`.
- */
- type suspendable = cps[Unit]
-
- /**
- * The `shift` function captures the remaining computation in a `reset` block
- * and passes it to a closure provided by the user.
- *
- * For example:
- * {{{
- * reset {
- * shift { (k: Int => Int) => k(5) } + 1
- * }
- * }}}
- *
- * In this example, `shift` is used in the expression `shift ... + 1`.
- * The compiler will alter this expression so that the call
- * to `shift` becomes a parameter to a function, creating something like:
- * {{{
- * { (k: Int => Int) => k(5) } apply { _ + 1 }
- * }}}
- * The result of this expression is 6.
- *
- * There can be more than one `shift` call in a `reset` block. Each call
- * to `shift` can alter the return type of expression within the reset block,
- * but will not change the return type of the entire `reset { block }`
- * expression.
- *
- * @param fun A function where
- * - The parameter is the remainder of computation within the current
- * `reset` block. This is passed as a function `A => B`.
- * - The return is the return value of the `ControlContext` which is
- * generated from this inversion.
- * @note Must be invoked in the context of a call to `reset` This context
- * may not be far up the stack, but a call to reset is needed to
- * eventually remove the `@cps` annotations from types.
- */
- def shift[A,B,C](fun: (A => B) => C): A @cpsParam[B,C] = {
- throw new NoSuchMethodException("this code has to be compiled with the Scala continuations plugin enabled")
- }
- /** Creates a context for continuations captured within the argument closure
- * of this `reset` call and returns the result of the entire transformed
- * computation. Within an expression of the form `reset { block }`,
- * the closure expression (`block`) will be modified such that at each
- * call to `shift` the remainder of the expression is transformed into a
- * function to be passed into the shift.
- * @return The result of a block of code that uses `shift` to capture continuations.
- */
- def reset[A,C](ctx: =>(A @cpsParam[A,C])): C = {
- val ctxR = reify[A,A,C](ctx)
- if (ctxR.isTrivial)
- ctxR.getTrivialValue.asInstanceOf[C]
- else
- ctxR.foreach((x:A) => x)
- }
-
- def reset0[A](ctx: =>(A @cpsParam[A,A])): A = reset(ctx)
-
- def run[A](ctx: =>(Any @cpsParam[Unit,A])): A = {
- val ctxR = reify[Any,Unit,A](ctx)
- if (ctxR.isTrivial)
- ctxR.getTrivialValue.asInstanceOf[A]
- else
- ctxR.foreach((x:Any) => ())
- }
-
-
- // methods below are primarily implementation details and are not
- // needed frequently in client code
-
- def shiftUnit0[A,B](x: A): A @cpsParam[B,B] = {
- shiftUnit[A,B,B](x)
- }
-
- def shiftUnit[A,B,C>:B](x: A): A @cpsParam[B,C] = {
- throw new NoSuchMethodException("this code has to be compiled with the Scala continuations plugin enabled")
- }
-
- /** This method converts from the sugared `A @cpsParam[B,C]` type to the desugared
- * `ControlContext[A,B,C]` type. The underlying data is not changed.
- */
- def reify[A,B,C](ctx: =>(A @cpsParam[B,C])): ControlContext[A,B,C] = {
- throw new NoSuchMethodException("this code has to be compiled with the Scala continuations plugin enabled")
- }
-
- def shiftUnitR[A,B](x: A): ControlContext[A,B,B] = { // called in code generated by SelectiveCPSTransform
- new ControlContext[A, B, B](null, x)
- }
-
- /**
- * Captures a computation into a `ControlContext`.
- * @param fun The function which accepts the inverted computation and returns
- * a final result.
- * @see shift
- */
- def shiftR[A,B,C](fun: (A => B) => C): ControlContext[A,B,C] = { // called in code generated by SelectiveCPSTransform
- new ControlContext((f:A=>B,g:Exception=>B) => fun(f), null.asInstanceOf[A])
- }
-
- def reifyR[A,B,C](ctx: => ControlContext[A,B,C]): ControlContext[A,B,C] = { // called in code generated by SelectiveCPSTransform
- ctx
- }
-
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala
deleted file mode 100644
index 3963447de3..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala
+++ /dev/null
@@ -1,520 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc.{ Global, Mode }
-import scala.tools.nsc.MissingRequirementError
-
-abstract class CPSAnnotationChecker extends CPSUtils {
- val global: Global
- import global._
- import analyzer.{AnalyzerPlugin, Typer}
- import definitions._
-
- //override val verbose = true
- @inline override final def vprintln(x: =>Any): Unit = if (verbose) println(x)
-
- /**
- * Checks whether @cps annotations conform
- */
- object checker extends AnnotationChecker {
- private[CPSAnnotationChecker] def addPlusMarker(tp: Type) = tp withAnnotation newPlusMarker()
- private[CPSAnnotationChecker] def addMinusMarker(tp: Type) = tp withAnnotation newMinusMarker()
-
- private[CPSAnnotationChecker] def cleanPlus(tp: Type) =
- removeAttribs(tp, MarkerCPSAdaptPlus, MarkerCPSTypes)
- private[CPSAnnotationChecker] def cleanPlusWith(tp: Type)(newAnnots: AnnotationInfo*) =
- cleanPlus(tp) withAnnotations newAnnots.toList
-
- /** Check annotations to decide whether tpe1 <:< tpe2 */
- def annotationsConform(tpe1: Type, tpe2: Type): Boolean = {
- if (!cpsEnabled) return true
-
- vprintln("check annotations: " + tpe1 + " <:< " + tpe2)
-
- // Nothing is least element, but Any is not the greatest
- if (tpe1.typeSymbol eq NothingClass)
- return true
-
- val annots1 = cpsParamAnnotation(tpe1)
- val annots2 = cpsParamAnnotation(tpe2)
-
- // @plus and @minus should only occur at the left, and never together
- // TODO: insert check
-
- // @minus @cps is the same as no annotations
- if (hasMinusMarker(tpe1))
- return annots2.isEmpty
-
- // to handle answer type modification, we must make @plus <:< @cps
- if (hasPlusMarker(tpe1) && annots1.isEmpty)
- return true
-
- // @plus @cps will fall through and compare the @cps type args
- // @cps parameters must match exactly
- if ((annots1 corresponds annots2)(_.atp <:< _.atp))
- return true
-
- // Need to handle uninstantiated type vars specially:
-
- // g map (x => x) with expected type List[Int] @cps
- // results in comparison ?That <:< List[Int] @cps
-
- // Instantiating ?That to an annotated type would fail during
- // transformation.
-
- // Instead we force-compare tpe1 <:< tpe2.withoutAnnotations
- // to trigger instantiation of the TypeVar to the base type
-
- // This is a bit unorthodox (we're only supposed to look at
- // annotations here) but seems to work.
-
- if (!annots2.isEmpty && !tpe1.isGround)
- return tpe1 <:< tpe2.withoutAnnotations
-
- false
- }
-
- /** Refine the computed least upper bound of a list of types.
- * All this should do is add annotations. */
- override def annotationsLub(tpe: Type, ts: List[Type]): Type = {
- if (!cpsEnabled) return tpe
-
- val annots1 = cpsParamAnnotation(tpe)
- val annots2 = ts flatMap cpsParamAnnotation
-
- if (annots2.nonEmpty) {
- val cpsLub = newMarker(global.lub(annots1:::annots2 map (_.atp)))
- val tpe1 = if (annots1.nonEmpty) removeAttribs(tpe, MarkerCPSTypes) else tpe
- tpe1.withAnnotation(cpsLub)
- }
- else tpe
- }
-
- /** Refine the bounds on type parameters to the given type arguments. */
- override def adaptBoundsToAnnotations(bounds: List[TypeBounds], tparams: List[Symbol], targs: List[Type]): List[TypeBounds] = {
- if (!cpsEnabled) return bounds
-
- val anyAtCPS = newCpsParamsMarker(NothingTpe, AnyTpe)
- if (isFunctionType(tparams.head.owner.tpe_*) || isPartialFunctionType(tparams.head.owner.tpe_*)) {
- vprintln("function bound: " + tparams.head.owner.tpe + "/"+bounds+"/"+targs)
- if (hasCpsParamTypes(targs.last))
- bounds.reverse match {
- case res::b if !hasCpsParamTypes(res.hi) =>
- (TypeBounds(res.lo, res.hi.withAnnotation(anyAtCPS))::b).reverse
- case _ => bounds
- }
- else
- bounds
- }
- else if (tparams.head.owner == ByNameParamClass) {
- vprintln("byname bound: " + tparams.head.owner.tpe + "/"+bounds+"/"+targs)
- val TypeBounds(lo, hi) = bounds.head
- if (hasCpsParamTypes(targs.head) && !hasCpsParamTypes(hi))
- TypeBounds(lo, hi withAnnotation anyAtCPS) :: Nil
- else bounds
- } else
- bounds
- }
- }
-
- object plugin extends AnalyzerPlugin {
-
- import checker._
-
- override def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Boolean = {
- if (!cpsEnabled) return false
- vprintln("can adapt annotations? " + tree + " / " + tree.tpe + " / " + mode + " / " + pt)
-
- val annots1 = cpsParamAnnotation(tree.tpe)
- val annots2 = cpsParamAnnotation(pt)
-
- if (mode.inPatternMode) {
- //println("can adapt pattern annotations? " + tree + " / " + tree.tpe + " / " + Integer.toHexString(mode) + " / " + pt)
- if (!annots1.isEmpty) {
- return true
- }
- }
-
-/*
- // not precise enough -- still relying on addAnnotations to remove things from ValDef symbols
- if (mode.inAllModes(TYPEmode | BYVALmode)) {
- if (!annots1.isEmpty) {
- return true
- }
- }
-*/
-
-/*
- this interferes with overloading resolution
- if (mode.inByValMode && tree.tpe <:< pt) {
- vprintln("already compatible, can't adapt further")
- return false
- }
-*/
- if (mode.inExprMode) {
- if ((annots1 corresponds annots2)(_.atp <:< _.atp)) {
- vprintln("already same, can't adapt further")
- false
- } else if (annots1.isEmpty && !annots2.isEmpty && !mode.inByValMode) {
- //println("can adapt annotations? " + tree + " / " + tree.tpe + " / " + Integer.toHexString(mode) + " / " + pt)
- if (!hasPlusMarker(tree.tpe)) {
- // val base = tree.tpe <:< removeAllCPSAnnotations(pt)
- // val known = global.analyzer.isFullyDefined(pt)
- // println(same + "/" + base + "/" + known)
- //val same = annots2 forall { case AnnotationInfo(atp: TypeRef, _, _) => atp.typeArgs(0) =:= atp.typeArgs(1) }
- // TBD: use same or not?
- //if (same) {
- vprintln("yes we can!! (unit)")
- true
- //}
- } else false
- } else if (!hasPlusMarker(tree.tpe) && annots1.isEmpty && !annots2.isEmpty && typer.context.inReturnExpr) {
- vprintln("checking enclosing method's result type without annotations")
- tree.tpe <:< pt.withoutAnnotations
- } else if (!hasMinusMarker(tree.tpe) && !annots1.isEmpty && mode.inByValMode) {
- val optCpsTypes: Option[(Type, Type)] = cpsParamTypes(tree.tpe)
- val optExpectedCpsTypes: Option[(Type, Type)] = cpsParamTypes(pt)
- if (optCpsTypes.isEmpty || optExpectedCpsTypes.isEmpty) {
- vprintln("yes we can!! (byval)")
- true
- } else { // check cps param types
- val cpsTpes = optCpsTypes.get
- val cpsPts = optExpectedCpsTypes.get
- // class cpsParam[-B,+C], therefore:
- cpsPts._1 <:< cpsTpes._1 && cpsTpes._2 <:< cpsPts._2
- }
- } else false
- } else false
- }
-
- override def adaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Tree = {
- if (!cpsEnabled) return tree
-
- vprintln("adapt annotations " + tree + " / " + tree.tpe + " / " + mode + " / " + pt)
-
- val annotsTree = cpsParamAnnotation(tree.tpe)
- val annotsExpected = cpsParamAnnotation(pt)
- def isMissingExpectedAnnots = annotsTree.isEmpty && annotsExpected.nonEmpty
-
- // not sure I rephrased this comment correctly:
- // replacing `mode.inPatternMode` in the condition below by `mode.inPatternMode || mode.inAllModes(TYPEmode | BYVALmode)`
- // doesn't work correctly -- still relying on addAnnotations to remove things from ValDef symbols
- if (mode.inPatternMode && annotsTree.nonEmpty) tree modifyType removeAllCPSAnnotations
- else if (mode.typingExprNotValue && !hasPlusMarker(tree.tpe) && isMissingExpectedAnnots) { // shiftUnit
- // add a marker annotation that will make tree.tpe behave as pt, subtyping wise
- // tree will look like having any possible annotation
- //println("adapt annotations " + tree + " / " + tree.tpe + " / " + Integer.toHexString(mode) + " / " + pt)
-
- // CAVEAT:
- // for monomorphic answer types we want to have @plus @cps (for better checking)
- // for answer type modification we want to have only @plus (because actual answer type may differ from pt)
-
- val res = tree modifyType (_ withAnnotations newPlusMarker() :: annotsExpected) // needed for #1807
- vprintln("adapted annotations (not by val) of " + tree + " to " + res.tpe)
- res
- } else if (mode.typingExprByValue && !hasMinusMarker(tree.tpe) && annotsTree.nonEmpty) { // dropping annotation
- // add a marker annotation that will make tree.tpe behave as pt, subtyping wise
- // tree will look like having no annotation
- val res = tree modifyType addMinusMarker
- vprintln("adapted annotations (by val) of " + tree + " to " + res.tpe)
- res
- } else if (typer.context.inReturnExpr && !hasPlusMarker(tree.tpe) && isMissingExpectedAnnots) {
- // add a marker annotation that will make tree.tpe behave as pt, subtyping wise
- // tree will look like having any possible annotation
-
- // note 1: we are only adding a plus marker if the method's result type is a cps type
- // (annotsExpected.nonEmpty == cpsParamAnnotation(pt).nonEmpty)
- // note 2: we are not adding the expected cps annotations, since they will be added
- // by adaptTypeOfReturn (see below).
- val res = tree modifyType (_ withAnnotation newPlusMarker())
- vprintln("adapted annotations (return) of " + tree + " to " + res.tpe)
- res
- } else tree
- }
-
- /** Returns an adapted type for a return expression if the method's result type (pt) is a CPS type.
- * Otherwise, it returns the `default` type (`typedReturn` passes `NothingTpe`).
- *
- * A return expression in a method that has a CPS result type is an error unless the return
- * is in tail position. Therefore, we are making sure that only the types of return expressions
- * are adapted which will either be removed, or lead to an error.
- */
- override def pluginsTypedReturn(default: Type, typer: Typer, tree: Return, pt: Type): Type = {
- val expr = tree.expr
- // only adapt if method's result type (pt) is cps type
- val annots = cpsParamAnnotation(pt)
- if (annots.nonEmpty) {
- // return type of `expr` without plus marker, but only if it doesn't have other cps annots
- if (hasPlusMarker(expr.tpe) && !hasCpsParamTypes(expr.tpe))
- expr.setType(removeAttribs(expr.tpe, MarkerCPSAdaptPlus))
- expr.tpe
- } else default
- }
-
- def updateAttributesFromChildren(tpe: Type, childAnnots: List[AnnotationInfo], byName: List[Tree]): Type = {
- tpe match {
- // Would need to push annots into each alternative of overloaded type
- // But we can't, since alternatives aren't types but symbols, which we
- // can't change (we'd be affecting symbols globally)
- /*
- case OverloadedType(pre, alts) =>
- OverloadedType(pre, alts.map((sym: Symbol) => updateAttributes(pre.memberType(sym), annots)))
- */
- case OverloadedType(pre, alts) => tpe //reconstruct correct annotations later
- case MethodType(params, restpe) => tpe
- case PolyType(params, restpe) => tpe
- case _ =>
- assert(childAnnots forall (_ matches MarkerCPSTypes), childAnnots)
- /*
- [] + [] = []
- plus + [] = plus
- cps + [] = cps
- plus cps + [] = plus cps
- minus cps + [] = minus cps
- synth cps + [] = synth cps // <- synth on left - does it happen?
-
- [] + cps = cps
- plus + cps = synth cps
- cps + cps = cps! <- lin
- plus cps + cps = synth cps! <- unify
- minus cps + cps = minus cps! <- lin
- synth cps + cps = synth cps! <- unify
- */
-
- val plus = hasPlusMarker(tpe) || (
- hasCpsParamTypes(tpe)
- && byName.nonEmpty
- && (byName forall (t => hasPlusMarker(t.tpe)))
- )
-
- // move @plus annotations outward from by-name children
- if (childAnnots.isEmpty) return {
- if (plus) { // @plus or @plus @cps
- byName foreach (_ modifyType cleanPlus)
- addPlusMarker(tpe)
- }
- else tpe
- }
-
- val annots1 = cpsParamAnnotation(tpe)
-
- if (annots1.isEmpty) { // nothing or @plus
- cleanPlusWith(tpe)(newSynthMarker(), linearize(childAnnots))
- }
- else {
- val annot1 = single(annots1)
- if (plus) { // @plus @cps
- val annot2 = linearize(childAnnots)
-
- if (annot2.atp <:< annot1.atp) {
- try cleanPlusWith(tpe)(newSynthMarker(), annot2)
- finally byName foreach (_ modifyType cleanPlus)
- }
- else throw new TypeError(annot2 + " is not a subtype of " + annot1)
- }
- else if (hasSynthMarker(tpe)) { // @synth @cps
- val annot2 = linearize(childAnnots)
- if (annot2.atp <:< annot1.atp)
- cleanPlusWith(tpe)(annot2)
- else
- throw new TypeError(annot2 + " is not a subtype of " + annot1)
- }
- else // @cps
- cleanPlusWith(tpe)(linearize(childAnnots:::annots1))
- }
- }
- }
-
- def transArgList(fun: Tree, args: List[Tree]): List[List[Tree]] = {
- val formals = fun.tpe.paramTypes
- val overshoot = args.length - formals.length
-
- for ((a,tp) <- args.zip(formals ::: List.fill(overshoot)(NoType))) yield {
- tp match {
- case TypeRef(_, ByNameParamClass, List(elemtp)) =>
- Nil // TODO: check conformance??
- case _ =>
- List(a)
- }
- }
- }
-
-
- def transStms(stms: List[Tree]): List[Tree] = stms match {
- case ValDef(mods, name, tpt, rhs)::xs =>
- rhs::transStms(xs)
- case Assign(lhs, rhs)::xs =>
- rhs::transStms(xs)
- case x::xs =>
- x::transStms(xs)
- case Nil =>
- Nil
- }
-
- def single(xs: List[AnnotationInfo]) = xs match {
- case List(x) => x
- case _ =>
- global.globalError("not a single cps annotation: " + xs)
- xs(0)
- }
-
- def emptyOrSingleList(xs: List[AnnotationInfo]) = if (xs.isEmpty) Nil else List(single(xs))
-
- def transChildrenInOrder(tree: Tree, tpe: Type, childTrees: List[Tree], byName: List[Tree]) = {
- def inspect(t: Tree): List[AnnotationInfo] = {
- if (t.tpe eq null) Nil else {
- val extra: List[AnnotationInfo] = t.tpe match {
- case _: MethodType | _: PolyType | _: OverloadedType =>
- // method types, poly types and overloaded types do not obtain cps annotions by propagation
- // need to reconstruct transitively from their children.
- t match {
- case Select(qual, name) => inspect(qual)
- case Apply(fun, args) => (fun::(transArgList(fun,args).flatten)) flatMap inspect
- case TypeApply(fun, args) => (fun::(transArgList(fun,args).flatten)) flatMap inspect
- case _ => Nil
- }
- case _ => Nil
- }
-
- val types = cpsParamAnnotation(t.tpe)
- // TODO: check that it has been adapted and if so correctly
- extra ++ emptyOrSingleList(types)
- }
- }
- val children = childTrees flatMap inspect
-
- val newtpe = updateAttributesFromChildren(tpe, children, byName)
-
- if (!newtpe.annotations.isEmpty)
- vprintln("[checker] inferred " + tree + " / " + tpe + " ===> "+ newtpe)
-
- newtpe
- }
-
- /** Modify the type that has thus far been inferred
- * for a tree. All this should do is add annotations. */
-
- override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Mode, pt: Type): Type = {
- if (!cpsEnabled) {
- val report = try hasCpsParamTypes(tpe) catch { case _: MissingRequirementError => false }
- if (report)
- global.reporter.error(tree.pos, "this code must be compiled with the Scala continuations plugin enabled")
-
- return tpe
- }
-
-// if (tree.tpe.hasAnnotation(MarkerCPSAdaptPlus))
-// println("addAnnotation " + tree + "/" + tpe)
-
- tree match {
-
- case Apply(fun @ Select(qual, name), args) if fun.isTyped =>
-
- // HACK: With overloaded methods, fun will never get annotated. This is because
- // the 'overloaded' type gets annotated, but not the alternatives (among which
- // fun's type is chosen)
-
- vprintln("[checker] checking select apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, tpe, qual::(transArgList(fun, args).flatten), Nil)
-
- case Apply(TypeApply(fun @ Select(qual, name), targs), args) if fun.isTyped => // not trigge
-
- vprintln("[checker] checking select apply type-apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, tpe, qual::(transArgList(fun, args).flatten), Nil)
-
- case TypeApply(fun @ Select(qual, name), args) if fun.isTyped =>
- def stripNullaryMethodType(tp: Type) = tp match { case NullaryMethodType(restpe) => restpe case tp => tp }
- vprintln("[checker] checking select type-apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, stripNullaryMethodType(tpe), List(qual, fun), Nil)
-
- case Apply(fun, args) if fun.isTyped =>
-
- vprintln("[checker] checking unknown apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, tpe, fun::(transArgList(fun, args).flatten), Nil)
-
- case TypeApply(fun, args) =>
-
- vprintln("[checker] checking unknown type apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, tpe, List(fun), Nil)
-
- case Select(qual, name) if qual.isTyped =>
-
- vprintln("[checker] checking select " + tree + "/" + tpe)
-
- // straightforward way is problematic (see select.scala and Test2.scala)
- // transChildrenInOrder(tree, tpe, List(qual), Nil)
-
- // the problem is that qual may be of type OverloadedType (or MethodType) and
- // we cannot safely annotate these. so we just ignore these cases and
- // clean up later in the Apply/TypeApply trees.
-
- if (hasCpsParamTypes(qual.tpe)) {
- // however there is one special case:
- // if it's a method without parameters, just apply it. normally done in adapt, but
- // we have to do it here so we don't lose the cps information (wouldn't trigger our
- // adapt and there is no Apply/TypeApply created)
- tpe match {
- case NullaryMethodType(restpe) =>
- //println("yep: " + restpe + "," + restpe.getClass)
- transChildrenInOrder(tree, restpe, List(qual), Nil)
- case _ : PolyType => tpe
- case _ : MethodType => tpe
- case _ : OverloadedType => tpe
- case _ =>
- transChildrenInOrder(tree, tpe, List(qual), Nil)
- }
- } else
- tpe
-
- case If(cond, thenp, elsep) =>
- transChildrenInOrder(tree, tpe, List(cond), List(thenp, elsep))
-
- case Match(select, cases) =>
- transChildrenInOrder(tree, tpe, List(select), cases:::(cases map { case CaseDef(_, _, body) => body }))
-
- case Try(block, catches, finalizer) =>
- val tpe1 = transChildrenInOrder(tree, tpe, Nil, block::catches:::(catches map { case CaseDef(_, _, body) => body }))
-
- val annots = cpsParamAnnotation(tpe1)
- if (annots.nonEmpty) {
- val ann = single(annots)
- val (atp0, atp1) = annTypes(ann)
- if (!(atp0 =:= atp1))
- throw new TypeError("only simple cps types allowed in try/catch blocks (found: " + tpe1 + ")")
- if (!finalizer.isEmpty) // no finalizers allowed. see explanation in SelectiveCPSTransform
- reporter.error(tree.pos, "try/catch blocks that use continuations cannot have finalizers")
- }
- tpe1
-
- case Block(stms, expr) =>
- // if any stm has annotation, so does block
- transChildrenInOrder(tree, tpe, transStms(stms), List(expr))
-
- case ValDef(mods, name, tpt, rhs) =>
- vprintln("[checker] checking valdef " + name + "/"+tpe+"/"+tpt+"/"+tree.symbol.tpe)
- // ValDef symbols must *not* have annotations!
- // lazy vals are currently not supported
- // but if we erase here all annotations, compiler will complain only
- // when generating bytecode.
- // This way lazy vals will be reported as unsupported feature later rather than weird type error.
- if (hasAnswerTypeAnn(tree.symbol.info) && !mods.isLazy) { // is it okay to modify sym here?
- vprintln("removing annotation from sym " + tree.symbol + "/" + tree.symbol.tpe + "/" + tpt)
- tpt modifyType removeAllCPSAnnotations
- tree.symbol modifyInfo removeAllCPSAnnotations
- }
- tpe
-
- case _ =>
- tpe
- }
-
-
- }
- }
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
deleted file mode 100644
index 98d0695865..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
+++ /dev/null
@@ -1,137 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc.Global
-
-trait CPSUtils {
- val global: Global
- import global._
-
- val cpsEnabled: Boolean
- val verbose: Boolean = System.getProperty("cpsVerbose", "false") == "true"
- def vprintln(x: =>Any): Unit = if (verbose) println(x)
-
- object cpsNames {
- val catches = newTermName("$catches")
- val ex = newTermName("$ex")
- val flatMapCatch = newTermName("flatMapCatch")
- val getTrivialValue = newTermName("getTrivialValue")
- val isTrivial = newTermName("isTrivial")
- val reify = newTermName("reify")
- val reifyR = newTermName("reifyR")
- val shift = newTermName("shift")
- val shiftR = newTermName("shiftR")
- val shiftSuffix = newTermName("$shift")
- val shiftUnit0 = newTermName("shiftUnit0")
- val shiftUnit = newTermName("shiftUnit")
- val shiftUnitR = newTermName("shiftUnitR")
- }
-
- lazy val MarkerCPSSym = rootMirror.getRequiredClass("scala.util.continuations.cpsSym")
- lazy val MarkerCPSTypes = rootMirror.getRequiredClass("scala.util.continuations.cpsParam")
- lazy val MarkerCPSSynth = rootMirror.getRequiredClass("scala.util.continuations.cpsSynth")
- lazy val MarkerCPSAdaptPlus = rootMirror.getRequiredClass("scala.util.continuations.cpsPlus")
- lazy val MarkerCPSAdaptMinus = rootMirror.getRequiredClass("scala.util.continuations.cpsMinus")
-
- lazy val Context = rootMirror.getRequiredClass("scala.util.continuations.ControlContext")
- lazy val ModCPS = rootMirror.getPackage("scala.util.continuations")
-
- lazy val MethShiftUnit = definitions.getMember(ModCPS, cpsNames.shiftUnit)
- lazy val MethShiftUnit0 = definitions.getMember(ModCPS, cpsNames.shiftUnit0)
- lazy val MethShiftUnitR = definitions.getMember(ModCPS, cpsNames.shiftUnitR)
- lazy val MethShift = definitions.getMember(ModCPS, cpsNames.shift)
- lazy val MethShiftR = definitions.getMember(ModCPS, cpsNames.shiftR)
- lazy val MethReify = definitions.getMember(ModCPS, cpsNames.reify)
- lazy val MethReifyR = definitions.getMember(ModCPS, cpsNames.reifyR)
-
- lazy val allCPSAnnotations = List(MarkerCPSSym, MarkerCPSTypes, MarkerCPSSynth,
- MarkerCPSAdaptPlus, MarkerCPSAdaptMinus)
-
- // TODO - needed? Can these all use the same annotation info?
- protected def newSynthMarker() = newMarker(MarkerCPSSynth)
- protected def newPlusMarker() = newMarker(MarkerCPSAdaptPlus)
- protected def newMinusMarker() = newMarker(MarkerCPSAdaptMinus)
- protected def newMarker(tpe: Type): AnnotationInfo = AnnotationInfo marker tpe
- protected def newMarker(sym: Symbol): AnnotationInfo = AnnotationInfo marker sym.tpe
-
- protected def newCpsParamsMarker(tp1: Type, tp2: Type) =
- newMarker(appliedType(MarkerCPSTypes, tp1, tp2))
-
- // annotation checker
-
- protected def annTypes(ann: AnnotationInfo): (Type, Type) = {
- val tp0 :: tp1 :: Nil = ann.atp.dealiasWiden.typeArgs
- ((tp0, tp1))
- }
- protected def hasMinusMarker(tpe: Type) = tpe hasAnnotation MarkerCPSAdaptMinus
- protected def hasPlusMarker(tpe: Type) = tpe hasAnnotation MarkerCPSAdaptPlus
- protected def hasSynthMarker(tpe: Type) = tpe hasAnnotation MarkerCPSSynth
- protected def hasCpsParamTypes(tpe: Type) = tpe hasAnnotation MarkerCPSTypes
- protected def cpsParamTypes(tpe: Type) = tpe getAnnotation MarkerCPSTypes map annTypes
-
- def filterAttribs(tpe:Type, cls:Symbol) =
- tpe.annotations filter (_ matches cls)
-
- def removeAttribs(tpe: Type, classes: Symbol*) =
- tpe filterAnnotations (ann => !(classes exists (ann matches _)))
-
- def removeAllCPSAnnotations(tpe: Type) = removeAttribs(tpe, allCPSAnnotations:_*)
-
- def cpsParamAnnotation(tpe: Type) = filterAttribs(tpe, MarkerCPSTypes)
-
- def linearize(ann: List[AnnotationInfo]): AnnotationInfo = {
- ann reduceLeft { (a, b) =>
- val (u0,v0) = annTypes(a)
- val (u1,v1) = annTypes(b)
- // vprintln("check lin " + a + " andThen " + b)
-
- if (v1 <:< u0)
- newCpsParamsMarker(u1, v0)
- else
- throw new TypeError("illegal answer type modification: " + a + " andThen " + b)
- }
- }
-
- // anf transform
-
- def getExternalAnswerTypeAnn(tp: Type) = {
- cpsParamTypes(tp) orElse {
- if (hasPlusMarker(tp))
- global.warning("trying to instantiate type " + tp + " to unknown cps type")
- None
- }
- }
-
- def getAnswerTypeAnn(tp: Type): Option[(Type, Type)] =
- cpsParamTypes(tp) filterNot (_ => hasPlusMarker(tp))
-
- def hasAnswerTypeAnn(tp: Type) =
- hasCpsParamTypes(tp) && !hasPlusMarker(tp)
-
- def updateSynthFlag(tree: Tree) = { // remove annotations if *we* added them (@synth present)
- if (hasSynthMarker(tree.tpe)) {
- log("removing annotation from " + tree)
- tree modifyType removeAllCPSAnnotations
- } else
- tree
- }
-
- type CPSInfo = Option[(Type,Type)]
-
- def linearize(a: CPSInfo, b: CPSInfo)(implicit unit: CompilationUnit, pos: Position): CPSInfo = {
- (a,b) match {
- case (Some((u0,v0)), Some((u1,v1))) =>
- vprintln("check lin " + a + " andThen " + b)
- if (!(v1 <:< u0)) {
- unit.error(pos,"cannot change answer type in composition of cps expressions " +
- "from " + u1 + " to " + v0 + " because " + v1 + " is not a subtype of " + u0 + ".")
- throw new Exception("check lin " + a + " andThen " + b)
- }
- Some((u1,v0))
- case (Some(_), _) => a
- case (_, Some(_)) => b
- case _ => None
- }
- }
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
deleted file mode 100644
index ae95a1bdac..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
+++ /dev/null
@@ -1,545 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc.transform._
-import scala.tools.nsc.symtab._
-import scala.tools.nsc.plugins._
-
-/**
- * In methods marked @cps, explicitly name results of calls to other @cps methods
- */
-abstract class SelectiveANFTransform extends PluginComponent with Transform with
- TypingTransformers with CPSUtils {
- // inherits abstract value `global` and class `Phase` from Transform
-
- import global._ // the global environment
- import definitions._ // standard classes and methods
- import typer.atOwner // methods to type trees
-
- override def description = "ANF pre-transform for @cps"
-
- /** the following two members override abstract members in Transform */
- val phaseName: String = "selectiveanf"
-
- protected def newTransformer(unit: CompilationUnit): Transformer =
- new ANFTransformer(unit)
-
- class ANFTransformer(unit: CompilationUnit) extends TypingTransformer(unit) {
-
- implicit val _unit = unit // allow code in CPSUtils.scala to report errors
- var cpsAllowed: Boolean = false // detect cps code in places we do not handle (yet)
-
- object RemoveTailReturnsTransformer extends Transformer {
- override def transform(tree: Tree): Tree = tree match {
- case Block(stms, r @ Return(expr)) =>
- treeCopy.Block(tree, stms, expr)
-
- case Block(stms, expr) =>
- treeCopy.Block(tree, stms, transform(expr))
-
- case If(cond, r1 @ Return(thenExpr), r2 @ Return(elseExpr)) =>
- treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
-
- case If(cond, r1 @ Return(thenExpr), elseExpr) =>
- treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
-
- case If(cond, thenExpr, r2 @ Return(elseExpr)) =>
- treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
-
- case If(cond, thenExpr, elseExpr) =>
- treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
-
- case Try(block, catches, finalizer) =>
- treeCopy.Try(tree,
- transform(block),
- (catches map (t => transform(t))).asInstanceOf[List[CaseDef]],
- transform(finalizer))
-
- case CaseDef(pat, guard, r @ Return(expr)) =>
- treeCopy.CaseDef(tree, pat, guard, expr)
-
- case CaseDef(pat, guard, body) =>
- treeCopy.CaseDef(tree, pat, guard, transform(body))
-
- case Return(_) =>
- unit.error(tree.pos, "return expressions in CPS code must be in tail position")
- tree
-
- case _ =>
- super.transform(tree)
- }
- }
-
- def removeTailReturns(body: Tree): Tree = {
- // support body with single return expression
- body match {
- case Return(expr) => expr
- case _ => RemoveTailReturnsTransformer.transform(body)
- }
- }
-
- override def transform(tree: Tree): Tree = {
- if (!cpsEnabled) return tree
-
- tree match {
-
- // Maybe we should further generalize the transform and move it over
- // to the regular Transformer facility. But then, actual and required cps
- // state would need more complicated (stateful!) tracking.
-
- // Making the default case use transExpr(tree, None, None) instead of
- // calling super.transform() would be a start, but at the moment,
- // this would cause infinite recursion. But we could remove the
- // ValDef case here.
-
- case dd @ DefDef(mods, name, tparams, vparamss, tpt, rhs0) =>
- debuglog("transforming " + dd.symbol)
-
- atOwner(dd.symbol) {
- val rhs =
- if (cpsParamTypes(tpt.tpe).nonEmpty) removeTailReturns(rhs0)
- else rhs0
- val rhs1 = transExpr(rhs, None, getExternalAnswerTypeAnn(tpt.tpe))(getExternalAnswerTypeAnn(tpt.tpe).isDefined)
-
- debuglog("result "+rhs1)
- debuglog("result is of type "+rhs1.tpe)
-
- treeCopy.DefDef(dd, mods, name, transformTypeDefs(tparams), transformValDefss(vparamss),
- transform(tpt), rhs1)
- }
-
- case ff @ Function(vparams, body) =>
- debuglog("transforming anon function " + ff.symbol)
-
- atOwner(ff.symbol) {
-
- //val body1 = transExpr(body, None, getExternalAnswerTypeAnn(body.tpe))
-
- // need to special case partial functions: if expected type is @cps
- // but all cases are pure, then we would transform
- // { x => x match { case A => ... }} to
- // { x => shiftUnit(x match { case A => ... })}
- // which Uncurry cannot handle (see function6.scala)
- // thus, we push down the shiftUnit to each of the case bodies
-
- val ext = getExternalAnswerTypeAnn(body.tpe)
- val pureBody = getAnswerTypeAnn(body.tpe).isEmpty
- implicit val isParentImpure = ext.isDefined
-
- def transformPureMatch(tree: Tree, selector: Tree, cases: List[CaseDef]) = {
- val caseVals = cases map { case cd @ CaseDef(pat, guard, body) =>
- // if (!hasPlusMarker(body.tpe)) body modifyType (_ withAnnotation newPlusMarker()) // TODO: to avoid warning
- val bodyVal = transExpr(body, None, ext) // ??? triggers "cps-transformed unexpectedly" warning in transTailValue
- treeCopy.CaseDef(cd, transform(pat), transform(guard), bodyVal)
- }
- treeCopy.Match(tree, transform(selector), caseVals)
- }
-
- def transformPureVirtMatch(body: Block, selDef: ValDef, cases: List[Tree], matchEnd: Tree) = {
- val stats = transform(selDef) :: (cases map (transExpr(_, None, ext)))
- treeCopy.Block(body, stats, transExpr(matchEnd, None, ext))
- }
-
- val body1 = body match {
- case Match(selector, cases) if ext.isDefined && pureBody =>
- transformPureMatch(body, selector, cases)
-
- // virtpatmat switch
- case Block(List(selDef: ValDef), mat@Match(selector, cases)) if ext.isDefined && pureBody =>
- treeCopy.Block(body, List(transform(selDef)), transformPureMatch(mat, selector, cases))
-
- // virtpatmat
- case b@Block(matchStats@((selDef: ValDef) :: cases), matchEnd) if ext.isDefined && pureBody && (matchStats forall treeInfo.hasSynthCaseSymbol) =>
- transformPureVirtMatch(b, selDef, cases, matchEnd)
-
- // virtpatmat that stores the scrut separately -- TODO: can we eliminate this case??
- case Block(List(selDef0: ValDef), mat@Block(matchStats@((selDef: ValDef) :: cases), matchEnd)) if ext.isDefined && pureBody && (matchStats forall treeInfo.hasSynthCaseSymbol)=>
- treeCopy.Block(body, List(transform(selDef0)), transformPureVirtMatch(mat, selDef, cases, matchEnd))
-
- case _ =>
- transExpr(body, None, ext)
- }
-
- debuglog("anf result "+body1+"\nresult is of type "+body1.tpe)
-
- treeCopy.Function(ff, transformValDefs(vparams), body1)
- }
-
- case vd @ ValDef(mods, name, tpt, rhs) => // object-level valdefs
- debuglog("transforming valdef " + vd.symbol)
-
- if (getExternalAnswerTypeAnn(tpt.tpe).isEmpty) {
-
- atOwner(vd.symbol) {
-
- val rhs1 = transExpr(rhs, None, None)
-
- treeCopy.ValDef(vd, mods, name, transform(tpt), rhs1)
- }
- } else {
- unit.error(tree.pos, "cps annotations not allowed on by-value parameters or value definitions")
- super.transform(tree)
- }
-
- case TypeTree() =>
- // circumvent cpsAllowed here
- super.transform(tree)
-
- case Apply(_,_) =>
- // this allows reset { ... } in object constructors
- // it's kind of a hack to put it here (see note above)
- transExpr(tree, None, None)
-
- case _ =>
- if (hasAnswerTypeAnn(tree.tpe)) {
- if (!cpsAllowed) {
- if (tree.symbol.isLazy)
- unit.error(tree.pos, "implementation restriction: cps annotations not allowed on lazy value definitions")
- else
- unit.error(tree.pos, "cps code not allowed here / " + tree.getClass + " / " + tree)
- }
- log(tree)
- }
-
- cpsAllowed = false
- super.transform(tree)
- }
- }
-
-
- def transExpr(tree: Tree, cpsA: CPSInfo, cpsR: CPSInfo)(implicit isAnyParentImpure: Boolean = false): Tree = {
- transTailValue(tree, cpsA, cpsR)(cpsR.isDefined || isAnyParentImpure) match {
- case (Nil, b) => b
- case (a, b) =>
- treeCopy.Block(tree, a,b)
- }
- }
-
-
- def transArgList(fun: Tree, args: List[Tree], cpsA: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[List[Tree]], List[Tree], CPSInfo) = {
- val formals = fun.tpe.paramTypes
- val overshoot = args.length - formals.length
-
- var spc: CPSInfo = cpsA
-
- val (stm,expr) = (for ((a,tp) <- args.zip(formals ::: List.fill(overshoot)(NoType))) yield {
- tp match {
- case TypeRef(_, ByNameParamClass, List(elemtp)) =>
- // note that we're not passing just isAnyParentImpure
- (Nil, transExpr(a, None, getAnswerTypeAnn(elemtp))(getAnswerTypeAnn(elemtp).isDefined || isAnyParentImpure))
- case _ =>
- val (valStm, valExpr, valSpc) = transInlineValue(a, spc)
- spc = valSpc
- (valStm, valExpr)
- }
- }).unzip
-
- (stm,expr,spc)
- }
-
-
- // precondition: cpsR.isDefined "implies" isAnyParentImpure
- def transValue(tree: Tree, cpsA: CPSInfo, cpsR: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], Tree, CPSInfo) = {
- // return value: (stms, expr, spc), where spc is CPSInfo after stms but *before* expr
- implicit val pos = tree.pos
- tree match {
- case Block(stms, expr) =>
- val (cpsA2, cpsR2) = (cpsA, linearize(cpsA, getAnswerTypeAnn(tree.tpe))) // tbd
- // val (cpsA2, cpsR2) = (None, getAnswerTypeAnn(tree.tpe))
-
- val (a, b) = transBlock(stms, expr, cpsA2, cpsR2)(cpsR2.isDefined || isAnyParentImpure)
- val tree1 = (treeCopy.Block(tree, a, b)) // no updateSynthFlag here!!!
-
- (Nil, tree1, cpsA)
-
- case If(cond, thenp, elsep) =>
- /* possible situations:
- cps before (cpsA)
- cps in condition (spc) <-- synth flag set if *only* here!
- cps in (one or both) branches */
- val (condStats, condVal, spc) = transInlineValue(cond, cpsA)
- val (cpsA2, cpsR2) = if (hasSynthMarker(tree.tpe))
- (spc, linearize(spc, getAnswerTypeAnn(tree.tpe))) else
- (None, getAnswerTypeAnn(tree.tpe)) // if no cps in condition, branches must conform to tree.tpe directly
- val thenVal = transExpr(thenp, cpsA2, cpsR2)(cpsR2.isDefined || isAnyParentImpure)
- val elseVal = transExpr(elsep, cpsA2, cpsR2)(cpsR2.isDefined || isAnyParentImpure)
-
- // check that then and else parts agree (not necessary any more, but left as sanity check)
- if (cpsR.isDefined) {
- if (elsep == EmptyTree)
- unit.error(tree.pos, "always need else part in cps code")
- }
- if (hasAnswerTypeAnn(thenVal.tpe) != hasAnswerTypeAnn(elseVal.tpe)) {
- unit.error(tree.pos, "then and else parts must both be cps code or neither of them")
- }
-
- (condStats, updateSynthFlag(treeCopy.If(tree, condVal, thenVal, elseVal)), spc)
-
- case Match(selector, cases) =>
- val (selStats, selVal, spc) = transInlineValue(selector, cpsA)
- val (cpsA2, cpsR2) =
- if (hasSynthMarker(tree.tpe)) (spc, linearize(spc, getAnswerTypeAnn(tree.tpe)))
- else (None, getAnswerTypeAnn(tree.tpe))
-
- val caseVals = cases map { case cd @ CaseDef(pat, guard, body) =>
- val bodyVal = transExpr(body, cpsA2, cpsR2)(cpsR2.isDefined || isAnyParentImpure)
- treeCopy.CaseDef(cd, transform(pat), transform(guard), bodyVal)
- }
-
- (selStats, updateSynthFlag(treeCopy.Match(tree, selVal, caseVals)), spc)
-
- // this is utterly broken: LabelDefs need to be considered together when transforming them to DefDefs:
- // suppose a Block {L1; ... ; LN}
- // this should become {D1def ; ... ; DNdef ; D1()}
- // where D$idef = def L$i(..) = {L$i.body; L${i+1}(..)}
-
- case ldef @ LabelDef(name, params, rhs) =>
- // println("trans LABELDEF "+(name, params, tree.tpe, hasAnswerTypeAnn(tree.tpe)))
- // TODO why does the labeldef's type have a cpsMinus annotation, whereas the rhs does not? (BYVALmode missing/too much somewhere?)
- if (hasAnswerTypeAnn(tree.tpe)) {
- // currentOwner.newMethod(name, tree.pos, Flags.SYNTHETIC) setInfo ldef.symbol.info
- val sym = ldef.symbol resetFlag Flags.LABEL
- val rhs1 = rhs //new TreeSymSubstituter(List(ldef.symbol), List(sym)).transform(rhs)
- val rhsVal = transExpr(rhs1, None, getAnswerTypeAnn(tree.tpe))(getAnswerTypeAnn(tree.tpe).isDefined || isAnyParentImpure) changeOwner (currentOwner -> sym)
-
- val stm1 = localTyper.typed(DefDef(sym, rhsVal))
- // since virtpatmat does not rely on fall-through, don't call the labels it emits
- // transBlock will take care of calling the first label
- // calling each labeldef is wrong, since some labels may be jumped over
- // we can get away with this for now since the only other labels we emit are for tailcalls/while loops,
- // which do not have consecutive labeldefs (and thus fall-through is irrelevant)
- if (treeInfo.hasSynthCaseSymbol(ldef)) (List(stm1), localTyper.typed{Literal(Constant(()))}, cpsA)
- else {
- assert(params.isEmpty, "problem in ANF transforming label with non-empty params "+ ldef)
- (List(stm1), localTyper.typed{Apply(Ident(sym), List())}, cpsA)
- }
- } else {
- val rhsVal = transExpr(rhs, None, None)
- (Nil, updateSynthFlag(treeCopy.LabelDef(tree, name, params, rhsVal)), cpsA)
- }
-
-
- case Try(block, catches, finalizer) =>
- val blockVal = transExpr(block, cpsA, cpsR)
-
- val catchVals = for {
- cd @ CaseDef(pat, guard, body) <- catches
- bodyVal = transExpr(body, cpsA, cpsR)
- } yield {
- treeCopy.CaseDef(cd, transform(pat), transform(guard), bodyVal)
- }
-
- val finallyVal = transExpr(finalizer, None, None) // for now, no cps in finally
-
- (Nil, updateSynthFlag(treeCopy.Try(tree, blockVal, catchVals, finallyVal)), cpsA)
-
- case Assign(lhs, rhs) =>
- // allow cps code in rhs only
- val (stms, expr, spc) = transInlineValue(rhs, cpsA)
- (stms, updateSynthFlag(treeCopy.Assign(tree, transform(lhs), expr)), spc)
-
- case Return(expr0) =>
- if (isAnyParentImpure)
- unit.error(tree.pos, "return expression not allowed, since method calls CPS method")
- val (stms, expr, spc) = transInlineValue(expr0, cpsA)
- (stms, updateSynthFlag(treeCopy.Return(tree, expr)), spc)
-
- case Throw(expr0) =>
- val (stms, expr, spc) = transInlineValue(expr0, cpsA)
- (stms, updateSynthFlag(treeCopy.Throw(tree, expr)), spc)
-
- case Typed(expr0, tpt) =>
- // TODO: should x: A @cps[B,C] have a special meaning?
- // type casts used in different ways (see match2.scala, #3199)
- val (stms, expr, spc) = transInlineValue(expr0, cpsA)
- val tpt1 = if (treeInfo.isWildcardStarArg(tree)) tpt else
- treeCopy.TypeTree(tpt).setType(removeAllCPSAnnotations(tpt.tpe))
-// (stms, updateSynthFlag(treeCopy.Typed(tree, expr, tpt1)), spc)
- (stms, treeCopy.Typed(tree, expr, tpt1).setType(removeAllCPSAnnotations(tree.tpe)), spc)
-
- case TypeApply(fun, args) =>
- val (stms, expr, spc) = transInlineValue(fun, cpsA)
- (stms, updateSynthFlag(treeCopy.TypeApply(tree, expr, args)), spc)
-
- case Select(qual, name) =>
- val (stms, expr, spc) = transInlineValue(qual, cpsA)
- (stms, updateSynthFlag(treeCopy.Select(tree, expr, name)), spc)
-
- case Apply(fun, args) =>
- val (funStm, funExpr, funSpc) = transInlineValue(fun, cpsA)
- val (argStm, argExpr, argSpc) = transArgList(fun, args, funSpc)
-
- (funStm ::: (argStm.flatten), updateSynthFlag(treeCopy.Apply(tree, funExpr, argExpr)),
- argSpc)
-
- case _ =>
- cpsAllowed = true
- (Nil, transform(tree), cpsA)
- }
- }
-
- // precondition: cpsR.isDefined "implies" isAnyParentImpure
- def transTailValue(tree: Tree, cpsA: CPSInfo, cpsR: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], Tree) = {
-
- val (stms, expr, spc) = transValue(tree, cpsA, cpsR)
-
- val bot = linearize(spc, getAnswerTypeAnn(expr.tpe))(unit, tree.pos)
-
- val plainTpe = removeAllCPSAnnotations(expr.tpe)
-
- if (cpsR.isDefined && !bot.isDefined) {
-
- if (!expr.isEmpty && (expr.tpe.typeSymbol ne NothingClass)) {
- // must convert!
- debuglog("cps type conversion (has: " + cpsA + "/" + spc + "/" + expr.tpe + ")")
- debuglog("cps type conversion (expected: " + cpsR.get + "): " + expr)
-
- if (!hasPlusMarker(expr.tpe))
- unit.warning(tree.pos, "expression " + tree + " is cps-transformed unexpectedly")
-
- try {
- val Some((a, b)) = cpsR
- /* Since shiftUnit is bounded [A,B,C>:B] this may not typecheck
- * if C is overly specific. So if !(B <:< C), call shiftUnit0
- * instead, which takes only two type arguments.
- */
- val conforms = a <:< b
- val call = localTyper.typedPos(tree.pos)(
- Apply(
- TypeApply(
- gen.mkAttributedRef( if (conforms) MethShiftUnit else MethShiftUnit0 ),
- List(TypeTree(plainTpe), TypeTree(a)) ++ ( if (conforms) List(TypeTree(b)) else Nil )
- ),
- List(expr)
- )
- )
- // This is today's sick/meaningless heuristic for spotting breakdown so
- // we don't proceed until stack traces start draping themselves over everything.
- // If there are wildcard types in the tree and B == Nothing, something went wrong.
- // (I thought WildcardTypes would be enough, but nope. 'reset0 { 0 }' has them.)
- //
- // Code as simple as reset((_: String).length)
- // will crash meaninglessly without this check. See SI-3718.
- //
- // TODO - obviously this should be done earlier, differently, or with
- // a more skilled hand. Most likely, all three.
- if ((b.typeSymbol eq NothingClass) && call.tpe.exists(_ eq WildcardType))
- unit.error(tree.pos, "cannot cps-transform malformed (possibly in shift/reset placement) expression")
- else
- return ((stms, call))
- }
- catch {
- case ex:TypeError =>
- unit.error(ex.pos, "cannot cps-transform expression " + tree + ": " + ex.msg)
- }
- }
-
- } else if (!cpsR.isDefined && bot.isDefined) {
- // error!
- debuglog("cps type error: " + expr)
- //println("cps type error: " + expr + "/" + expr.tpe + "/" + getAnswerTypeAnn(expr.tpe))
-
- //println(cpsR + "/" + spc + "/" + bot)
-
- unit.error(tree.pos, "found cps expression in non-cps position")
- } else {
- // all is well
-
- if (hasPlusMarker(expr.tpe)) {
- unit.warning(tree.pos, "expression " + expr + " of type " + expr.tpe + " is not expected to have a cps type")
- expr modifyType removeAllCPSAnnotations
- }
-
- // TODO: sanity check that types agree
- }
-
- (stms, expr)
- }
-
- def transInlineValue(tree: Tree, cpsA: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], Tree, CPSInfo) = {
-
- val (stms, expr, spc) = transValue(tree, cpsA, None) // never required to be cps
-
- getAnswerTypeAnn(expr.tpe) match {
- case spcVal @ Some(_) =>
-
- val valueTpe = removeAllCPSAnnotations(expr.tpe)
-
- val sym: Symbol = (
- currentOwner.newValue(newTermName(unit.fresh.newName("tmp")), tree.pos, Flags.SYNTHETIC)
- setInfo valueTpe
- setAnnotations List(AnnotationInfo(MarkerCPSSym.tpe_*, Nil, Nil))
- )
- expr.changeOwner(currentOwner -> sym)
-
- (stms ::: List(ValDef(sym, expr) setType(NoType)),
- Ident(sym) setType(valueTpe) setPos(tree.pos), linearize(spc, spcVal)(unit, tree.pos))
-
- case _ =>
- (stms, expr, spc)
- }
-
- }
-
-
-
- def transInlineStm(stm: Tree, cpsA: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], CPSInfo) = {
- stm match {
-
- // TODO: what about DefDefs?
- // TODO: relation to top-level val def?
- // TODO: what about lazy vals?
-
- case tree @ ValDef(mods, name, tpt, rhs) =>
- val (stms, anfRhs, spc) = atOwner(tree.symbol) { transValue(rhs, cpsA, None) }
-
- val tv = new ChangeOwnerTraverser(tree.symbol, currentOwner)
- stms.foreach(tv.traverse(_))
-
- // TODO: symbol might already have annotation. Should check conformance
- // TODO: better yet: do without annotations on symbols
-
- val spcVal = getAnswerTypeAnn(anfRhs.tpe)
- spcVal foreach (_ => tree.symbol setAnnotations List(AnnotationInfo(MarkerCPSSym.tpe_*, Nil, Nil)))
-
- (stms:::List(treeCopy.ValDef(tree, mods, name, tpt, anfRhs)), linearize(spc, spcVal)(unit, tree.pos))
-
- case _ =>
- val (headStms, headExpr, headSpc) = transInlineValue(stm, cpsA)
- val valSpc = getAnswerTypeAnn(headExpr.tpe)
- (headStms:::List(headExpr), linearize(headSpc, valSpc)(unit, stm.pos))
- }
- }
-
- // precondition: cpsR.isDefined "implies" isAnyParentImpure
- def transBlock(stms: List[Tree], expr: Tree, cpsA: CPSInfo, cpsR: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], Tree) = {
- def rec(currStats: List[Tree], currAns: CPSInfo, accum: List[Tree]): (List[Tree], Tree) =
- currStats match {
- case Nil =>
- val (anfStats, anfExpr) = transTailValue(expr, currAns, cpsR)
- (accum ++ anfStats, anfExpr)
-
- case stat :: rest =>
- val (stats, nextAns) = transInlineStm(stat, currAns)
- rec(rest, nextAns, accum ++ stats)
- }
-
- val (anfStats, anfExpr) = rec(stms, cpsA, List())
- // println("\nanf-block:\n"+ ((stms :+ expr) mkString ("{", "\n", "}")) +"\nBECAME\n"+ ((anfStats :+ anfExpr) mkString ("{", "\n", "}")))
- // println("synth case? "+ (anfStats map (t => (t, t.isDef, treeInfo.hasSynthCaseSymbol(t)))))
- // SUPER UGLY HACK: handle virtpatmat-style matches, whose labels have already been turned into DefDefs
- if (anfStats.nonEmpty && (anfStats forall (t => !t.isDef || treeInfo.hasSynthCaseSymbol(t)))) {
- val (prologue, rest) = (anfStats :+ anfExpr) span (s => !s.isInstanceOf[DefDef]) // find first case
- // println("rest: "+ rest)
- // val (defs, calls) = rest partition (_.isInstanceOf[DefDef])
- if (rest.nonEmpty) {
- // the filter drops the ()'s emitted when transValue encountered a LabelDef
- val stats = prologue ++ (rest filter (_.isInstanceOf[DefDef])).reverse // ++ calls
- // println("REVERSED "+ (stats mkString ("{", "\n", "}")))
- (stats, localTyper.typed{Apply(Ident(rest.head.symbol), List())}) // call first label to kick-start the match
- } else (anfStats, anfExpr)
- } else (anfStats, anfExpr)
- }
- }
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
deleted file mode 100644
index a7e82e949b..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc
-import nsc.Global
-import nsc.plugins.Plugin
-import nsc.plugins.PluginComponent
-
-class SelectiveCPSPlugin(val global: Global) extends Plugin {
- val name = "continuations"
- val description = "applies selective cps conversion"
-
- val pluginEnabled = options contains "enable"
-
- val anfPhase = new {
- val global = SelectiveCPSPlugin.this.global
- val cpsEnabled = pluginEnabled
- override val enabled = cpsEnabled
- } with SelectiveANFTransform {
- val runsAfter = List("pickler")
- }
-
- val cpsPhase = new {
- val global = SelectiveCPSPlugin.this.global
- val cpsEnabled = pluginEnabled
- override val enabled = cpsEnabled
- } with SelectiveCPSTransform {
- val runsAfter = List("selectiveanf")
- override val runsBefore = List("uncurry")
- }
-
- val components = List[PluginComponent](anfPhase, cpsPhase)
-
- val checker = new {
- val global: SelectiveCPSPlugin.this.global.type = SelectiveCPSPlugin.this.global
- val cpsEnabled = pluginEnabled
- } with CPSAnnotationChecker
-
- // TODO don't muck up global with unused checkers
- global.addAnnotationChecker(checker.checker)
- global.analyzer.addAnalyzerPlugin(checker.plugin)
-
- global.log("instantiated cps plugin: " + this)
-
- override def init(options: List[String], error: String => Unit) = {
- options foreach {
- case "enable" => // in initializer
- case arg => error(s"Bad argument: $arg")
- }
- pluginEnabled
- }
-
- override val optionsHelp: Option[String] =
- Some(" -P:continuations:enable Enable continuations")
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
deleted file mode 100644
index 0210ad3459..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
+++ /dev/null
@@ -1,383 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc.transform._
-import scala.tools.nsc.plugins._
-import scala.tools.nsc.ast._
-
-/**
- * In methods marked @cps, CPS-transform assignments introduced by ANF-transform phase.
- */
-abstract class SelectiveCPSTransform extends PluginComponent with
- InfoTransform with TypingTransformers with CPSUtils with TreeDSL {
- // inherits abstract value `global` and class `Phase` from Transform
-
- import global._ // the global environment
- import definitions._ // standard classes and methods
- import typer.atOwner // methods to type trees
-
- override def description = "@cps-driven transform of selectiveanf assignments"
-
- /** the following two members override abstract members in Transform */
- val phaseName: String = "selectivecps"
-
- protected def newTransformer(unit: CompilationUnit): Transformer =
- new CPSTransformer(unit)
-
- /** This class does not change linearization */
- override def changesBaseClasses = false
-
- /** - return symbol's transformed type,
- */
- def transformInfo(sym: Symbol, tp: Type): Type = {
- if (!cpsEnabled) return tp
-
- val newtp = transformCPSType(tp)
-
- if (newtp != tp)
- debuglog("transformInfo changed type for " + sym + " to " + newtp);
-
- if (sym == MethReifyR)
- debuglog("transformInfo (not)changed type for " + sym + " to " + newtp);
-
- newtp
- }
-
- def transformCPSType(tp: Type): Type = { // TODO: use a TypeMap? need to handle more cases?
- tp match {
- case PolyType(params,res) => PolyType(params, transformCPSType(res))
- case NullaryMethodType(res) => NullaryMethodType(transformCPSType(res))
- case MethodType(params,res) => MethodType(params, transformCPSType(res))
- case TypeRef(pre, sym, args) => TypeRef(pre, sym, args.map(transformCPSType(_)))
- case _ =>
- getExternalAnswerTypeAnn(tp) match {
- case Some((res, outer)) =>
- appliedType(Context.tpeHK, List(removeAllCPSAnnotations(tp), res, outer))
- case _ =>
- removeAllCPSAnnotations(tp)
- }
- }
- }
-
-
- class CPSTransformer(unit: CompilationUnit) extends TypingTransformer(unit) {
- private val patmatTransformer = patmat.newTransformer(unit)
-
- override def transform(tree: Tree): Tree = {
- if (!cpsEnabled) return tree
- postTransform(mainTransform(tree))
- }
-
- def postTransform(tree: Tree): Tree = {
- tree.setType(transformCPSType(tree.tpe))
- }
-
-
- def mainTransform(tree: Tree): Tree = {
- tree match {
-
- // TODO: can we generalize this?
-
- case Apply(TypeApply(fun, targs), args)
- if (fun.symbol == MethShift) =>
- debuglog("found shift: " + tree)
- atPos(tree.pos) {
- val funR = gen.mkAttributedRef(MethShiftR) // TODO: correct?
- //gen.mkAttributedSelect(gen.mkAttributedSelect(gen.mkAttributedSelect(gen.mkAttributedIdent(ScalaPackage),
- //ScalaPackage.tpe.member("util")), ScalaPackage.tpe.member("util").tpe.member("continuations")), MethShiftR)
- //gen.mkAttributedRef(ModCPS.tpe, MethShiftR) // TODO: correct?
- debuglog("funR.tpe: " + funR.tpe)
- Apply(
- TypeApply(funR, targs).setType(appliedType(funR.tpe, targs.map((t:Tree) => t.tpe))),
- args.map(transform(_))
- ).setType(transformCPSType(tree.tpe))
- }
-
- case Apply(TypeApply(fun, targs), args)
- if (fun.symbol == MethShiftUnit) =>
- debuglog("found shiftUnit: " + tree)
- atPos(tree.pos) {
- val funR = gen.mkAttributedRef(MethShiftUnitR) // TODO: correct?
- debuglog("funR.tpe: " + funR.tpe)
- Apply(
- TypeApply(funR, List(targs(0), targs(1))).setType(appliedType(funR.tpe,
- List(targs(0).tpe, targs(1).tpe))),
- args.map(transform(_))
- ).setType(appliedType(Context.tpeHK, List(targs(0).tpe,targs(1).tpe,targs(1).tpe)))
- }
-
- case Apply(TypeApply(fun, targs), args)
- if (fun.symbol == MethReify) =>
- log("found reify: " + tree)
- atPos(tree.pos) {
- val funR = gen.mkAttributedRef(MethReifyR) // TODO: correct?
- debuglog("funR.tpe: " + funR.tpe)
- Apply(
- TypeApply(funR, targs).setType(appliedType(funR.tpe, targs.map((t:Tree) => t.tpe))),
- args.map(transform(_))
- ).setType(transformCPSType(tree.tpe))
- }
-
- case Try(block, catches, finalizer) =>
- // currently duplicates the catch block into a partial function.
- // this is kinda risky, but we don't expect there will be lots
- // of try/catches inside catch blocks (exp. blowup unlikely).
-
- // CAVEAT: finalizers are surprisingly tricky!
- // the problem is that they cannot easily be removed
- // from the regular control path and hence will
- // also be invoked after creating the Context object.
-
- /*
- object Test {
- def foo1 = {
- throw new Exception("in sub")
- shift((k:Int=>Int) => k(1))
- 10
- }
- def foo2 = {
- shift((k:Int=>Int) => k(2))
- 20
- }
- def foo3 = {
- shift((k:Int=>Int) => k(3))
- throw new Exception("in sub")
- 30
- }
- def foo4 = {
- shift((k:Int=>Int) => 4)
- throw new Exception("in sub")
- 40
- }
- def bar(x: Int) = try {
- if (x == 1)
- foo1
- else if (x == 2)
- foo2
- else if (x == 3)
- foo3
- else //if (x == 4)
- foo4
- } catch {
- case _ =>
- println("exception")
- 0
- } finally {
- println("done")
- }
- }
-
- reset(Test.bar(1)) // should print: exception,done,0
- reset(Test.bar(2)) // should print: done,20 <-- but prints: done,done,20
- reset(Test.bar(3)) // should print: exception,done,0 <-- but prints: done,exception,done,0
- reset(Test.bar(4)) // should print: 4 <-- but prints: done,4
- */
-
- val block1 = transform(block)
- val catches1 = transformCaseDefs(catches)
- val finalizer1 = transform(finalizer)
-
- if (hasAnswerTypeAnn(tree.tpe)) {
- //vprintln("CPS Transform: " + tree + "/" + tree.tpe + "/" + block1.tpe)
-
- val (stms, expr1) = block1 match {
- case Block(stms, expr) => (stms, expr)
- case expr => (Nil, expr)
- }
-
- val targettp = transformCPSType(tree.tpe)
-
- val pos = catches.head.pos
- val funSym = currentOwner.newValueParameter(cpsNames.catches, pos).setInfo(appliedType(PartialFunctionClass, ThrowableTpe, targettp))
- val funDef = localTyper.typedPos(pos) {
- ValDef(funSym, Match(EmptyTree, catches1))
- }
- val expr2 = localTyper.typedPos(pos) {
- Apply(Select(expr1, expr1.tpe.member(cpsNames.flatMapCatch)), List(Ident(funSym)))
- }
-
- val exSym = currentOwner.newValueParameter(cpsNames.ex, pos).setInfo(ThrowableTpe)
-
- import CODE._
- // generate a case that is supported directly by the back-end
- val catchIfDefined = CaseDef(
- Bind(exSym, Ident(nme.WILDCARD)),
- EmptyTree,
- IF ((REF(funSym) DOT nme.isDefinedAt)(REF(exSym))) THEN (REF(funSym) APPLY (REF(exSym))) ELSE Throw(REF(exSym))
- )
-
- val catch2 = localTyper.typedCases(List(catchIfDefined), ThrowableTpe, targettp)
- //typedCases(tree, catches, ThrowableTpe, pt)
-
- patmatTransformer.transform(localTyper.typed(Block(List(funDef), treeCopy.Try(tree, treeCopy.Block(block1, stms, expr2), catch2, finalizer1))))
-
-
-/*
- disabled for now - see notes above
-
- val expr3 = if (!finalizer.isEmpty) {
- val pos = finalizer.pos
- val finalizer2 = duplicateTree(finalizer1)
- val fun = Function(List(), finalizer2)
- val expr3 = localTyper.typedPos(pos) { Apply(Select(expr2, expr2.tpe.member("mapFinally")), List(fun)) }
-
- val chown = new ChangeOwnerTraverser(currentOwner, fun.symbol)
- chown.traverse(finalizer2)
-
- expr3
- } else
- expr2
-*/
- } else {
- treeCopy.Try(tree, block1, catches1, finalizer1)
- }
-
- case Block(stms, expr) =>
-
- val (stms1, expr1) = transBlock(stms, expr)
- treeCopy.Block(tree, stms1, expr1)
-
- case _ =>
- super.transform(tree)
- }
- }
-
-
-
- def transBlock(stms: List[Tree], expr: Tree): (List[Tree], Tree) = {
-
- stms match {
- case Nil =>
- (Nil, transform(expr))
-
- case stm::rest =>
-
- stm match {
- case vd @ ValDef(mods, name, tpt, rhs)
- if (vd.symbol.hasAnnotation(MarkerCPSSym)) =>
-
- debuglog("found marked ValDef "+name+" of type " + vd.symbol.tpe)
-
- val tpe = vd.symbol.tpe
- val rhs1 = atOwner(vd.symbol) { transform(rhs) }
- rhs1.changeOwner(vd.symbol -> currentOwner) // TODO: don't traverse twice
-
- debuglog("valdef symbol " + vd.symbol + " has type " + tpe)
- debuglog("right hand side " + rhs1 + " has type " + rhs1.tpe)
-
- debuglog("currentOwner: " + currentOwner)
- debuglog("currentMethod: " + currentMethod)
-
- val (bodyStms, bodyExpr) = transBlock(rest, expr)
- // FIXME: result will later be traversed again by TreeSymSubstituter and
- // ChangeOwnerTraverser => exp. running time.
- // Should be changed to fuse traversals into one.
-
- val specialCaseTrivial = bodyExpr match {
- case Apply(fun, args) =>
- // for now, look for explicit tail calls only.
- // are there other cases that could profit from specializing on
- // trivial contexts as well?
- (bodyExpr.tpe.typeSymbol == Context) && (currentMethod == fun.symbol)
- case _ => false
- }
-
- def applyTrivial(ctxValSym: Symbol, body: Tree) = {
-
- val body1 = (new TreeSymSubstituter(List(vd.symbol), List(ctxValSym)))(body)
-
- val body2 = localTyper.typedPos(vd.symbol.pos) { body1 }
-
- // in theory it would be nicer to look for an @cps annotation instead
- // of testing for Context
- if ((body2.tpe == null) || !(body2.tpe.typeSymbol == Context)) {
- //println(body2 + "/" + body2.tpe)
- unit.error(rhs.pos, "cannot compute type for CPS-transformed function result")
- }
- body2
- }
-
- def applyCombinatorFun(ctxR: Tree, body: Tree) = {
- val arg = currentOwner.newValueParameter(name, ctxR.pos).setInfo(tpe)
- val body1 = (new TreeSymSubstituter(List(vd.symbol), List(arg)))(body)
- val fun = localTyper.typedPos(vd.symbol.pos) { Function(List(ValDef(arg)), body1) } // types body as well
- arg.owner = fun.symbol
- body1.changeOwner(currentOwner -> fun.symbol)
-
- // see note about multiple traversals above
-
- debuglog("fun.symbol: "+fun.symbol)
- debuglog("fun.symbol.owner: "+fun.symbol.owner)
- debuglog("arg.owner: "+arg.owner)
-
- debuglog("fun.tpe:"+fun.tpe)
- debuglog("return type of fun:"+body1.tpe)
-
- var methodName = nme.map
-
- if (body1.tpe != null) {
- if (body1.tpe.typeSymbol == Context)
- methodName = nme.flatMap
- }
- else
- unit.error(rhs.pos, "cannot compute type for CPS-transformed function result")
-
- debuglog("will use method:"+methodName)
-
- localTyper.typedPos(vd.symbol.pos) {
- Apply(Select(ctxR, ctxR.tpe.member(methodName)), List(fun))
- }
- }
-
- // TODO use gen.mkBlock after 2.11.0-M6. Why wait? It allows us to still build in development
- // mode with `ant -DskipLocker=1`
- def mkBlock(stms: List[Tree], expr: Tree) = if (stms.nonEmpty) Block(stms, expr) else expr
-
- try {
- if (specialCaseTrivial) {
- debuglog("will optimize possible tail call: " + bodyExpr)
-
- // FIXME: flatMap impl has become more complicated due to
- // exceptions. do we need to put a try/catch in the then part??
-
- // val ctx = <rhs>
- // if (ctx.isTrivial)
- // val <lhs> = ctx.getTrivialValue; ... <--- TODO: try/catch ??? don't bother for the moment...
- // else
- // ctx.flatMap { <lhs> => ... }
- val ctxSym = currentOwner.newValue(newTermName("" + vd.symbol.name + cpsNames.shiftSuffix)).setInfo(rhs1.tpe)
- val ctxDef = localTyper.typed(ValDef(ctxSym, rhs1))
- def ctxRef = localTyper.typed(Ident(ctxSym))
- val argSym = currentOwner.newValue(vd.symbol.name.toTermName).setInfo(tpe)
- val argDef = localTyper.typed(ValDef(argSym, Select(ctxRef, ctxRef.tpe.member(cpsNames.getTrivialValue))))
- val switchExpr = localTyper.typedPos(vd.symbol.pos) {
- val body2 = mkBlock(bodyStms, bodyExpr).duplicate // dup before typing!
- If(Select(ctxRef, ctxSym.tpe.member(cpsNames.isTrivial)),
- applyTrivial(argSym, mkBlock(argDef::bodyStms, bodyExpr)),
- applyCombinatorFun(ctxRef, body2))
- }
- (List(ctxDef), switchExpr)
- } else {
- // ctx.flatMap { <lhs> => ... }
- // or
- // ctx.map { <lhs> => ... }
- (Nil, applyCombinatorFun(rhs1, mkBlock(bodyStms, bodyExpr)))
- }
- } catch {
- case ex:TypeError =>
- unit.error(ex.pos, ex.msg)
- (bodyStms, bodyExpr)
- }
-
- case _ =>
- val stm1 = transform(stm)
- val (a, b) = transBlock(rest, expr)
- (stm1::a, b)
- }
- }
- }
-
-
- }
-}
diff --git a/src/continuations/plugin/scalac-plugin.xml b/src/continuations/plugin/scalac-plugin.xml
deleted file mode 100644
index 04d42655c5..0000000000
--- a/src/continuations/plugin/scalac-plugin.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<!-- $Id$ -->
-<plugin>
- <name>continuations</name>
- <classname>scala.tools.selectivecps.SelectiveCPSPlugin</classname>
-</plugin>
diff --git a/src/eclipse/continuations-library/.classpath b/src/eclipse/continuations-library/.classpath
deleted file mode 100644
index 61cb3f060e..0000000000
--- a/src/eclipse/continuations-library/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="continuations-library"/>
- <classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
- <classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="build-quick-continuations-library"/>
-</classpath>
diff --git a/src/eclipse/continuations-library/.project b/src/eclipse/continuations-library/.project
deleted file mode 100644
index 33cc57d667..0000000000
--- a/src/eclipse/continuations-library/.project
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>continuations-library</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.scala-ide.sdt.core.scalabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.scala-ide.sdt.core.scalanature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
- <linkedResources>
- <link>
- <name>build-quick-continuations-library</name>
- <type>2</type>
- <locationURI>SCALA_BASEDIR/build/quick/classes/continuations/library</locationURI>
- </link>
- <link>
- <name>continuations-library</name>
- <type>2</type>
- <locationURI>SCALA_BASEDIR/src/continuations/library</locationURI>
- </link>
- </linkedResources>
-</projectDescription>
diff --git a/src/eclipse/continuations-library/.settings/org.scala-ide.sdt.core.prefs b/src/eclipse/continuations-library/.settings/org.scala-ide.sdt.core.prefs
deleted file mode 100644
index 63e1df247f..0000000000
--- a/src/eclipse/continuations-library/.settings/org.scala-ide.sdt.core.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
-P=continuations\:enable
-scala.compiler.useProjectSettings=true
diff --git a/src/eclipse/reflect/.classpath b/src/eclipse/reflect/.classpath
index 1eb37e3f5f..3f14621da7 100644
--- a/src/eclipse/reflect/.classpath
+++ b/src/eclipse/reflect/.classpath
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="src" path="reflect"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
- <classpathentry combineaccessrules="false" kind="src" path="/continuations-library"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build-quick-reflect"/>
</classpath>
diff --git a/src/eclipse/scala-compiler/.classpath b/src/eclipse/scala-compiler/.classpath
index c185bc5391..e81cacca26 100644
--- a/src/eclipse/scala-compiler/.classpath
+++ b/src/eclipse/scala-compiler/.classpath
@@ -4,7 +4,6 @@
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/asm"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/reflect"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scala-library"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/continuations-library"/>
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build-quick-compiler"/>
diff --git a/src/eclipse/test-junit/.classpath b/src/eclipse/test-junit/.classpath
index fe3c3e4f18..d028dcc21e 100644
--- a/src/eclipse/test-junit/.classpath
+++ b/src/eclipse/test-junit/.classpath
@@ -5,7 +5,6 @@
<classpathentry kind="var" path="M2_REPO/junit/junit/4.10/junit-4.10.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/reflect"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
- <classpathentry combineaccessrules="false" kind="src" path="/continuations-library"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
<classpathentry kind="output" path="build-test-junit"/>
diff --git a/src/intellij/continuations-library.iml.SAMPLE b/src/intellij/continuations-library.iml.SAMPLE
deleted file mode 100644
index 364cc3dcdb..0000000000
--- a/src/intellij/continuations-library.iml.SAMPLE
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="scala" name="Scala">
- <configuration>
- <option name="compilerLibraryLevel" value="Project" />
- <option name="compilerLibraryName" value="compiler-locker" />
- <option name="maximumHeapSize" value="1536" />
- <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$/../continuations/library">
- <sourceFolder url="file://$MODULE_DIR$/../continuations/library" isTestSource="false" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="module" module-name="library" />
- </component>
-</module>
-
diff --git a/src/intellij/continuations-plugin.iml.SAMPLE b/src/intellij/continuations-plugin.iml.SAMPLE
deleted file mode 100644
index 27213374b3..0000000000
--- a/src/intellij/continuations-plugin.iml.SAMPLE
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="scala" name="Scala">
- <configuration>
- <option name="compilerLibraryLevel" value="Project" />
- <option name="compilerLibraryName" value="compiler-locker" />
- <option name="maximumHeapSize" value="1536" />
- <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$/../continuations/plugin">
- <sourceFolder url="file://$MODULE_DIR$/../continuations/plugin" isTestSource="false" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="module" module-name="library" />
- <orderEntry type="module" module-name="compiler" />
- <orderEntry type="module" module-name="reflect" />
- </component>
-</module>
-
diff --git a/src/intellij/parser-combinators.iml.SAMPLE b/src/intellij/parser-combinators.iml.SAMPLE
deleted file mode 100644
index 1ef913dbe4..0000000000
--- a/src/intellij/parser-combinators.iml.SAMPLE
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="scala" name="Scala">
- <configuration>
- <option name="compilerLibraryLevel" value="Project" />
- <option name="compilerLibraryName" value="compiler-locker" />
- <option name="maximumHeapSize" value="1536" />
- <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$/../parser-combinators">
- <sourceFolder url="file://$MODULE_DIR$/../parser-combinators" isTestSource="false" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="module" module-name="library" />
- </component>
-</module>
diff --git a/src/intellij/partest.iml.SAMPLE b/src/intellij/partest.iml.SAMPLE
deleted file mode 100644
index 893236b621..0000000000
--- a/src/intellij/partest.iml.SAMPLE
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="scala" name="Scala">
- <configuration>
- <option name="compilerLibraryLevel" value="Project" />
- <option name="compilerLibraryName" value="compiler-locker" />
- <option name="maximumHeapSize" value="1536" />
- <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$/../partest-extras">
- <sourceFolder url="file://$MODULE_DIR$/../partest-extras" isTestSource="false" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="library" name="partest-deps" level="project" />
- <orderEntry type="module" module-name="repl" />
- </component>
-</module>
-
diff --git a/src/intellij/scala-lang.ipr.SAMPLE b/src/intellij/scala-lang.ipr.SAMPLE
index f91a346b75..a0765b3e99 100644
--- a/src/intellij/scala-lang.ipr.SAMPLE
+++ b/src/intellij/scala-lang.ipr.SAMPLE
@@ -201,22 +201,16 @@
<module fileurl="file://$PROJECT_DIR$/actors.iml" filepath="$PROJECT_DIR$/actors.iml" />
<module fileurl="file://$PROJECT_DIR$/asm.iml" filepath="$PROJECT_DIR$/asm.iml" />
<module fileurl="file://$PROJECT_DIR$/compiler.iml" filepath="$PROJECT_DIR$/compiler.iml" />
- <module fileurl="file://$PROJECT_DIR$/continuations-library.iml" filepath="$PROJECT_DIR$/continuations-library.iml" />
- <module fileurl="file://$PROJECT_DIR$/continuations-plugin.iml" filepath="$PROJECT_DIR$/continuations-plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/forkjoin.iml" filepath="$PROJECT_DIR$/forkjoin.iml" />
<module fileurl="file://$PROJECT_DIR$/interactive.iml" filepath="$PROJECT_DIR$/interactive.iml" />
<module fileurl="file://$PROJECT_DIR$/library.iml" filepath="$PROJECT_DIR$/library.iml" />
<module fileurl="file://$PROJECT_DIR$/manual.iml" filepath="$PROJECT_DIR$/manual.iml" />
- <module fileurl="file://$PROJECT_DIR$/parser-combinators.iml" filepath="$PROJECT_DIR$/parser-combinators.iml" />
- <module fileurl="file://$PROJECT_DIR$/partest.iml" filepath="$PROJECT_DIR$/partest.iml" />
<module fileurl="file://$PROJECT_DIR$/reflect.iml" filepath="$PROJECT_DIR$/reflect.iml" />
<module fileurl="file://$PROJECT_DIR$/repl.iml" filepath="$PROJECT_DIR$/repl.iml" />
<module fileurl="file://$PROJECT_DIR$/scala.iml" filepath="$PROJECT_DIR$/scala.iml" />
<module fileurl="file://$PROJECT_DIR$/scaladoc.iml" filepath="$PROJECT_DIR$/scaladoc.iml" />
<module fileurl="file://$PROJECT_DIR$/scalap.iml" filepath="$PROJECT_DIR$/scalap.iml" />
- <module fileurl="file://$PROJECT_DIR$/swing.iml" filepath="$PROJECT_DIR$/swing.iml" />
<module fileurl="file://$PROJECT_DIR$/test.iml" filepath="$PROJECT_DIR$/test.iml" />
- <module fileurl="file://$PROJECT_DIR$/xml.iml" filepath="$PROJECT_DIR$/xml.iml" />
</modules>
</component>
<component name="ProjectResources">
diff --git a/src/intellij/swing.iml.SAMPLE b/src/intellij/swing.iml.SAMPLE
deleted file mode 100644
index c97bfdf91f..0000000000
--- a/src/intellij/swing.iml.SAMPLE
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="scala" name="Scala">
- <configuration>
- <option name="compilerLibraryLevel" value="Project" />
- <option name="compilerLibraryName" value="compiler-locker" />
- <option name="maximumHeapSize" value="1536" />
- <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$/../swing">
- <sourceFolder url="file://$MODULE_DIR$/../swing" isTestSource="false" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="module" module-name="library" />
- <orderEntry type="module" module-name="actors" />
- </component>
-</module>
-
diff --git a/src/intellij/xml.iml.SAMPLE b/src/intellij/xml.iml.SAMPLE
deleted file mode 100644
index b721f4e7f2..0000000000
--- a/src/intellij/xml.iml.SAMPLE
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="scala" name="Scala">
- <configuration>
- <option name="compilerLibraryLevel" value="Project" />
- <option name="compilerLibraryName" value="compiler-locker" />
- <option name="maximumHeapSize" value="1536" />
- <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$/../xml">
- <sourceFolder url="file://$MODULE_DIR$/../xml" isTestSource="false" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="module" module-name="library" />
- </component>
-</module>
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index 467a210cab..27f10ff00a 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -1018,7 +1018,11 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
val enclosing = new Members[ScopeMember]
def addScopeMember(sym: Symbol, pre: Type, viaImport: Tree) =
locals.add(sym, pre, implicitlyAdded = false) { (s, st) =>
- new ScopeMember(s, st, context.isAccessible(s, pre, superAccess = false), viaImport)
+ // imported val and var are always marked as inaccessible, but they could be accessed through their getters. SI-7995
+ if (s.hasGetter)
+ new ScopeMember(s, st, context.isAccessible(s.getter, pre, superAccess = false), viaImport)
+ else
+ new ScopeMember(s, st, context.isAccessible(s, pre, superAccess = false), viaImport)
}
def localsToEnclosing() = {
enclosing.addNonShadowed(locals)
@@ -1234,6 +1238,18 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
}
}
+ // We need to force a number of symbols that might be touched by a parser.
+ // Otherwise thread safety property of parseTree method would be violated.
+ protected def forceSymbolsUsedByParser(): Unit = {
+ val symbols =
+ Set(UnitClass, BooleanClass, ByteClass,
+ ShortClass, IntClass, LongClass, FloatClass,
+ DoubleClass, NilModule, ListClass) ++ TupleClass.seq
+ symbols.foreach(_.initialize)
+ }
+
+ forceSymbolsUsedByParser()
+
/** The compiler has been initialized. Constructors are evaluated in textual order,
* so this is set to true only after all super constructors and the primary constructor
* have been executed.
diff --git a/src/library/scala/MatchError.scala b/src/library/scala/MatchError.scala
index 6ba7e833d3..9965bb19b5 100644
--- a/src/library/scala/MatchError.scala
+++ b/src/library/scala/MatchError.scala
@@ -23,9 +23,15 @@ final class MatchError(obj: Any) extends RuntimeException {
/** There's no reason we need to call toString eagerly,
* so defer it until getMessage is called.
*/
- private lazy val objString =
+ private lazy val objString = {
+ def ofClass = "of class " + obj.getClass.getName
if (obj == null) "null"
- else obj.toString() + " (of class " + obj.getClass.getName + ")"
+ else try {
+ obj.toString() + " (" + ofClass + ")"
+ } catch {
+ case _: Throwable => "an instance " + ofClass
+ }
+ }
override def getMessage() = objString
}
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index c3a6351336..fb0a34e64d 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -180,21 +180,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
override def get0(key: A, hash: Int, level: Int): Option[B] =
if (hash == this.hash && key == this.key) Some(value) else None
- // override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1)): HashMap[A, B1] =
- // if (hash == this.hash && key == this.key) new HashMap1(key, hash, value, kv)
- // else {
- // var thatindex = (hash >>> level) & 0x1f
- // var thisindex = (this.hash >>> level) & 0x1f
- // if (hash != this.hash) {
- // --new HashTrieMap[A,B1](level+5, this, new HashMap1(key, hash, value, kv))
- // val m = new HashTrieMap[A,B1](0,new Array[HashMap[A,B1]](0),0) // TODO: could save array alloc
- // m.updated0(this.key, this.hash, level, this.value, this.kv).updated0(key, hash, level, value, kv) TODO and it will
- // } else {
- // 32-bit hash collision (rare, but not impossible)
- // new HashMapCollision1(hash, ListMap.empty.updated(this.key,this.value).updated(key,value))
- // }
- // }
-
private[collection] override def updated0[B1 >: B](key: A, hash: Int, level: Int, value: B1, kv: (A, B1), merger: Merger[A, B1]): HashMap[A, B1] =
if (hash == this.hash && key == this.key ) {
if (merger eq null) {
@@ -283,24 +268,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
// assert(Integer.bitCount(bitmap) == elems.length)
// assert(elems.length > 1 || (elems.length == 1 && elems(0).isInstanceOf[HashTrieMap[_,_]]))
-/*
- def this (level: Int, m1: HashMap1[A,B], m2: HashMap1[A,B]) = {
- this(((m1.hash >>> level) & 0x1f) | ((m2.hash >>> level) & 0x1f), {
- val idx1 = (m1.hash >>> level) & 0x1f
- val idx2 = (m2.hash >>> level) & 0x1f
- assert(idx1 != idx2, m1.hash + "==" + m2.hash + " at level " + level) // TODO
- val elems = new Array[HashMap[A,B]](2)
- if (idx1 < idx2) {
- elems(0) = m1
- elems(1) = m2
- } else {
- elems(0) = m2
- elems(1) = m1
- }
- elems
- }, 2)
- }
-*/
override def size = size0
override def get0(key: A, hash: Int, level: Int): Option[B] = {
@@ -379,24 +346,6 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
final override def getElem(cc: AnyRef): (A, B) = cc.asInstanceOf[HashMap1[A, B]].ensurePair
}
-/*
-def time(block: =>Unit) = { val t0 = System.nanoTime; block; println("elapsed: " + (System.nanoTime - t0)/1000000.0) }
-var mOld = OldHashMap.empty[Int,Int]
-var mNew = HashMap.empty[Int,Int]
-time { for (i <- 0 until 100000) mOld = mOld.updated(i,i) }
-time { for (i <- 0 until 100000) mOld = mOld.updated(i,i) }
-time { for (i <- 0 until 100000) mOld = mOld.updated(i,i) }
-time { for (i <- 0 until 100000) mNew = mNew.updated(i,i) }
-time { for (i <- 0 until 100000) mNew = mNew.updated(i,i) }
-time { for (i <- 0 until 100000) mNew = mNew.updated(i,i) }
-time { mOld.iterator.foreach( p => ()) }
-time { mOld.iterator.foreach( p => ()) }
-time { mOld.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-*/
-
override def foreach[U](f: ((A, B)) => U): Unit = {
var i = 0
while (i < elems.length) {
diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala
index 0546c54826..9eaceccd9f 100644
--- a/src/library/scala/collection/immutable/HashSet.scala
+++ b/src/library/scala/collection/immutable/HashSet.scala
@@ -282,28 +282,10 @@ object HashSet extends ImmutableSetFactory[HashSet] {
override def iterator = new TrieIterator[A](elems.asInstanceOf[Array[Iterable[A]]]) {
final override def getElem(cc: AnyRef): A = cc.asInstanceOf[HashSet1[A]].key
}
-/*
-
-def time(block: =>Unit) = { val t0 = System.nanoTime; block; println("elapsed: " + (System.nanoTime - t0)/1000000.0) }
-var mOld = OldHashSet.empty[Int]
-var mNew = HashSet.empty[Int]
-time { for (i <- 0 until 100000) mOld = mOld + i }
-time { for (i <- 0 until 100000) mOld = mOld + i }
-time { for (i <- 0 until 100000) mOld = mOld + i }
-time { for (i <- 0 until 100000) mNew = mNew + i }
-time { for (i <- 0 until 100000) mNew = mNew + i }
-time { for (i <- 0 until 100000) mNew = mNew + i }
-time { mOld.iterator.foreach( p => ()) }
-time { mOld.iterator.foreach( p => ()) }
-time { mOld.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-time { mNew.iterator.foreach( p => ()) }
-
-*/
+
override def foreach[U](f: A => U): Unit = {
var i = 0
- while (i < elems.length) {
+ while (i < elems.length) {
elems(i).foreach(f)
i += 1
}
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 57618d64a5..90aabc5a9a 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -322,6 +322,39 @@ sealed abstract class List[+A] extends AbstractSeq[A]
override def toStream : Stream[A] =
if (isEmpty) Stream.Empty
else new Stream.Cons(head, tail.toStream)
+
+ // Create a proxy for Java serialization that allows us to avoid mutation
+ // during de-serialization. This is the Serialization Proxy Pattern.
+ protected final def writeReplace(): AnyRef = new SerializationProxy(this)
+}
+
+@SerialVersionUID(1L)
+private class SerializationProxy[B](@transient private var orig: List[B]) extends Serializable {
+
+ private def writeObject(out: ObjectOutputStream) {
+ var xs: List[B] = orig
+ while (!xs.isEmpty) {
+ out.writeObject(xs.head)
+ xs = xs.tail
+ }
+ out.writeObject(ListSerializeEnd)
+ }
+
+ // Java serialization calls this before readResolve during de-serialization.
+ // Read the whole list and store it in `orig`.
+ private def readObject(in: ObjectInputStream) {
+ val builder = List.newBuilder[B]
+ while (true) in.readObject match {
+ case ListSerializeEnd =>
+ orig = builder.result()
+ return
+ case a =>
+ builder += a.asInstanceOf[B]
+ }
+ }
+
+ // Provide the result stored in `orig` for Java serialization
+ private def readResolve(): AnyRef = orig
}
/** The empty list.
@@ -352,33 +385,10 @@ case object Nil extends List[Nothing] {
* @version 1.0, 15/07/2003
* @since 2.8
*/
-@SerialVersionUID(0L - 8476791151983527571L)
-final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extends List[B] {
+final case class ::[B](private val hd: B, private[scala] var tl: List[B]) extends List[B] {
override def head : B = hd
override def tail : List[B] = tl
override def isEmpty: Boolean = false
-
- private def readObject(in: ObjectInputStream) {
- val firstObject = in.readObject()
- hd = firstObject.asInstanceOf[B]
- assert(hd != ListSerializeEnd)
- var current: ::[B] = this
- while (true) in.readObject match {
- case ListSerializeEnd =>
- current.tl = Nil
- return
- case a =>
- val list : ::[B] = new ::(a.asInstanceOf[B], Nil)
- current.tl = list
- current = list
- }
- }
-
- private def writeObject(out: ObjectOutputStream) {
- var xs: List[B] = this
- while (!xs.isEmpty) { out.writeObject(xs.head); xs = xs.tail }
- out.writeObject(ListSerializeEnd)
- }
}
/** $factoryInfo
diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala
index 05c5dd799d..264304db68 100644
--- a/src/library/scala/collection/immutable/Queue.scala
+++ b/src/library/scala/collection/immutable/Queue.scala
@@ -89,6 +89,16 @@ class Queue[+A] protected(protected val in: List[A], protected val out: List[A])
*/
override def length = in.length + out.length
+ override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Queue[A], B, That]): That = bf match {
+ case _: Queue.GenericCanBuildFrom[_] => new Queue(in, elem :: out).asInstanceOf[That]
+ case _ => super.+:(elem)(bf)
+ }
+
+ override def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Queue[A], B, That]): That = bf match {
+ case _: Queue.GenericCanBuildFrom[_] => enqueue(elem).asInstanceOf[That]
+ case _ => super.:+(elem)(bf)
+ }
+
/** Creates a new queue with element added at the end
* of the old queue.
*
@@ -119,6 +129,13 @@ class Queue[+A] protected(protected val in: List[A], protected val out: List[A])
case _ => throw new NoSuchElementException("dequeue on empty queue")
}
+ /** Optionally retrieves the first element and a queue of the remaining elements.
+ *
+ * @return A tuple of the first element of the queue, and a new queue with this element removed.
+ * If the queue is empty, `None` is returned.
+ */
+ def dequeueOption: Option[(A, Queue[A])] = if(isEmpty) None else Some(dequeue)
+
/** Returns the first element in the queue, or throws an error if there
* is no element contained in the queue.
*
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index 5e1de44749..a82e31f5da 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -955,7 +955,7 @@ self =>
* `Stream`.
* @example {{{
* val sov: Stream[Vector[Int]] = Vector(0) #:: Vector(0, 0) #:: sov.zip(sov.tail).map { n => n._1 ++ n._2 }
- * sov flatten take 10 mkString ", "
+ * sov.flatten take 10 mkString ", "
* // produces: "0, 0, 0, 0, 0, 0, 0, 0, 0, 0"
* }}}
*/
diff --git a/src/library/scala/concurrent/SyncVar.scala b/src/library/scala/concurrent/SyncVar.scala
index 76d21c3dbf..d5dc3d7e3f 100644
--- a/src/library/scala/concurrent/SyncVar.scala
+++ b/src/library/scala/concurrent/SyncVar.scala
@@ -8,6 +8,8 @@
package scala.concurrent
+import java.util.concurrent.TimeUnit
+
/** A class to provide safe concurrent access to a mutable cell.
* All methods are synchronized.
*
@@ -23,14 +25,16 @@ class SyncVar[A] {
value.get
}
- /** Waits `timeout` millis. If `timeout <= 0` just returns 0. If the system clock
- * went backward, it will return 0, so it never returns negative results.
- */
+ /** Waits `timeout` millis. If `timeout <= 0` just returns 0.
+ * It never returns negative results.
+ */
private def waitMeasuringElapsed(timeout: Long): Long = if (timeout <= 0) 0 else {
- val start = System.currentTimeMillis
+ val start = System.nanoTime()
wait(timeout)
- val elapsed = System.currentTimeMillis - start
- if (elapsed < 0) 0 else elapsed
+ val elapsed = System.nanoTime() - start
+ // nanoTime should be monotonic, but it's not possible to rely on that.
+ // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6458294.
+ if (elapsed < 0) 0 else TimeUnit.NANOSECONDS.toMillis(elapsed)
}
/** Waits for this SyncVar to become defined at least for
diff --git a/src/reflect/scala/reflect/api/BuildUtils.scala b/src/reflect/scala/reflect/api/BuildUtils.scala
index cf05aefe72..6971175f88 100644
--- a/src/reflect/scala/reflect/api/BuildUtils.scala
+++ b/src/reflect/scala/reflect/api/BuildUtils.scala
@@ -90,9 +90,9 @@ private[reflect] trait BuildUtils { self: Universe =>
def RefTree(qual: Tree, sym: Symbol): Tree
- def withFreshTermName[T](prefix: String)(f: TermName => T): T
+ def freshTermName(prefix: String): TermName
- def withFreshTypeName[T](prefix: String)(f: TypeName => T): T
+ def freshTypeName(prefix: String): TypeName
val ScalaDot: ScalaDotExtractor
@@ -122,19 +122,12 @@ private[reflect] trait BuildUtils { self: Universe =>
def unapply(tree: Tree): Some[(Tree, List[List[Tree]])]
}
- val SyntacticApply: SyntacticApplyExtractor
-
- trait SyntacticApplyExtractor {
- def apply(tree: Tree, args: List[Tree]): Tree
- def unapply(tree: Tree): Some[(Tree, List[Tree])]
- }
-
val SyntacticClassDef: SyntacticClassDefExtractor
trait SyntacticClassDefExtractor {
- def apply(mods: Modifiers, name: TypeName, tparams: List[TypeDef],
- constrMods: Modifiers, vparamss: List[List[ValDef]], earlyDefs: List[Tree],
- parents: List[Tree], selfType: ValDef, body: List[Tree]): ClassDef
+ def apply(mods: Modifiers, name: TypeName, tparams: List[Tree],
+ constrMods: Modifiers, vparamss: List[List[Tree]], earlyDefs: List[Tree],
+ parents: List[Tree], selfType: Tree, body: List[Tree]): ClassDef
def unapply(tree: Tree): Option[(Modifiers, TypeName, List[TypeDef], Modifiers, List[List[ValDef]],
List[Tree], List[Tree], ValDef, List[Tree])]
}
@@ -142,8 +135,8 @@ private[reflect] trait BuildUtils { self: Universe =>
val SyntacticTraitDef: SyntacticTraitDefExtractor
trait SyntacticTraitDefExtractor {
- def apply(mods: Modifiers, name: TypeName, tparams: List[TypeDef],
- earlyDefs: List[Tree], parents: List[Tree], selfType: ValDef, body: List[Tree]): ClassDef
+ def apply(mods: Modifiers, name: TypeName, tparams: List[Tree],
+ earlyDefs: List[Tree], parents: List[Tree], selfType: Tree, body: List[Tree]): ClassDef
def unapply(tree: Tree): Option[(Modifiers, TypeName, List[TypeDef],
List[Tree], List[Tree], ValDef, List[Tree])]
}
@@ -152,7 +145,7 @@ private[reflect] trait BuildUtils { self: Universe =>
trait SyntacticObjectDefExtractor {
def apply(mods: Modifiers, name: TermName, earlyDefs: List[Tree],
- parents: List[Tree], selfType: ValDef, body: List[Tree]): Tree
+ parents: List[Tree], selfType: Tree, body: List[Tree]): Tree
def unapply(tree: Tree): Option[(Modifiers, TermName, List[Tree], List[Tree], ValDef, List[Tree])]
}
@@ -160,7 +153,7 @@ private[reflect] trait BuildUtils { self: Universe =>
trait SyntacticPackageObjectDefExtractor {
def apply(name: TermName, earlyDefs: List[Tree],
- parents: List[Tree], selfType: ValDef, body: List[Tree]): Tree
+ parents: List[Tree], selfType: Tree, body: List[Tree]): Tree
def unapply(tree: Tree): Option[(TermName, List[Tree], List[Tree], ValDef, List[Tree])]
}
@@ -182,7 +175,7 @@ private[reflect] trait BuildUtils { self: Universe =>
val SyntacticNew: SyntacticNewExtractor
trait SyntacticNewExtractor {
- def apply(earlyDefs: List[Tree], parents: List[Tree], selfType: ValDef, body: List[Tree]): Tree
+ def apply(earlyDefs: List[Tree], parents: List[Tree], selfType: Tree, body: List[Tree]): Tree
def unapply(tree: Tree): Option[(List[Tree], List[Tree], ValDef, List[Tree])]
}
@@ -196,7 +189,7 @@ private[reflect] trait BuildUtils { self: Universe =>
val SyntacticFunction: SyntacticFunctionExtractor
trait SyntacticFunctionExtractor {
- def apply(params: List[ValDef], body: Tree): Tree
+ def apply(params: List[Tree], body: Tree): Tree
def unapply(tree: Tree): Option[(List[ValDef], Tree)]
}
@@ -204,7 +197,7 @@ private[reflect] trait BuildUtils { self: Universe =>
val SyntacticDefDef: SyntacticDefDefExtractor
trait SyntacticDefDefExtractor {
- def apply(mods: Modifiers, name: TermName, tparams: List[Tree], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef
+ def apply(mods: Modifiers, name: TermName, tparams: List[Tree], vparamss: List[List[Tree]], tpt: Tree, rhs: Tree): DefDef
def unapply(tree: Tree): Option[(Modifiers, TermName, List[Tree], List[List[ValDef]], Tree, Tree)]
}
@@ -252,5 +245,33 @@ private[reflect] trait BuildUtils { self: Universe =>
def apply(enums: List[Tree], body: Tree): Tree
def unapply(tree: Tree): Option[(List[Tree], Tree)]
}
+
+ def UnliftHelper1[T](unliftable: Unliftable[T]): UnliftHelper1[T]
+ trait UnliftHelper1[T] {
+ def unapply(lst: List[Tree]): Option[List[T]]
+ }
+
+ def UnliftHelper2[T](unliftable: Unliftable[T]): UnliftHelper2[T]
+ trait UnliftHelper2[T] {
+ def unapply(lst: List[List[Tree]]): Option[List[List[T]]]
+ }
+
+ val SyntacticMatch: SyntacticMatchExtractor
+ trait SyntacticMatchExtractor {
+ def apply(selector: Tree, cases: List[Tree]): Match
+ def unapply(tree: Match): Option[(Tree, List[CaseDef])]
+ }
+
+ val SyntacticTry: SyntacticTryExtractor
+ trait SyntacticTryExtractor {
+ def apply(block: Tree, catches: List[Tree], finalizer: Tree): Try
+ def unapply(tree: Try): Option[(Tree, List[CaseDef], Tree)]
+ }
+
+ val SyntacticIdent: SyntacticIdentExtractor
+ trait SyntacticIdentExtractor {
+ def apply(name: Name, isBackquoted: Boolean = false): Ident
+ def unapply(tree: Ident): Option[(Name, Boolean)]
+ }
}
}
diff --git a/src/reflect/scala/reflect/api/Liftable.scala b/src/reflect/scala/reflect/api/Liftable.scala
deleted file mode 100644
index 8f6fe066dd..0000000000
--- a/src/reflect/scala/reflect/api/Liftable.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-package scala.reflect
-package api
-
-trait Liftable[T] {
- def apply(universe: api.Universe, value: T): universe.Tree
-}
-
-object Liftable {
- private class LiftableConstant[T] extends Liftable[T] {
- def apply(universe: Universe, value: T): universe.Tree =
- universe.Literal(universe.Constant(value))
- }
-
- implicit lazy val liftByte: Liftable[Byte] = new LiftableConstant[Byte]
- implicit lazy val liftShort: Liftable[Short] = new LiftableConstant[Short]
- implicit lazy val liftChar: Liftable[Char] = new LiftableConstant[Char]
- implicit lazy val liftInt: Liftable[Int] = new LiftableConstant[Int]
- implicit lazy val liftLong: Liftable[Long] = new LiftableConstant[Long]
- implicit lazy val liftFloat: Liftable[Float] = new LiftableConstant[Float]
- implicit lazy val liftDouble: Liftable[Double] = new LiftableConstant[Double]
- implicit lazy val liftBoolean: Liftable[Boolean] = new LiftableConstant[Boolean]
- implicit lazy val liftString: Liftable[String] = new LiftableConstant[String]
- implicit lazy val liftUnit: Liftable[Unit] = new LiftableConstant[Unit]
-
- implicit lazy val liftScalaSymbol: Liftable[scala.Symbol] = new Liftable[scala.Symbol] {
- def apply(universe: Universe, value: scala.Symbol): universe.Tree = {
- import universe._
- val symbol = Select(Ident(TermName("scala")), TermName("Symbol"))
- Apply(symbol, List(Literal(Constant(value.name))))
- }
- }
-}
diff --git a/src/reflect/scala/reflect/api/Liftables.scala b/src/reflect/scala/reflect/api/Liftables.scala
new file mode 100644
index 0000000000..6ac5557caa
--- /dev/null
+++ b/src/reflect/scala/reflect/api/Liftables.scala
@@ -0,0 +1,30 @@
+package scala
+package reflect
+package api
+
+// TODO: needs a Scaladoc
+trait Liftables { self: Universe =>
+
+ // TODO: needs a Scaladoc
+ trait Liftable[T] {
+ def apply(value: T): Tree
+ }
+
+ // TODO: needs a Scaladoc
+ object Liftable extends StandardLiftableInstances {
+ def apply[T](f: T => Tree): Liftable[T] =
+ new Liftable[T] { def apply(value: T): Tree = f(value) }
+ }
+
+ // TODO: needs a Scaladoc
+ trait Unliftable[T] {
+ def unapply(tree: Tree): Option[T]
+ }
+
+ // TODO: needs a Scaladoc
+ object Unliftable extends StandardUnliftableInstances {
+ def apply[T](pf: PartialFunction[Tree, T]): Unliftable[T] = new Unliftable[T] {
+ def unapply(value: Tree): Option[T] = pf.lift(value)
+ }
+ }
+}
diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala
index 6e2e2c3781..1e0854d171 100644
--- a/src/reflect/scala/reflect/api/Printers.scala
+++ b/src/reflect/scala/reflect/api/Printers.scala
@@ -68,7 +68,7 @@ import java.io.{ PrintWriter, StringWriter }
* scala> import scala.reflect.runtime.{currentMirror => cm}
* import scala.reflect.runtime.{currentMirror=>cm}
*
- * scala> showRaw(cm.mkToolBox().typeCheck(tree), printTypes = true)
+ * scala> showRaw(cm.mkToolBox().typecheck(tree), printTypes = true)
* res2: String = Block[1](List(
* ClassDef[2](Modifiers(FINAL), newTypeName("C"), List(), Template[3](
* List(Ident[4](newTypeName("AnyRef"))),
diff --git a/src/reflect/scala/reflect/api/StandardLiftables.scala b/src/reflect/scala/reflect/api/StandardLiftables.scala
index ecea550225..6756d5e114 100644
--- a/src/reflect/scala/reflect/api/StandardLiftables.scala
+++ b/src/reflect/scala/reflect/api/StandardLiftables.scala
@@ -2,35 +2,229 @@ package scala.reflect
package api
trait StandardLiftables { self: Universe =>
+ import build.{SyntacticTuple, ScalaDot}
- private def requireSameUniverse[T](universe: Universe, tp: String, value: T) =
- require(universe eq self, s"Can't lift $tp ${showRaw(value)} from universe ${showRaw(universe)} using lift$tp defined for ${showRaw(self)}.")
+ trait StandardLiftableInstances {
+ private def lift[T: Liftable](value: T): Tree = implicitly[Liftable[T]].apply(value)
+ private def selectScala(names: Name*) = names.tail.foldLeft(ScalaDot(names.head)) { Select(_, _) }
+ private def callScala(names: Name*)(args: List[Tree]) = Apply(selectScala(names: _*), args)
+ private def callCollection(name: Name)(args: List[Tree]) = callScala(nme.collection, nme.immutable, name)(args)
+ private def liftAsLiteral[T]: Liftable[T] = Liftable { v => Literal(Constant(v)) }
- implicit def liftExpr[T <: Expr[_]]: Liftable[T] = new Liftable[T] {
- def apply(universe: Universe, value: T): universe.Tree = {
- requireSameUniverse(universe, "Expr", value)
- value.tree.asInstanceOf[universe.Tree]
+ implicit def liftByte[T <: Byte]: Liftable[T] = liftAsLiteral[T]
+ implicit def liftShort[T <: Short]: Liftable[T] = liftAsLiteral[T]
+ implicit def liftChar[T <: Char]: Liftable[T] = liftAsLiteral[T]
+ implicit def liftInt[T <: Int]: Liftable[T] = liftAsLiteral[T]
+ implicit def liftLong[T <: Long]: Liftable[T] = liftAsLiteral[T]
+ implicit def liftFloat[T <: Float]: Liftable[T] = liftAsLiteral[T]
+ implicit def liftDouble[T <: Double]: Liftable[T] = liftAsLiteral[T]
+ implicit def liftBoolean: Liftable[Boolean] = liftAsLiteral[Boolean]
+ implicit def liftUnit: Liftable[Unit] = liftAsLiteral[Unit]
+ implicit def liftString: Liftable[String] = liftAsLiteral[String]
+
+ implicit def liftScalaSymbol: Liftable[scala.Symbol] = Liftable { v =>
+ callScala(nme.Symbol)(Literal(Constant(v.name)) :: Nil)
}
- }
- implicit def liftType[T <: Type]: Liftable[T] = new Liftable[T] {
- def apply(universe: Universe, value: T): universe.Tree = {
- requireSameUniverse(universe, "Type", value)
- universe.TypeTree(value.asInstanceOf[universe.Type])
+ implicit def liftName[T <: Name]: Liftable[T] = Liftable { name => Ident(name) }
+ implicit def liftExpr[T <: Expr[_]]: Liftable[T] = Liftable { expr => expr.tree }
+ implicit def liftType[T <: Type]: Liftable[T] = Liftable { tpe => TypeTree(tpe) }
+ implicit def liftTypeTag[T <: WeakTypeTag[_]]: Liftable[T] = Liftable { ttag => TypeTree(ttag.tpe) }
+ implicit def liftConstant[T <: Constant]: Liftable[T] = Liftable { const => Literal(const) }
+
+ implicit def liftArray[T: Liftable]: Liftable[Array[T]] = Liftable { arr => callScala(nme.Array)(arr.map(lift(_)).toList) }
+ implicit def liftVector[T: Liftable]: Liftable[Vector[T]] = Liftable { vect => callCollection(nme.Vector)(vect.map(lift(_)).toList) }
+ implicit def liftList[T: Liftable]: Liftable[List[T]] = Liftable { lst => callCollection(nme.List)(lst.map(lift(_))) }
+ implicit def liftMap[K: Liftable, V: Liftable]: Liftable[Map[K, V]] = Liftable { m => callCollection(nme.Map)(m.toList.map(lift(_))) }
+ implicit def liftSet[T: Liftable]: Liftable[Set[T]] = Liftable { s => callCollection(nme.Set)(s.toList.map(lift(_))) }
+
+ implicit def liftOption[T: Liftable]: Liftable[Option[T]] = Liftable {
+ case Some(v) => callScala(nme.Some)(lift(v) :: Nil)
+ case None => selectScala(nme.None)
+ }
+ implicit def liftEither[L: Liftable, R: Liftable]: Liftable[Either[L, R]] = Liftable {
+ case Left(l) => callScala(nme.util, nme.Left)(lift(l) :: Nil)
+ case Right(r) => callScala(nme.util, nme.Right)(lift(r) :: Nil)
}
- }
- implicit def liftTypeTag[T <: WeakTypeTag[_]]: Liftable[T] = new Liftable[T] {
- def apply(universe: Universe, value: T): universe.Tree = {
- requireSameUniverse(universe, "TypeTag", value)
- universe.TypeTree(value.asInstanceOf[universe.WeakTypeTag[_]].tpe)
+ implicit def liftTuple1[T1](implicit liftT1: Liftable[T1]): Liftable[Tuple1[T1]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: Nil)
+ }
+ implicit def liftTuple2[T1, T2](implicit liftT1: Liftable[T1], liftT2: Liftable[T2]): Liftable[Tuple2[T1, T2]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: Nil)
+ }
+ implicit def liftTuple3[T1, T2, T3](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3]): Liftable[Tuple3[T1, T2, T3]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: Nil)
+ }
+ implicit def liftTuple4[T1, T2, T3, T4](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4]): Liftable[Tuple4[T1, T2, T3, T4]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: Nil)
+ }
+ implicit def liftTuple5[T1, T2, T3, T4, T5](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5]): Liftable[Tuple5[T1, T2, T3, T4, T5]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: Nil)
+ }
+ implicit def liftTuple6[T1, T2, T3, T4, T5, T6](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6]): Liftable[Tuple6[T1, T2, T3, T4, T5, T6]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: Nil)
+ }
+ implicit def liftTuple7[T1, T2, T3, T4, T5, T6, T7](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7]): Liftable[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: Nil)
+ }
+ implicit def liftTuple8[T1, T2, T3, T4, T5, T6, T7, T8](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8]): Liftable[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: Nil)
+ }
+ implicit def liftTuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9]): Liftable[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: Nil)
+ }
+ implicit def liftTuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10]): Liftable[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: Nil)
+ }
+ implicit def liftTuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11]): Liftable[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: Nil)
+ }
+ implicit def liftTuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12]): Liftable[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: Nil)
+ }
+ implicit def liftTuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13]): Liftable[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: Nil)
+ }
+ implicit def liftTuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13], liftT14: Liftable[T14]): Liftable[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: liftT14(t._14) :: Nil)
+ }
+ implicit def liftTuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13], liftT14: Liftable[T14], liftT15: Liftable[T15]): Liftable[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: liftT14(t._14) :: liftT15(t._15) :: Nil)
+ }
+ implicit def liftTuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13], liftT14: Liftable[T14], liftT15: Liftable[T15], liftT16: Liftable[T16]): Liftable[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: liftT14(t._14) :: liftT15(t._15) :: liftT16(t._16) :: Nil)
+ }
+ implicit def liftTuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13], liftT14: Liftable[T14], liftT15: Liftable[T15], liftT16: Liftable[T16], liftT17: Liftable[T17]): Liftable[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: liftT14(t._14) :: liftT15(t._15) :: liftT16(t._16) :: liftT17(t._17) :: Nil)
+ }
+ implicit def liftTuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13], liftT14: Liftable[T14], liftT15: Liftable[T15], liftT16: Liftable[T16], liftT17: Liftable[T17], liftT18: Liftable[T18]): Liftable[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: liftT14(t._14) :: liftT15(t._15) :: liftT16(t._16) :: liftT17(t._17) :: liftT18(t._18) :: Nil)
+ }
+ implicit def liftTuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13], liftT14: Liftable[T14], liftT15: Liftable[T15], liftT16: Liftable[T16], liftT17: Liftable[T17], liftT18: Liftable[T18], liftT19: Liftable[T19]): Liftable[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: liftT14(t._14) :: liftT15(t._15) :: liftT16(t._16) :: liftT17(t._17) :: liftT18(t._18) :: liftT19(t._19) :: Nil)
+ }
+ implicit def liftTuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13], liftT14: Liftable[T14], liftT15: Liftable[T15], liftT16: Liftable[T16], liftT17: Liftable[T17], liftT18: Liftable[T18], liftT19: Liftable[T19], liftT20: Liftable[T20]): Liftable[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: liftT14(t._14) :: liftT15(t._15) :: liftT16(t._16) :: liftT17(t._17) :: liftT18(t._18) :: liftT19(t._19) :: liftT20(t._20) :: Nil)
+ }
+ implicit def liftTuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13], liftT14: Liftable[T14], liftT15: Liftable[T15], liftT16: Liftable[T16], liftT17: Liftable[T17], liftT18: Liftable[T18], liftT19: Liftable[T19], liftT20: Liftable[T20], liftT21: Liftable[T21]): Liftable[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: liftT14(t._14) :: liftT15(t._15) :: liftT16(t._16) :: liftT17(t._17) :: liftT18(t._18) :: liftT19(t._19) :: liftT20(t._20) :: liftT21(t._21) :: Nil)
+ }
+ implicit def liftTuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22](implicit liftT1: Liftable[T1], liftT2: Liftable[T2], liftT3: Liftable[T3], liftT4: Liftable[T4], liftT5: Liftable[T5], liftT6: Liftable[T6], liftT7: Liftable[T7], liftT8: Liftable[T8], liftT9: Liftable[T9], liftT10: Liftable[T10], liftT11: Liftable[T11], liftT12: Liftable[T12], liftT13: Liftable[T13], liftT14: Liftable[T14], liftT15: Liftable[T15], liftT16: Liftable[T16], liftT17: Liftable[T17], liftT18: Liftable[T18], liftT19: Liftable[T19], liftT20: Liftable[T20], liftT21: Liftable[T21], liftT22: Liftable[T22]): Liftable[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = Liftable { t =>
+ SyntacticTuple(liftT1(t._1) :: liftT2(t._2) :: liftT3(t._3) :: liftT4(t._4) :: liftT5(t._5) :: liftT6(t._6) :: liftT7(t._7) :: liftT8(t._8) :: liftT9(t._9) :: liftT10(t._10) :: liftT11(t._11) :: liftT12(t._12) :: liftT13(t._13) :: liftT14(t._14) :: liftT15(t._15) :: liftT16(t._16) :: liftT17(t._17) :: liftT18(t._18) :: liftT19(t._19) :: liftT20(t._20) :: liftT21(t._21) :: liftT22(t._22) :: Nil)
}
}
- implicit def liftConstant[T <: Constant]: Liftable[T] = new Liftable[T] {
- def apply(universe: Universe, value: T): universe.Tree = {
- requireSameUniverse(universe, "Constant", value)
- universe.Literal(value.asInstanceOf[universe.Constant])
+ trait StandardUnliftableInstances {
+ private def unliftPrimitive[Unboxed: ClassTag, Boxed: ClassTag] = Unliftable[Unboxed] {
+ case Literal(Constant(value))
+ if value.getClass == implicitly[ClassTag[Boxed]].runtimeClass
+ || value.getClass == implicitly[ClassTag[Unboxed]].runtimeClass =>
+ value.asInstanceOf[Unboxed]
}
+ implicit def unliftByte: Unliftable[Byte] = unliftPrimitive[Byte, java.lang.Byte]
+ implicit def unliftShort: Unliftable[Short] = unliftPrimitive[Short, java.lang.Short]
+ implicit def unliftChar: Unliftable[Char] = unliftPrimitive[Char, java.lang.Character]
+ implicit def unliftInt: Unliftable[Int] = unliftPrimitive[Int, java.lang.Integer]
+ implicit def unliftLong: Unliftable[Long] = unliftPrimitive[Long, java.lang.Long]
+ implicit def unliftFloat: Unliftable[Float] = unliftPrimitive[Float, java.lang.Float]
+ implicit def unliftDouble: Unliftable[Double] = unliftPrimitive[Double, java.lang.Double]
+ implicit def unliftBoolean: Unliftable[Boolean] = unliftPrimitive[Boolean, java.lang.Boolean]
+ implicit def unliftUnit: Unliftable[Unit] = unliftPrimitive[Unit, scala.runtime.BoxedUnit]
+ implicit def unliftString: Unliftable[String] = Unliftable { case Literal(Constant(s: String)) => s }
+
+ implicit def unliftScalaSymbol: Unliftable[scala.Symbol] = Unliftable {
+ case Apply(ScalaDot(symbol), List(Literal(Constant(name: String)))) if symbol == nme.Symbol => scala.Symbol(name)
+ }
+
+ implicit def unliftName[T <: Name : ClassTag]: Unliftable[T] = Unliftable[T] { case Ident(name: T) => name; case Bind(name: T, Ident(nme.WILDCARD)) => name}
+ implicit def unliftType: Unliftable[Type] = Unliftable[Type] { case tt: TypeTree if tt.tpe != null => tt.tpe }
+ implicit def unliftConstant: Unliftable[Constant] = Unliftable[Constant] { case Literal(const) => const }
+
+ implicit def unliftTuple1[T1](implicit UnliftT1: Unliftable[T1]): Unliftable[Tuple1[T1]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: Nil) => Tuple1(v1)
+ }
+ implicit def unliftTuple2[T1, T2](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2]): Unliftable[Tuple2[T1, T2]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: Nil) => Tuple2(v1, v2)
+ }
+ implicit def unliftTuple3[T1, T2, T3](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3]): Unliftable[Tuple3[T1, T2, T3]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: Nil) => Tuple3(v1, v2, v3)
+ }
+ implicit def unliftTuple4[T1, T2, T3, T4](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4]): Unliftable[Tuple4[T1, T2, T3, T4]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: Nil) => Tuple4(v1, v2, v3, v4)
+ }
+ implicit def unliftTuple5[T1, T2, T3, T4, T5](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5]): Unliftable[Tuple5[T1, T2, T3, T4, T5]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: Nil) => Tuple5(v1, v2, v3, v4, v5)
+ }
+ implicit def unliftTuple6[T1, T2, T3, T4, T5, T6](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6]): Unliftable[Tuple6[T1, T2, T3, T4, T5, T6]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: Nil) => Tuple6(v1, v2, v3, v4, v5, v6)
+ }
+ implicit def unliftTuple7[T1, T2, T3, T4, T5, T6, T7](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7]): Unliftable[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: Nil) => Tuple7(v1, v2, v3, v4, v5, v6, v7)
+ }
+ implicit def unliftTuple8[T1, T2, T3, T4, T5, T6, T7, T8](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8]): Unliftable[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: Nil) => Tuple8(v1, v2, v3, v4, v5, v6, v7, v8)
+ }
+ implicit def unliftTuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9]): Unliftable[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: Nil) => Tuple9(v1, v2, v3, v4, v5, v6, v7, v8, v9)
+ }
+ implicit def unliftTuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10]): Unliftable[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: Nil) => Tuple10(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10)
+ }
+ implicit def unliftTuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11]): Unliftable[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: Nil) => Tuple11(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
+ }
+ implicit def unliftTuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12]): Unliftable[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: Nil) => Tuple12(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
+ }
+ implicit def unliftTuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13]): Unliftable[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: Nil) => Tuple13(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
+ }
+ implicit def unliftTuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13], UnliftT14: Unliftable[T14]): Unliftable[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: UnliftT14(v14) :: Nil) => Tuple14(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
+ }
+ implicit def unliftTuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13], UnliftT14: Unliftable[T14], UnliftT15: Unliftable[T15]): Unliftable[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: UnliftT14(v14) :: UnliftT15(v15) :: Nil) => Tuple15(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
+ }
+ implicit def unliftTuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13], UnliftT14: Unliftable[T14], UnliftT15: Unliftable[T15], UnliftT16: Unliftable[T16]): Unliftable[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: UnliftT14(v14) :: UnliftT15(v15) :: UnliftT16(v16) :: Nil) => Tuple16(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
+ }
+ implicit def unliftTuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13], UnliftT14: Unliftable[T14], UnliftT15: Unliftable[T15], UnliftT16: Unliftable[T16], UnliftT17: Unliftable[T17]): Unliftable[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: UnliftT14(v14) :: UnliftT15(v15) :: UnliftT16(v16) :: UnliftT17(v17) :: Nil) => Tuple17(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
+ }
+ implicit def unliftTuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13], UnliftT14: Unliftable[T14], UnliftT15: Unliftable[T15], UnliftT16: Unliftable[T16], UnliftT17: Unliftable[T17], UnliftT18: Unliftable[T18]): Unliftable[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: UnliftT14(v14) :: UnliftT15(v15) :: UnliftT16(v16) :: UnliftT17(v17) :: UnliftT18(v18) :: Nil) => Tuple18(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
+ }
+ implicit def unliftTuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13], UnliftT14: Unliftable[T14], UnliftT15: Unliftable[T15], UnliftT16: Unliftable[T16], UnliftT17: Unliftable[T17], UnliftT18: Unliftable[T18], UnliftT19: Unliftable[T19]): Unliftable[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: UnliftT14(v14) :: UnliftT15(v15) :: UnliftT16(v16) :: UnliftT17(v17) :: UnliftT18(v18) :: UnliftT19(v19) :: Nil) => Tuple19(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
+ }
+ implicit def unliftTuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13], UnliftT14: Unliftable[T14], UnliftT15: Unliftable[T15], UnliftT16: Unliftable[T16], UnliftT17: Unliftable[T17], UnliftT18: Unliftable[T18], UnliftT19: Unliftable[T19], UnliftT20: Unliftable[T20]): Unliftable[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: UnliftT14(v14) :: UnliftT15(v15) :: UnliftT16(v16) :: UnliftT17(v17) :: UnliftT18(v18) :: UnliftT19(v19) :: UnliftT20(v20) :: Nil) => Tuple20(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
+ }
+ implicit def unliftTuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13], UnliftT14: Unliftable[T14], UnliftT15: Unliftable[T15], UnliftT16: Unliftable[T16], UnliftT17: Unliftable[T17], UnliftT18: Unliftable[T18], UnliftT19: Unliftable[T19], UnliftT20: Unliftable[T20], UnliftT21: Unliftable[T21]): Unliftable[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: UnliftT14(v14) :: UnliftT15(v15) :: UnliftT16(v16) :: UnliftT17(v17) :: UnliftT18(v18) :: UnliftT19(v19) :: UnliftT20(v20) :: UnliftT21(v21) :: Nil) => Tuple21(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
+ }
+ implicit def unliftTuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22](implicit UnliftT1: Unliftable[T1], UnliftT2: Unliftable[T2], UnliftT3: Unliftable[T3], UnliftT4: Unliftable[T4], UnliftT5: Unliftable[T5], UnliftT6: Unliftable[T6], UnliftT7: Unliftable[T7], UnliftT8: Unliftable[T8], UnliftT9: Unliftable[T9], UnliftT10: Unliftable[T10], UnliftT11: Unliftable[T11], UnliftT12: Unliftable[T12], UnliftT13: Unliftable[T13], UnliftT14: Unliftable[T14], UnliftT15: Unliftable[T15], UnliftT16: Unliftable[T16], UnliftT17: Unliftable[T17], UnliftT18: Unliftable[T18], UnliftT19: Unliftable[T19], UnliftT20: Unliftable[T20], UnliftT21: Unliftable[T21], UnliftT22: Unliftable[T22]): Unliftable[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = Unliftable {
+ case SyntacticTuple(UnliftT1(v1) :: UnliftT2(v2) :: UnliftT3(v3) :: UnliftT4(v4) :: UnliftT5(v5) :: UnliftT6(v6) :: UnliftT7(v7) :: UnliftT8(v8) :: UnliftT9(v9) :: UnliftT10(v10) :: UnliftT11(v11) :: UnliftT12(v12) :: UnliftT13(v13) :: UnliftT14(v14) :: UnliftT15(v15) :: UnliftT16(v16) :: UnliftT17(v17) :: UnliftT18(v18) :: UnliftT19(v19) :: UnliftT20(v20) :: UnliftT21(v21) :: UnliftT22(v22) :: Nil) => Tuple22(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
+ }
+ }
+
+ // names used internally by implementations of standard liftables and unliftables
+ import scala.language.implicitConversions
+ private implicit def cachedNames(nme: self.nme.type): CachedNames.type = CachedNames
+ private object CachedNames {
+ val Array = TermName("Array")
+ val collection = TermName("collection")
+ val immutable = TermName("immutable")
+ val Left = TermName("Left")
+ val List = TermName("List")
+ val Map = TermName("Map")
+ val None = TermName("None")
+ val Right = TermName("Right")
+ val Set = TermName("Set")
+ val Some = TermName("Some")
+ val Symbol = TermName("Symbol")
+ val Vector = TermName("Vector")
+ val util = TermName("util")
}
}
diff --git a/src/reflect/scala/reflect/api/Universe.scala b/src/reflect/scala/reflect/api/Universe.scala
index 534f69a23e..1da2c24306 100644
--- a/src/reflect/scala/reflect/api/Universe.scala
+++ b/src/reflect/scala/reflect/api/Universe.scala
@@ -78,6 +78,7 @@ abstract class Universe extends Symbols
with Mirrors
with Printers
with Importers
+ with Liftables
with Quasiquotes
{
/** Use `refiy` to produce the abstract syntax tree representing a given Scala expression.
diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala
index 8fc1869dd2..0a81bfa2a5 100644
--- a/src/reflect/scala/reflect/internal/BuildUtils.scala
+++ b/src/reflect/scala/reflect/internal/BuildUtils.scala
@@ -71,12 +71,16 @@ trait BuildUtils { self: SymbolTable =>
def mkAnnotation(trees: List[Tree]): List[Tree] = trees.map(mkAnnotation)
- def mkVparamss(argss: List[List[ValDef]]): List[List[ValDef]] = argss.map(_.map(mkParam))
+ def mkVparamss(argss: List[List[Tree]]): List[List[ValDef]] = argss.map(_.map(mkParam))
- def mkParam(vd: ValDef): ValDef = {
- var newmods = (vd.mods | PARAM) & (~DEFERRED)
- if (vd.rhs.nonEmpty) newmods |= DEFAULTPARAM
- copyValDef(vd)(mods = newmods)
+ def mkParam(tree: Tree): ValDef = tree match {
+ case vd: ValDef =>
+ var newmods = (vd.mods | PARAM) & (~DEFERRED)
+ if (vd.rhs.nonEmpty) newmods |= DEFAULTPARAM
+ copyValDef(vd)(mods = newmods)
+ case _ =>
+ throw new IllegalArgumentException(s"$tree is not valid represenation of function parameter, " +
+ """consider reformatting it into q"val $name: $T = $default" shape""")
}
def mkTparams(tparams: List[Tree]): List[TypeDef] =
@@ -130,9 +134,9 @@ trait BuildUtils { self: SymbolTable =>
def RefTree(qual: Tree, sym: Symbol) = self.RefTree(qual, sym.name) setSymbol sym
- def withFreshTermName[T](prefix: String)(f: TermName => T): T = f(freshTermName(prefix))
+ def freshTermName(prefix: String): TermName = self.freshTermName(prefix)
- def withFreshTypeName[T](prefix: String)(f: TypeName => T): T = f(freshTypeName(prefix))
+ def freshTypeName(prefix: String): TypeName = self.freshTypeName(prefix)
protected implicit def fresh: FreshNameCreator = self.currentFreshNameCreator
@@ -159,18 +163,11 @@ trait BuildUtils { self: SymbolTable =>
def apply(tree: Tree, argss: List[List[Tree]]): Tree =
argss.foldLeft(tree) { (f, args) => Apply(f, args.map(treeInfo.assignmentToMaybeNamedArg)) }
- def unapply(tree: Tree): Some[(Tree, List[List[Tree]])] = {
- val treeInfo.Applied(fun, targs, argss) = tree
- Some((SyntacticTypeApplied(fun, targs), argss))
- }
- }
-
- object SyntacticApply extends SyntacticApplyExtractor {
- def apply(tree: Tree, args: List[Tree]): Tree = SyntacticApplied(tree, List(args))
-
- def unapply(tree: Tree): Some[(Tree, List[Tree])] = tree match {
- case Apply(fun, args) => Some((fun, args))
- case other => Some((other, Nil))
+ def unapply(tree: Tree): Some[(Tree, List[List[Tree]])] = tree match {
+ case UnApply(treeInfo.Unapplied(Select(fun, nme.unapply)), pats) =>
+ Some((fun, pats :: Nil))
+ case treeInfo.Applied(fun, targs, argss) =>
+ Some((SyntacticTypeApplied(fun, targs), argss))
}
}
@@ -215,24 +212,41 @@ trait BuildUtils { self: SymbolTable =>
case Nil :: (tail @ ((head :: _) :: _)) if head.mods.isImplicit => tail
case other => other
}
- // undo flag modifications by mergeing flag info from constructor args and fieldDefs
+ // undo flag modifications by merging flag info from constructor args and fieldDefs
val modsMap = fieldDefs.map { case ValDef(mods, name, _, _) => name -> mods }.toMap
- val vparamss = mmap(vparamssRestoredImplicits) { vd =>
- val originalMods = modsMap(vd.name) | (vd.mods.flags & DEFAULTPARAM)
- atPos(vd.pos)(ValDef(originalMods, vd.name, vd.tpt, vd.rhs))
+ def ctorArgsCorrespondToFields = vparamssRestoredImplicits.flatten.forall { vd => modsMap.contains(vd.name) }
+ if (!ctorArgsCorrespondToFields) None
+ else {
+ val vparamss = mmap(vparamssRestoredImplicits) { vd =>
+ val originalMods = modsMap(vd.name) | (vd.mods.flags & DEFAULTPARAM)
+ atPos(vd.pos)(ValDef(originalMods, vd.name, vd.tpt, vd.rhs))
+ }
+ result(ctorMods, vparamss, edefs, body)
}
- result(ctorMods, vparamss, edefs, body)
}
}
}
}
+ protected def mkSelfType(tree: Tree) = tree match {
+ case vd: ValDef =>
+ require(vd.rhs.isEmpty, "self types must have empty right hand side")
+ copyValDef(vd)(mods = (vd.mods | PRIVATE) & (~DEFERRED))
+ case _ =>
+ throw new IllegalArgumentException(s"$tree is not a valid representation of self type, " +
+ """consider reformatting into q"val $self: $T" shape""")
+ }
+
object SyntacticClassDef extends SyntacticClassDefExtractor {
- def apply(mods: Modifiers, name: TypeName, tparams: List[TypeDef],
- constrMods: Modifiers, vparamss: List[List[ValDef]], earlyDefs: List[Tree],
- parents: List[Tree], selfType: ValDef, body: List[Tree]): ClassDef = {
+ def apply(mods: Modifiers, name: TypeName, tparams: List[Tree],
+ constrMods: Modifiers, vparamss: List[List[Tree]], earlyDefs: List[Tree],
+ parents: List[Tree], selfType: Tree, body: List[Tree]): ClassDef = {
val extraFlags = PARAMACCESSOR | (if (mods.isCase) CASEACCESSOR else 0L)
- val vparamss0 = vparamss.map { _.map { vd => copyValDef(vd)(mods = (vd.mods | extraFlags) & (~DEFERRED)) } }
+ val vparamss0 = vparamss.map { _.map {
+ case vd: ValDef => copyValDef(vd)(mods = (vd.mods | extraFlags) & (~DEFERRED))
+ case tree => throw new IllegalArgumentException(s"$tree is not valid representation of class parameter, " +
+ """consider reformatting it into q"val $name: $T = $default" shape""")
+ } }
val tparams0 = mkTparams(tparams)
val parents0 = gen.mkParents(mods,
if (mods.isCase) parents.filter {
@@ -241,7 +255,8 @@ trait BuildUtils { self: SymbolTable =>
} else parents
)
val body0 = earlyDefs ::: body
- val templ = gen.mkTemplate(parents0, selfType, constrMods, vparamss0, body0)
+ val selfType0 = mkSelfType(selfType)
+ val templ = gen.mkTemplate(parents0, selfType0, constrMods, vparamss0, body0)
gen.mkClassDef(mods, name, tparams0, templ)
}
@@ -256,10 +271,10 @@ trait BuildUtils { self: SymbolTable =>
}
object SyntacticTraitDef extends SyntacticTraitDefExtractor {
- def apply(mods: Modifiers, name: TypeName, tparams: List[TypeDef], earlyDefs: List[Tree],
- parents: List[Tree], selfType: ValDef, body: List[Tree]): ClassDef = {
+ def apply(mods: Modifiers, name: TypeName, tparams: List[Tree], earlyDefs: List[Tree],
+ parents: List[Tree], selfType: Tree, body: List[Tree]): ClassDef = {
val mods0 = mods | TRAIT | ABSTRACT
- val templ = gen.mkTemplate(parents, selfType, Modifiers(TRAIT), Nil, earlyDefs ::: body)
+ val templ = gen.mkTemplate(parents, mkSelfType(selfType), Modifiers(TRAIT), Nil, earlyDefs ::: body)
gen.mkClassDef(mods0, name, mkTparams(tparams), templ)
}
@@ -274,8 +289,8 @@ trait BuildUtils { self: SymbolTable =>
object SyntacticObjectDef extends SyntacticObjectDefExtractor {
def apply(mods: Modifiers, name: TermName, earlyDefs: List[Tree],
- parents: List[Tree], selfType: ValDef, body: List[Tree]) =
- ModuleDef(mods, name, gen.mkTemplate(parents, selfType, NoMods, Nil, earlyDefs ::: body))
+ parents: List[Tree], selfType: Tree, body: List[Tree]) =
+ ModuleDef(mods, name, gen.mkTemplate(parents, mkSelfType(selfType), NoMods, Nil, earlyDefs ::: body))
def unapply(tree: Tree): Option[(Modifiers, TermName, List[Tree], List[Tree], ValDef, List[Tree])] = tree match {
case ModuleDef(mods, name, UnMkTemplate(parents, selfType, _, _, earlyDefs, body)) =>
@@ -287,7 +302,7 @@ trait BuildUtils { self: SymbolTable =>
object SyntacticPackageObjectDef extends SyntacticPackageObjectDefExtractor {
def apply(name: TermName, earlyDefs: List[Tree],
- parents: List[Tree], selfType: ValDef, body: List[Tree]): Tree =
+ parents: List[Tree], selfType: Tree, body: List[Tree]): Tree =
gen.mkPackageObject(SyntacticObjectDef(NoMods, name, earlyDefs, parents, selfType, body))
def unapply(tree: Tree): Option[(TermName, List[Tree], List[Tree], ValDef, List[Tree])] = tree match {
@@ -377,11 +392,9 @@ trait BuildUtils { self: SymbolTable =>
}
object SyntacticFunction extends SyntacticFunctionExtractor {
- def apply(params: List[ValDef], body: Tree): Tree = {
- val params0 = params.map { arg =>
- require(arg.rhs.isEmpty, "anonymous functions don't support default values")
- mkParam(arg)
- }
+ def apply(params: List[Tree], body: Tree): Tree = {
+ val params0 :: Nil = mkVparamss(params :: Nil)
+ require(params0.forall { _.rhs.isEmpty }, "anonymous functions don't support parameters with default values")
Function(params0, body)
}
@@ -392,8 +405,8 @@ trait BuildUtils { self: SymbolTable =>
}
object SyntacticNew extends SyntacticNewExtractor {
- def apply(earlyDefs: List[Tree], parents: List[Tree], selfType: ValDef, body: List[Tree]): Tree =
- gen.mkNew(parents, selfType, earlyDefs ::: body, NoPosition, NoPosition)
+ def apply(earlyDefs: List[Tree], parents: List[Tree], selfType: Tree, body: List[Tree]): Tree =
+ gen.mkNew(parents, mkSelfType(selfType), earlyDefs ::: body, NoPosition, NoPosition)
def unapply(tree: Tree): Option[(List[Tree], List[Tree], ValDef, List[Tree])] = tree match {
case SyntacticApplied(Select(New(SyntacticTypeApplied(ident, targs)), nme.CONSTRUCTOR), argss) =>
@@ -407,7 +420,7 @@ trait BuildUtils { self: SymbolTable =>
}
object SyntacticDefDef extends SyntacticDefDefExtractor {
- def apply(mods: Modifiers, name: TermName, tparams: List[Tree], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef =
+ def apply(mods: Modifiers, name: TermName, tparams: List[Tree], vparamss: List[List[Tree]], tpt: Tree, rhs: Tree): DefDef =
DefDef(mods, name, mkTparams(tparams), mkVparamss(vparamss), tpt, rhs)
def unapply(tree: Tree): Option[(Modifiers, TermName, List[Tree], List[List[ValDef]], Tree, Tree)] = tree match {
@@ -442,6 +455,20 @@ trait BuildUtils { self: SymbolTable =>
}
}
+ def UnliftHelper1[T](unliftable: Unliftable[T]) = new UnliftHelper1[T] {
+ def unapply(lst: List[Tree]): Option[List[T]] = {
+ val unlifted = lst.flatMap { unliftable.unapply(_) }
+ if (unlifted.length == lst.length) Some(unlifted) else None
+ }
+ }
+
+ def UnliftHelper2[T](unliftable: Unliftable[T]) = new UnliftHelper2[T] {
+ def unapply(lst: List[List[Tree]]): Option[List[List[T]]] = {
+ val unlifted = lst.map { l => l.flatMap { unliftable.unapply(_) } }
+ if (unlifted.flatten.length == lst.flatten.length) Some(unlifted) else None
+ }
+ }
+
object SyntacticValFrom extends SyntacticValFromExtractor {
def apply(pat: Tree, rhs: Tree): Tree = gen.ValFrom(pat, gen.mkCheckIfRefutable(pat, rhs))
def unapply(tree: Tree): Option[(Tree, Tree)] = tree match {
@@ -672,6 +699,30 @@ trait BuildUtils { self: SymbolTable =>
case annottee => Some(annottee)
}
}
+
+ protected def mkCases(cases: List[Tree]): List[CaseDef] = cases.map {
+ case c: CaseDef => c
+ case tree => throw new IllegalArgumentException("$tree is not valid representation of pattern match case")
+ }
+
+ object SyntacticMatch extends SyntacticMatchExtractor {
+ def apply(selector: Tree, cases: List[Tree]) = Match(selector, mkCases(cases))
+ def unapply(tree: Match): Option[(Tree, List[CaseDef])] = Match.unapply(tree)
+ }
+
+ object SyntacticTry extends SyntacticTryExtractor {
+ def apply(block: Tree, catches: List[Tree], finalizer: Tree) = Try(block, mkCases(catches), finalizer)
+ def unapply(tree: Try): Option[(Tree, List[CaseDef], Tree)] = Try.unapply(tree)
+ }
+
+ object SyntacticIdent extends SyntacticIdentExtractor {
+ def apply(name: Name, isBackquoted: Boolean) = {
+ val id = self.Ident(name)
+ if (isBackquoted) id updateAttachment BackquotedIdentifierAttachment
+ id
+ }
+ def unapply(tree: Ident): Some[(Name, Boolean)] = Some((tree.name, tree.hasAttachment[BackquotedIdentifierAttachment.type]))
+ }
}
val build: BuildImpl = new BuildImpl
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 19f06894c8..1fe6f249b8 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -481,7 +481,6 @@ trait Definitions extends api.StandardDefinitions {
lazy val TypeCreatorClass = getClassIfDefined("scala.reflect.api.TypeCreator") // defined in scala-reflect.jar, so we need to be careful
lazy val TreeCreatorClass = getClassIfDefined("scala.reflect.api.TreeCreator") // defined in scala-reflect.jar, so we need to be careful
- lazy val LiftableClass = getClassIfDefined("scala.reflect.api.Liftable") // defined in scala-reflect.jar, so we need to be careful
lazy val BlackboxMacroClass = getClassIfDefined("scala.reflect.macros.BlackboxMacro") // defined in scala-reflect.jar, so we need to be careful
def BlackboxMacroContextValue = BlackboxMacroClass.map(sym => getMemberValue(sym, nme.c))
@@ -1371,6 +1370,8 @@ trait Definitions extends api.StandardDefinitions {
lazy val symbolType = universeMemberType(tpnme.Symbol)
lazy val treeType = universeMemberType(tpnme.Tree)
lazy val caseDefType = universeMemberType(tpnme.CaseDef)
+ lazy val liftableType = universeMemberType(tpnme.Liftable)
+ lazy val unliftableType = universeMemberType(tpnme.Unliftable)
lazy val iterableTreeType = appliedType(IterableClass, treeType)
lazy val listTreeType = appliedType(ListClass, treeType)
lazy val listListTreeType = appliedType(ListClass, listTreeType)
diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala
index 3a630b6a16..9c5a593ca5 100644
--- a/src/reflect/scala/reflect/internal/Mirrors.scala
+++ b/src/reflect/scala/reflect/internal/Mirrors.scala
@@ -281,7 +281,6 @@ trait Mirrors extends api.Mirrors {
class RootPackage extends ModuleSymbol(rootOwner, NoPosition, nme.ROOTPKG) with RootSymbol {
this setInfo NullaryMethodType(RootClass.tpe)
- RootClass.sourceModule = this
override def isRootPackage = true
}
@@ -296,6 +295,7 @@ trait Mirrors extends api.Mirrors {
override def isRoot = true
override def isEffectiveRoot = true
override def isNestedClass = false
+ override def sourceModule = RootPackage
}
// This is <root>, the actual root of everything except the package _root_.
@@ -316,6 +316,7 @@ trait Mirrors extends api.Mirrors {
class EmptyPackageClass extends PackageClassSymbol(RootClass, NoPosition, tpnme.EMPTY_PACKAGE_NAME) with WellKnownSymbol {
override def isEffectiveRoot = true
override def isEmptyPackageClass = true
+ override def sourceModule = EmptyPackage
}
lazy val EmptyPackageClass = new EmptyPackageClass
diff --git a/src/reflect/scala/reflect/internal/StdAttachments.scala b/src/reflect/scala/reflect/internal/StdAttachments.scala
index 46f241643b..09fd996f39 100644
--- a/src/reflect/scala/reflect/internal/StdAttachments.scala
+++ b/src/reflect/scala/reflect/internal/StdAttachments.scala
@@ -35,4 +35,7 @@ trait StdAttachments {
/** Identifies trees are either result or intermidiate value of for loop desugaring.
*/
case object ForAttachment extends PlainAttachment
+
+ /** Untyped list of subpatterns attached to selector dummy. */
+ case class SubpatternsAttachment(patterns: List[Tree])
}
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala
index c26e815df1..ea6afa7349 100644
--- a/src/reflect/scala/reflect/internal/StdNames.scala
+++ b/src/reflect/scala/reflect/internal/StdNames.scala
@@ -239,6 +239,8 @@ trait StdNames {
final val Enum: NameType = "Enum"
final val Group: NameType = "Group"
final val implicitNotFound: NameType = "implicitNotFound"
+ final val Liftable: NameType = "Liftable"
+ final val Unliftable: NameType = "Unliftable"
final val Name: NameType = "Name"
final val Tree: NameType = "Tree"
final val TermName: NameType = "TermName"
@@ -328,6 +330,7 @@ trait StdNames {
val QUASIQUOTE_TUPLE: NameType = "$quasiquote$tuple$"
val QUASIQUOTE_CASE: NameType = "$quasiquote$case$"
val QUASIQUOTE_FOR_ENUM: NameType = "$quasiquote$for$enum$"
+ val QUASIQUOTE_UNLIFT_HELPER: String = "$quasiquote$unlift$helper$"
val MIXIN_CONSTRUCTOR: NameType = "$init$"
val MODULE_INSTANCE_FIELD: NameType = NameTransformer.MODULE_INSTANCE_NAME // "MODULE$"
val OUTER: NameType = "$outer"
@@ -588,7 +591,6 @@ trait StdNames {
val Select: NameType = "Select"
val SelectFromTypeTree: NameType = "SelectFromTypeTree"
val SyntacticApplied: NameType = "SyntacticApplied"
- val SyntacticApply: NameType = "SyntacticApply"
val SyntacticAssign: NameType = "SyntacticAssign"
val SyntacticBlock: NameType = "SyntacticBlock"
val SyntacticClassDef: NameType = "SyntacticClassDef"
@@ -598,10 +600,13 @@ trait StdNames {
val SyntacticForYield: NameType = "SyntacticForYield"
val SyntacticFunction: NameType = "SyntacticFunction"
val SyntacticFunctionType: NameType = "SyntacticFunctionType"
- val SyntacticPackageObjectDef: NameType = "SyntacticPackageObjectDef"
- val SyntacticObjectDef: NameType = "SyntacticObjectDef"
+ val SyntacticIdent: NameType = "SyntacticIdent"
+ val SyntacticMatch: NameType = "SyntacticMatch"
val SyntacticNew: NameType = "SyntacticNew"
+ val SyntacticObjectDef: NameType = "SyntacticObjectDef"
+ val SyntacticPackageObjectDef: NameType = "SyntacticPackageObjectDef"
val SyntacticTraitDef: NameType = "SyntacticTraitDef"
+ val SyntacticTry: NameType = "SyntacticTry"
val SyntacticTuple: NameType = "SyntacticTuple"
val SyntacticTupleType: NameType = "SyntacticTupleType"
val SyntacticTypeApplied: NameType = "SyntacticTypeApplied"
@@ -669,6 +674,8 @@ trait StdNames {
val find_ : NameType = "find"
val flatMap: NameType = "flatMap"
val foreach: NameType = "foreach"
+ val freshTermName: NameType = "freshTermName"
+ val freshTypeName: NameType = "freshTypeName"
val get: NameType = "get"
val hashCode_ : NameType = "hashCode"
val hash_ : NameType = "hash"
@@ -755,6 +762,8 @@ trait StdNames {
val unapplySeq: NameType = "unapplySeq"
val unbox: NameType = "unbox"
val universe: NameType = "universe"
+ val UnliftHelper1: NameType = "UnliftHelper1"
+ val UnliftHelper2: NameType = "UnliftHelper2"
val update: NameType = "update"
val updateDynamic: NameType = "updateDynamic"
val value: NameType = "value"
diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala
index c3f3e35fb3..0ce5a0fbea 100644
--- a/src/reflect/scala/reflect/internal/SymbolTable.scala
+++ b/src/reflect/scala/reflect/internal/SymbolTable.scala
@@ -10,6 +10,7 @@ package internal
import scala.annotation.elidable
import scala.collection.{ mutable, immutable }
import util._
+import java.util.concurrent.TimeUnit
abstract class SymbolTable extends macros.Universe
with Collections
@@ -55,7 +56,7 @@ abstract class SymbolTable extends macros.Universe
def abort(msg: String): Nothing = throw new FatalError(supplementErrorMessage(msg))
protected def elapsedMessage(msg: String, start: Long) =
- msg + " in " + (System.currentTimeMillis() - start) + "ms"
+ msg + " in " + (TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start) + "ms"
def informProgress(msg: String) = if (settings.verbose) inform("[" + msg + "]")
def informTime(msg: String, start: Long) = informProgress(elapsedMessage(msg, start))
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 85bc3158f6..0dfcf06874 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -1379,6 +1379,13 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def hasRawInfo: Boolean = infos ne null
def hasCompleteInfo = hasRawInfo && rawInfo.isComplete
+ // does not run adaptToNewRun, which is prone to trigger cycles (SI-8029)
+ // TODO: give this a better name if you understand the intent of the caller.
+ // Is it something to do with `reallyExists` or `isStale`?
+ final def rawInfoIsNoType: Boolean = {
+ hasRawInfo && (infos.info eq NoType)
+ }
+
/** Return info without checking for initialization or completing */
def rawInfo: Type = {
var infos = this.infos
@@ -2038,7 +2045,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** Is this symbol defined in the same scope and compilation unit as `that` symbol? */
def isCoDefinedWith(that: Symbol) = (
- (this.rawInfo ne NoType)
+ !rawInfoIsNoType
&& (this.effectiveOwner == that.effectiveOwner)
&& ( !this.effectiveOwner.isPackageClass
|| (this.associatedFile eq NoAbstractFile)
@@ -2475,10 +2482,14 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** String representation, including symbol's kind e.g., "class Foo", "method Bar".
* If hasMeaninglessName is true, uses the owner's name to disambiguate identity.
*/
- override def toString: String = compose(
- kindString,
- if (hasMeaninglessName) owner.decodedName + idString else nameString
- )
+ override def toString: String = {
+ if (isPackageObjectOrClass && !settings.debug)
+ s"package object ${owner.decodedName}"
+ else compose(
+ kindString,
+ if (hasMeaninglessName) owner.decodedName + idString else nameString
+ )
+ }
/** String representation of location.
*/
diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala
index a0bd64f850..6269004298 100644
--- a/src/reflect/scala/reflect/internal/TreeGen.scala
+++ b/src/reflect/scala/reflect/internal/TreeGen.scala
@@ -16,8 +16,7 @@ abstract class TreeGen extends macros.TreeBuilder {
def rootScalaDot(name: Name) = Select(rootId(nme.scala_) setSymbol ScalaPackage, name)
def scalaDot(name: Name) = Select(Ident(nme.scala_) setSymbol ScalaPackage, name)
def scalaAnnotationDot(name: Name) = Select(scalaDot(nme.annotation), name)
- def scalaAnyRefConstrRaw = scalaDot(tpnme.AnyRef)
- def scalaAnyRefConstr = scalaAnyRefConstrRaw setSymbol AnyRefClass // used in ide
+ def scalaAnyRefConstr = scalaDot(tpnme.AnyRef) // used in ide
def scalaFunctionConstr(argtpes: List[Tree], restpe: Tree, abstractFun: Boolean = false): Tree = {
val cls = if (abstractFun)
@@ -393,7 +392,7 @@ abstract class TreeGen extends macros.TreeBuilder {
def mkParents(ownerMods: Modifiers, parents: List[Tree], parentPos: Position = NoPosition) =
if (ownerMods.isCase) parents ::: List(scalaDot(tpnme.Product), scalaDot(tpnme.Serializable))
- else if (parents.isEmpty) atPos(parentPos)(scalaAnyRefConstrRaw) :: Nil
+ else if (parents.isEmpty) atPos(parentPos)(scalaAnyRefConstr) :: Nil
else parents
def mkClassDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], templ: Template): ClassDef = {
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index e483fa6ba8..99e6ae633f 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -3392,11 +3392,14 @@ trait Types
/** Rebind symbol `sym` to an overriding member in type `pre`. */
private def rebind(pre: Type, sym: Symbol): Symbol = {
if (!sym.isOverridableMember || sym.owner == pre.typeSymbol) sym
- else pre.nonPrivateMember(sym.name).suchThat(sym =>
- // SI-7928 `isModuleNotMethod` is here to avoid crashing with overloaded module accessor and module symbols
- // after refchecks eliminates a ModuleDef that implements and interface.
- sym.isType || (!sym.isModuleNotMethod && sym.isStable && !sym.hasVolatileType)
- ) orElse sym
+ else pre.nonPrivateMember(sym.name).suchThat { sym =>
+ // SI-7928 `isModuleNotMethod` is here to avoid crashing with spuriously "overloaded" module accessor and module symbols.
+ // These appear after refchecks eliminates ModuleDefs that implement an interface.
+ // Here, we exclude the module symbol, which allows us to bind to the accessor.
+ // SI-8054 We must only do this after refchecks, otherwise we exclude the module symbol which does not yet have an accessor!
+ val isModuleWithAccessor = phase.refChecked && sym.isModuleNotMethod
+ sym.isType || (!isModuleWithAccessor && sym.isStable && !sym.hasVolatileType)
+ } orElse sym
}
/** Convert a `super` prefix to a this-type if `sym` is abstract or final. */
diff --git a/src/reflect/scala/reflect/internal/util/StringOps.scala b/src/reflect/scala/reflect/internal/util/StringOps.scala
index 14f349f502..efb8126ff0 100644
--- a/src/reflect/scala/reflect/internal/util/StringOps.scala
+++ b/src/reflect/scala/reflect/internal/util/StringOps.scala
@@ -23,12 +23,16 @@ trait StringOps {
def oempty(xs: String*) = xs filterNot (x => x == null || x == "")
def ojoin(xs: String*): String = oempty(xs: _*) mkString " "
def longestCommonPrefix(xs: List[String]): String = xs match {
- case Nil => ""
- case xs if xs contains "" => ""
- case x :: xs =>
- val ch = x charAt 0
- if (xs exists (_.head != ch)) ""
- else "" + ch + longestCommonPrefix(xs map (_ substring 1))
+ case Nil => ""
+ case w :: Nil => w
+ case _ =>
+ def lcp(ss: List[String]): String = {
+ val w :: ws = ss
+ if (w == "") ""
+ else if (ws exists (s => s == "" || (s charAt 0) != (w charAt 0))) ""
+ else w.substring(0, 1) + lcp(ss map (_ substring 1))
+ }
+ lcp(xs)
}
/** Like String#trim, but trailing whitespace only.
*/
diff --git a/src/reflect/scala/reflect/macros/Typers.scala b/src/reflect/scala/reflect/macros/Typers.scala
index 29c1af110b..5a25801335 100644
--- a/src/reflect/scala/reflect/macros/Typers.scala
+++ b/src/reflect/scala/reflect/macros/Typers.scala
@@ -23,6 +23,12 @@ trait Typers {
*/
def openMacros: List[BlackboxContext]
+ /** @see `Typers.typecheck`
+ */
+ @deprecated("Use `c.typecheck` instead", "2.11.0")
+ def typeCheck(tree: Tree, pt: Type = universe.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree =
+ typecheck(tree, pt, silent, withImplicitViewsDisabled, withMacrosDisabled)
+
/** Typechecks the provided tree against the expected type `pt` in the macro callsite context.
*
* If `silent` is false, `TypecheckException` will be thrown in case of a typecheck error.
@@ -36,7 +42,7 @@ trait Typers {
*
* @throws [[scala.reflect.macros.TypecheckException]]
*/
- def typeCheck(tree: Tree, pt: Type = universe.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree
+ def typecheck(tree: Tree, pt: Type = universe.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree
/** Infers an implicit value of the expected type `pt` in the macro callsite context.
* Optional `pos` parameter provides a position that will be associated with the implicit search.
@@ -44,7 +50,7 @@ trait Typers {
* If `silent` is false, `TypecheckException` will be thrown in case of an inference error.
* If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in `typeCheck`, `silent` is true by default.
+ * Unlike in `typecheck`, `silent` is true by default.
*
* @throws [[scala.reflect.macros.TypecheckException]]
*/
@@ -56,7 +62,7 @@ trait Typers {
* If `silent` is false, `TypecheckException` will be thrown in case of an inference error.
* If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in `typeCheck`, `silent` is true by default.
+ * Unlike in `typecheck`, `silent` is true by default.
*
* @throws [[scala.reflect.macros.TypecheckException]]
*/
diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
index 344f7682c1..9c4a3a5fe1 100644
--- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
+++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
@@ -57,6 +57,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
this.CompoundTypeTreeOriginalAttachment
this.BackquotedIdentifierAttachment
this.ForAttachment
+ this.SubpatternsAttachment
this.noPrint
this.typeDebug
// inaccessible: this.maxFree
@@ -203,7 +204,10 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
// inaccessible: this.TypeHistory
this.TermName
this.TypeName
+ this.Liftable
+ this.Unliftable
this.BooleanFlag
+ // inaccessible: this.CachedNames
this.WeakTypeTag
this.TypeTag
this.Expr
@@ -315,7 +319,6 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
definitions.MirrorClass
definitions.TypeCreatorClass
definitions.TreeCreatorClass
- definitions.LiftableClass
definitions.BlackboxMacroClass
definitions.WhiteboxMacroClass
definitions.BlackboxContextClass
diff --git a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala
index 1b3d60d41a..53c7c82e89 100644
--- a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala
+++ b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala
@@ -294,7 +294,7 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput
// This is jline's entry point for completion.
override def complete(buf: String, cursor: Int): Candidates = {
verbosity = if (isConsecutiveTabs(buf, cursor)) verbosity + 1 else 0
- repldbg("\ncomplete(%s, %d) last = (%s, %d), verbosity: %s".format(buf, cursor, lastBuf, lastCursor, verbosity))
+ repldbg(f"%ncomplete($buf, $cursor%d) last = ($lastBuf, $lastCursor%d), verbosity: $verbosity")
// we don't try lower priority completions unless higher ones return no results.
def tryCompletion(p: Parsed, completionFunction: Parsed => List[String]): Option[Candidates] = {
@@ -307,8 +307,7 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput
val advance = longestCommonPrefix(winners)
lastCursor = p.position + advance.length
lastBuf = (buf take p.position) + advance
- repldbg("tryCompletion(%s, _) lastBuf = %s, lastCursor = %s, p.position = %s".format(
- p, lastBuf, lastCursor, p.position))
+ repldbg(s"tryCompletion($p, _) lastBuf = $lastBuf, lastCursor = $lastCursor, p.position = ${p.position}")
p.position
}
diff --git a/src/swing/doc/README b/src/swing/doc/README
deleted file mode 100644
index cdfee01f82..0000000000
--- a/src/swing/doc/README
+++ /dev/null
@@ -1,39 +0,0 @@
-scala.swing BETA
-
-This is a UI library that will wrap most of Java Swing for Scala in a straightforward manner.
-The widget class hierarchy loosely resembles that of Java Swing. The main differences are:
-
- In Java Swing all components are containers per default. This doesn't make much sense for
- a number of components, like TextField, CheckBox, RadioButton, and so on. Our guess is that
- this architecture was chosen because Java lacks multiple inheritance.
- In scala.swing, components that can have child components extend the Container trait.
-
- Layout managers and panels are coupled. There is no way to exchange the layout manager
- of a panel. As a result, the layout constraints for widgets can be typed.
- (Note that you gain more type-safety and don't loose much flexibility here. Besides
- being not a common operation, exchanging the layout manager of a panel in Java
- Swing almost always leads to exchanging the layout constraints for every of the panel's
- child component. In the end, it is not more work to move all children to a newly created
- panel.)
-
- The event system. TODO
-
-
-The library comprises three main packages:
-
- scala.swing
- All widget classes and traits.
-
- scala.swing.event
- The event hierarchy.
-
- scala.swing.test
- A set of demos.
-
-
-Notes:
-
-Visual appearance of combo boxes using the GTK LaF is broken on JDKs < 1.7b30.
-This is a Java Swing problem.
-
-To download the latest version, go to http://lamp.epfl.ch/~imaier or use sbaz.
diff --git a/src/swing/doc/build.xml b/src/swing/doc/build.xml
deleted file mode 100644
index 20e141152b..0000000000
--- a/src/swing/doc/build.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<project name="swing" default="build">
-
- <property name="scala.home" value="${user.home}/apps/scala-recent"/>
-
- <property file="swing/swing.version.properties"/>
- <property name="version" value="${version.major}.${version.minor}"/>
-
- <taskdef
- resource="scala/tools/ant/antlib.xml">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-compiler.jar"/>
- <pathelement location="${scala.home}/lib/scala-library.jar"/>
- <pathelement location="${scala.home}/lib/junit.jar"/>
- </classpath>
- </taskdef>
-
-
- <target name="build">
- <mkdir dir="build/build.main"/>
- <scalac srcdir="swing"
- destdir="build/build.main">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-library.jar"/>
- <pathelement location="${scala.home}/lib/scala-compiler.jar"/>
- </classpath>
- <include name="**/*.scala"/>
- </scalac>
-
- <jar destfile="build/scala-swing.jar">
- <fileset dir="build/build.main"/>
- <fileset file="swing.version.properties"/>
- </jar>
- <jar destfile="build/scala-swing-src.jar"
- basedir="swing"
- includes="**/*.scala"
- />
- </target>
-
- <!--<target name="build.tests" depends="build">
- <mkdir dir="build/build.tests"/>
- <scalac srcdir="tests" destdir="build/build.tests">
- <classpath>
- <pathelement location="${scala.home}/lib/scala-library.jar"/>
- <pathelement location="${scala.home}/lib/scala-compiler.jar"/>
- <pathelement location="${scala.home}/lib/junit.jar"/>
- <pathelement location="build/swing.jar"/>
- </classpath>
- </scalac>
-
- <jar destfile="build/swing-tests.jar" basedir="build/build.tests"/>
- </target>-->
-
- <target name="dist" depends="build">
- <mkdir dir="build"/>
- <sbaz file="build/scala-swing-${version}.sbp"
- adfile="build/scala-swing-${version}.advert"
- name="scala-swing"
- version="${version}"
- depends="scala"
- desc="A Scala Swing library"
- link="http://scala.epfl.ch/downloads/packages/scala-swing-${version}.sbp">
- <libset dir="build" includes="scala-swing.jar"/>
- <libset dir="build" includes="scala-swing-tests.jar"/>
- <srcset dir="build" includes="scala-swing-src.jar"/>
- <docset dir="swing/doc" includes="Manual.txt"/>
- </sbaz>
- </target>
-
- <target name="install" depends="dist">
- <exec executable="sbaz">
- <arg line="-v install -f build/scala-swing-${version}.sbp"/>
- </exec>
- </target>
-
- <target name="clean">
- <delete dir="build"
- includeemptydirs="yes"
- quiet="yes"
- failonerror="no"/>
- </target>
-</project>
diff --git a/src/swing/scala/swing/AbstractButton.scala b/src/swing/scala/swing/AbstractButton.scala
deleted file mode 100644
index fd84d6f151..0000000000
--- a/src/swing/scala/swing/AbstractButton.scala
+++ /dev/null
@@ -1,87 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import event._
-import javax.swing.{AbstractButton => JAbstractButton, Icon}
-
-/**
- * Base class of all button-like widgets, such as push buttons,
- * check boxes, and radio buttons.
- *
- * @see javax.swing.AbstractButton
- */
-abstract class AbstractButton extends Component with Action.Trigger.Wrapper with Publisher {
- override lazy val peer: JAbstractButton = new JAbstractButton with SuperMixin {}
-
- def text: String = peer.getText
- def text_=(s: String) = peer.setText(s)
-
- def icon: Icon = peer.getIcon
- def icon_=(i: Icon) = peer.setIcon(i)
- def pressedIcon: Icon = peer.getPressedIcon
- def pressedIcon_=(i: Icon) = peer.setPressedIcon(i)
- def selectedIcon: Icon = peer.getSelectedIcon
- def selectedIcon_=(i: Icon) = peer.setSelectedIcon(i)
- def disabledIcon: Icon = peer.getDisabledIcon
- def disabledIcon_=(i: Icon) = peer.setDisabledIcon(i)
- def disabledSelectedIcon: Icon = peer.getDisabledSelectedIcon
- def disabledSelectedIcon_=(i: Icon) = peer.setDisabledSelectedIcon(i)
- def rolloverIcon: Icon = peer.getRolloverIcon
- def rolloverIcon_=(b: Icon) = peer.setRolloverIcon(b)
- def rolloverSelectedIcon: Icon = peer.getRolloverSelectedIcon
- def rolloverSelectedIcon_=(b: Icon) = peer.setRolloverSelectedIcon(b)
-
- peer.addActionListener(Swing.ActionListener { e =>
- publish(ButtonClicked(AbstractButton.this))
- })
-
- def selected: Boolean = peer.isSelected
- def selected_=(b: Boolean) = peer.setSelected(b)
-
- def contentAreaFilled: Boolean = peer.isContentAreaFilled
- def contentAreaFilled_=(b: Boolean) { peer.setContentAreaFilled(b) }
-
- def borderPainted: Boolean = peer.isBorderPainted
- def borderPainted_=(b: Boolean) { peer.setBorderPainted(b) }
- def focusPainted: Boolean = peer.isFocusPainted
- def focusPainted_=(b: Boolean) { peer.setFocusPainted(b) }
-
- def rolloverEnabled: Boolean = peer.isRolloverEnabled
- def rolloverEnabled_=(b: Boolean) = peer.setRolloverEnabled(b)
-
- def verticalTextPosition: Alignment.Value = Alignment(peer.getVerticalTextPosition)
- def verticalTextPosition_=(a: Alignment.Value) { peer.setVerticalTextPosition(a.id) }
- def verticalAlignment: Alignment.Value = Alignment(peer.getVerticalAlignment)
- def verticalAlignment_=(a: Alignment.Value) { peer.setVerticalAlignment(a.id) }
-
- def horizontalTextPosition: Alignment.Value = Alignment(peer.getHorizontalTextPosition)
- def horizontalTextPosition_=(a: Alignment.Value) { peer.setHorizontalTextPosition(a.id) }
- def horizontalAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment)
- def horizontalAlignment_=(a: Alignment.Value) { peer.setHorizontalAlignment(a.id) }
-
- def iconTextGap: Int = peer.getIconTextGap
- def iconTextGap_=(x: Int) { peer.setIconTextGap(x) }
-
- def mnemonic: Key.Value = Key(peer.getMnemonic)
- def mnemonic_=(k: Key.Value) { peer.setMnemonic(k.id) }
- def displayedMnemonicIndex: Int = peer.getDisplayedMnemonicIndex
- def displayedMnemonicIndex_=(n: Int) { peer.setDisplayedMnemonicIndex(n) }
-
- def multiClickThreshold: Long = peer.getMultiClickThreshhold
- def multiClickThreshold_=(n: Long) { peer.setMultiClickThreshhold(n) }
-
- def doClick() { peer.doClick() }
- def doClick(times: Int) { peer.doClick(times) }
-
- def margin: Insets = peer.getMargin
- def margin_=(i: Insets) { peer.setMargin(i) }
-}
diff --git a/src/swing/scala/swing/Action.scala b/src/swing/scala/swing/Action.scala
deleted file mode 100644
index 98b9fee2ee..0000000000
--- a/src/swing/scala/swing/Action.scala
+++ /dev/null
@@ -1,162 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing.{KeyStroke, Icon}
-import java.awt.event.ActionListener
-
-object Action {
- /**
- * Special action that has an empty title and all default properties and does nothing.
- * Use this as a "null action", i.e., to tell components that they do not have any
- * associated action. A component may then obtain its properties from its direct members
- * instead of from its action.
- * In Java Swing, one would use `null` instead of a designated action.
- */
- case object NoAction extends Action("") { def apply() {} }
-
- object Trigger {
- trait Wrapper extends Action.Trigger {
- def peer: javax.swing.JComponent {
- def addActionListener(a: ActionListener)
- def removeActionListener(a: ActionListener)
- def setAction(a: javax.swing.Action)
- def getAction(): javax.swing.Action
- }
-
- // TODO: we need an action cache
- private var _action: Action = Action.NoAction
- def action: Action = _action
- def action_=(a: Action) {
- _action = a;
-
- import scala.language.reflectiveCalls
- peer.setAction(a.peer)
- }
-
- //1.6: def hideActionText: Boolean = peer.getHideActionText
- //def hideActionText_=(b: Boolean) = peer.setHideActionText(b)
- }
- }
-
- /**
- * Something that triggers an action.
- */
- trait Trigger {
- def action: Action
- def action_=(a: Action)
-
- //1.6: def hideActionText: Boolean
- //def hideActionText_=(b: Boolean)
- }
-
- /**
- * Convenience method to create an action with a given title and body to run.
- */
- def apply(title: String)(body: =>Unit) = new Action(title) {
- def apply() { body }
- }
-}
-
-/**
- * An abstract action to be performed in reaction to user input.
- *
- * Not every action component will honor every property of its action.
- * An action itself can generally be configured so that certain properties
- * should be ignored and instead taken from the component directly. In the
- * end, it is up to a component which property it uses in which way.
- *
- * @see javax.swing.Action
- */
-abstract class Action(title0: String) {
- import Swing._
-
- lazy val peer: javax.swing.Action = new javax.swing.AbstractAction(title0) {
- def actionPerformed(a: java.awt.event.ActionEvent) = apply()
- }
-
- /**
- * Title is not optional.
- */
- def title: String = ifNull(peer.getValue(javax.swing.Action.NAME),"")
- def title_=(t: String) { peer.putValue(javax.swing.Action.NAME, t) }
-
- /**
- * None if large icon and small icon are not equal.
- */
- def icon: Icon = smallIcon //if(largeIcon == smallIcon) largeIcon else None
- def icon_=(i: Icon) { /*largeIcon = i;*/ smallIcon = i }
- // 1.6: def largeIcon: Icon = toNoIcon(peer.getValue(javax.swing.Action.LARGE_ICON_KEY).asInstanceOf[Icon])
- // def largeIcon_=(i: Icon) { peer.putValue(javax.swing.Action.LARGE_ICON_KEY, toNullIcon(i)) }
- def smallIcon: Icon = toNoIcon(peer.getValue(javax.swing.Action.SMALL_ICON).asInstanceOf[Icon])
- def smallIcon_=(i: Icon) { peer.putValue(javax.swing.Action.SMALL_ICON, toNullIcon(i)) }
-
- /**
- * For all components.
- */
- def toolTip: String =
- ifNull(peer.getValue(javax.swing.Action.SHORT_DESCRIPTION), "")
- def toolTip_=(t: String) {
- peer.putValue(javax.swing.Action.SHORT_DESCRIPTION, t)
- }
- /**
- * Can be used for status bars, for example.
- */
- def longDescription: String =
- ifNull(peer.getValue(javax.swing.Action.LONG_DESCRIPTION), "")
- def longDescription_=(t: String) {
- peer.putValue(javax.swing.Action.LONG_DESCRIPTION, t)
- }
-
- /**
- * Default: java.awt.event.KeyEvent.VK_UNDEFINED, i.e., no mnemonic key.
- * For all buttons and thus menu items.
- */
- def mnemonic: Int = ifNull(peer.getValue(javax.swing.Action.MNEMONIC_KEY),
- java.awt.event.KeyEvent.VK_UNDEFINED)
- def mnemonic_=(m: Int) { peer.putValue(javax.swing.Action.MNEMONIC_KEY, m) }
-
- /*/**
- * Indicates which character of the title should be underlined to indicate the mnemonic key.
- * Ignored if out of bounds of the title string. Default: -1, i.e., ignored.
- * For all buttons and thus menu items.
- */
- 1.6: def mnemonicIndex: Int =
- ifNull(peer.getValue(javax.swing.Action.DISPLAYED_MNEMONIC_INDEX_KEY), -1)
- def mnemonicIndex_=(n: Int) { peer.putValue(javax.swing.Action.DISPLAYED_MNEMONIC_INDEX_KEY, n) }
- */
-
- /**
- * For menus.
- */
- def accelerator: Option[KeyStroke] =
- toOption(peer.getValue(javax.swing.Action.ACCELERATOR_KEY))
- def accelerator_=(k: Option[KeyStroke]) {
- peer.putValue(javax.swing.Action.ACCELERATOR_KEY, k.orNull)
- }
-
- /**
- * For all components.
- */
- def enabled: Boolean = peer.isEnabled
- def enabled_=(b: Boolean) { peer.setEnabled(b) }
-
- /*/**
- * Only honored if not <code>None</code>. For various buttons.
- */
- 1.6: def selected: Option[Boolean] = Option(peer.getValue(javax.swing.Action.SELECTED_KEY))
- def selected_=(b: Option[Boolean]) {
- peer.putValue(javax.swing.Action.SELECTED_KEY,
- if (b == None) null else new java.lang.Boolean(b.get))
- }*/
-
- def apply()
-}
diff --git a/src/swing/scala/swing/Adjustable.scala b/src/swing/scala/swing/Adjustable.scala
deleted file mode 100644
index 590153fb33..0000000000
--- a/src/swing/scala/swing/Adjustable.scala
+++ /dev/null
@@ -1,53 +0,0 @@
-package scala.swing
-
-import java.awt.{Adjustable => JAdjustable}
-
-object Adjustable {
- trait Wrapper extends Oriented.Wrapper with Adjustable {
- def peer: JAdjustable with OrientedMixin
-
- def unitIncrement = peer.getUnitIncrement
- def unitIncrement_=(i: Int) = peer.setUnitIncrement(i)
- def blockIncrement = peer.getBlockIncrement
- def blockIncrement_=(i: Int) = peer.setBlockIncrement(i)
-
- def value = peer.getValue
- def value_=(v: Int) = peer.setValue(v)
-
- def visibleAmount = peer.getVisibleAmount
- def visibleAmount_=(v: Int) = peer.setVisibleAmount(v)
-
- def minimum = peer.getMinimum
- def minimum_=(m: Int) = peer.setMinimum(m)
- def maximum = peer.getMaximum
- def maximum_=(m: Int) = peer.setMaximum(m)
- }
-}
-
-trait Adjustable extends Oriented {
- def unitIncrement: Int
- def unitIncrement_=(i: Int)
- def blockIncrement: Int
- def blockIncrement_=(i: Int)
-
- def value: Int
- def value_=(v : Int)
-
- def visibleAmount: Int
- def visibleAmount_=(v: Int)
-
- def minimum: Int
- def minimum_=(m: Int)
- def maximum: Int
- def maximum_=(m: Int)
-
-// Needs implementation of AdjustmentEvent
-//
-// val adjustments: Publisher = new Publisher {
-// peer.addAdjustmentListener(new AdjustmentListener {
-// def adjustmentValueChanged(e: java.awt.event.AdjustmentEvent) {
-// publish(new AdjustmentEvent(e))
-// }
-// })
-// }
-}
diff --git a/src/swing/scala/swing/Alignment.scala b/src/swing/scala/swing/Alignment.scala
deleted file mode 100644
index b49e89dbd9..0000000000
--- a/src/swing/scala/swing/Alignment.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing.SwingConstants._
-
-/**
- * Horizontal and vertical alignments. We sacrifice a bit of type-safety
- * for simplicity here.
- *
- * @see javax.swing.SwingConstants
- */
-object Alignment extends Enumeration {
- val Left = Value(LEFT)
- val Right = Value(RIGHT)
- val Center = Value(CENTER)
- val Top = Value(TOP)
- val Bottom = Value(BOTTOM)
- //1.6: val Baseline = Value(BASELINE)
-
- val Leading = Value(LEADING)
- val Trailing = Value(TRAILING)
-}
-
diff --git a/src/swing/scala/swing/Applet.scala b/src/swing/scala/swing/Applet.scala
deleted file mode 100644
index b8ba4eabc0..0000000000
--- a/src/swing/scala/swing/Applet.scala
+++ /dev/null
@@ -1,46 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing.JApplet
-
-/** <p>
- * Clients should implement the ui field. See the <code>SimpleApplet</code>
- * demo for an example.
- * </p>
- * <p>
- * <b>Note</b>: <code>Applet</code> extends <code>javax.swing.JApplet</code>
- * to satisfy Java's applet loading mechanism. The usual component wrapping
- * scheme doesn't work here.
- * </p>
- *
- * @see javax.swing.JApplet
- */
-abstract class Applet extends JApplet { outer =>
- val ui: UI
-
- override def init() { ui.init() }
- override def start() { ui.start() }
- override def stop() { ui.stop() }
-
- abstract class UI extends RootPanel {
- def peer = outer
- override def contents_=(c: Component) {
- super.contents_=(c)
- peer.validate()
- }
-
- def init()
- def start() {}
- def stop() {}
- }
-}
-
diff --git a/src/swing/scala/swing/BorderPanel.scala b/src/swing/scala/swing/BorderPanel.scala
deleted file mode 100644
index 75bb721ffc..0000000000
--- a/src/swing/scala/swing/BorderPanel.scala
+++ /dev/null
@@ -1,60 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import java.awt.BorderLayout
-
-object BorderPanel {
- /**
- * The position of a component in a <code>BorderPanel</code>
- */
- object Position extends Enumeration {
- val North = Value(BorderLayout.NORTH)
- val South = Value(BorderLayout.SOUTH)
- val West = Value(BorderLayout.WEST)
- val East = Value(BorderLayout.EAST)
- val Center = Value(BorderLayout.CENTER)
- }
- private[swing] def wrapPosition(s: String): Position.Value = s match {
- case BorderLayout.NORTH => Position.North
- case BorderLayout.SOUTH => Position.South
- case BorderLayout.WEST => Position.West
- case BorderLayout.EAST => Position.East
- case BorderLayout.CENTER => Position.Center
- }
-}
-
-/**
- * A container that arranges its children around a central component that
- * takes most of the space. The other children are placed on one of four
- * borders: north, east, south, west.
- *
- * @see javax.swing.BorderLayout
- */
-class BorderPanel extends Panel with LayoutContainer {
- import BorderPanel._
- def layoutManager = peer.getLayout.asInstanceOf[BorderLayout]
- override lazy val peer = new javax.swing.JPanel(new BorderLayout) with SuperMixin
-
- type Constraints = Position.Value
-
- protected def constraintsFor(comp: Component) =
- wrapPosition(layoutManager.getConstraints(comp.peer).asInstanceOf[String])
-
- protected def areValid(c: Constraints): (Boolean, String) = (true, "")
- protected def add(c: Component, l: Constraints) {
- // we need to remove previous components with the same constraints as the new one,
- // otherwise the layout manager loses track of the old one
- val old = layoutManager.getLayoutComponent(l.toString)
- if(old != null) peer.remove(old)
- peer.add(c.peer, l.toString)
- }
-}
diff --git a/src/swing/scala/swing/BoxPanel.scala b/src/swing/scala/swing/BoxPanel.scala
deleted file mode 100644
index f5859a8bb1..0000000000
--- a/src/swing/scala/swing/BoxPanel.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-/**
- * A panel that lays out its contents one after the other,
- * either horizontally or vertically.
- *
- * @see javax.swing.BoxLayout
- */
-class BoxPanel(orientation: Orientation.Value) extends Panel with SequentialContainer.Wrapper {
- override lazy val peer = {
- val p = new javax.swing.JPanel with SuperMixin
- val l = new javax.swing.BoxLayout(p, orientation.id)
- p.setLayout(l)
- p
- }
-}
diff --git a/src/swing/scala/swing/BufferWrapper.scala b/src/swing/scala/swing/BufferWrapper.scala
deleted file mode 100644
index 38230ba6eb..0000000000
--- a/src/swing/scala/swing/BufferWrapper.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import scala.collection.mutable.Buffer
-import scala.collection.Iterator
-
-/**
- * Default partial implementation for buffer adapters.
- */
-protected[swing] abstract class BufferWrapper[A] extends Buffer[A] { outer =>
- def clear() { for (i <- 0 until length) remove(0) }
- def update(n: Int, a: A) {
- remove(n)
- insertAt(n, a)
- }
- def insertAll(n: Int, elems: Traversable[A]) {
- var i = n
- for (el <- elems) {
- insertAt(i, el)
- i += 1
- }
- }
- protected def insertAt(n: Int, a: A)
-
- def +=:(a: A): this.type = { insertAt(0, a); this }
- def iterator = Iterator.range(0,length).map(apply(_))
-}
diff --git a/src/swing/scala/swing/Button.scala b/src/swing/scala/swing/Button.scala
deleted file mode 100644
index 0170727e3b..0000000000
--- a/src/swing/scala/swing/Button.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import javax.swing._
-
-object Button {
- def apply(text0: String)(op: => Unit) = new Button(Action(text0)(op))
-}
-
-/**
- * A button that can be clicked, usually to perform some action.
- *
- * @see javax.swing.JButton
- */
-class Button(text0: String) extends AbstractButton with Publisher {
- override lazy val peer: JButton = new JButton(text0) with SuperMixin
- def this() = this("")
- def this(a: Action) = {
- this("")
- action = a
- }
-
- def defaultButton: Boolean = peer.isDefaultButton
-
- def defaultCapable: Boolean = peer.isDefaultCapable
- def defaultCapable_=(capable: Boolean) { peer.setDefaultCapable(capable) }
-}
diff --git a/src/swing/scala/swing/ButtonGroup.scala b/src/swing/scala/swing/ButtonGroup.scala
deleted file mode 100644
index 0b04d20837..0000000000
--- a/src/swing/scala/swing/ButtonGroup.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import scala.collection.mutable
-
-/**
- * A button mutex. At most one of its associated buttons is selected
- * at a time.
- *
- * @see javax.swing.ButtonGroup
- */
-class ButtonGroup(initialButtons: AbstractButton*) {
- val peer: javax.swing.ButtonGroup = new javax.swing.ButtonGroup
-
- val buttons: mutable.Set[AbstractButton] = new mutable.Set[AbstractButton] {
- def -=(b: AbstractButton): this.type = { peer.remove(b.peer); this }
- def +=(b: AbstractButton): this.type = { peer.add(b.peer); this }
- def contains(b: AbstractButton) = this.iterator.contains(b)
- override def size = peer.getButtonCount
- def iterator: Iterator[AbstractButton] = new Iterator[AbstractButton] {
- val enum = peer.getElements
- def next = UIElement.cachedWrapper[AbstractButton](enum.nextElement)
- def hasNext = enum.hasMoreElements
- }
- }
- buttons ++= initialButtons
-
- //1.6: def deselectAll() { peer.clearSelection }
- def selected: Option[AbstractButton] = buttons.find(_.selected)
- def select(b: AbstractButton) { peer.setSelected(b.peer.getModel, true) }
-}
diff --git a/src/swing/scala/swing/CheckBox.scala b/src/swing/scala/swing/CheckBox.scala
deleted file mode 100644
index 7287c95a5d..0000000000
--- a/src/swing/scala/swing/CheckBox.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing._
-
-/**
- * Two state button that can either be checked or unchecked.
- *
- * @see javax.swing.JCheckBox
- */
-class CheckBox(text: String) extends ToggleButton {
- override lazy val peer: JCheckBox = new JCheckBox(text) with SuperMixin
- def this() = this("")
-
- def borderPaintedFlat: Boolean = peer.isBorderPaintedFlat
- def borderPaintedFlat_=(flat: Boolean) { peer.setBorderPaintedFlat(flat) }
-}
diff --git a/src/swing/scala/swing/ColorChooser.scala b/src/swing/scala/swing/ColorChooser.scala
deleted file mode 100644
index 591e652f1c..0000000000
--- a/src/swing/scala/swing/ColorChooser.scala
+++ /dev/null
@@ -1,45 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing.JColorChooser
-import event._
-
-/**
- * Wrapper for JColorChooser. Publishes `ColorChanged` events, when the color selection changes.
- *
- * @author andy@hicks.net
- * @author Ingo Maier
- * @see javax.swing.JColorChooser
- */
-object ColorChooser {
- def showDialog(parent: Component, title: String, color: Color): scala.Option[Color] = {
- toOption[Color](javax.swing.JColorChooser.showDialog(parent.peer, title, color))
- }
-}
-
-class ColorChooser(color0: Color) extends Component {
- def this() = this(java.awt.Color.white)
-
- override lazy val peer: JColorChooser = new JColorChooser(color0) with SuperMixin
-
- peer.getSelectionModel.addChangeListener(new javax.swing.event.ChangeListener {
- def stateChanged(e: javax.swing.event.ChangeEvent) {
- publish(ColorChanged(ColorChooser.this, peer.getColor))
- }
- })
-
- def color: Color = peer.getColor
- def color_=(c: Color) = peer.setColor(c)
-
- def dragEnabled: Boolean = peer.getDragEnabled
- def dragEnabled_=(b: Boolean) = peer.setDragEnabled(b)
-} \ No newline at end of file
diff --git a/src/swing/scala/swing/ComboBox.scala b/src/swing/scala/swing/ComboBox.scala
deleted file mode 100644
index a075d22a7e..0000000000
--- a/src/swing/scala/swing/ComboBox.scala
+++ /dev/null
@@ -1,209 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import event._
-import javax.swing.{JList, JComponent, JComboBox, JTextField, ComboBoxModel, AbstractListModel, ListCellRenderer}
-import java.awt.event.ActionListener
-import scala.language.implicitConversions
-
-object ComboBox {
- /**
- * An editor for a combo box. Let's you edit the currently selected item.
- * It is highly recommended to use the BuiltInEditor class. For anything
- * else, one cannot guarantee that it integrates nicely with the current
- * LookAndFeel.
- *
- * Publishes action events.
- */
- trait Editor[A] extends Publisher {
- lazy val comboBoxPeer: javax.swing.ComboBoxEditor = new javax.swing.ComboBoxEditor with Publisher {
- def addActionListener(l: ActionListener) {
- this match {
- // TODO case w: Action.Trigger.Wrapper =>
- // w.peer.addActionListener(l)
- case _ =>
- this.subscribe(new Reactions.Wrapper(l) ({
- case ActionEvent(c) => l.actionPerformed(new java.awt.event.ActionEvent(c.peer, 0, ""))
- }))
- }
- }
- def removeActionListener(l: ActionListener) {
- this match {
- // TODO case w: Action.Trigger.Wrapper =>
- // w.peer.removeActionListener(l)
- case _ =>
- this.unsubscribe(new Reactions.Wrapper(l)({ case _ => }))
- }
- }
- def getEditorComponent: JComponent = Editor.this.component.peer
- def getItem(): AnyRef = item.asInstanceOf[AnyRef]
- def selectAll() { startEditing() }
- def setItem(a: Any) { item = a.asInstanceOf[A] }
- }
- def component: Component
- def item: A
- def item_=(a: A)
- def startEditing()
- }
-
- /**
- * Use this editor, if you want to reuse the builtin editor supplied by the current
- * Look and Feel. This is restricted to a text field as the editor widget. The
- * conversion from and to a string is done by the supplied functions.
- *
- * It's okay if string2A throws exceptions. They are caught by an input verifier.
- */
- class BuiltInEditor[A](comboBox: ComboBox[A])(string2A: String => A,
- a2String: A => String) extends ComboBox.Editor[A] {
- protected[swing] class DelegatedEditor(editor: javax.swing.ComboBoxEditor) extends javax.swing.ComboBoxEditor {
- var value: A = {
- val v = comboBox.peer.getSelectedItem
- try {
- v match {
- case s: String => string2A(s)
- case _ => v.asInstanceOf[A]
- }
- } catch {
- case _: Exception =>
- throw new IllegalArgumentException("ComboBox not initialized with a proper value, was '" + v + "'.")
- }
- }
- def addActionListener(l: ActionListener) {
- editor.addActionListener(l)
- }
- def removeActionListener(l: ActionListener) {
- editor.removeActionListener(l)
- }
-
- def getEditorComponent: JComponent = editor.getEditorComponent.asInstanceOf[JComponent]
- def selectAll() { editor.selectAll() }
- def getItem(): AnyRef = { verifier.verify(getEditorComponent); value.asInstanceOf[AnyRef] }
- def setItem(a: Any) { editor.setItem(a) }
-
- val verifier = new javax.swing.InputVerifier {
- // TODO: should chain with potentially existing verifier in editor
- def verify(c: JComponent) = try {
- value = string2A(c.asInstanceOf[JTextField].getText)
- true
- }
- catch {
- case e: Exception => false
- }
- }
-
- def textEditor = getEditorComponent.asInstanceOf[JTextField]
- textEditor.setInputVerifier(verifier)
- textEditor.addActionListener(Swing.ActionListener{ a =>
- getItem() // make sure our value is updated
- textEditor.setText(a2String(value))
- })
- }
-
- override lazy val comboBoxPeer: javax.swing.ComboBoxEditor = new DelegatedEditor(comboBox.peer.getEditor)
-
- def component = Component.wrap(comboBoxPeer.getEditorComponent.asInstanceOf[JComponent])
- def item: A = { comboBoxPeer.asInstanceOf[DelegatedEditor].value }
- def item_=(a: A) { comboBoxPeer.setItem(a2String(a)) }
- def startEditing() { comboBoxPeer.selectAll() }
- }
-
- implicit def stringEditor(c: ComboBox[String]): Editor[String] = new BuiltInEditor(c)(s => s, s => s)
- implicit def intEditor(c: ComboBox[Int]): Editor[Int] = new BuiltInEditor(c)(s => s.toInt, s => s.toString)
- implicit def floatEditor(c: ComboBox[Float]): Editor[Float] = new BuiltInEditor(c)(s => s.toFloat, s => s.toString)
- implicit def doubleEditor(c: ComboBox[Double]): Editor[Double] = new BuiltInEditor(c)(s => s.toDouble, s => s.toString)
-
- def newConstantModel[A](items: Seq[A]): ComboBoxModel = {
- new AbstractListModel with ComboBoxModel {
- private var selected: A = if (items.isEmpty) null.asInstanceOf[A] else items(0)
- def getSelectedItem: AnyRef = selected.asInstanceOf[AnyRef]
- def setSelectedItem(a: Any) {
- if ((selected != null && selected != a) ||
- selected == null && a != null) {
- selected = a.asInstanceOf[A]
- fireContentsChanged(this, -1, -1)
- }
- }
- def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef]
- def getSize = items.size
- }
- }
-
- /*def newMutableModel[A, Self](items: Seq[A] with scala.collection.mutable.Publisher[scala.collection.mutable.Message[A], Self]): ComboBoxModel = {
- new AbstractListModel with ComboBoxModel {
- private var selected = items(0)
- def getSelectedItem: AnyRef = selected.asInstanceOf[AnyRef]
- def setSelectedItem(a: Any) { selected = a.asInstanceOf[A] }
- def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef]
- def getSize = items.size
- }
- }
-
- def newConstantModel[A](items: Seq[A]): ComboBoxModel = items match {
- case items: Seq[A] with scala.collection.mutable.Publisher[scala.collection.mutable.Message[A], Self] => newMutableModel
- case _ => newConstantModel(items)
- }*/
-}
-
-/**
- * Let's the user make a selection from a list of predefined items. Visually,
- * this is implemented as a button-like component with a pull-down menu.
- *
- * @see javax.swing.JComboBox
- */
-class ComboBox[A](items: Seq[A]) extends Component with Publisher {
- override lazy val peer: JComboBox = new JComboBox(ComboBox.newConstantModel(items)) with SuperMixin
-
- object selection extends Publisher {
- def index: Int = peer.getSelectedIndex
- def index_=(n: Int) { peer.setSelectedIndex(n) }
- def item: A = peer.getSelectedItem.asInstanceOf[A]
- def item_=(a: A) { peer.setSelectedItem(a) }
-
- peer.addActionListener(Swing.ActionListener { e =>
- publish(event.SelectionChanged(ComboBox.this))
- })
- }
-
- /**
- * Sets the renderer for this combo box's items. Index -1 is
- * passed to the renderer for the selected item (not in the pull-down menu).
- *
- * The underlying combo box renders all items in a <code>ListView</code>
- * (both, in the pull-down menu as well as in the box itself), hence the
- * <code>ListView.Renderer</code>.
- *
- * Note that the UI peer of a combo box usually changes the colors
- * of the component to its own defaults _after_ the renderer has been
- * configured. That's Swing's principle of most suprise.
- */
- def renderer: ListView.Renderer[A] = ListView.Renderer.wrap[A](peer.getRenderer)
- def renderer_=(r: ListView.Renderer[A]) { peer.setRenderer(r.peer) }
-
- /* XXX: currently not safe to expose:
- def editor: ComboBox.Editor[A] =
- def editor_=(r: ComboBox.Editor[A]) { peer.setEditor(r.comboBoxPeer) }
- */
- def editable: Boolean = peer.isEditable
-
- /**
- * Makes this combo box editable. In order to do so, this combo needs an
- * editor which is supplied by the implicit argument. For default
- * editors, see ComboBox companion object.
- */
- def makeEditable()(implicit editor: ComboBox[A] => ComboBox.Editor[A]) {
- peer.setEditable(true)
- peer.setEditor(editor(this).comboBoxPeer)
- }
-
- def prototypeDisplayValue: Option[A] = toOption[A](peer.getPrototypeDisplayValue)
- def prototypeDisplayValue_=(v: Option[A]) {
- peer.setPrototypeDisplayValue((v map toAnyRef).orNull)
- }
-}
diff --git a/src/swing/scala/swing/Component.scala b/src/swing/scala/swing/Component.scala
deleted file mode 100644
index 3a47784562..0000000000
--- a/src/swing/scala/swing/Component.scala
+++ /dev/null
@@ -1,295 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import event._
-
-import java.awt.Graphics
-import java.awt.event._
-import javax.swing.JComponent
-import javax.swing.border.Border
-
-/**
- * Utility methods, mostly for wrapping components.
- */
-object Component {
- /**
- * Wraps a given Java Swing Component into a new wrapper.
- */
- def wrap(c: JComponent): Component = {
- val w = UIElement.cachedWrapper[Component](c)
- if (w != null) w
- else new Component { override lazy val peer = c }
- }
-}
-
-/**
- * Base class for all UI elements that can be displayed in a window.
- * Components are publishers that fire the following event classes:
- * ComponentEvent, FocusEvent, FontChanged, ForegroundChanged, BackgroundChanged.
- *
- * @note [Java Swing] Unlike in Java Swing, not all components are also containers.
- *
- * @see javax.swing.JComponent
- * @see http://java.sun.com/products/jfc/tsc/articles/painting/ for the component
- * painting mechanism
- */
-abstract class Component extends UIElement {
- override lazy val peer: javax.swing.JComponent = new javax.swing.JComponent with SuperMixin {}
- var initP: JComponent = null
-
- /**
- * This trait is used to redirect certain calls from the peer to the wrapper
- * and back. Useful to expose methods that can be customized by overriding.
- */
- protected trait SuperMixin extends JComponent {
- override def paintComponent(g: Graphics) {
- Component.this.paintComponent(g.asInstanceOf[Graphics2D])
- }
- def __super__paintComponent(g: Graphics) {
- super.paintComponent(g)
- }
- override def paintBorder(g: Graphics) {
- Component.this.paintBorder(g.asInstanceOf[Graphics2D])
- }
- def __super__paintBorder(g: Graphics) {
- super.paintBorder(g)
- }
- override def paintChildren(g: Graphics) {
- Component.this.paintChildren(g.asInstanceOf[Graphics2D])
- }
- def __super__paintChildren(g: Graphics) {
- super.paintChildren(g)
- }
-
- override def paint(g: Graphics) {
- Component.this.paint(g.asInstanceOf[Graphics2D])
- }
- def __super__paint(g: Graphics) {
- super.paint(g)
- }
- }
-
- def name: String = peer.getName
- def name_=(s: String) = peer.setName(s)
-
- /**
- * Used by certain layout managers, e.g., BoxLayout or OverlayLayout to
- * align components relative to each other.
- */
- def xLayoutAlignment: Double = peer.getAlignmentX.toDouble
- def xLayoutAlignment_=(x: Double) = peer.setAlignmentX(x.toFloat)
- def yLayoutAlignment: Double = peer.getAlignmentY.toDouble
- def yLayoutAlignment_=(y: Double) = peer.setAlignmentY(y.toFloat)
-
- def border: Border = peer.getBorder
- def border_=(b: Border) { peer.setBorder(b) }
-
- def opaque: Boolean = peer.isOpaque
- def opaque_=(b: Boolean) = peer.setOpaque(b)
-
- def enabled: Boolean = peer.isEnabled
- def enabled_=(b: Boolean) = peer.setEnabled(b)
-
- def tooltip: String = peer.getToolTipText
- def tooltip_=(t: String) = peer.setToolTipText(t)
-
- def inputVerifier: Component => Boolean = { a =>
- Option(peer.getInputVerifier) forall (_ verify a.peer)
- }
- def inputVerifier_=(v: Component => Boolean) {
- peer.setInputVerifier(new javax.swing.InputVerifier {
- def verify(c: javax.swing.JComponent) = v(UIElement.cachedWrapper[Component](c))
- })
- }
-
- /*def verifyOnTraversal: (Component, Component) => Boolean = { a =>
- peer.getInputVerifier().verify(a.peer)
- }
- def verifyOnTraversal_=(v: (Component, Component) => Boolean) {
- peer.setInputVerifier(new javax.swing.InputVerifier {
- def verify(c: javax.swing.JComponent) = v(UIElement.cachedWrapper[Component](c))
- })
- }*/
- /**
- * Contains publishers for various mouse events. They are separated for
- * efficiency reasons.
- */
- object mouse {
- /**
- * Publishes clicks, presses and releases.
- */
- val clicks: Publisher = new LazyPublisher {
- lazy val l = new MouseListener {
- def mouseEntered(e: java.awt.event.MouseEvent) {}
- def mouseExited(e: java.awt.event.MouseEvent) {}
- def mouseClicked(e: java.awt.event.MouseEvent) {
- publish(new MouseClicked(e))
- }
- def mousePressed(e: java.awt.event.MouseEvent) {
- publish(new MousePressed(e))
- }
- def mouseReleased(e: java.awt.event.MouseEvent) {
- publish(new MouseReleased(e))
- }
- }
-
- def onFirstSubscribe() = peer.addMouseListener(l)
- def onLastUnsubscribe() = peer.removeMouseListener(l)
- }
- /**
- * Publishes enters, exits, moves, and drags.
- */
- val moves: Publisher = new LazyPublisher {
- lazy val mouseListener = new MouseListener {
- def mouseEntered(e: java.awt.event.MouseEvent) {
- publish(new MouseEntered(e))
- }
- def mouseExited(e: java.awt.event.MouseEvent) {
- publish(new MouseExited(e))
- }
- def mouseClicked(e: java.awt.event.MouseEvent) {}
- def mousePressed(e: java.awt.event.MouseEvent) {}
- def mouseReleased(e: java.awt.event.MouseEvent) {}
- }
-
- lazy val mouseMotionListener = new MouseMotionListener {
- def mouseMoved(e: java.awt.event.MouseEvent) {
- publish(new MouseMoved(e))
- }
- def mouseDragged(e: java.awt.event.MouseEvent) {
- publish(new MouseDragged(e))
- }
- }
- def onFirstSubscribe() {
- peer.addMouseListener(mouseListener)
- peer.addMouseMotionListener(mouseMotionListener)
- }
- def onLastUnsubscribe() {
- peer.removeMouseListener(mouseListener)
- peer.removeMouseMotionListener(mouseMotionListener)
- }
- }
- /**
- * Publishes mouse wheel moves.
- */
- val wheel: Publisher = new LazyPublisher {
- // We need to subscribe lazily and unsubscribe, since components in scroll panes capture
- // mouse wheel events if there is a listener installed. See ticket #1442.
- lazy val l = new MouseWheelListener {
- def mouseWheelMoved(e: java.awt.event.MouseWheelEvent) {
- publish(new MouseWheelMoved(e))
- }
- }
- def onFirstSubscribe() = peer.addMouseWheelListener(l)
- def onLastUnsubscribe() = peer.removeMouseWheelListener(l)
- }
- }
-
- object keys extends Publisher {
- peer.addKeyListener(new KeyListener {
- def keyPressed(e: java.awt.event.KeyEvent) { publish(new KeyPressed(e)) }
- def keyReleased(e: java.awt.event.KeyEvent) { publish(new KeyReleased(e)) }
- def keyTyped(e: java.awt.event.KeyEvent) { publish(new KeyTyped(e)) }
- })
- }
-
- def focusable: Boolean = peer.isFocusable
- def focusable_=(b: Boolean) = peer.setFocusable(b)
- def requestFocus() = peer.requestFocus()
- def requestFocusInWindow() = peer.requestFocusInWindow()
- def hasFocus: Boolean = peer.isFocusOwner
-
- protected override def onFirstSubscribe() {
- super.onFirstSubscribe
- // TODO: deprecated, remove after 2.8
- peer.addComponentListener(new java.awt.event.ComponentListener {
- def componentHidden(e: java.awt.event.ComponentEvent) {
- publish(UIElementHidden(Component.this))
- }
- def componentShown(e: java.awt.event.ComponentEvent) {
- publish(UIElementShown(Component.this))
- }
- def componentMoved(e: java.awt.event.ComponentEvent) {
- publish(UIElementMoved(Component.this))
- }
- def componentResized(e: java.awt.event.ComponentEvent) {
- publish(UIElementResized(Component.this))
- }
- })
-
- peer.addFocusListener(new java.awt.event.FocusListener {
- def other(e: java.awt.event.FocusEvent) = e.getOppositeComponent match {
- case c: JComponent => Some(UIElement.cachedWrapper[Component](c))
- case _ => None
- }
-
- def focusGained(e: java.awt.event.FocusEvent) {
- publish(FocusGained(Component.this, other(e), e.isTemporary))
- }
- def focusLost(e: java.awt.event.FocusEvent) {
- publish(FocusLost(Component.this, other(e), e.isTemporary))
- }
- })
-
- peer.addPropertyChangeListener(new java.beans.PropertyChangeListener {
- def propertyChange(e: java.beans.PropertyChangeEvent) {
- e.getPropertyName match {
- case "font" => publish(FontChanged(Component.this))
- case "background" => publish(BackgroundChanged(Component.this))
- case "foreground" => publish(ForegroundChanged(Component.this))
- case _ =>
- /*case "focusable" =>
- case "focusTraversalKeysEnabled" =>
- case "forwardFocusTraversalKeys" =>
- case "backwardFocusTraversalKeys" =>
- case "upCycleFocusTraversalKeys" =>
- case "downCycleFocusTraversalKeys" =>
- case "focusTraversalPolicy" =>
- case "focusCycleRoot" =>*/
- }
- }
- })
- }
-
- def revalidate() { peer.revalidate() }
-
- /**
- * For custom painting, users should usually override this method.
- */
- protected def paintComponent(g: Graphics2D) {
- peer match {
- case peer: SuperMixin => peer.__super__paintComponent(g)
- case _ =>
- }
- }
-
- protected def paintBorder(g: Graphics2D) {
- peer match {
- case peer: SuperMixin => peer.__super__paintBorder(g)
- case _ =>
- }
- }
-
- protected def paintChildren(g: Graphics2D) {
- peer match {
- case peer: SuperMixin => peer.__super__paintChildren(g)
- case _ =>
- }
- }
-
- def paint(g: Graphics2D) {
- peer match {
- case peer: SuperMixin => peer.__super__paint(g)
- case _ => peer.paint(g)
- }
- }
-
- override def toString = "scala.swing wrapper " + peer.toString
-}
diff --git a/src/swing/scala/swing/Container.scala b/src/swing/scala/swing/Container.scala
deleted file mode 100644
index 24889f0ceb..0000000000
--- a/src/swing/scala/swing/Container.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import event._
-import scala.collection.mutable.Buffer
-
-object Container {
- /**
- * Utility trait for wrapping containers. Provides an immutable
- * implementation of the contents member.
- */
- trait Wrapper extends Container with Publisher {
- override def peer: javax.swing.JComponent
-
- protected val _contents = new Content
- def contents: Seq[Component] = _contents
-
- protected class Content extends BufferWrapper[Component] {
- override def clear() { peer.removeAll() }
- override def remove(n: Int): Component = {
- val c = peer.getComponent(n)
- peer.remove(n)
- UIElement.cachedWrapper[Component](c)
- }
- protected def insertAt(n: Int, c: Component) { peer.add(c.peer, n) }
- def +=(c: Component): this.type = { peer.add(c.peer) ; this }
- def length = peer.getComponentCount
- def apply(n: Int) = UIElement.cachedWrapper[Component](peer.getComponent(n))
- }
-
- peer.addContainerListener(new java.awt.event.ContainerListener {
- def componentAdded(e: java.awt.event.ContainerEvent) {
- publish(ComponentAdded(Wrapper.this,
- UIElement.cachedWrapper[Component](e.getChild.asInstanceOf[javax.swing.JComponent])))
- }
- def componentRemoved(e: java.awt.event.ContainerEvent) {
- publish(ComponentRemoved(Wrapper.this,
- UIElement.cachedWrapper[Component](e.getChild.asInstanceOf[javax.swing.JComponent])))
- }
- })
- }
-}
-
-/**
- * The base traits for UI elements that can contain <code>Component</code>s.
- *
- * @note [Java Swing] This is not the wrapper for java.awt.Container but a trait
- * that extracts a common interface for components, menus, and windows.
- */
-trait Container extends UIElement {
- /**
- * The child components of this container.
- */
- def contents: Seq[Component]
-}
diff --git a/src/swing/scala/swing/EditorPane.scala b/src/swing/scala/swing/EditorPane.scala
deleted file mode 100644
index 9b1aab7874..0000000000
--- a/src/swing/scala/swing/EditorPane.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import javax.swing._
-import javax.swing.text._
-
-/**
- * A text component that allows multiline text input and display.
- *
- * @see javax.swing.JEditorPane
- */
-class EditorPane(contentType0: String, text0: String) extends TextComponent {
- override lazy val peer: JEditorPane = new JEditorPane(contentType0, text0) with SuperMixin
- def this() = this("text/plain", "")
-
- def contentType: String = peer.getContentType
- def contentType_=(t: String) = peer.setContentType(t)
-
- def editorKit: EditorKit = peer.getEditorKit
- def editorKit_=(k: EditorKit) = peer.setEditorKit(k)
-}
diff --git a/src/swing/scala/swing/FileChooser.scala b/src/swing/scala/swing/FileChooser.scala
deleted file mode 100644
index e731c676c2..0000000000
--- a/src/swing/scala/swing/FileChooser.scala
+++ /dev/null
@@ -1,111 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import java.io.File
-import javax.swing._
-import javax.swing.filechooser._
-
-object FileChooser {
- /**
- * The result of a file dialog. The precise meaning of the `Approve`
- * result depends on the specific dialog type. Could be `"save"` or
- * `"open"` for instance.
- */
- object Result extends Enumeration {
- val Cancel = Value(JFileChooser.CANCEL_OPTION)
- val Approve = Value(JFileChooser.APPROVE_OPTION)
- val Error = Value(JFileChooser.ERROR_OPTION)
- }
-
- /**
- * The kind of elements a user can select in a file dialog.
- */
- object SelectionMode extends Enumeration {
- val FilesOnly = Value(JFileChooser.FILES_ONLY)
- val DirectoriesOnly = Value(JFileChooser.DIRECTORIES_ONLY)
- val FilesAndDirectories = Value(JFileChooser.FILES_AND_DIRECTORIES)
- }
-}
-
-/**
- * Used to open file dialogs.
- *
- * @see [[javax.swing.JFileChooser]]
- */
-class FileChooser(dir: File) {
- import FileChooser._
- lazy val peer: JFileChooser = new JFileChooser(dir)
-
- def this() = this(null)
-
- import Swing._
- def showOpenDialog(over: Component): Result.Value = Result(peer.showOpenDialog(nullPeer(over)))
- def showSaveDialog(over: Component): Result.Value = Result(peer.showSaveDialog(nullPeer(over)))
- def showDialog(over: Component, approveText: String): Result.Value = Result(peer.showDialog(nullPeer(over), approveText))
-
- def controlButtonsAreShown: Boolean = peer.getControlButtonsAreShown
- def controlButtonsAreShown_=(b: Boolean) { peer.setControlButtonsAreShown(b) }
-
- def title: String = peer.getDialogTitle
- def title_=(t: String) { peer.setDialogTitle(t) }
-
- def accessory: Component = UIElement.cachedWrapper[Component](peer.getAccessory)
- def accessory_=(c: Component) { peer.setAccessory(c.peer) }
-
- def fileHidingEnabled: Boolean = peer.isFileHidingEnabled
- def fileHidingEnabled_=(b: Boolean) { peer.setFileHidingEnabled(b) }
- def fileSelectionMode: SelectionMode.Value = SelectionMode(peer.getFileSelectionMode)
- def fileSelectionMode_=(s: SelectionMode.Value) { peer.setFileSelectionMode(s.id) }
- def fileFilter: FileFilter = peer.getFileFilter
- def fileFilter_=(f: FileFilter) { peer setFileFilter f }
-
- def selectedFile: File = peer.getSelectedFile
- def selectedFile_=(file: File) { peer.setSelectedFile(file) }
- def selectedFiles: Seq[File] = peer.getSelectedFiles
- def selectedFiles_=(files: File*) { peer.setSelectedFiles(files.toArray) }
-
- def multiSelectionEnabled: Boolean = peer.isMultiSelectionEnabled
- def multiSelectionEnabled_=(b: Boolean) { peer.setMultiSelectionEnabled(b) }
-
- def iconFor(f: File) = peer.getIcon(f)
- def descriptionFor(f: File) = peer.getDescription(f)
- def nameFor(f: File) = peer.getName(f)
- def typeDescriptionFor(f: File) = peer.getTypeDescription(f)
- def traversable(f: File) = peer.isTraversable(f)
-
- def acceptAllFileFilter = peer.getAcceptAllFileFilter
-
- /*peer.addPropertyChangeListener(new java.beans.PropertyChangeListener {
- def propertyChange(e: java.beans.PropertyChangeEvent) {
- import JFileChooser._
- e.getPropertyName match {
- case APPROVE_BUTTON_TEXT_CHANGED_PROPERTY =>
- case ACCESSORY_CHANGED_PROPERTY =>
- case APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY =>
- case APPROVE_BUTTON_TEXT_CHANGED_PROPERTY =>
- case APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY =>
- case CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY =>
- case CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY =>
- case DIALOG_TITLE_CHANGED_PROPERTY =>
- case DIALOG_TYPE_CHANGED_PROPERTY =>
- case DIRECTORY_CHANGED_PROPERTY =>
- case FILE_FILTER_CHANGED_PROPERTY =>
- case FILE_HIDING_CHANGED_PROPERTY =>
- case FILE_SELECTION_MODE_CHANGED_PROPERTY =>
- case FILE_SYSTEM_VIEW_CHANGED_PROPERTY =>
- case FILE_VIEW_CHANGED_PROPERTY =>
- case MULTI_SELECTION_ENABLED_CHANGED_PROPERTY =>
- case SELECTED_FILE_CHANGED_PROPERTY =>
- case SELECTED_FILES_CHANGED_PROPERTY =>
- case _ =>
- }
- }
- })*/
-}
diff --git a/src/swing/scala/swing/FlowPanel.scala b/src/swing/scala/swing/FlowPanel.scala
deleted file mode 100644
index feeb3d4742..0000000000
--- a/src/swing/scala/swing/FlowPanel.scala
+++ /dev/null
@@ -1,46 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import java.awt.FlowLayout
-import javax.swing.JPanel
-
-object FlowPanel {
- object Alignment extends Enumeration {
- val Leading = Value(FlowLayout.LEADING)
- val Trailing = Value(FlowLayout.TRAILING)
- val Left = Value(FlowLayout.LEFT)
- val Right = Value(FlowLayout.RIGHT)
- val Center = Value(FlowLayout.CENTER)
- }
-}
-
-/**
- * A panel that arranges its contents horizontally, one after the other.
- * If they don't fit, this panel will try to insert line breaks.
- *
- * @see java.awt.FlowLayout
- */
-class FlowPanel(alignment: FlowPanel.Alignment.Value)(contents0: Component*) extends Panel with SequentialContainer.Wrapper {
- override lazy val peer: JPanel =
- new JPanel(new java.awt.FlowLayout(alignment.id)) with SuperMixin
- def this(contents0: Component*) = this(FlowPanel.Alignment.Center)(contents0: _*)
- def this() = this(FlowPanel.Alignment.Center)()
-
- contents ++= contents0
-
- private def layoutManager = peer.getLayout.asInstanceOf[java.awt.FlowLayout]
-
- def vGap: Int = layoutManager.getVgap
- def vGap_=(n: Int) { layoutManager.setVgap(n) }
- def hGap: Int = layoutManager.getHgap
- def hGap_=(n: Int) { layoutManager.setHgap(n) }
-}
diff --git a/src/swing/scala/swing/FormattedTextField.scala b/src/swing/scala/swing/FormattedTextField.scala
deleted file mode 100644
index b08075850c..0000000000
--- a/src/swing/scala/swing/FormattedTextField.scala
+++ /dev/null
@@ -1,40 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import javax.swing._
-
-object FormattedTextField {
- /**
- * The behavior of a formatted text field when it loses its focus.
- */
- object FocusLostBehavior extends Enumeration {
- val Commit = Value(JFormattedTextField.COMMIT)
- val CommitOrRevert = Value(JFormattedTextField.COMMIT_OR_REVERT)
- val Persist = Value(JFormattedTextField.PERSIST)
- val Revert = Value(JFormattedTextField.REVERT)
- }
-}
-
-/**
- * A text field with formatted input.
- *
- * @see javax.swing.JFormattedTextField
- */
-class FormattedTextField(format: java.text.Format) extends TextComponent {
- override lazy val peer: JFormattedTextField = new JFormattedTextField(format) with SuperMixin
-
- import FormattedTextField._
-
- def commitEdit() { peer.commitEdit() }
- def editValid: Boolean = peer.isEditValid
-
- def focusLostBehavior: FocusLostBehavior.Value = FocusLostBehavior(peer.getFocusLostBehavior)
- def focusLostBehavior_=(b: FocusLostBehavior.Value) { peer.setFocusLostBehavior(b.id) }
-}
diff --git a/src/swing/scala/swing/GridBagPanel.scala b/src/swing/scala/swing/GridBagPanel.scala
deleted file mode 100644
index c58d398737..0000000000
--- a/src/swing/scala/swing/GridBagPanel.scala
+++ /dev/null
@@ -1,114 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import java.awt.{GridBagConstraints, GridBagLayout}
-import scala.language.implicitConversions
-
-object GridBagPanel {
- object Fill extends Enumeration {
- val None = Value(GridBagConstraints.NONE)
- val Horizontal = Value(GridBagConstraints.HORIZONTAL)
- val Vertical = Value(GridBagConstraints.VERTICAL)
- val Both = Value(GridBagConstraints.BOTH)
- }
- object Anchor extends Enumeration {
- val North = Value(GridBagConstraints.NORTH)
- val NorthEast = Value(GridBagConstraints.NORTHEAST)
- val East = Value(GridBagConstraints.EAST)
- val SouthEast = Value(GridBagConstraints.SOUTHEAST)
- val South = Value(GridBagConstraints.SOUTH)
- val SouthWest = Value(GridBagConstraints.SOUTHWEST)
- val West = Value(GridBagConstraints.WEST)
- val NorthWest = Value(GridBagConstraints.NORTHWEST)
- val Center = Value(GridBagConstraints.CENTER)
-
- val PageStart = Value(GridBagConstraints.PAGE_START)
- val PageEnd = Value(GridBagConstraints.PAGE_END)
- val LineStart = Value(GridBagConstraints.LINE_START)
- val LineEnd = Value(GridBagConstraints.LINE_END)
- val FirstLineStart = Value(GridBagConstraints.FIRST_LINE_START)
- val FirstLineEnd = Value(GridBagConstraints.FIRST_LINE_END)
- val LastLineStart = Value(GridBagConstraints.LAST_LINE_START)
- val LastLineEnd = Value(GridBagConstraints.LAST_LINE_END)
- }
-}
-
-/**
- * A panel that arranges its children in a grid. Layout details can be
- * given for each cell of the grid.
- *
- * @see java.awt.GridBagLayout
- */
-class GridBagPanel extends Panel with LayoutContainer {
- override lazy val peer = new javax.swing.JPanel(new GridBagLayout) with SuperMixin
- import GridBagPanel._
-
- private def layoutManager = peer.getLayout.asInstanceOf[GridBagLayout]
-
- /**
- * Convenient conversion from xy-coords given as pairs to
- * grid bag constraints.
- */
- implicit def pair2Constraints(p: (Int, Int)): Constraints = {
- val c = new Constraints
- c.gridx = p._1
- c.gridy = p._2
- c
- }
-
- class Constraints(val peer: GridBagConstraints) extends Proxy {
- def self = peer
- def this(gridx: Int, gridy: Int,
- gridwidth: Int, gridheight: Int,
- weightx: Double, weighty: Double,
- anchor: Int, fill: Int, insets: Insets,
- ipadx: Int, ipady: Int) =
- this(new GridBagConstraints(gridx, gridy,
- gridwidth, gridheight,
- weightx, weighty,
- anchor, fill, insets,
- ipadx, ipady))
- def this() = this(new GridBagConstraints())
- def gridx: Int = peer.gridx
- def gridx_=(x: Int) { peer.gridx = x }
- def gridy: Int = peer.gridy
- def gridy_=(y: Int) { peer.gridy = y }
- def grid: (Int, Int) = (gridx, gridy)
- def grid_=(c: (Int, Int)) = {
- gridx = c._1
- gridy = c._2
- }
-
- def gridwidth: Int = peer.gridwidth
- def gridwidth_=(w: Int) { peer.gridwidth = w }
- def gridheight: Int = peer.gridheight
- def gridheight_=(h: Int) { peer.gridheight = h }
- def weightx: Double = peer.weightx
- def weightx_=(x: Double) { peer.weightx = x }
- def weighty: Double = peer.weighty
- def weighty_=(y: Double) { peer.weighty = y }
- def anchor: Anchor.Value = Anchor(peer.anchor)
- def anchor_=(a: Anchor.Value) { peer.anchor = a.id }
- def fill: Fill.Value = Fill(peer.fill)
- def fill_=(f: Fill.Value) { peer.fill = f.id }
- def insets: Insets = peer.insets
- def insets_=(i: Insets) { peer.insets = i }
- def ipadx: Int = peer.ipadx
- def ipadx_=(x: Int) { peer.ipadx = x }
- def ipady: Int = peer.ipady
- def ipady_=(y: Int) { peer.ipady = y }
- }
-
- protected def constraintsFor(comp: Component) =
- new Constraints(layoutManager.getConstraints(comp.peer))
-
- protected def areValid(c: Constraints): (Boolean, String) = (true, "")
- protected def add(c: Component, l: Constraints) { peer.add(c.peer, l.peer) }
-}
diff --git a/src/swing/scala/swing/GridPanel.scala b/src/swing/scala/swing/GridPanel.scala
deleted file mode 100644
index d41f9e1c13..0000000000
--- a/src/swing/scala/swing/GridPanel.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-object GridPanel {
- val Adapt = 0
-}
-
-/**
- * A panel that lays out its contents in a uniform grid.
- *
- * @see java.awt.GridLayout
- */
-class GridPanel(rows0: Int, cols0: Int) extends Panel with SequentialContainer.Wrapper {
- override lazy val peer =
- new javax.swing.JPanel(new java.awt.GridLayout(rows0, cols0)) with SuperMixin
-
- /*type Constraints = (Int, Int)
-
- protected def constraintsFor(comp: Component) = {
- assert(peer.getComponentOrientation.isHorizontal)
- val idx = contents.indexOf(comp)
- val (r, c) = (((idx-1)/columns)+1, ((idx-1)%columns)+1)
- if (peer.getComponentOrientation.isLeftToRight) (r, c)
- else (r, columns-c+1)
- }
-
- protected def add(c: Component, l: Constraints) { peer.add(c.peer, (l._1-1)*columns+l._2) }
- protected def areValid(c: Constraints): (Boolean, String) =
- ((c._1 > 0 && c._2 > 0), "Grid coordinates (row,col) must be >= 1 but where " + c)*/
-
- private def layoutManager = peer.getLayout.asInstanceOf[java.awt.GridLayout]
-
- def rows: Int = layoutManager.getRows
- def rows_=(n: Int) { layoutManager.setRows(n) }
- def columns: Int = layoutManager.getColumns
- def columns_=(n: Int) { layoutManager.setColumns(n) }
-
- def vGap: Int = layoutManager.getVgap
- def vGap_=(n: Int) { layoutManager.setVgap(n) }
- def hGap: Int = layoutManager.getHgap
- def hGap_=(n: Int) { layoutManager.setHgap(n) }
-}
diff --git a/src/swing/scala/swing/Label.scala b/src/swing/scala/swing/Label.scala
deleted file mode 100644
index 65d43cbe19..0000000000
--- a/src/swing/scala/swing/Label.scala
+++ /dev/null
@@ -1,62 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing._
-import scala.swing.Swing._
-
-/**
- * A label component that display either a text, an icon, or both.
- *
- * @see javax.swing.JLabel
- */
-class Label(text0: String, icon0: Icon, align: Alignment.Value) extends Component {
- override lazy val peer: JLabel =
- new JLabel(text0, toNullIcon(icon0), align.id) with SuperMixin
-
- def this() = this("", EmptyIcon, Alignment.Center)
- def this(s: String) = this(s, EmptyIcon, Alignment.Center)
- def text: String = peer.getText
- def text_=(s: String) = peer.setText(s)
- def icon: Icon = peer.getIcon
- def icon_=(i: Icon) = peer.setIcon(i)
-
- /**
- * The alignment of the label's contents relative to its bounding box.
- */
- def xAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment)
- def xAlignment_=(x: Alignment.Value) { peer.setHorizontalAlignment(x.id) }
- def yAlignment: Alignment.Value = Alignment(peer.getVerticalAlignment)
- def yAlignment_=(x: Alignment.Value) { peer.setVerticalAlignment(x.id) }
-
- /** @see javax.swing.JLabel#getHorizontalAlignment() */
- def horizontalAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment)
- /** @see javax.swing.JLabel#setHorizontalAlignment() */
- def horizontalAlignment_=(x: Alignment.Value) { peer.setHorizontalAlignment(x.id) }
-
- def verticalAlignment: Alignment.Value = Alignment(peer.getVerticalAlignment)
- def verticalAlignment_=(x: Alignment.Value) { peer.setVerticalAlignment(x.id) }
-
- def horizontalTextPosition: Alignment.Value = Alignment(peer.getHorizontalTextPosition)
- def horizontalTextPosition_=(x: Alignment.Value) { peer.setHorizontalTextPosition(x.id) }
-
- def verticalTextPosition: Alignment.Value = Alignment(peer.getVerticalTextPosition)
- def verticalTextPosition_=(x: Alignment.Value) { peer.setVerticalTextPosition(x.id) }
-
- def disabledIcon: Icon = peer.getDisabledIcon
- def disabledIcon_=(icon: Icon) { peer.setDisabledIcon(icon) }
-
- def iconTextGap: Int = peer.getIconTextGap
- def iconTextGap_=(gap: Int) { peer.setIconTextGap(gap) }
-
- def displayedMnemonicIndex: Int = peer.getDisplayedMnemonicIndex
- def displayedMnemonicIndex_=(index: Int) { peer.setDisplayedMnemonicIndex(index) }
-}
diff --git a/src/swing/scala/swing/LayoutContainer.scala b/src/swing/scala/swing/LayoutContainer.scala
deleted file mode 100644
index 37d351459e..0000000000
--- a/src/swing/scala/swing/LayoutContainer.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import javax.swing.JComponent
-import scala.collection.mutable
-
-/** A container that associates layout constraints of member type
- * `Constraints` with its children.
- *
- * See `GridBagPanel` for an example container with custom constraints.
- *
- * @note [Java Swing] In scala.swing, panels and layout managers are
- * combined into subclasses of this base class. This approach allows for
- * typed component constraints.
- */
-trait LayoutContainer extends Container.Wrapper {
- /**
- * The type of component constraints for this container.
- */
- type Constraints <: AnyRef
-
- /**
- * Obtains the constraints for the given component from the underlying
- * Swing layout manager.
- */
- protected def constraintsFor(c: Component): Constraints
- /**
- * Checks whether the given constraints are valid. Additionally returns
- * an error string that is only fetched if the constraints aren't valid.
- */
- protected def areValid(c: Constraints): (Boolean, String)
- /**
- * Adds a component with the given constraints to the underlying layout
- * manager and the component peer. This method needs to interact properly
- * with method `constraintsFor`, i.e., it might need to remove previously
- * held components in order to maintain layout consistency. See `BorderPanel`
- * for an example.
- */
- protected def add(comp: Component, c: Constraints)
-
- /**
- * A map of components to the associated layout constraints.
- * Any element in this map is automatically added to the contents of this
- * panel. Therefore, specifying the layout of a component via
- *
- * layout(myComponent) = myConstraints
- *
- * also ensures that myComponent is properly added to this container.
- */
- def layout: mutable.Map[Component, Constraints] = new mutable.Map[Component, Constraints] {
- def -= (c: Component): this.type = { _contents -= c; this }
- def += (cl: (Component, Constraints)): this.type = { update(cl._1, cl._2); this }
- override def update (c: Component, l: Constraints) {
- val (v, msg) = areValid(l)
- if (!v) throw new IllegalArgumentException(msg)
- add(c, l)
- }
- def get(c: Component) = Option(constraintsFor(c))
- override def size = peer.getComponentCount
- def iterator: Iterator[(Component, Constraints)] =
- peer.getComponents.iterator.map { c =>
- val comp = UIElement.cachedWrapper[Component](c.asInstanceOf[JComponent])
- (comp, constraintsFor(comp))
- }
- }
-}
diff --git a/src/swing/scala/swing/ListView.scala b/src/swing/scala/swing/ListView.scala
deleted file mode 100644
index 6904afd78a..0000000000
--- a/src/swing/scala/swing/ListView.scala
+++ /dev/null
@@ -1,246 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import event._
-import javax.swing._
-import javax.swing.event._
-
-object ListView {
- /**
- * The supported modes of user selections.
- */
- object IntervalMode extends Enumeration {
- val Single = Value(ListSelectionModel.SINGLE_SELECTION)
- val SingleInterval = Value(ListSelectionModel.SINGLE_INTERVAL_SELECTION)
- val MultiInterval = Value(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
- }
-
- def wrap[A](c: JList) = new ListView[A] {
- override lazy val peer = c
- }
-
- object Renderer {
- def wrap[A](r: ListCellRenderer): Renderer[A] = new Wrapped[A](r)
-
- /**
- * Wrapper for <code>javax.swing.ListCellRenderer<code>s
- */
- class Wrapped[A](override val peer: ListCellRenderer) extends Renderer[A] {
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int) = {
- Component.wrap(peer.getListCellRendererComponent(list.peer, a, index, isSelected, focused).asInstanceOf[JComponent])
- }
- }
-
- /**
- * Returns a renderer for items of type <code>A</code>. The given function
- * converts items of type <code>A</code> to items of type <code>B</code>
- * for which a renderer is implicitly given. This allows chaining of
- * renderers, e.g.:
- *
- * <code>
- * case class Person(name: String, email: String)
- * val persons = List(Person("John", "j.doe@a.com"), Person("Mary", "m.jane@b.com"))
- * new ListView(persons) {
- * renderer = ListView.Renderer(_.name)
- * }
- * </code>
- */
- def apply[A,B](f: A => B)(implicit renderer: Renderer[B]): Renderer[A] = new Renderer[A] {
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component =
- renderer.componentFor(list, isSelected, focused, f(a), index)
- }
- }
-
- /**
- * Item renderer for a list view. This is contravariant on the type of the
- * items, so a more general renderer can be used in place of a more specific
- * one. For instance, an <code>Any</code> renderer can be used for a list view
- * of strings.
- *
- * @see javax.swing.ListCellRenderer
- */
- abstract class Renderer[-A] {
- def peer: ListCellRenderer = new ListCellRenderer {
- def getListCellRendererComponent(list: JList, a: Any, index: Int, isSelected: Boolean, focused: Boolean) =
- componentFor(ListView.wrap[A](list), isSelected, focused, a.asInstanceOf[A], index).peer
- }
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component
- }
-
- /**
- * A default renderer that maintains a single component for item rendering
- * and preconfigures it to sensible defaults. It is polymorphic on the
- * component's type so clients can easily use component specific attributes
- * during configuration.
- */
- abstract class AbstractRenderer[-A, C<:Component](protected val component: C) extends Renderer[A] {
- // The renderer component is responsible for painting selection
- // backgrounds. Hence, make sure it is opaque to let it draw
- // the background.
- component.opaque = true
-
- /**
- * Standard preconfiguration that is commonly done for any component.
- * This includes foreground and background colors, as well as colors
- * of item selections.
- */
- def preConfigure(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int) {
- if (isSelected) {
- component.background = list.selectionBackground
- component.foreground = list.selectionForeground
- } else {
- component.background = list.background
- component.foreground = list.foreground
- }
- }
- /**
- * Configuration that is specific to the component and this renderer.
- */
- def configure(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int)
-
- /**
- * Configures the component before returning it.
- */
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: A, index: Int): Component = {
- preConfigure(list, isSelected, focused, a, index)
- configure(list, isSelected, focused, a, index)
- component
- }
- }
-
- /**
- * A generic renderer that uses Swing's built-in renderers. If there is no
- * specific renderer for a type, this renderer falls back to a renderer
- * that renders the string returned from an item's <code>toString</code>.
- */
- implicit object GenericRenderer extends Renderer[Any] {
- override lazy val peer: ListCellRenderer = new DefaultListCellRenderer
- def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean, a: Any, index: Int): Component = {
- val c = peer.getListCellRendererComponent(list.peer, a, index, isSelected, focused).asInstanceOf[JComponent]
- Component.wrap(c)
- }
- }
-}
-
-/**
- * A component that displays a number of elements in a list. A list view does
- * not support inline editing of items. If you need it, use a table view instead.
- *
- * Named <code>ListView</code> to avoid a clash with the frequently used
- * <code>scala.List</code>
- *
- * @see javax.swing.JList
- */
-class ListView[A] extends Component {
- import ListView._
- override lazy val peer: JList = new JList with SuperMixin
-
- def this(items: Seq[A]) = {
- this()
- listData = items
- }
-
- protected class ModelWrapper(val items: Seq[A]) extends AbstractListModel {
- def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef]
- def getSize = items.size
- }
-
- def listData: Seq[A] = peer.getModel match {
- case model: ModelWrapper => model.items
- case model @ _ => new Seq[A] { selfSeq =>
- def length = model.getSize
- def iterator = new Iterator[A] {
- var idx = 0
- def next = { idx += 1; apply(idx-1) }
- def hasNext = idx < selfSeq.length
- }
- def apply(n: Int) = model.getElementAt(n).asInstanceOf[A]
- }
- }
-
- def listData_=(items: Seq[A]) {
- peer.setModel(new AbstractListModel {
- def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef]
- def getSize = items.size
- })
- }
-
- /**
- * The current item selection.
- */
- object selection extends Publisher {
- protected abstract class Indices[A](a: =>Seq[A]) extends scala.collection.mutable.Set[A] {
- def -=(n: A): this.type
- def +=(n: A): this.type
- def contains(n: A) = a.contains(n)
- override def size = a.length
- def iterator = a.iterator
- }
-
- def leadIndex: Int = peer.getSelectionModel.getLeadSelectionIndex
- def anchorIndex: Int = peer.getSelectionModel.getAnchorSelectionIndex
-
- /**
- * The indices of the currently selected items.
- */
- object indices extends Indices(peer.getSelectedIndices) {
- def -=(n: Int): this.type = { peer.removeSelectionInterval(n,n); this }
- def +=(n: Int): this.type = { peer.addSelectionInterval(n,n); this }
- }
-
- /**
- * The currently selected items.
- */
- lazy val items = peer.getSelectedValues.map(_.asInstanceOf[A])
-
- def intervalMode: IntervalMode.Value = IntervalMode(peer.getSelectionModel.getSelectionMode)
- def intervalMode_=(m: IntervalMode.Value) { peer.getSelectionModel.setSelectionMode(m.id) }
-
- peer.getSelectionModel.addListSelectionListener(new ListSelectionListener {
- def valueChanged(e: javax.swing.event.ListSelectionEvent) {
- publish(new ListSelectionChanged(ListView.this, e.getFirstIndex to e.getLastIndex, e.getValueIsAdjusting))
- }
- })
-
- def adjusting = peer.getSelectionModel.getValueIsAdjusting
- }
-
- def renderer: ListView.Renderer[A] = ListView.Renderer.wrap[A](peer.getCellRenderer)
- def renderer_=(r: ListView.Renderer[A]) { peer.setCellRenderer(r.peer) }
-
- def fixedCellWidth = peer.getFixedCellWidth
- def fixedCellWidth_=(x: Int) = peer.setFixedCellWidth(x)
-
- def fixedCellHeight = peer.getFixedCellHeight
- def fixedCellHeight_=(x: Int) = peer.setFixedCellHeight(x)
-
- def prototypeCellValue: A = peer.getPrototypeCellValue.asInstanceOf[A]
- def prototypeCellValue_=(a: A) { peer.setPrototypeCellValue(a) }
-
- def visibleRowCount = peer.getVisibleRowCount
- def visibleRowCount_=(n: Int) = peer.setVisibleRowCount(n)
-
- def ensureIndexIsVisible(idx: Int) = peer.ensureIndexIsVisible(idx)
-
- def selectionForeground: Color = peer.getSelectionForeground
- def selectionForeground_=(c: Color) = peer.setSelectionForeground(c)
- def selectionBackground: Color = peer.getSelectionBackground
- def selectionBackground_=(c: Color) = peer.setSelectionBackground(c)
-
- def selectIndices(ind: Int*) = peer.setSelectedIndices(ind.toArray)
-
- peer.getModel.addListDataListener(new ListDataListener {
- def contentsChanged(e: ListDataEvent) { publish(ListChanged(ListView.this)) }
- def intervalRemoved(e: ListDataEvent) { publish(ListElementsRemoved(ListView.this, e.getIndex0 to e.getIndex1)) }
- def intervalAdded(e: ListDataEvent) { publish(ListElementsAdded(ListView.this, e.getIndex0 to e.getIndex1)) }
- })
-}
diff --git a/src/swing/scala/swing/MainFrame.scala b/src/swing/scala/swing/MainFrame.scala
deleted file mode 100644
index 1dfc155f9c..0000000000
--- a/src/swing/scala/swing/MainFrame.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-/**
- * A frame that can be used for main application windows. Shuts down the
- * framework and quits the application when closed.
- */
-class MainFrame(gc: java.awt.GraphicsConfiguration = null) extends Frame(gc) {
- override def closeOperation() { sys.exit(0) }
-}
diff --git a/src/swing/scala/swing/Menu.scala b/src/swing/scala/swing/Menu.scala
deleted file mode 100644
index 38b1787cfc..0000000000
--- a/src/swing/scala/swing/Menu.scala
+++ /dev/null
@@ -1,70 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import scala.collection.mutable
-import javax.swing._
-
-object MenuBar {
- case object NoMenuBar extends MenuBar
-}
-
-/**
- * A menu bar. Each window can contain at most one. Contains a number of menus.
- *
- * @see javax.swing.JMenuBar
- */
-class MenuBar extends Component with SequentialContainer.Wrapper {
- override lazy val peer: JMenuBar = new JMenuBar with SuperMixin
-
- def menus: mutable.Seq[Menu] = contents.filter(_.isInstanceOf[Menu]).map(_.asInstanceOf[Menu])
-
- // Not implemented by Swing
- //def helpMenu: Menu = UIElement.cachedWrapper(peer.getHelpMenu)
- //def helpMenu_=(m: Menu) { peer.setHelpMenu(m.peer) }
-}
-
-/**
- * A menu item that can be used in a menu.
- *
- * @see javax.swing.JMenuItem
- */
-class MenuItem(title0: String) extends AbstractButton {
- override lazy val peer: JMenuItem = new JMenuItem(title0)
- def this(a: Action) = {
- this("")
- action = a
- }
-}
-
-/**
- * A menu. Contains menu items. Being a menu item itself, menus can be nested.
- *
- * @see javax.swing.JMenu
- */
-class Menu(title0: String) extends MenuItem(title0) with SequentialContainer.Wrapper { self: Menu =>
- override lazy val peer: JMenu = new JMenu(title0)
-}
-
-/**
- * A menu item with a radio button.
- *
- * @see javax.swing.JRadioButtonMenuItem
- */
-class RadioMenuItem(title0: String) extends MenuItem(title0) {
- override lazy val peer: JRadioButtonMenuItem = new JRadioButtonMenuItem(title0)
-}
-/**
- * A menu item with a check box.
- *
- * @see javax.swing.JCheckBoxMenuItem
- */
-class CheckMenuItem(title0: String) extends MenuItem(title0) {
- override lazy val peer: JCheckBoxMenuItem = new JCheckBoxMenuItem(title0)
-}
diff --git a/src/swing/scala/swing/Orientable.scala b/src/swing/scala/swing/Orientable.scala
deleted file mode 100644
index db7cf09f27..0000000000
--- a/src/swing/scala/swing/Orientable.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-object Orientable {
- trait Wrapper extends Oriented.Wrapper with Orientable {
- def orientation_=(o: Orientation.Value) {
- import scala.language.reflectiveCalls
- peer.setOrientation(o.id)
- }
- }
-}
-
-/**
- * An <code>Oriented</code> whose orientation can be changed.
- */
-trait Orientable extends Oriented {
- def orientation_=(o: Orientation.Value)
-}
diff --git a/src/swing/scala/swing/Orientation.scala b/src/swing/scala/swing/Orientation.scala
deleted file mode 100644
index ad616ec690..0000000000
--- a/src/swing/scala/swing/Orientation.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import java.awt.Adjustable._
-
-object Orientation extends Enumeration {
- val Horizontal = Value(HORIZONTAL)
- val Vertical = Value(VERTICAL)
- val NoOrientation = Value(NO_ORIENTATION)
-}
diff --git a/src/swing/scala/swing/Oriented.scala b/src/swing/scala/swing/Oriented.scala
deleted file mode 100644
index 72d7d574e2..0000000000
--- a/src/swing/scala/swing/Oriented.scala
+++ /dev/null
@@ -1,35 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-object Oriented {
- trait Wrapper extends Oriented {
- def peer: OrientedMixin
-
- /*
- * Need to revert to structural type, since scroll bars are oriented
- * and these are created by scroll panes. Shouldn't be a bootleneck.
- */
- protected type OrientedMixin = {
- def getOrientation(): Int
- def setOrientation(n: Int)
- }
- import scala.language.reflectiveCalls
- def orientation: Orientation.Value = Orientation(peer.getOrientation)
- }
-}
-
-/**
- * Something that can have an orientation.
- */
-trait Oriented {
- def orientation: Orientation.Value
-}
diff --git a/src/swing/scala/swing/Panel.scala b/src/swing/scala/swing/Panel.scala
deleted file mode 100644
index 89ad4d3d66..0000000000
--- a/src/swing/scala/swing/Panel.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-/**
- * A component that can contain other components.
- *
- * @see javax.swing.JPanel
- */
-abstract class Panel extends Component with Container.Wrapper {
- override lazy val peer: javax.swing.JPanel = new javax.swing.JPanel with SuperMixin
-}
diff --git a/src/swing/scala/swing/PasswordField.scala b/src/swing/scala/swing/PasswordField.scala
deleted file mode 100644
index fd0b586a0f..0000000000
--- a/src/swing/scala/swing/PasswordField.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import javax.swing._
-
-/**
- * A password field, that displays a replacement character for each character in the password.
- *
- * @see javax.swing.JPasswordField
- */
-class PasswordField(text0: String, columns0: Int) extends TextField(text0, columns0) {
- override lazy val peer: JPasswordField = new JPasswordField(text0, columns0) with SuperMixin
- def this(text: String) = this(text, 0)
- def this(columns: Int) = this("", columns)
- def this() = this("")
-
- def echoChar: Char = peer.getEchoChar
- def echoChar_=(c: Char) = peer.setEchoChar(c)
-
- /**
- * The text property should not be used on a password field for
- * security reasons.
- */
- override def text: String = ""
- override def text_=(s: String) {}
- def password: Array[Char] = peer.getPassword
-}
diff --git a/src/swing/scala/swing/PopupMenu.scala b/src/swing/scala/swing/PopupMenu.scala
deleted file mode 100644
index e82c3a1b28..0000000000
--- a/src/swing/scala/swing/PopupMenu.scala
+++ /dev/null
@@ -1,65 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing.JPopupMenu
-import javax.swing.event.{PopupMenuListener, PopupMenuEvent}
-import event._
-
-/**
- * A popup menu.
- *
- * Example usage:
- *
- * {{{
- * val popupMenu = new PopupMenu {
- * contents += new Menu("menu 1") {
- * contents += new RadioMenuItem("radio 1.1")
- * contents += new RadioMenuItem("radio 1.2")
- * }
- * contents += new Menu("menu 2") {
- * contents += new RadioMenuItem("radio 2.1")
- * contents += new RadioMenuItem("radio 2.2")
- * }
- * }
- * val button = new Button("Show Popup Menu")
- * reactions += {
- * case e: ButtonClicked => popupMenu.show(button, 0, button.bounds.height)
- * }
- * listenTo(button)
- * }}}
- *
- * @author John Sullivan
- * @author Ingo Maier
- * @see javax.swing.JPopupMenu
- */
-class PopupMenu extends Component with SequentialContainer.Wrapper with Publisher {
- override lazy val peer: JPopupMenu = new JPopupMenu with SuperMixin
-
- peer.addPopupMenuListener(new PopupMenuListener {
- def popupMenuCanceled(e: PopupMenuEvent) {
- publish(PopupMenuCanceled(PopupMenu.this))
- }
- def popupMenuWillBecomeInvisible(e: PopupMenuEvent) {
- publish(PopupMenuWillBecomeInvisible(PopupMenu.this))
- }
- def popupMenuWillBecomeVisible(e: PopupMenuEvent) {
- publish(PopupMenuWillBecomeVisible(PopupMenu.this))
- }
- })
-
- def show(invoker: Component, x: Int, y: Int): Unit = peer.show(invoker.peer, x, y)
-
- def margin: Insets = peer.getMargin
- def label: String = peer.getLabel
- def label_=(s: String) { peer.setLabel(s) }
-}
-
diff --git a/src/swing/scala/swing/ProgressBar.scala b/src/swing/scala/swing/ProgressBar.scala
deleted file mode 100644
index 81e2989c3e..0000000000
--- a/src/swing/scala/swing/ProgressBar.scala
+++ /dev/null
@@ -1,40 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-/**
- * A bar indicating progress of some action. Can be in indeterminate mode,
- * in which it indicates that the action is in progress (usually by some
- * animation) but does not indicate the amount of work done or to be done.
- *
- * @see javax.swing.JProgressBar
- */
-class ProgressBar extends Component with Orientable.Wrapper {
- override lazy val peer: javax.swing.JProgressBar =
- new javax.swing.JProgressBar with SuperMixin
-
- def min: Int = peer.getMinimum
- def min_=(v: Int) { peer.setMinimum(v) }
- def max: Int = peer.getMaximum
- def max_=(v: Int) { peer.setMaximum(v) }
- def value: Int = peer.getValue
- def value_=(v: Int) { peer.setValue(v) }
-
- def labelPainted: Boolean = peer.isStringPainted
- def labelPainted_=(v: Boolean) { peer.setStringPainted(v) }
-
- def label: String = peer.getString
- def label_=(v: String) = peer.setString(v)
-
- def indeterminate: Boolean = peer.isIndeterminate
- def indeterminate_=(v: Boolean) { peer.setIndeterminate(v) }
-
- def paintBorder: Boolean = peer.isBorderPainted
- def paintBorder(v: Boolean) { peer.setBorderPainted(v) }
-}
diff --git a/src/swing/scala/swing/Publisher.scala b/src/swing/scala/swing/Publisher.scala
index 96207de808..578ef71e09 100644
--- a/src/swing/scala/swing/Publisher.scala
+++ b/src/swing/scala/swing/Publisher.scala
@@ -44,7 +44,7 @@ trait Publisher extends Reactor {
/**
* Notify all registered reactions.
*/
- def publish(e: Event) { for (l <- listeners) l(e) }
+ def publish(e: Event) { for (l <- listeners) if (l.isDefinedAt(e)) l(e) }
listenTo(this)
}
diff --git a/src/swing/scala/swing/RadioButton.scala b/src/swing/scala/swing/RadioButton.scala
deleted file mode 100644
index 64f8b23756..0000000000
--- a/src/swing/scala/swing/RadioButton.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing._
-
-/**
- * A two state button that is usually used in a <code>ButtonGroup</code>
- * together with other <code>RadioButton</code>s, in order to indicate
- * that at most one of them can be selected.
- *
- * @see javax.swing.JRadioButton
- */
-class RadioButton(text0: String) extends ToggleButton {
- override lazy val peer: JRadioButton = new JRadioButton(text0) with SuperMixin
- def this() = this("")
-}
diff --git a/src/swing/scala/swing/Reactions.scala b/src/swing/scala/swing/Reactions.scala
deleted file mode 100644
index c32212cf3a..0000000000
--- a/src/swing/scala/swing/Reactions.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import event.Event
-import scala.collection.mutable.{Buffer, ListBuffer}
-
-object Reactions {
- class Impl extends Reactions {
- private val parts: Buffer[Reaction] = new ListBuffer[Reaction]
- def isDefinedAt(e: Event) = parts.exists(_ isDefinedAt e)
- def += (r: Reaction): this.type = { parts += r; this }
- def -= (r: Reaction): this.type = { parts -= r; this }
- def apply(e: Event) {
- for (p <- parts) if (p isDefinedAt e) p(e)
- }
- }
-
- type Reaction = PartialFunction[Event, Unit]
-
- /**
- * A Reaction implementing this trait is strongly referenced in the reaction list
- */
- trait StronglyReferenced
-
- class Wrapper(listener: Any)(r: Reaction) extends Reaction with StronglyReferenced with Proxy {
- def self = listener
- def isDefinedAt(e: Event) = r.isDefinedAt(e)
- def apply(e: Event) { r(e) }
- }
-}
-
-/**
- * Used by reactors to let clients register custom event reactions.
- */
-abstract class Reactions extends Reactions.Reaction {
- /**
- * Add a reaction.
- */
- def += (r: Reactions.Reaction): this.type
-
- /**
- * Remove the given reaction.
- */
- def -= (r: Reactions.Reaction): this.type
-}
diff --git a/src/swing/scala/swing/Reactor.scala b/src/swing/scala/swing/Reactor.scala
deleted file mode 100644
index 8f74831a5d..0000000000
--- a/src/swing/scala/swing/Reactor.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-/**
- * The counterpart to publishers. Listens to events from registered publishers.
- */
-trait Reactor {
- /**
- * All reactions of this reactor.
- */
- val reactions: Reactions = new Reactions.Impl
- /**
- * Listen to the given publisher as long as <code>deafTo</code> isn't called for
- * them.
- */
- def listenTo(ps: Publisher*) = for (p <- ps) p.subscribe(reactions)
- /**
- * Installed reaction won't receive events from the given publisher anylonger.
- */
- def deafTo(ps: Publisher*) = for (p <- ps) p.unsubscribe(reactions)
-}
diff --git a/src/swing/scala/swing/RichWindow.scala b/src/swing/scala/swing/RichWindow.scala
deleted file mode 100644
index a60cdd339e..0000000000
--- a/src/swing/scala/swing/RichWindow.scala
+++ /dev/null
@@ -1,195 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import java.awt.{ Window => AWTWindow, Frame => AWTFrame }
-import javax.swing._
-import Swing._
-
-object RichWindow {
- /**
- * Mixin this trait if you want an undecorated window.
- */
- trait Undecorated extends RichWindow {
- // we do a mixin here, since setUndecorated is only allowed to be called
- // when the component is not displayable.
- peer.setUndecorated(true)
- }
-}
-
-/**
- * A window that adds some functionality to the plain Window class and serves as
- * the common base class for frames and dialogs.
- *
- * Implementation note: this class is sealed since we need to know that a rich
- * window is either a dialog or a frame at some point.
- */
-sealed trait RichWindow extends Window {
- def peer: AWTWindow with InterfaceMixin
-
- trait InterfaceMixin extends super.InterfaceMixin {
- def getJMenuBar(): JMenuBar
- def setJMenuBar(b: JMenuBar)
- def setUndecorated(b: Boolean)
- def setTitle(s: String)
- def getTitle(): String
- def setResizable(b: Boolean)
- def isResizable(): Boolean
- }
-
- def title: String = peer.getTitle
- def title_=(s: String) = peer.setTitle(s)
-
- /**
- * The menu bar of this frame or `NoMenuBar` if no menu bar is set.
- */
- def menuBar: MenuBar = {
- val m = UIElement.cachedWrapper[MenuBar](peer.getJMenuBar)
- if (m != null) m else MenuBar.NoMenuBar
- }
- /**
- * Set the current menu bar of this frame. Pass `NoMenuBar` if this frame
- * should not show a menu bar.
- */
- def menuBar_=(m: MenuBar) =
- peer.setJMenuBar(if (m == MenuBar.NoMenuBar) null else m.peer)
-
- def resizable_=(b: Boolean) { peer.setResizable(b) }
- def resizable = peer.isResizable
-}
-
-/**
- * A window with decoration such as a title, border, and action buttons.
- *
- * An AWT window cannot be wrapped dynamically with this class, i.e., you cannot
- * write something like new Window { def peer = myAWTWindow }
- *
- * @see javax.swing.JFrame
- */
-class Frame(gc: java.awt.GraphicsConfiguration = null) extends RichWindow {
- override lazy val peer: JFrame with InterfaceMixin = new JFrame(gc) with InterfaceMixin with SuperMixin
-
- def iconify() { peer.setExtendedState(peer.getExtendedState | AWTFrame.ICONIFIED) }
- def uniconify() { peer.setExtendedState(peer.getExtendedState & ~AWTFrame.ICONIFIED) }
- def iconified: Boolean = (peer.getExtendedState & AWTFrame.ICONIFIED) != 0
- def maximize() { peer.setExtendedState(peer.getExtendedState | AWTFrame.MAXIMIZED_BOTH) }
- def unmaximize() { peer.setExtendedState(peer.getExtendedState & ~AWTFrame.MAXIMIZED_BOTH) }
- def maximized: Boolean = (peer.getExtendedState & AWTFrame.MAXIMIZED_BOTH) != 0
-
- def iconImage: Image = peer.getIconImage
- def iconImage_=(i: Image) { peer.setIconImage(i) }
-}
-
-/**
- * Simple predefined dialogs.
- *
- * @see javax.swing.JOptionPane
- */
-object Dialog {
- /**
- * The message type of a dialog.
- */
- object Message extends Enumeration {
- val Error = Value(JOptionPane.ERROR_MESSAGE)
- val Info = Value(JOptionPane.INFORMATION_MESSAGE)
- val Warning = Value(JOptionPane.WARNING_MESSAGE)
- val Question = Value(JOptionPane.QUESTION_MESSAGE)
- val Plain = Value(JOptionPane.PLAIN_MESSAGE)
- }
-
- /**
- * The possible answers a user can select.
- */
- object Options extends Enumeration {
- val Default = Value(JOptionPane.DEFAULT_OPTION)
- val YesNo = Value(JOptionPane.YES_NO_OPTION)
- val YesNoCancel = Value(JOptionPane.YES_NO_CANCEL_OPTION)
- val OkCancel = Value(JOptionPane.OK_CANCEL_OPTION)
- }
-
- /**
- * The selected result of dialog.
- */
- object Result extends Enumeration {
- val Yes = Value(JOptionPane.YES_OPTION)
- val Ok = Yes
- val No = Value(JOptionPane.NO_OPTION)
- val Cancel = Value(JOptionPane.CANCEL_OPTION)
- val Closed = Value(JOptionPane.CLOSED_OPTION)
- }
-
- private def uiString(txt: String) = UIManager.getString(txt)
-
- def showConfirmation(parent: Component = null,
- message: Any,
- title: String = uiString("OptionPane.titleText"),
- optionType: Options.Value = Options.YesNo,
- messageType: Message.Value = Message.Question,
- icon: Icon = EmptyIcon): Result.Value =
- Result(JOptionPane.showConfirmDialog(nullPeer(parent), message, title,
- optionType.id, messageType.id, Swing.wrapIcon(icon)))
-
- def showOptions(parent: Component = null,
- message: Any,
- title: String = uiString("OptionPane.titleText"),
- optionType: Options.Value = Options.YesNo,
- messageType: Message.Value = Message.Question,
- icon: Icon = EmptyIcon,
- entries: Seq[Any],
- initial: Int): Result.Value = {
- val r = JOptionPane.showOptionDialog(nullPeer(parent), message, title,
- optionType.id, messageType.id, Swing.wrapIcon(icon),
- (entries map toAnyRef).toArray, entries(initial))
- Result(r)
- }
-
- def showInput[A](parent: Component = null,
- message: Any,
- title: String = uiString("OptionPane.inputDialogTitle"),
- messageType: Message.Value = Message.Question,
- icon: Icon = EmptyIcon,
- entries: Seq[A] = Nil,
- initial: A): Option[A] = {
- val e = if (entries.isEmpty) null
- else (entries map toAnyRef).toArray
- val r = JOptionPane.showInputDialog(nullPeer(parent), message, title,
- messageType.id, Swing.wrapIcon(icon),
- e, initial)
-
- toOption[A](r)
- }
- def showMessage(parent: Component = null,
- message: Any,
- title: String = uiString("OptionPane.messageDialogTitle"),
- messageType: Message.Value = Message.Info,
- icon: Icon = EmptyIcon) {
- JOptionPane.showMessageDialog(nullPeer(parent), message, title,
- messageType.id, Swing.wrapIcon(icon))
- }
-}
-
-/**
- * A dialog window.
- *
- * @see javax.swing.JDialog
- */
-class Dialog(owner: Window, gc: java.awt.GraphicsConfiguration = null) extends RichWindow {
- override lazy val peer: JDialog with InterfaceMixin =
- if (owner == null) new JDialog with InterfaceMixin with SuperMixin
- else owner match {
- case f: Frame => new JDialog(f.peer, "", false, gc) with InterfaceMixin with SuperMixin
- case d: Dialog => new JDialog(d.peer, "", false, gc) with InterfaceMixin with SuperMixin
- }
-
- def this() = this(null)
-
- def modal_=(b: Boolean) { peer.setModal(b) }
- def modal = peer.isModal
-}
-
diff --git a/src/swing/scala/swing/RootPanel.scala b/src/swing/scala/swing/RootPanel.scala
deleted file mode 100644
index 7e4882d7da..0000000000
--- a/src/swing/scala/swing/RootPanel.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-/**
- * The root of a component hierarchy. Contains at most one component.
- *
- * @see javax.swing.RootPaneContainer
- */
-trait RootPanel extends Container {
- def peer: java.awt.Component with javax.swing.RootPaneContainer
-
- /**
- * At most one component.
- */
- def contents: Seq[Component] =
- if (peer.getContentPane.getComponentCount == 0) Nil
- else {
- val c = peer.getContentPane.getComponent(0).asInstanceOf[javax.swing.JComponent]
- List(UIElement.cachedWrapper[Component](c))
- }
-
- def contents_=(c: Component) {
- if (peer.getContentPane.getComponentCount > 0) {
- val old = peer.getContentPane.getComponent(0)
- peer.getContentPane.remove(old)
- }
- peer.getContentPane.add(c.peer)
- }
-}
diff --git a/src/swing/scala/swing/ScrollBar.scala b/src/swing/scala/swing/ScrollBar.scala
deleted file mode 100644
index 6a1acdca04..0000000000
--- a/src/swing/scala/swing/ScrollBar.scala
+++ /dev/null
@@ -1,39 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing.{JScrollBar, BoundedRangeModel}
-import java.awt.event.{AdjustmentListener}
-
-object ScrollBar {
- def wrap(c: JScrollBar): ScrollBar = {
- val w = UIElement.cachedWrapper[ScrollBar](c)
- if (w != null) w
- else new ScrollBar { override lazy val peer = c }
- }
-}
-
-class ScrollBar extends Component with Orientable.Wrapper with Adjustable.Wrapper {
- override lazy val peer: JScrollBar = new JScrollBar with SuperMixin
-
- def valueIsAjusting = peer.getValueIsAdjusting
- def valueIsAjusting_=(b : Boolean) = peer.setValueIsAdjusting(b)
-
- // TODO: can we find a better interface?
- //def setValues(value: Int = this.value, visible: Int = visibleAmount,
- // min: Int = minimum, max: Int = maximum) =
- // peer.setValues(value, visible, min, max)
-
-// Not currently needed, requires wrapper for BoundedRangeModel
-//
-// def model = peer.getModel
-// def model_=(m : BoundedRangeModel) = peer.setModel(m)
-}
diff --git a/src/swing/scala/swing/ScrollPane.scala b/src/swing/scala/swing/ScrollPane.scala
deleted file mode 100644
index afd6cf27fb..0000000000
--- a/src/swing/scala/swing/ScrollPane.scala
+++ /dev/null
@@ -1,88 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing.{JScrollPane, ScrollPaneConstants}
-
-object ScrollPane {
- object BarPolicy extends Enumeration {
- import ScrollPaneConstants._
- val AsNeeded = new Value(HORIZONTAL_SCROLLBAR_AS_NEEDED,
- VERTICAL_SCROLLBAR_AS_NEEDED)
- val Never = new Value(HORIZONTAL_SCROLLBAR_NEVER,
- VERTICAL_SCROLLBAR_NEVER)
- val Always = new Value(HORIZONTAL_SCROLLBAR_ALWAYS,
- VERTICAL_SCROLLBAR_ALWAYS)
-
- def wrap(id: Int) = id match {
- case HORIZONTAL_SCROLLBAR_AS_NEEDED | VERTICAL_SCROLLBAR_AS_NEEDED => AsNeeded
- case HORIZONTAL_SCROLLBAR_NEVER | VERTICAL_SCROLLBAR_NEVER => Never
- case HORIZONTAL_SCROLLBAR_ALWAYS | VERTICAL_SCROLLBAR_ALWAYS => Always
- }
- class Value(val horizontalPeer: Int, val verticalPeer: Int) extends super.Val {
- override def id = horizontalPeer
- }
- }
-}
-
-/**
- * Can have at most a single child component, which will be put inside a canvas (the viewport)
- * that can be scrolled.
- *
- * @see javax.swing.JScrollPane
- */
-class ScrollPane extends Component with Container {
- import ScrollPane._
-
- override lazy val peer: JScrollPane = new JScrollPane with SuperMixin
- def this(c: Component) = {
- this()
- contents = c
- }
- def contents: Seq[Component] =
- List(UIElement.cachedWrapper[Component](peer.getViewport.getView.asInstanceOf[javax.swing.JComponent]))
-
- /**
- * Sets the single child.
- */
- def contents_=(c: Component) { peer.setViewportView(c.peer) }
-
- /**
- * The component being displayed in this pane's row header.
- *
- * If you want to create a row header for lists or tables, you probably
- * want to let the row header be a list view with the same row height as
- * the viewport component.
- */
- def rowHeaderView: Option[Component] =
- Option(peer.getRowHeader.getView) map UIElement.cachedWrapper[Component]
- def rowHeaderView_=(c: Component) = peer.setRowHeaderView(c.peer)
- def rowHeaderView_=(c: Option[Component]) = peer.setRowHeaderView(c.map(_.peer).orNull)
-
- def columnHeaderView: Option[Component] =
- Option(peer.getColumnHeader.getView) map UIElement.cachedWrapper[Component]
- def columnHeaderView_=(c: Component) = peer.setColumnHeaderView(c.peer)
- def columnHeaderView_=(c: Option[Component]) = peer.setColumnHeaderView(c.map(_.peer).orNull)
-
- def viewportView: Option[Component] =
- Option(peer.getViewport.getView) map UIElement.cachedWrapper[Component]
- def viewportView_=(c: Component) = peer.setViewportView(c.peer)
- def viewportView_=(c: Option[Component]) = peer.setViewportView(c.map(_.peer).orNull)
-
- def verticalScrollBarPolicy = BarPolicy.wrap(peer.getVerticalScrollBarPolicy)
- def verticalScrollBarPolicy_=(p: BarPolicy.Value) = peer.setVerticalScrollBarPolicy(p.verticalPeer)
-
- def horizontalScrollBarPolicy = BarPolicy.wrap(peer.getHorizontalScrollBarPolicy)
- def horizontalScrollBarPolicy_=(p: BarPolicy.Value) = peer.setHorizontalScrollBarPolicy(p.horizontalPeer)
-
- def horizontalScrollBar = ScrollBar.wrap(peer.getHorizontalScrollBar)
- def verticalScrollBar = ScrollBar.wrap(peer.getVerticalScrollBar)
-}
diff --git a/src/swing/scala/swing/Scrollable.scala b/src/swing/scala/swing/Scrollable.scala
deleted file mode 100644
index 1253ac8df0..0000000000
--- a/src/swing/scala/swing/Scrollable.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-object Scrollable {
- trait Wrapper extends Scrollable {
- protected def scrollablePeer: javax.swing.Scrollable
- def preferredViewportSize = scrollablePeer.getPreferredScrollableViewportSize
-
- def tracksViewportHeight: Boolean = scrollablePeer.getScrollableTracksViewportHeight
- def tracksViewportWidth: Boolean = scrollablePeer.getScrollableTracksViewportWidth
-
- def blockIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int =
- scrollablePeer.getScrollableBlockIncrement(visibleRect, orientation.id, direction)
-
- def unitIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int =
- scrollablePeer.getScrollableUnitIncrement(visibleRect, orientation.id, direction)
- }
-}
-
-/**
- * A component that is specially suitable for being placed inside a
- * <code>ScrollPane</code>.
- *
- * @see javax.swing.Scrollable
- */
-trait Scrollable extends Component {
- def preferredViewportSize: Dimension
-
- def tracksViewportHeight: Boolean
- def tracksViewportWidth: Boolean
-
- def blockIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int
- def unitIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int
-}
diff --git a/src/swing/scala/swing/Separator.scala b/src/swing/scala/swing/Separator.scala
deleted file mode 100644
index 32d209d579..0000000000
--- a/src/swing/scala/swing/Separator.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing._
-
-/**
- * A bar that can be used a separator, most commonly in menus.
- *
- * @see javax.swing.JSeparator
- */
-class Separator(o: Orientation.Value) extends Component with Oriented.Wrapper {
- override lazy val peer: JSeparator = new JSeparator(o.id) with SuperMixin
- def this() = this(Orientation.Horizontal)
-}
diff --git a/src/swing/scala/swing/SequentialContainer.scala b/src/swing/scala/swing/SequentialContainer.scala
deleted file mode 100644
index 5f32b08d25..0000000000
--- a/src/swing/scala/swing/SequentialContainer.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import scala.collection.mutable.Buffer
-
-object SequentialContainer {
- /**
- * Utility trait for wrapping sequential containers.
- */
- trait Wrapper extends SequentialContainer with Container.Wrapper {
- override val contents: Buffer[Component] = new Content
- //def contents_=(c: Component*) { contents.clear(); contents ++= c }
- }
-}
-
-/**
- * A container for which a sequential order of children makes sense, such as
- * flow panels, or menus. Its contents are mutable.
- */
-trait SequentialContainer extends Container {
- /**
- * The mutable child components of this container. The order matters and
- * usually indicates the layout of the children.
- */
- override def contents: Buffer[Component]
- //def contents_=(c: Component*)
-}
diff --git a/src/swing/scala/swing/SimpleSwingApplication.scala b/src/swing/scala/swing/SimpleSwingApplication.scala
deleted file mode 100644
index cd0f2be874..0000000000
--- a/src/swing/scala/swing/SimpleSwingApplication.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package scala.swing
-
-/**
- * Extend this class for most simple UI applications. Clients need to
- * implement the `top` method. Framework initialization is done by this class.
- *
- * In order to conform to Swing's threading policy, never implement top or any
- * additional member that created Swing components as a value unless component
- * creation happens on the EDT (see `Swing.onEDT` and `Swing.onEDTWait`).
- * Lazy values are okay for the same reason if they are initialized on the EDT
- * always.
- */
-abstract class SimpleSwingApplication extends SwingApplication {
-
- /**
- * A GUI application's version of the main method. Called by the default
- * main method implementation provided by this class.
- * Implement to return the top-level frame of this application.
- */
- def top: Frame
-
- /**
- * Calls `top`, packs the frame, and displays it.
- */
- override def startup(args: Array[String]) {
- val t = top
- if (t.size == new Dimension(0,0)) t.pack()
- t.visible = true
- }
-
- def resourceFromClassloader(path: String): java.net.URL =
- this.getClass.getResource(path)
-
- def resourceFromUserDirectory(path: String): java.io.File =
- new java.io.File(util.Properties.userDir, path)
-}
diff --git a/src/swing/scala/swing/Slider.scala b/src/swing/scala/swing/Slider.scala
deleted file mode 100644
index 241876587b..0000000000
--- a/src/swing/scala/swing/Slider.scala
+++ /dev/null
@@ -1,71 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import javax.swing.{JSlider, JLabel}
-import event._
-
-/**
- * Lets users select a value from a given range. Visually, this is represented
- * as a draggable knob on a horizontal or vertical bar.
- *
- * Fires a ValueChanged event whenever the slider's value changes and
- * when the knob is released.
- *
- * @see javax.swing.JSlider
- */
-class Slider extends Component with Orientable.Wrapper with Publisher {
- override lazy val peer: JSlider = new JSlider with SuperMixin
-
- def min: Int = peer.getMinimum
- def min_=(v: Int) { peer.setMinimum(v) }
- def max: Int = peer.getMaximum
- def max_=(v: Int) { peer.setMaximum(v) }
- def value: Int = peer.getValue
- def value_=(v: Int) { peer.setValue(v) }
- def extent: Int = peer.getExtent
- def extent_=(v: Int) { peer.setExtent(v) }
-
- def paintLabels: Boolean = peer.getPaintLabels
- def paintLabels_=(v: Boolean) { peer.setPaintLabels(v) }
- def paintTicks: Boolean = peer.getPaintTicks
- def paintTicks_=(v: Boolean) { peer.setPaintTicks(v) }
- def paintTrack: Boolean = peer.getPaintTrack
- def paintTrack_=(v: Boolean) { peer.setPaintTrack(v) }
-
- def snapToTicks: Boolean = peer.getSnapToTicks
- def snapToTicks_=(v: Boolean) { peer.setSnapToTicks(v) }
-
- def minorTickSpacing: Int = peer.getMinorTickSpacing
- def minorTickSpacing_=(v: Int) { peer.setMinorTickSpacing(v) }
- def majorTickSpacing: Int = peer.getMajorTickSpacing
- def majorTickSpacing_=(v: Int) { peer.setMajorTickSpacing(v) }
-
- def adjusting = peer.getValueIsAdjusting
-
- def labels: scala.collection.Map[Int, Label] = {
- val labelTable = peer.getLabelTable.asInstanceOf[java.util.Hashtable[Int, JLabel]]
- new scala.collection.convert.Wrappers.JMapWrapper(labelTable)
- .mapValues(v => UIElement.cachedWrapper[Label](v))
- }
- def labels_=(l: scala.collection.Map[Int, Label]) {
- // TODO: do some lazy wrapping
- val table = new java.util.Hashtable[Any, Any]
- for ((k,v) <- l) table.put(k, v.peer)
- peer.setLabelTable(table)
- }
-
- peer.addChangeListener(new javax.swing.event.ChangeListener {
- def stateChanged(e: javax.swing.event.ChangeEvent) {
- publish(new ValueChanged(Slider.this))
- }
- })
-}
diff --git a/src/swing/scala/swing/SplitPane.scala b/src/swing/scala/swing/SplitPane.scala
deleted file mode 100644
index f61dfedbf4..0000000000
--- a/src/swing/scala/swing/SplitPane.scala
+++ /dev/null
@@ -1,63 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import Swing._
-
-/**
- * A container with exactly two children. Arranges them side by side, either
- * horizontally or vertically. Displays a draggable divider component between
- * them that lets the user adjust the size ratio of the children.
- *
- * @see javax.swing.JSplitPane
- */
-class SplitPane(o: Orientation.Value, left: Component, right: Component) extends Component with Container with Orientable.Wrapper {
- override lazy val peer: javax.swing.JSplitPane =
- new javax.swing.JSplitPane(o.id, left.peer, right.peer) with SuperMixin
- def this(o: Orientation.Value) = this(o, new Component {}, new Component {})
- def this() = this(Orientation.Horizontal)
-
- def contents: Seq[Component] = List(leftComponent, rightComponent)
- def contents_=(left: Component, right: Component) {
- peer.setLeftComponent(nullPeer(left))
- peer.setRightComponent(nullPeer(right))
- }
-
- def topComponent: Component =
- UIElement.cachedWrapper[Component](peer.getTopComponent.asInstanceOf[javax.swing.JComponent])
- def topComponent_=(c: Component) { peer.setTopComponent(nullPeer(c)) }
- def bottomComponent: Component =
- UIElement.cachedWrapper[Component](peer.getBottomComponent.asInstanceOf[javax.swing.JComponent])
- def bottomComponent_=(c: Component) { peer.setBottomComponent(nullPeer(c)) }
-
- def leftComponent: Component = topComponent
- def leftComponent_=(c: Component) { topComponent = c }
- def rightComponent: Component = bottomComponent
- def rightComponent_=(c: Component) { bottomComponent = c }
-
- def dividerLocation: Int = peer.getDividerLocation
- def dividerLocation_=(n: Int) { peer.setDividerLocation(n) }
-
- /*def proportionalDividerLocation: Double =
- if (orientation == Orientation.Vertical) dividerLocation / (size.height - dividerSize)
- else dividerLocation / (size.width - dividerSize)*/
- def dividerLocation_=(f: Double) { peer.setDividerLocation(f) }
-
- def dividerSize: Int = peer.getDividerSize
- def dividerSize_=(n: Int) { peer.setDividerSize(n) }
- def resizeWeight: Double = peer.getResizeWeight
- def resizeWeight_=(n: Double) { peer.setResizeWeight(n) }
-
- def resetToPreferredSizes() { peer.resetToPreferredSizes() }
-
- def oneTouchExpandable: Boolean = peer.isOneTouchExpandable
- def oneTouchExpandable_=(b: Boolean) { peer.setOneTouchExpandable(b) }
- def continuousLayout: Boolean = peer.isContinuousLayout
- def continuousLayout_=(b: Boolean) { peer.setContinuousLayout(b) }
-}
diff --git a/src/swing/scala/swing/Swing.scala b/src/swing/scala/swing/Swing.scala
deleted file mode 100644
index e2c8479354..0000000000
--- a/src/swing/scala/swing/Swing.scala
+++ /dev/null
@@ -1,141 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import java.awt.event._
-import javax.swing.event._
-import javax.swing.border._
-import javax.swing.{JComponent, Icon, BorderFactory, SwingUtilities}
-import scala.language.implicitConversions
-
-
-/**
- * Helpers for this package.
- */
-object Swing {
- protected[swing] def toNoIcon(i: Icon): Icon = if(i == null) EmptyIcon else i
- protected[swing] def toNullIcon(i: Icon): Icon = if(i == EmptyIcon) null else i
- protected[swing] def nullPeer(c: Component) = if (c != null) c.peer else null
-
- implicit def pair2Dimension(p: (Int, Int)): Dimension = new Dimension(p._1, p._2)
- implicit def pair2Point(p: (Int, Int)): Point = new Point(p._1, p._2)
- implicit def pair2Point(p: (Int, Int, Int, Int)): Rectangle = new Rectangle(p._1, p._2, p._3, p._4)
-
- @inline final def Runnable(@inline block: =>Unit) = new Runnable {
- def run = block
- }
- final def ChangeListener(f: ChangeEvent => Unit) = new ChangeListener {
- def stateChanged(e: ChangeEvent) { f(e) }
- }
- final def ActionListener(f: ActionEvent => Unit) = new ActionListener {
- def actionPerformed(e: ActionEvent) { f(e) }
- }
-
- def Box(min: Dimension, pref: Dimension, max: Dimension) = new Component {
- override lazy val peer = new javax.swing.Box.Filler(min, pref, max)
- }
- def HGlue = new Component {
- override lazy val peer = javax.swing.Box.createHorizontalGlue.asInstanceOf[JComponent]
- }
- def VGlue = new Component {
- override lazy val peer = javax.swing.Box.createVerticalGlue.asInstanceOf[JComponent]
- }
- def Glue = new Component {
- override lazy val peer = javax.swing.Box.createGlue.asInstanceOf[JComponent]
- }
- def RigidBox(dim: Dimension) = new Component {
- override lazy val peer = javax.swing.Box.createRigidArea(dim).asInstanceOf[JComponent]
- }
- def HStrut(width: Int) = new Component {
- override lazy val peer = javax.swing.Box.createHorizontalStrut(width).asInstanceOf[JComponent]
- }
- def VStrut(height: Int) = new Component {
- override lazy val peer = javax.swing.Box.createVerticalStrut(height).asInstanceOf[JComponent]
- }
-
- def Icon(image: java.awt.Image) = new javax.swing.ImageIcon(image)
- def Icon(filename: String) = new javax.swing.ImageIcon(filename)
- def Icon(url: java.net.URL) = new javax.swing.ImageIcon(url)
-
- /**
- * The empty icon. Use this icon instead of <code>null</code> to indicate
- * that you don't want an icon.
- */
- case object EmptyIcon extends Icon {
- def getIconHeight: Int = 0
- def getIconWidth: Int = 0
- def paintIcon(c: java.awt.Component, g: java.awt.Graphics, x: Int, y: Int) {}
- }
-
- def unwrapIcon(icon: Icon): Icon = if (icon == null) EmptyIcon else icon
- def wrapIcon(icon: Icon): Icon = if (icon == EmptyIcon) null else icon
-
- def EmptyBorder = BorderFactory.createEmptyBorder()
- def EmptyBorder(weight: Int) =
- BorderFactory.createEmptyBorder(weight, weight, weight, weight)
- def EmptyBorder(top: Int, left: Int, bottom: Int, right: Int) =
- BorderFactory.createEmptyBorder(top, left, bottom, right)
-
- def LineBorder(c: Color) = BorderFactory.createLineBorder(c)
- def LineBorder(c: Color, weight: Int) = BorderFactory.createLineBorder(c, weight)
-
- def BeveledBorder(kind: Embossing) = BorderFactory.createBevelBorder(kind.bevelPeer)
- def BeveledBorder(kind: Embossing, highlight: Color, shadow: Color) =
- BorderFactory.createBevelBorder(kind.bevelPeer, highlight, shadow)
- def BeveledBorder(kind: Embossing,
- highlightOuter: Color, highlightInner: Color,
- shadowOuter: Color, shadowInner: Color) =
- BorderFactory.createBevelBorder(kind.bevelPeer,
- highlightOuter, highlightInner,
- shadowOuter, shadowInner)
-
- sealed abstract class Embossing {
- def bevelPeer: Int
- def etchPeer: Int
- }
- case object Lowered extends Embossing {
- def bevelPeer = BevelBorder.LOWERED
- def etchPeer = javax.swing.border.EtchedBorder.LOWERED
- }
- case object Raised extends Embossing {
- def bevelPeer = BevelBorder.RAISED
- def etchPeer = javax.swing.border.EtchedBorder.RAISED
- }
-
- def EtchedBorder = BorderFactory.createEtchedBorder()
- def EtchedBorder(kind: Embossing) =
- BorderFactory.createEtchedBorder(kind.etchPeer)
- def EtchedBorder(kind: Embossing, highlight: Color, shadow: Color) =
- BorderFactory.createEtchedBorder(kind.etchPeer, highlight, shadow)
-
- def MatteBorder(top: Int, left: Int, bottom: Int, right: Int, color: Color) =
- BorderFactory.createMatteBorder(top, left, bottom, right, color)
- def MatteBorder(top: Int, left: Int, bottom: Int, right: Int, icon: Icon) =
- BorderFactory.createMatteBorder(top, left, bottom, right, icon)
-
- def CompoundBorder(outside: Border, inside: Border) =
- BorderFactory.createCompoundBorder(outside, inside)
-
- def TitledBorder(border: Border, title: String) =
- BorderFactory.createTitledBorder(border, title)
-
- /**
- * Schedule the given code to be executed on the Swing event dispatching
- * thread (EDT). Returns immediately.
- */
- @inline final def onEDT(op: =>Unit) = SwingUtilities invokeLater Runnable(op)
-
- /**
- * Schedule the given code to be executed on the Swing event dispatching
- * thread (EDT). Blocks until after the code has been run.
- */
- @inline final def onEDTWait(op: =>Unit) = SwingUtilities invokeAndWait Runnable(op)
-}
diff --git a/src/swing/scala/swing/SwingApplication.scala b/src/swing/scala/swing/SwingApplication.scala
deleted file mode 100644
index 214001f72a..0000000000
--- a/src/swing/scala/swing/SwingApplication.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-package scala.swing
-
-/** Convenience class with utility methods for GUI applications. */
-abstract class SwingApplication extends Reactor {
-
- /** Initializes the application and runs the given program. */
- def main(args: Array[String]) = Swing.onEDT { startup(args) }
-
- /** Called before the GUI is created. Override to customize. */
- def startup(args: Array[String])
-
- /** Finalizes the application by calling `shutdown` and exits.*/
- def quit() { shutdown(); sys.exit(0) }
-
- /** Called before the application is exited. Override to customize. */
- def shutdown() {}
-}
diff --git a/src/swing/scala/swing/TabbedPane.scala b/src/swing/scala/swing/TabbedPane.scala
deleted file mode 100644
index 6e46256f86..0000000000
--- a/src/swing/scala/swing/TabbedPane.scala
+++ /dev/null
@@ -1,131 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import event._
-import scala.collection.mutable.Buffer
-import javax.swing.{JTabbedPane, JComponent}
-
-
-object TabbedPane {
- object Layout extends Enumeration {
- val Wrap = Value(JTabbedPane.WRAP_TAB_LAYOUT)
- val Scroll = Value(JTabbedPane.SCROLL_TAB_LAYOUT)
- }
-
- class Page protected[TabbedPane](parent0: TabbedPane, title0: String, content0: Component, tip0: String) extends Proxy {
- def self = content0
-
- def this(title0: String, content0: Component, tip0: String) =
- this(null, title0, content0, tip0)
- def this(title0: String, content0: Component) =
- this(title0, content0, "")
- content = content0 // first add component, *then* set other things
- title = title0
- tip = tip0
-
- protected[TabbedPane] var parent: TabbedPane = parent0
-
- protected var _title = title0
- def title: String = _title
- def title_=(t: String) {
- // beware to keep this order since, index depends on the _old_ title
- if (parent != null) parent.peer.setTitleAt(index, t)
- _title = t
- }
- protected var _content = content0
- def content: Component = _content//UIElement.cachedWrapper(peer.getComponentAt(index).asInstanceOf[JComponent])
- def content_=(c: Component) { _content = c; if (parent != null) parent.peer.setComponentAt(index, c.peer) }
- protected var _tip = tip0
- def tip: String = _tip//peer.getToolTipTextAt(index)
- def tip_=(t: String) { _tip = t; if (parent != null) parent.peer.setToolTipTextAt(index, t) }
- protected var _enabled = true
- def enabled: Boolean = _enabled//peer.isEnabledAt(index)
- def enabled_=(b: Boolean) { _enabled = b; if (parent != null) parent.peer.setEnabledAt(index, b) }
- protected var _mnemonic = -1
- def mnemonic: Int = _mnemonic//peer.getMnemonicAt(index)
- def mnemonic_=(k: Int) { _mnemonic = k; if (parent != null) parent.peer.setMnemonicAt(index, k)}
- protected var _foreground: Color = null
- def foreground: Color = _foreground//peer.getForegroundAt(index)
- def foreground_=(c: Color) { _foreground = c; if (parent != null) parent.peer.setForegroundAt(index, c)}
- protected var _background: Color = null
- def background: Color = _background //peer.getBackgroundAt(index)
- def background_=(c: Color) { _background = c; if (parent != null) parent.peer.setBackgroundAt(index, c)}
- def bounds: Rectangle = parent.peer.getBoundsAt(index)
-
- // TODO: icon, disabledIcon
-
- def index = if(parent != null) parent.peer.indexOfTab(title) else 0//_index
- //protected[TabbedPane] var _index: Int = index0
- }
-}
-
-/**
- * Displays the contents of one of several pages at a time. For each page a tab is
- * visible at all times. The user can click on one of these tabs to move the
- * corresponding page to the front.
- *
- * @see javax.swing.JTabbedPane
- */
-class TabbedPane extends Component with Publisher {
- override lazy val peer: JTabbedPane = new JTabbedPane with SuperMixin
- import TabbedPane._
-
- object pages extends BufferWrapper[Page] {
- def runCount: Int = peer.getTabRunCount
-
- def remove(n: Int): Page = {
- val t = apply(n)
- peer.removeTabAt(n)
- t.parent = null
- //for(i <- n to length) apply(i)._index -= 1
- t
- }
- protected def insertAt(n: Int, t: Page) {
- //for(i <- n to length) apply(i)._index += 1
- t.parent = TabbedPane.this
- peer.insertTab(t.title, null, t.content.peer, t.tip, n)
- }
-
- def +=(t: Page): this.type = { t.parent = TabbedPane.this; peer.addTab(t.title, null, t.content.peer, t.tip); this }
- def length = peer.getTabCount
- def apply(n: Int) = new Page(TabbedPane.this, peer.getTitleAt(n),
- UIElement.cachedWrapper[Component](peer.getComponentAt(n).asInstanceOf[javax.swing.JComponent]),
- peer.getToolTipTextAt(n))
- }
-
- def tabLayoutPolicy: Layout.Value = Layout(peer.getTabLayoutPolicy)
- def tabLayoutPolicy_=(p: Layout.Value) { peer.setTabLayoutPolicy(p.id) }
-
-
- def tabPlacement: Alignment.Value = Alignment(peer.getTabPlacement)
- /**
- * Possible values are Left, Right, Top, Bottom.
- */
- def tabPlacement_=(b: Alignment.Value) { peer.setTabPlacement(b.id) }
-
- /**
- * The current page selection
- */
- object selection extends Publisher {
- def page: Page = pages(index)
- def page_=(p: Page) { index = p.index }
-
- def index: Int = peer.getSelectedIndex
- def index_=(n: Int) { peer.setSelectedIndex(n) }
-
- peer.addChangeListener(new javax.swing.event.ChangeListener {
- def stateChanged(e: javax.swing.event.ChangeEvent) {
- publish(SelectionChanged(TabbedPane.this))
- }
- })
- }
-}
diff --git a/src/swing/scala/swing/Table.scala b/src/swing/scala/swing/Table.scala
deleted file mode 100644
index 45053f0411..0000000000
--- a/src/swing/scala/swing/Table.scala
+++ /dev/null
@@ -1,320 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import event._
-import javax.swing._
-import javax.swing.table._
-import javax.swing.event._
-import scala.collection.mutable
-
-object Table {
- object AutoResizeMode extends Enumeration {
- import JTable._
- val Off = Value(AUTO_RESIZE_OFF, "Off")
- val NextColumn = Value(AUTO_RESIZE_NEXT_COLUMN, "NextColumn")
- val SubsequentColumns = Value(AUTO_RESIZE_SUBSEQUENT_COLUMNS, "SubsequentColumns")
- val LastColumn = Value(AUTO_RESIZE_LAST_COLUMN, "LastColumn")
- val AllColumns = Value(AUTO_RESIZE_ALL_COLUMNS, "AllColumns")
- }
-
- object IntervalMode extends Enumeration {
- val Single = Value(ListSelectionModel.SINGLE_SELECTION)
- val SingleInterval = Value(ListSelectionModel.SINGLE_INTERVAL_SELECTION)
- val MultiInterval = Value(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
- }
- object ElementMode extends Enumeration {
- val Row, Column, Cell, None = Value
- }
-
- /**
- * A table item renderer.
- *
- * @see javax.swing.table.TableCellRenderer
- */
- abstract class Renderer[-A] {
- def peer: TableCellRenderer = new TableCellRenderer {
- def getTableCellRendererComponent(table: JTable, value: AnyRef, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int) = {
- componentFor(table match {
- case t: JTableMixin => t.tableWrapper
- case _ => assert(false); null
- }, isSelected, hasFocus, value.asInstanceOf[A], row, column).peer
- }
- }
- def componentFor(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int): Component
- }
-
- abstract class AbstractRenderer[-A, C<:Component](val component: C) extends Renderer[A] {
- // The renderer component is responsible for painting selection
- // backgrounds. Hence, make sure it is opaque to let it draw
- // the background.
- component.opaque = true
-
- /**
- * Standard preconfiguration that is commonly done for any component.
- */
- def preConfigure(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int) {
- if (isSelected) {
- component.background = table.selectionBackground
- component.foreground = table.selectionForeground
- } else {
- component.background = table.background
- component.foreground = table.foreground
- }
- }
- /**
- * Configuration that is specific to the component and this renderer.
- */
- def configure(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int)
-
- /**
- * Configures the component before returning it.
- */
- def componentFor(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int): Component = {
- preConfigure(table, isSelected, hasFocus, a, row, column)
- configure(table, isSelected, hasFocus, a, row, column)
- component
- }
- }
-
- class LabelRenderer[A](convert: A => (Icon, String)) extends AbstractRenderer[A, Label](new Label) {
- def this() {
- this{ a => (null, a.toString) }
- }
-
- def configure(table: Table, isSelected: Boolean, hasFocus: Boolean, a: A, row: Int, column: Int) {
- val (icon, text) = convert(a)
- component.icon = icon
- component.text = text
- }
- }
-
- private[swing] trait JTableMixin { def tableWrapper: Table }
-}
-
-/**
- * Displays a matrix of items.
- *
- * To obtain a scrollable table or row and columns headers,
- * wrap the table in a scroll pane.
- *
- * @see javax.swing.JTable
- */
-class Table extends Component with Scrollable.Wrapper {
- override lazy val peer: JTable = new JTable with Table.JTableMixin with SuperMixin {
- def tableWrapper = Table.this
- override def getCellRenderer(r: Int, c: Int) = new TableCellRenderer {
- def getTableCellRendererComponent(table: JTable, value: AnyRef, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int) =
- Table.this.rendererComponent(isSelected, hasFocus, row, column).peer
- }
- override def getCellEditor(r: Int, c: Int) = editor(r, c)
- override def getValueAt(r: Int, c: Int) = Table.this.apply(r,c).asInstanceOf[AnyRef]
- }
- import Table._
-
- // TODO: use IndexedSeq[_ <: IndexedSeq[Any]], see ticket #2005
- def this(rowData: Array[Array[Any]], columnNames: Seq[_]) = {
- this()
- model = new AbstractTableModel {
- override def getColumnName(column: Int) = columnNames(column).toString
- def getRowCount() = rowData.length
- def getColumnCount() = columnNames.length
- def getValueAt(row: Int, col: Int): AnyRef = rowData(row)(col).asInstanceOf[AnyRef]
- override def isCellEditable(row: Int, column: Int) = true
- override def setValueAt(value: Any, row: Int, col: Int) {
- rowData(row)(col) = value
- fireTableCellUpdated(row, col)
- }
- }
- }
- def this(rows: Int, columns: Int) = {
- this()
- model = new DefaultTableModel(rows, columns) {
- override def setValueAt(value: Any, row: Int, col: Int) {
- super.setValueAt(value, row, col)
- }
- }
- }
-
- protected def scrollablePeer = peer
-
- def rowHeight = peer.getRowHeight
- def rowHeight_=(x: Int) = peer.setRowHeight(x)
-
- def rowCount = peer.getRowCount
-
- def model = peer.getModel()
- def model_=(x: TableModel) = {
- peer.setModel(x)
- model.removeTableModelListener(modelListener)
- model.addTableModelListener(modelListener)
- }
-
- def autoResizeMode: AutoResizeMode.Value = AutoResizeMode(peer.getAutoResizeMode)
- def autoResizeMode_=(x: Table.AutoResizeMode.Value) = peer.setAutoResizeMode(x.id)
-
- def showGrid = peer.getShowHorizontalLines && peer.getShowVerticalLines
- def showGrid_=(grid: Boolean) = peer.setShowGrid(grid)
-
- def gridColor = peer.getGridColor
- def gridColor_=(color: Color) = peer.setGridColor(color)
-
- def preferredViewportSize_=(dim: Dimension) = peer.setPreferredScrollableViewportSize(dim)
- //1.6: def fillsViewportHeight: Boolean = peer.getFillsViewportHeight
- //def fillsViewportHeight_=(b: Boolean) = peer.setFillsViewportHeight(b)
-
- object selection extends Publisher {
- // TODO: could be a sorted set
- protected abstract class SelectionSet[A](a: =>Seq[A]) extends mutable.Set[A] {
- def -=(n: A): this.type
- def +=(n: A): this.type
- def contains(n: A) = a.contains(n)
- override def size = a.length
- def iterator = a.iterator
- }
-
- object rows extends SelectionSet(peer.getSelectedRows) {
- def -=(n: Int) = { peer.removeRowSelectionInterval(n,n); this }
- def +=(n: Int) = { peer.addRowSelectionInterval(n,n); this }
-
- def leadIndex: Int = peer.getSelectionModel.getLeadSelectionIndex
- def anchorIndex: Int = peer.getSelectionModel.getAnchorSelectionIndex
- }
-
- object columns extends SelectionSet(peer.getSelectedColumns) {
- def -=(n: Int) = { peer.removeColumnSelectionInterval(n,n); this }
- def +=(n: Int) = { peer.addColumnSelectionInterval(n,n); this }
-
- def leadIndex: Int = peer.getColumnModel.getSelectionModel.getLeadSelectionIndex
- def anchorIndex: Int = peer.getColumnModel.getSelectionModel.getAnchorSelectionIndex
- }
-
- def cells: mutable.Set[(Int, Int)] =
- new SelectionSet[(Int, Int)]((for(r <- selection.rows; c <- selection.columns) yield (r,c)).toSeq) { outer =>
- def -=(n: (Int, Int)) = {
- peer.removeRowSelectionInterval(n._1,n._1)
- peer.removeColumnSelectionInterval(n._2,n._2)
- this
- }
- def +=(n: (Int, Int)) = {
- peer.addRowSelectionInterval(n._1,n._1)
- peer.addColumnSelectionInterval(n._2,n._2)
- this
- }
- override def size = peer.getSelectedRowCount * peer.getSelectedColumnCount
- }
-
- /**
- * From the JTable Swing tutorial:
- * You can specify selection by cell in multiple interval selection mode,
- * but the result is a table that does not produce useful selections.
- */
- def intervalMode: IntervalMode.Value = IntervalMode(peer.getSelectionModel.getSelectionMode)
- def intervalMode_=(m: IntervalMode.Value) { peer.setSelectionMode(m.id) }
- def elementMode: ElementMode.Value =
- if(peer.getColumnSelectionAllowed && peer.getRowSelectionAllowed) ElementMode.Cell
- else if(peer.getColumnSelectionAllowed) ElementMode.Column
- else if(peer.getRowSelectionAllowed) ElementMode.Row
- else ElementMode.None
- def elementMode_=(m: ElementMode.Value) {
- m match {
- case ElementMode.Cell => peer.setCellSelectionEnabled(true)
- case ElementMode.Column => peer.setRowSelectionAllowed(false); peer.setColumnSelectionAllowed(true)
- case ElementMode.Row => peer.setRowSelectionAllowed(true); peer.setColumnSelectionAllowed(false)
- case ElementMode.None => peer.setRowSelectionAllowed(false); peer.setColumnSelectionAllowed(false)
- }
- }
-
- peer.getColumnModel.getSelectionModel.addListSelectionListener(new ListSelectionListener {
- def valueChanged(e: javax.swing.event.ListSelectionEvent) {
- publish(TableColumnsSelected(Table.this, e.getFirstIndex to e.getLastIndex, e.getValueIsAdjusting))
- }
- })
- peer.getSelectionModel.addListSelectionListener(new ListSelectionListener {
- def valueChanged(e: javax.swing.event.ListSelectionEvent) {
- publish(TableRowsSelected(Table.this, e.getFirstIndex to e.getLastIndex, e.getValueIsAdjusting))
- }
- })
- }
-
- /**
- * Supplies a renderer component for a given cell.
- */
- protected def rendererComponent(isSelected: Boolean, focused: Boolean, row: Int, column: Int): Component =
- new Component {
- override lazy val peer = {
- val v = apply(row, column).asInstanceOf[AnyRef]
- if (v != null)
- Table.this.peer.getDefaultRenderer(v.getClass).getTableCellRendererComponent(Table.this.peer,
- v, isSelected, focused, row, column).asInstanceOf[JComponent]
- else Table.this.peer.getDefaultRenderer(classOf[Object]).getTableCellRendererComponent(Table.this.peer,
- v, isSelected, focused, row, column).asInstanceOf[JComponent]
- }
- }
-
- // TODO: a public API for setting editors
- protected def editor(row: Int, column: Int) = {
- val v = apply(row, column).asInstanceOf[AnyRef]
- if (v != null)
- Table.this.peer.getDefaultEditor(v.getClass)
- else
- Table.this.peer.getDefaultEditor(classOf[Object])
- }
-
- /**
- * Get the current value of the given cell.
- * The given cell coordinates are in view coordinates and thus not
- * necessarily the same as for the model.
- */
- def apply(row: Int, column: Int): Any = model.getValueAt(row, viewToModelColumn(column))
-
- // TODO: this is Java 6 stuff
- // def apply(row: Int, column: Int): Any = model.getValueAt(viewToModelRow(row), viewToModelColumn(column))
- //def viewToModelRow(idx: Int) = peer.convertRowIndexToModel(idx)
- //def modelToViewRow(idx: Int) = peer.convertRowIndexToView(idx)
-
- def viewToModelColumn(idx: Int) = peer.convertColumnIndexToModel(idx)
- def modelToViewColumn(idx: Int) = peer.convertColumnIndexToView(idx)
-
-
- /**
- * Change the value of the given cell.
- */
- def update(row: Int, column: Int, value: Any) { model.setValueAt(value, row, viewToModelColumn(column)) }
-
- /**
- * Visually update the given cell.
- */
- def updateCell(row: Int, column: Int) = update(row, column, apply(row, column))
-
- def selectionForeground: Color = peer.getSelectionForeground
- def selectionForeground_=(c: Color) = peer.setSelectionForeground(c)
- def selectionBackground: Color = peer.getSelectionBackground
- def selectionBackground_=(c: Color) = peer.setSelectionBackground(c)
-
- protected val modelListener = new TableModelListener {
- def tableChanged(e: TableModelEvent) = publish(
- e.getType match {
- case TableModelEvent.UPDATE =>
- if (e.getFirstRow == 0 && e.getLastRow == Int.MaxValue && e.getColumn == TableModelEvent.ALL_COLUMNS)
- TableChanged(Table.this)
- else if (e.getFirstRow == TableModelEvent.HEADER_ROW)
- TableStructureChanged(Table.this)
- else
- TableUpdated(Table.this, e.getFirstRow to e.getLastRow, e.getColumn)
- case TableModelEvent.INSERT =>
- TableRowsAdded(Table.this, e.getFirstRow to e.getLastRow)
- case TableModelEvent.DELETE =>
- TableRowsRemoved(Table.this, e.getFirstRow to e.getLastRow)
- }
- )
- }
-}
diff --git a/src/swing/scala/swing/TextArea.scala b/src/swing/scala/swing/TextArea.scala
deleted file mode 100644
index 2f6bdca119..0000000000
--- a/src/swing/scala/swing/TextArea.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import javax.swing._
-
-/**
- * A text component that allows multiline text input and display.
- *
- * @see javax.swing.JTextArea
- */
-class TextArea(text0: String, rows0: Int, columns0: Int) extends TextComponent
- with TextComponent.HasColumns with TextComponent.HasRows {
- override lazy val peer: JTextArea = new JTextArea(text0, rows0, columns0) with SuperMixin
- def this(text: String) = this(text, 0, 0)
- def this(rows: Int, columns: Int) = this("", rows, columns)
- def this() = this("", 0, 0)
-
- // TODO: we could make contents StringBuilder-like
- def append(t: String) { peer.append(t) }
-
- def rows: Int = peer.getRows
- def rows_=(n: Int) = peer.setRows(n)
- def columns: Int = peer.getColumns
- def columns_=(n: Int) = peer.setColumns(n)
-
- def tabSize: Int = peer.getTabSize
- def tabSize_=(n: Int) = peer.setTabSize(n)
- def lineCount: Int = peer.getLineCount
-
- def lineWrap: Boolean = peer.getLineWrap
- def lineWrap_=(w: Boolean) = peer.setLineWrap(w)
- def wordWrap: Boolean = peer.getWrapStyleWord
- def wordWrap_=(w: Boolean) = peer.setWrapStyleWord(w)
- def charWrap: Boolean = !peer.getWrapStyleWord
- def charWrap_=(w: Boolean) = peer.setWrapStyleWord(!w)
-}
diff --git a/src/swing/scala/swing/TextComponent.scala b/src/swing/scala/swing/TextComponent.scala
deleted file mode 100644
index 4d23399737..0000000000
--- a/src/swing/scala/swing/TextComponent.scala
+++ /dev/null
@@ -1,75 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import event._
-import javax.swing.text._
-import javax.swing.event._
-
-object TextComponent {
- trait HasColumns extends TextComponent {
- def columns: Int
- def columns_=(n: Int)
- }
- trait HasRows extends TextComponent {
- def rows: Int
- def rows_=(n: Int)
- }
-}
-
-/**
- * A component that allows some kind of text input and display.
- *
- * @see javax.swing.JTextComponent
- */
-class TextComponent extends Component with Publisher {
- override lazy val peer: JTextComponent = new JTextComponent with SuperMixin {}
- def text: String = peer.getText
- def text_=(t: String) = peer.setText(t)
-
- class Caret extends Publisher {
- def dot: Int = peer.getCaret.getDot
- def dot_=(n: Int) { peer.getCaret.setDot(n) }
- def mark: Int = peer.getCaret.getMark
- def moveDot(n: Int) { peer.getCaret.moveDot(n) }
- def visible: Boolean = peer.getCaret.isVisible
- def visible_=(b: Boolean) { peer.getCaret.setVisible(b) }
- def selectionVisible: Boolean = peer.getCaret.isSelectionVisible
- def selectionVisible_=(b: Boolean) { peer.getCaret.setSelectionVisible(b) }
- def blinkRate: Int = peer.getCaret.getBlinkRate
- def blinkRate_=(n: Int) { peer.getCaret.setBlinkRate(n) }
- def color: Color = peer.getCaretColor
- def color_=(c: Color) = peer.setCaretColor(c)
- def position: Int = peer.getCaretPosition
- def position_=(p: Int) = peer.setCaretPosition(p)
-
- peer.addCaretListener {
- new CaretListener {
- def caretUpdate(e: CaretEvent) { publish(CaretUpdate(TextComponent.this)) }
- }
- }
- }
-
- object caret extends Caret
-
- def editable: Boolean = peer.isEditable
- def editable_=(x: Boolean) = peer.setEditable(x)
- def cut() { peer.cut() }
- def copy() { peer.copy() }
- def paste() { peer.paste() }
- def selected: String = peer.getSelectedText
-
- def selectAll() { peer.selectAll() }
-
- peer.getDocument.addDocumentListener(new DocumentListener {
- def changedUpdate(e:DocumentEvent) { publish(new ValueChanged(TextComponent.this)) }
- def insertUpdate(e:DocumentEvent) { publish(new ValueChanged(TextComponent.this)) }
- def removeUpdate(e:DocumentEvent) { publish(new ValueChanged(TextComponent.this)) }
- })
-}
diff --git a/src/swing/scala/swing/TextField.scala b/src/swing/scala/swing/TextField.scala
deleted file mode 100644
index a28e8f84e6..0000000000
--- a/src/swing/scala/swing/TextField.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-
-import event._
-import javax.swing._
-import java.awt.event._
-
-
-/*object TextField {
- object FocusLostBehavior extends Enumeration {
- val Revert = Value(JFormattedTextField.REVERT)
- val Commit = Value(JFormattedTextField.REVERT)
- val CommitOrRevert = Value(JFormattedTextField.REVERT)
- val Persist = Value(JFormattedTextField.REVERT)
- }
-}*/
-
-/**
- * A text component that allows single line text input and display.
- *
- * @see javax.swing.JTextField
- */
-class TextField(text0: String, columns0: Int) extends TextComponent with TextComponent.HasColumns with Action.Trigger.Wrapper {
- override lazy val peer: JTextField = new JTextField(text0, columns0) with SuperMixin
- def this(text: String) = this(text, 0)
- def this(columns: Int) = this("", columns)
- def this() = this("")
-
- def columns: Int = peer.getColumns
- def columns_=(n: Int) = peer.setColumns(n)
-
- /** @see javax.swing.JTextField#getHorizontalAlignment() */
- def horizontalAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment)
- /** @see javax.swing.JTextField#setHorizontalAlignment() */
- def horizontalAlignment_=(x: Alignment.Value) { peer.setHorizontalAlignment(x.id) }
-
- private lazy val actionListener = Swing.ActionListener { e =>
- publish(EditDone(TextField.this))
- }
-
- protected override def onFirstSubscribe() {
- super.onFirstSubscribe
- peer.addActionListener(actionListener)
- peer.addFocusListener(new FocusAdapter {
- override def focusLost(e: java.awt.event.FocusEvent) { publish(EditDone(TextField.this)) }
- })
- }
-
- protected override def onLastUnsubscribe() {
- super.onLastUnsubscribe
- peer.removeActionListener(actionListener)
- }
-
- def verifier: String => Boolean = s => Option(peer.getInputVerifier) forall (_ verify peer)
- def verifier_=(v: String => Boolean) {
- peer.setInputVerifier(new InputVerifier {
- private val old = Option(peer.getInputVerifier)
- def verify(c: JComponent) = v(text)
- override def shouldYieldFocus(c: JComponent) = old forall (_ shouldYieldFocus c)
- })
- }
- def shouldYieldFocus: String => Boolean = s => Option(peer.getInputVerifier) forall (_ shouldYieldFocus peer)
- def shouldYieldFocus_=(y: String=>Boolean) {
- peer.setInputVerifier(new InputVerifier {
- private val old = peer.getInputVerifier
- def verify(c: JComponent) = old.verify(c)
- override def shouldYieldFocus(c: JComponent) = y(text)
- })
- }
-}
diff --git a/src/swing/scala/swing/ToggleButton.scala b/src/swing/scala/swing/ToggleButton.scala
deleted file mode 100644
index 8f210d00d8..0000000000
--- a/src/swing/scala/swing/ToggleButton.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import javax.swing._
-
-/**
- * A two state button with a push button like user interface.
- * Usually used in tool bars.
- *
- * @see javax.swing.JToggleButton
- */
-class ToggleButton(text0: String) extends AbstractButton {
- override lazy val peer: JToggleButton = new JToggleButton(text0) with SuperMixin
- def this() = this("")
-}
diff --git a/src/swing/scala/swing/UIElement.scala b/src/swing/scala/swing/UIElement.scala
deleted file mode 100644
index 16b8738392..0000000000
--- a/src/swing/scala/swing/UIElement.scala
+++ /dev/null
@@ -1,133 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import java.awt.Cursor
-import event._
-import scala.ref._
-import java.util.WeakHashMap
-
-object UIElement {
- private val ClientKey = "scala.swingWrapper"
- private[this] val wrapperCache = new WeakHashMap[java.awt.Component, WeakReference[UIElement]]
-
- private def cache(e: UIElement) = e.peer match {
- case p: javax.swing.JComponent => p.putClientProperty(ClientKey, e)
- case _ => wrapperCache.put(e.peer, new WeakReference(e))
- }
-
- /**
- * Looks up the internal component cache for a wrapper of the given
- * Java Swing peer. If this method finds one of the given type `C`,
- * it will return that wrapper. Otherwise it returns `null`. This
- * method never throws an exception.
- *
- * Clients should be extremely careful with type parameter `C` and
- * its interaction with type inference. Better err on the side of caution
- * and explicitly specify `C`.
- */
- private[swing] def cachedWrapper[C>:Null<:UIElement](c: java.awt.Component): C = {
- val w = c match {
- case c: javax.swing.JComponent => c.getClientProperty(ClientKey)
- case _ => wrapperCache.get(c)
- }
- try { w.asInstanceOf[C] } catch { case _: Exception => null }
- }
-
- /**
- * Returns a wrapper for a given Java Swing peer. If there is a
- * compatible wrapper in use, this method will return it.
- *
- * `wrap` methods in companion objects of subclasses of `UIElement` have
- * the same behavior, except that they return more specific wrappers.
- */
- def wrap(c: java.awt.Component): UIElement = {
- val w = cachedWrapper[UIElement](c)
- if (w != null) w
- else new UIElement { def peer = c }
- }
-}
-
-/**
- * The base trait of all user interface elements. Subclasses belong to one
- * of two groups: top-level elements such as windows and dialogs, or
- * `Component`s.
- *
- * @note [Java Swing] This trait does not have an exact counterpart in
- * Java Swing. The peer is of type java.awt.Component since this is the
- * least common upper bound of possible underlying peers.
- *
- * @note [Implementation] A UIElement automatically adds itself to the
- * component cache on creation.
- *
- * @see java.awt.Component
- */
-trait UIElement extends Proxy with LazyPublisher {
- /**
- * The underlying Swing peer.
- */
- def peer: java.awt.Component
- def self = peer
-
- UIElement.cache(this)
-
- def foreground: Color = peer.getForeground
- def foreground_=(c: Color) = peer setForeground c
- def background: Color = peer.getBackground
- def background_=(c: Color) = peer setBackground c
-
- def minimumSize = peer.getMinimumSize
- def minimumSize_=(x: Dimension) = peer setMinimumSize x
- def maximumSize = peer.getMaximumSize
- def maximumSize_=(x: Dimension) = peer setMaximumSize x
- def preferredSize = peer.getPreferredSize
- def preferredSize_=(x: Dimension) = peer setPreferredSize x
-
- def font: Font = peer.getFont
- def font_=(f: Font) = peer setFont f
-
- def locationOnScreen = peer.getLocationOnScreen
- def location = peer.getLocation
- def bounds = peer.getBounds
- def size = peer.getSize
-
- def locale = peer.getLocale
- def toolkit = peer.getToolkit
-
- def cursor: Cursor = peer.getCursor
- def cursor_=(c: Cursor) { peer.setCursor(c) }
-
- def visible: Boolean = peer.isVisible
- def visible_=(b: Boolean) { peer.setVisible(b) }
- def showing: Boolean = peer.isShowing
- def displayable: Boolean = peer.isDisplayable
-
- def repaint() { peer.repaint }
- def repaint(rect: Rectangle) { peer.repaint(rect.x, rect.y, rect.width, rect.height) }
- def ignoreRepaint: Boolean = peer.getIgnoreRepaint
- def ignoreRepaint_=(b: Boolean) { peer.setIgnoreRepaint(b) }
-
- protected def onFirstSubscribe() {
- peer.addComponentListener(new java.awt.event.ComponentListener {
- def componentHidden(e: java.awt.event.ComponentEvent) {
- publish(UIElementHidden(UIElement.this))
- }
- def componentShown(e: java.awt.event.ComponentEvent) {
- publish(UIElementShown(UIElement.this))
- }
- def componentMoved(e: java.awt.event.ComponentEvent) {
- publish(UIElementMoved(UIElement.this))
- }
- def componentResized(e: java.awt.event.ComponentEvent) {
- publish(UIElementResized(UIElement.this))
- }
- })
- }
- protected def onLastUnsubscribe() {}
-}
diff --git a/src/swing/scala/swing/Window.scala b/src/swing/scala/swing/Window.scala
deleted file mode 100644
index a9f4ae7538..0000000000
--- a/src/swing/scala/swing/Window.scala
+++ /dev/null
@@ -1,78 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.swing
-
-import java.awt.{Window => AWTWindow}
-import event._
-
-/**
- * A window with decoration such as a title, border, and action buttons.
- *
- * An AWT window cannot be wrapped dynamically with this class, i.e., you cannot
- * write something like new Window { def peer = myAWTWindow }
- *
- * @see javax.swing.JFrame
- */
-abstract class Window extends UIElement with RootPanel with Publisher { outer =>
- def peer: AWTWindow with InterfaceMixin
-
- protected trait InterfaceMixin extends javax.swing.RootPaneContainer
-
- protected trait SuperMixin extends AWTWindow {
- override protected def processWindowEvent(e: java.awt.event.WindowEvent) {
- super.processWindowEvent(e)
- if (e.getID() == java.awt.event.WindowEvent.WINDOW_CLOSING)
- closeOperation()
- }
- }
-
- /**
- * This method is called when the window is closing, after all other window
- * event listeners have been processed.
- */
- def closeOperation() {}
-
- override def contents_=(c: Component) {
- super.contents_=(c)
- peer.pack() // pack also validates, which is generally required after an add
- }
- def defaultButton: Option[Button] =
- toOption(peer.getRootPane.getDefaultButton) map UIElement.cachedWrapper[Button]
- def defaultButton_=(b: Button) {
- peer.getRootPane.setDefaultButton(b.peer)
- }
- def defaultButton_=(b: Option[Button]) {
- peer.getRootPane.setDefaultButton(b.map(_.peer).orNull)
- }
-
- def dispose() { peer.dispose() }
-
- def pack(): this.type = { peer.pack(); this }
-
- def setLocationRelativeTo(c: UIElement) { peer.setLocationRelativeTo(c.peer) }
- def centerOnScreen() { peer.setLocationRelativeTo(null) }
- def location_=(p: Point) { peer.setLocation(p) }
- def size_=(size: Dimension) { peer.setSize(size) }
- def bounds_=(rect: Rectangle) { peer.setBounds(rect) }
-
- def owner: Window = UIElement.cachedWrapper[Window](peer.getOwner)
-
- def open() { peer setVisible true }
- def close() { peer setVisible false }
-
- peer.addWindowListener(new java.awt.event.WindowListener {
- def windowActivated(e: java.awt.event.WindowEvent) { publish(WindowActivated(outer)) }
- def windowClosed(e: java.awt.event.WindowEvent) { publish(WindowClosed(outer)) }
- def windowClosing(e: java.awt.event.WindowEvent) { publish(WindowClosing(outer)) }
- def windowDeactivated(e: java.awt.event.WindowEvent) { publish(WindowDeactivated(outer)) }
- def windowDeiconified(e: java.awt.event.WindowEvent) { publish(WindowDeiconified(outer)) }
- def windowIconified(e: java.awt.event.WindowEvent) { publish(WindowIconified(outer)) }
- def windowOpened(e: java.awt.event.WindowEvent) { publish(WindowOpened(outer)) }
- })
-}
diff --git a/src/swing/scala/swing/event/ActionEvent.scala b/src/swing/scala/swing/event/ActionEvent.scala
deleted file mode 100644
index 7b2de43dc8..0000000000
--- a/src/swing/scala/swing/event/ActionEvent.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-object ActionEvent {
- def unapply(a: ActionEvent): Option[Component] = Some(a.source)
-}
-
-class ActionEvent(override val source: Component) extends ComponentEvent
diff --git a/src/swing/scala/swing/event/AdjustingEvent.scala b/src/swing/scala/swing/event/AdjustingEvent.scala
deleted file mode 100644
index a4b7d29c7d..0000000000
--- a/src/swing/scala/swing/event/AdjustingEvent.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-/** An event that indicates some editing operation that can be still
- * in progress.
- *
- * Example: dragging a slider creates a number of `AdjustmentEvents`
- * with `adjusting == '''true'''` until the user finally releases the
- * mouse button.
- */
-trait AdjustingEvent extends ComponentEvent {
- def adjusting: Boolean
- def committed: Boolean = !adjusting
-}
diff --git a/src/swing/scala/swing/event/BackgroundChanged.scala b/src/swing/scala/swing/event/BackgroundChanged.scala
deleted file mode 100644
index bdd67f9525..0000000000
--- a/src/swing/scala/swing/event/BackgroundChanged.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class BackgroundChanged(override val source: Component) extends ComponentEvent
diff --git a/src/swing/scala/swing/event/ButtonClicked.scala b/src/swing/scala/swing/event/ButtonClicked.scala
deleted file mode 100644
index d02201909e..0000000000
--- a/src/swing/scala/swing/event/ButtonClicked.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class ButtonClicked(override val source: AbstractButton) extends ActionEvent(source)
-
diff --git a/src/swing/scala/swing/event/CaretUpdate.scala b/src/swing/scala/swing/event/CaretUpdate.scala
deleted file mode 100644
index 2821175ec0..0000000000
--- a/src/swing/scala/swing/event/CaretUpdate.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class CaretUpdate(override val source: TextComponent) extends ComponentEvent
diff --git a/src/swing/scala/swing/event/ColorChanged.scala b/src/swing/scala/swing/event/ColorChanged.scala
deleted file mode 100644
index 6cb35e7755..0000000000
--- a/src/swing/scala/swing/event/ColorChanged.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class ColorChanged(source: Component, c: Color) extends ComponentEvent with SelectionEvent
diff --git a/src/swing/scala/swing/event/ComponentEvent.scala b/src/swing/scala/swing/event/ComponentEvent.scala
deleted file mode 100644
index 701b962934..0000000000
--- a/src/swing/scala/swing/event/ComponentEvent.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-trait ComponentEvent extends UIEvent {
- val source: Component
-}
diff --git a/src/swing/scala/swing/event/ContainerEvent.scala b/src/swing/scala/swing/event/ContainerEvent.scala
deleted file mode 100644
index 46f3768e97..0000000000
--- a/src/swing/scala/swing/event/ContainerEvent.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-abstract class ContainerEvent(override val source: Container) extends UIEvent
-
-case class ComponentAdded(override val source: Container, child: Component) extends ContainerEvent(source)
-case class ComponentRemoved(override val source: Container, child: Component) extends ContainerEvent(source)
diff --git a/src/swing/scala/swing/event/EditDone.scala b/src/swing/scala/swing/event/EditDone.scala
deleted file mode 100644
index 9d38234757..0000000000
--- a/src/swing/scala/swing/event/EditDone.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class EditDone(override val source: TextField) extends ValueChanged(source)
diff --git a/src/swing/scala/swing/event/Event.scala b/src/swing/scala/swing/event/Event.scala
deleted file mode 100644
index fd1135601d..0000000000
--- a/src/swing/scala/swing/event/Event.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-trait Event
diff --git a/src/swing/scala/swing/event/FocusEvent.scala b/src/swing/scala/swing/event/FocusEvent.scala
deleted file mode 100644
index 5c29d8f6d2..0000000000
--- a/src/swing/scala/swing/event/FocusEvent.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-/**
- * The other component is None if it is a non Swing, i.e., AWT or native, component.
- */
-abstract class FocusEvent(override val source: Component, val other: Option[Component], val temporary: Boolean) extends ComponentEvent
-
-case class FocusGained(override val source: Component, override val other: Option[Component], override val temporary: Boolean)
- extends FocusEvent(source, other, temporary)
-
-case class FocusLost(override val source: Component, override val other: Option[Component], override val temporary: Boolean)
- extends FocusEvent(source, other, temporary)
diff --git a/src/swing/scala/swing/event/FontChanged.scala b/src/swing/scala/swing/event/FontChanged.scala
deleted file mode 100644
index ca936e1924..0000000000
--- a/src/swing/scala/swing/event/FontChanged.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class FontChanged(override val source: Component) extends ComponentEvent
diff --git a/src/swing/scala/swing/event/ForegroundChanged.scala b/src/swing/scala/swing/event/ForegroundChanged.scala
deleted file mode 100644
index 42b45aae54..0000000000
--- a/src/swing/scala/swing/event/ForegroundChanged.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class ForegroundChanged(override val source: Component) extends ComponentEvent
diff --git a/src/swing/scala/swing/event/InputEvent.scala b/src/swing/scala/swing/event/InputEvent.scala
deleted file mode 100644
index b515b01525..0000000000
--- a/src/swing/scala/swing/event/InputEvent.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-trait InputEvent extends ComponentEvent {
- def peer: java.awt.event.InputEvent
- def when: Long = peer.getWhen
- def modifiers: Key.Modifiers
- def consume() { peer.consume() }
- def consumed: Boolean = peer.isConsumed
-}
diff --git a/src/swing/scala/swing/event/Key.scala b/src/swing/scala/swing/event/Key.scala
deleted file mode 100644
index 5e9e0cbecd..0000000000
--- a/src/swing/scala/swing/event/Key.scala
+++ /dev/null
@@ -1,232 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-/**
- * Enumeration of key codes used by key events.
- */
-object Key extends Enumeration {
- import java.awt.event.KeyEvent._
-
- object Location extends Enumeration {
- val Left = Value(java.awt.event.KeyEvent.KEY_LOCATION_LEFT)
- val Right = Value(java.awt.event.KeyEvent.KEY_LOCATION_RIGHT)
- val Numpad = Value(java.awt.event.KeyEvent.KEY_LOCATION_NUMPAD)
- val Standard = Value(java.awt.event.KeyEvent.KEY_LOCATION_STANDARD)
- val Unknown = Value(java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN)
- }
-
- type Modifiers = Int
-
- object Modifier {
- import java.awt.event.InputEvent._
- val Shift = SHIFT_DOWN_MASK
- val Control = CTRL_DOWN_MASK
- val Alt = ALT_DOWN_MASK
- val AltGraph = ALT_GRAPH_DOWN_MASK
- val Meta = META_DOWN_MASK
- def text(mods: Int) = java.awt.event.KeyEvent.getKeyModifiersText(mods)
- }
-
- //def text(k: Value) = java.awt.event.KeyEvent.getKeyText(k.id)
-
- val Shift = Value(VK_SHIFT, getKeyText(VK_SHIFT))
- val Control = Value(VK_CONTROL, getKeyText(VK_CONTROL))
- val Alt = Value(VK_ALT, getKeyText(VK_ALT))
- val AltGraph = Value(VK_ALT_GRAPH, getKeyText(VK_ALT_GRAPH))
- val Meta = Value(VK_META, getKeyText(VK_META))
-
- val Enter = Value(VK_ENTER, getKeyText(VK_ENTER))
- val BackSpace = Value(VK_BACK_SPACE, getKeyText(VK_BACK_SPACE))
- val Tab = Value(VK_TAB, getKeyText(VK_TAB))
- val Cancel = Value(VK_CANCEL, getKeyText(VK_CANCEL))
- val Clear = Value(VK_CLEAR, getKeyText(VK_CLEAR))
-
- val Pause = Value(VK_PAUSE, getKeyText(VK_PAUSE))
- val CapsLock = Value(VK_CAPS_LOCK, getKeyText(VK_CAPS_LOCK))
- val Escape = Value(VK_ESCAPE, getKeyText(VK_ESCAPE))
- val Space = Value(VK_SPACE, getKeyText(VK_SPACE))
- val PageUp = Value(VK_PAGE_UP, getKeyText(VK_PAGE_UP))
- val PageDown = Value(VK_PAGE_DOWN, getKeyText(VK_PAGE_DOWN))
- val End = Value(VK_END, getKeyText(VK_END))
- val Home = Value(VK_HOME, getKeyText(VK_HOME))
- val Left = Value(VK_LEFT, getKeyText(VK_LEFT))
- val Up = Value(VK_UP, getKeyText(VK_UP))
- val Right = Value(VK_RIGHT, getKeyText(VK_RIGHT))
- val Down = Value(VK_DOWN, getKeyText(VK_DOWN))
- val Comma = Value(VK_COMMA, getKeyText(VK_COMMA))
- val Minus = Value(VK_MINUS, getKeyText(VK_MINUS))
- val Period = Value(VK_PERIOD, getKeyText(VK_PERIOD))
- val Slash = Value(VK_SLASH, getKeyText(VK_SLASH))
- val Key0 = Value(VK_0, getKeyText(VK_0))
- val Key1 = Value(VK_1, getKeyText(VK_1))
- val Key2 = Value(VK_2, getKeyText(VK_2))
- val Key3 = Value(VK_3, getKeyText(VK_3))
- val Key4 = Value(VK_4, getKeyText(VK_4))
- val Key5 = Value(VK_5, getKeyText(VK_5))
- val Key6 = Value(VK_6, getKeyText(VK_6))
- val Key7 = Value(VK_7, getKeyText(VK_7))
- val Key8 = Value(VK_8, getKeyText(VK_8))
- val Key9 = Value(VK_9, getKeyText(VK_9))
- val Semicolon = Value(VK_SEMICOLON, getKeyText(VK_SEMICOLON))
- val Equals = Value(VK_EQUALS, getKeyText(VK_EQUALS))
- val A = Value(VK_A, getKeyText(VK_A))
- val B = Value(VK_B, getKeyText(VK_B))
- val C = Value(VK_C, getKeyText(VK_C))
- val D = Value(VK_D, getKeyText(VK_D))
- val E = Value(VK_E, getKeyText(VK_E))
- val F = Value(VK_F, getKeyText(VK_F))
- val G = Value(VK_G, getKeyText(VK_G))
- val H = Value(VK_H, getKeyText(VK_H))
- val I = Value(VK_I, getKeyText(VK_I))
- val J = Value(VK_J, getKeyText(VK_J))
- val K = Value(VK_K, getKeyText(VK_K))
- val L = Value(VK_L, getKeyText(VK_L))
- val M = Value(VK_M, getKeyText(VK_M))
- val N = Value(VK_N, getKeyText(VK_N))
- val O = Value(VK_O, getKeyText(VK_O))
- val P = Value(VK_P, getKeyText(VK_P))
- val Q = Value(VK_Q, getKeyText(VK_Q))
- val R = Value(VK_R, getKeyText(VK_R))
- val S = Value(VK_S, getKeyText(VK_S))
- val T = Value(VK_T, getKeyText(VK_T))
- val U = Value(VK_U, getKeyText(VK_U))
- val V = Value(VK_V, getKeyText(VK_V))
- val W = Value(VK_W, getKeyText(VK_W))
- val X = Value(VK_X, getKeyText(VK_X))
- val Y = Value(VK_Y, getKeyText(VK_Y))
- val Z = Value(VK_Z, getKeyText(VK_Z))
- val OpenBracket = Value(VK_OPEN_BRACKET, getKeyText(VK_OPEN_BRACKET))
- val BackSlash = Value(VK_BACK_SLASH, getKeyText(VK_BACK_SLASH))
- val CloseBracket = Value(VK_CLOSE_BRACKET, getKeyText(VK_CLOSE_BRACKET))
- val Numpad0 = Value(VK_NUMPAD0, getKeyText(VK_NUMPAD0))
- val Numpad1 = Value(VK_NUMPAD1, getKeyText(VK_NUMPAD1))
- val Numpad2 = Value(VK_NUMPAD2, getKeyText(VK_NUMPAD2))
- val Numpad3 = Value(VK_NUMPAD3, getKeyText(VK_NUMPAD3))
- val Numpad4 = Value(VK_NUMPAD4, getKeyText(VK_NUMPAD4))
- val Numpad5 = Value(VK_NUMPAD5, getKeyText(VK_NUMPAD5))
- val Numpad6 = Value(VK_NUMPAD6, getKeyText(VK_NUMPAD6))
- val Numpad7 = Value(VK_NUMPAD7, getKeyText(VK_NUMPAD7))
- val Numpad8 = Value(VK_NUMPAD8, getKeyText(VK_NUMPAD8))
- val Numpad9 = Value(VK_NUMPAD9, getKeyText(VK_NUMPAD9))
- val Multiply = Value(VK_MULTIPLY, getKeyText(VK_MULTIPLY))
- val Add = Value(VK_ADD, getKeyText(VK_ADD))
- val Separator = Value(VK_SEPARATOR, getKeyText(VK_SEPARATOR))
- val Subtract = Value(VK_SUBTRACT, getKeyText(VK_SUBTRACT))
- val Decimal = Value(VK_DECIMAL, getKeyText(VK_DECIMAL))
- val Divide = Value(VK_DIVIDE, getKeyText(VK_DIVIDE))
- val Delete = Value(VK_DELETE, getKeyText(VK_DELETE))
- val NumLock = Value(VK_NUM_LOCK, getKeyText(VK_NUM_LOCK))
- val ScrollLock = Value(VK_SCROLL_LOCK, getKeyText(VK_SCROLL_LOCK))
- val F1 = Value(VK_F1, getKeyText(VK_F1))
- val F2 = Value(VK_F2, getKeyText(VK_F2))
- val F3 = Value(VK_F3, getKeyText(VK_F3))
- val F4 = Value(VK_F4, getKeyText(VK_F4))
- val F5 = Value(VK_F5, getKeyText(VK_F5))
- val F6 = Value(VK_F6, getKeyText(VK_F6))
- val F7 = Value(VK_F7, getKeyText(VK_F7))
- val F8 = Value(VK_F8, getKeyText(VK_F8))
- val F9 = Value(VK_F9, getKeyText(VK_F9))
- val F10 = Value(VK_F10, getKeyText(VK_F10))
- val F11 = Value(VK_F11, getKeyText(VK_F11))
- val F12 = Value(VK_F12, getKeyText(VK_F12))
- val F13 = Value(VK_F13, getKeyText(VK_F13))
- val F14 = Value(VK_F14, getKeyText(VK_F14))
- val F15 = Value(VK_F15, getKeyText(VK_F15))
- val F16 = Value(VK_F16, getKeyText(VK_F16))
- val F17 = Value(VK_F17, getKeyText(VK_F17))
- val F18 = Value(VK_F18, getKeyText(VK_F18))
- val F19 = Value(VK_F19, getKeyText(VK_F19))
- val F20 = Value(VK_F20, getKeyText(VK_F20))
- val F21 = Value(VK_F21, getKeyText(VK_F21))
- val F22 = Value(VK_F22, getKeyText(VK_F22))
- val F23 = Value(VK_F23, getKeyText(VK_F23))
- val F24 = Value(VK_F24, getKeyText(VK_F24))
- val Printscreen = Value(VK_PRINTSCREEN, getKeyText(VK_PRINTSCREEN))
- val Insert = Value(VK_INSERT, getKeyText(VK_INSERT))
- val Help = Value(VK_HELP, getKeyText(VK_HELP))
- val BackQuote = Value(VK_BACK_QUOTE, getKeyText(VK_BACK_QUOTE))
- val Quote = Value(VK_QUOTE, getKeyText(VK_QUOTE))
- val KpUp = Value(VK_KP_UP, getKeyText(VK_KP_UP))
- val KpDown = Value(VK_KP_DOWN, getKeyText(VK_KP_DOWN))
- val KpLeft = Value(VK_KP_LEFT, getKeyText(VK_KP_LEFT))
- val KpRight = Value(VK_KP_RIGHT, getKeyText(VK_KP_RIGHT))
- val DeadGrave = Value(VK_DEAD_GRAVE, getKeyText(VK_DEAD_GRAVE))
- val DeadAcute = Value(VK_DEAD_ACUTE, getKeyText(VK_DEAD_ACUTE))
- val DeadCircumflex = Value(VK_DEAD_CIRCUMFLEX, getKeyText(VK_DEAD_CIRCUMFLEX))
- val DeadTilde = Value(VK_DEAD_TILDE, getKeyText(VK_DEAD_TILDE))
- val DeadMacron = Value(VK_DEAD_MACRON, getKeyText(VK_DEAD_MACRON))
- val DeadBreve = Value(VK_DEAD_BREVE, getKeyText(VK_DEAD_BREVE))
- val DeadAbovedot = Value(VK_DEAD_ABOVEDOT, getKeyText(VK_DEAD_ABOVEDOT))
- val DeadDiaeresis = Value(VK_DEAD_DIAERESIS, getKeyText(VK_DEAD_DIAERESIS))
- val DeadAbovering = Value(VK_DEAD_ABOVERING, getKeyText(VK_DEAD_ABOVERING))
- val DeadDoubleacute = Value(VK_DEAD_DOUBLEACUTE, getKeyText(VK_DEAD_DOUBLEACUTE))
- val DeadCaron = Value(VK_DEAD_CARON, getKeyText(VK_DEAD_CARON))
- val DeadCedilla = Value(VK_DEAD_CEDILLA, getKeyText(VK_DEAD_CEDILLA))
- val DeadOgonek = Value(VK_DEAD_OGONEK, getKeyText(VK_DEAD_OGONEK))
- val DeadIota = Value(VK_DEAD_IOTA, getKeyText(VK_DEAD_IOTA))
- val DeadVoicedSound = Value(VK_DEAD_VOICED_SOUND, getKeyText(VK_DEAD_VOICED_SOUND))
- val DeadSemivoicedSound = Value(VK_DEAD_SEMIVOICED_SOUND, getKeyText(VK_DEAD_SEMIVOICED_SOUND))
- val Ampersand = Value(VK_AMPERSAND, getKeyText(VK_AMPERSAND))
- val Asterisk = Value(VK_ASTERISK, getKeyText(VK_ASTERISK))
- val Quotedbl = Value(VK_QUOTEDBL, getKeyText(VK_QUOTEDBL))
- val Less = Value(VK_LESS, getKeyText(VK_LESS))
- val Greater = Value(VK_GREATER, getKeyText(VK_GREATER))
- val Braceleft = Value(VK_BRACELEFT, getKeyText(VK_BRACELEFT))
- val Braceright = Value(VK_BRACERIGHT, getKeyText(VK_BRACERIGHT))
- val At = Value(VK_AT, getKeyText(VK_AT))
- val Colon = Value(VK_COLON, getKeyText(VK_COLON))
- val Circumflex = Value(VK_CIRCUMFLEX, getKeyText(VK_CIRCUMFLEX))
- val Dollar = Value(VK_DOLLAR, getKeyText(VK_DOLLAR))
- val EuroSign = Value(VK_EURO_SIGN, getKeyText(VK_EURO_SIGN))
- val ExclamationMark = Value(VK_EXCLAMATION_MARK, getKeyText(VK_EXCLAMATION_MARK))
- val InvertedExclamationMark = Value(VK_INVERTED_EXCLAMATION_MARK, getKeyText(VK_INVERTED_EXCLAMATION_MARK))
- val LeftParenthesis = Value(VK_LEFT_PARENTHESIS, getKeyText(VK_LEFT_PARENTHESIS))
- val NumberSign = Value(VK_NUMBER_SIGN, getKeyText(VK_NUMBER_SIGN))
- val Plus = Value(VK_PLUS, getKeyText(VK_PLUS))
- val RightParenthesis = Value(VK_RIGHT_PARENTHESIS, getKeyText(VK_RIGHT_PARENTHESIS))
- val Underscore = Value(VK_UNDERSCORE, getKeyText(VK_UNDERSCORE))
- val Windows = Value(VK_WINDOWS, getKeyText(VK_WINDOWS))
- val ContextMenu = Value(VK_CONTEXT_MENU, getKeyText(VK_CONTEXT_MENU))
- val Final = Value(VK_FINAL, getKeyText(VK_FINAL))
- val Convert = Value(VK_CONVERT, getKeyText(VK_CONVERT))
- val Nonconvert = Value(VK_NONCONVERT, getKeyText(VK_NONCONVERT))
- val Accept = Value(VK_ACCEPT, getKeyText(VK_ACCEPT))
- val Modechange = Value(VK_MODECHANGE, getKeyText(VK_MODECHANGE))
- val Kana = Value(VK_KANA, getKeyText(VK_KANA))
- val Kanji = Value(VK_KANJI, getKeyText(VK_KANJI))
- val Alphanumeric = Value(VK_ALPHANUMERIC, getKeyText(VK_ALPHANUMERIC))
- val Katakana = Value(VK_KATAKANA, getKeyText(VK_KATAKANA))
- val Hiragana = Value(VK_HIRAGANA, getKeyText(VK_HIRAGANA))
- val FullWidth = Value(VK_FULL_WIDTH, getKeyText(VK_FULL_WIDTH))
- val HalfWidth = Value(VK_HALF_WIDTH, getKeyText(VK_HALF_WIDTH))
- val RomanCharacters = Value(VK_ROMAN_CHARACTERS, getKeyText(VK_ROMAN_CHARACTERS))
- val AllCandidates = Value(VK_ALL_CANDIDATES, getKeyText(VK_ALL_CANDIDATES))
- val PreviousCandidate = Value(VK_PREVIOUS_CANDIDATE, getKeyText(VK_PREVIOUS_CANDIDATE))
- val CodeInput = Value(VK_CODE_INPUT, getKeyText(VK_CODE_INPUT))
- val JapaneseKatakana = Value(VK_JAPANESE_KATAKANA, getKeyText(VK_JAPANESE_KATAKANA))
- val JapaneseHiragana = Value(VK_JAPANESE_HIRAGANA, getKeyText(VK_JAPANESE_HIRAGANA))
- val JapaneseRoman = Value(VK_JAPANESE_ROMAN, getKeyText(VK_JAPANESE_ROMAN))
- val KanaLock = Value(VK_KANA_LOCK, getKeyText(VK_KANA_LOCK))
- val InputMethodOnOff = Value(VK_INPUT_METHOD_ON_OFF, getKeyText(VK_INPUT_METHOD_ON_OFF))
- val Cut = Value(VK_CUT, getKeyText(VK_CUT))
- val Copy = Value(VK_COPY, getKeyText(VK_COPY))
- val Paste = Value(VK_PASTE, getKeyText(VK_PASTE))
- val Undo = Value(VK_UNDO, getKeyText(VK_UNDO))
- val Again = Value(VK_AGAIN, getKeyText(VK_AGAIN))
- val Find = Value(VK_FIND, getKeyText(VK_FIND))
- val Props = Value(VK_PROPS, getKeyText(VK_PROPS))
- val Stop = Value(VK_STOP, getKeyText(VK_STOP))
- val Compose = Value(VK_COMPOSE, getKeyText(VK_COMPOSE))
- val Begin = Value(VK_BEGIN, getKeyText(VK_BEGIN))
- val Undefined = Value(VK_UNDEFINED, getKeyText(VK_UNDEFINED))
-}
diff --git a/src/swing/scala/swing/event/KeyEvent.scala b/src/swing/scala/swing/event/KeyEvent.scala
deleted file mode 100644
index 1345c77479..0000000000
--- a/src/swing/scala/swing/event/KeyEvent.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-import javax.swing.JComponent
-
-sealed abstract class KeyEvent extends InputEvent {
- def peer: java.awt.event.KeyEvent
-}
-
-case class KeyTyped(val source: Component, char: Char, val modifiers: Key.Modifiers,
- location: Key.Location.Value)
- (val peer: java.awt.event.KeyEvent) extends KeyEvent {
- def this(e: java.awt.event.KeyEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- e.getKeyChar, e.getModifiersEx,
- Key.Location(e.getKeyLocation))(e)
-}
-
-case class KeyPressed(val source: Component, key: Key.Value, val modifiers: Key.Modifiers,
- location: Key.Location.Value)
- (val peer: java.awt.event.KeyEvent) extends KeyEvent {
- def this(e: java.awt.event.KeyEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- Key(e.getKeyCode), e.getModifiersEx, Key.Location(e.getKeyLocation))(e)
-}
-
-case class KeyReleased(val source: Component, key: Key.Value, val modifiers: Key.Modifiers,
- location: Key.Location.Value)
- (val peer: java.awt.event.KeyEvent) extends KeyEvent {
- def this(e: java.awt.event.KeyEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- Key(e.getKeyCode), e.getModifiersEx, Key.Location(e.getKeyLocation))(e)
-}
diff --git a/src/swing/scala/swing/event/ListEvent.scala b/src/swing/scala/swing/event/ListEvent.scala
deleted file mode 100644
index bdb769d45b..0000000000
--- a/src/swing/scala/swing/event/ListEvent.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-trait ListEvent[A] extends ComponentEvent {
- override val source: ListView[A]
-}
-
-//case class ElementSelected[A](override val source: ListView[A], range: Range, live: Boolean)
-// extends ListEvent[A] with AdjustingEvent with ListSelectionEvent
-
-abstract class ListChange[A](override val source: ListView[A]) extends ListEvent[A]
-
-object ListChanged {
- def unapply[A](e: ListChanged[A]) = Some(e.source)
- def apply[A](source: ListView[A]) = new ListChanged(source)
-}
-
-class ListChanged[A](override val source: ListView[A]) extends ListChange(source)
-
-object ListElementsAdded {
- def unapply[A](e: ListElementsAdded[A]) = Some((e.source, e.range))
- def apply[A](source: ListView[A], range: Range) = new ListElementsAdded(source, range)
-}
-
-class ListElementsAdded[A](override val source: ListView[A], val range: Range)
- extends ListChange(source)
-
-object ListElementsRemoved {
- def unapply[A](e: ListElementsRemoved[A]) = Some((e.source, e.range))
- def apply[A](source: ListView[A], range: Range) = new ListElementsRemoved(source, range)
-}
-class ListElementsRemoved[A](override val source: ListView[A], val range: Range)
- extends ListChange(source)
diff --git a/src/swing/scala/swing/event/MouseEvent.scala b/src/swing/scala/swing/event/MouseEvent.scala
deleted file mode 100644
index 8629d71db2..0000000000
--- a/src/swing/scala/swing/event/MouseEvent.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-import java.awt.Point
-import javax.swing.JComponent
-
-sealed abstract class MouseEvent extends InputEvent {
- def peer: java.awt.event.MouseEvent
- def point: Point
-}
-
-sealed abstract class MouseButtonEvent extends MouseEvent {
- def clicks: Int
- def triggersPopup: Boolean
-}
-case class MouseClicked(val source: Component, point: Point, val modifiers: Key.Modifiers,
- clicks: Int, triggersPopup: Boolean)(val peer: java.awt.event.MouseEvent)
- extends MouseButtonEvent {
- def this(e: java.awt.event.MouseEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- e.getPoint, e.getModifiersEx, e.getClickCount, e.isPopupTrigger)(e)
-}
-case class MousePressed(val source: Component, point: Point, val modifiers: Key.Modifiers,
- clicks: Int, triggersPopup: Boolean)(val peer: java.awt.event.MouseEvent)
- extends MouseButtonEvent {
- def this(e: java.awt.event.MouseEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- e.getPoint, e.getModifiersEx, e.getClickCount, e.isPopupTrigger)(e)
-}
-case class MouseReleased(val source: Component, point: Point, val modifiers: Key.Modifiers,
- clicks: Int, triggersPopup: Boolean)(val peer: java.awt.event.MouseEvent)
- extends MouseButtonEvent {
- def this(e: java.awt.event.MouseEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- e.getPoint, e.getModifiersEx, e.getClickCount, e.isPopupTrigger)(e)
-}
-
-sealed abstract class MouseMotionEvent extends MouseEvent
-case class MouseMoved(val source: Component, point: Point, val modifiers: Key.Modifiers)(val peer: java.awt.event.MouseEvent)
- extends MouseMotionEvent {
- def this(e: java.awt.event.MouseEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- e.getPoint, e.getModifiersEx)(e)
-}
-case class MouseDragged(val source: Component, point: Point, val modifiers: Key.Modifiers)(val peer: java.awt.event.MouseEvent)
- extends MouseMotionEvent {
- def this(e: java.awt.event.MouseEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- e.getPoint, e.getModifiersEx)(e)
-}
-case class MouseEntered(val source: Component, point: Point, val modifiers: Key.Modifiers)(val peer: java.awt.event.MouseEvent)
- extends MouseMotionEvent {
- def this(e: java.awt.event.MouseEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- e.getPoint, e.getModifiersEx)(e)
-}
-case class MouseExited(val source: Component, point: Point, val modifiers: Key.Modifiers)(val peer: java.awt.event.MouseEvent)
- extends MouseMotionEvent {
- def this(e: java.awt.event.MouseEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- e.getPoint, e.getModifiersEx)(e)
-}
-
-case class MouseWheelMoved(val source: Component, point: Point, val modifiers: Key.Modifiers, rotation: Int)(val peer: java.awt.event.MouseEvent)
- extends MouseEvent {
- def this(e: java.awt.event.MouseWheelEvent) =
- this(UIElement.cachedWrapper[Component](e.getSource.asInstanceOf[JComponent]),
- e.getPoint, e.getModifiersEx, e.getWheelRotation)(e)
-}
diff --git a/src/swing/scala/swing/event/PopupMenuEvent.scala b/src/swing/scala/swing/event/PopupMenuEvent.scala
deleted file mode 100644
index ad39eb351a..0000000000
--- a/src/swing/scala/swing/event/PopupMenuEvent.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-abstract class PopupMenuEvent extends ComponentEvent
-
-case class PopupMenuCanceled(source: PopupMenu) extends PopupMenuEvent
-case class PopupMenuWillBecomeInvisible(source: PopupMenu) extends PopupMenuEvent
-case class PopupMenuWillBecomeVisible(source: PopupMenu) extends PopupMenuEvent \ No newline at end of file
diff --git a/src/swing/scala/swing/event/SelectionEvent.scala b/src/swing/scala/swing/event/SelectionEvent.scala
deleted file mode 100644
index 39d6a13bc2..0000000000
--- a/src/swing/scala/swing/event/SelectionEvent.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-/**
- * An event that indicates a change in a selection such as in a list view or a table.
- */
-trait SelectionEvent
-
-/**
- * An event that indicates a selection of a range of indices.
- */
-trait ListSelectionEvent extends SelectionEvent {
- def range: Range
-}
-
-case class SelectionChanged(override val source: Component) extends ComponentEvent with SelectionEvent
-
-object ListSelectionChanged {
- def unapply[A](e: ListSelectionChanged[A]): Option[(ListView[A], Range, Boolean)] =
- Some((e.source, e.range, e.live))
-}
-
-class ListSelectionChanged[A](override val source: ListView[A], val range: Range, val live: Boolean)
- extends SelectionChanged(source) with ListEvent[A]
diff --git a/src/swing/scala/swing/event/TableEvent.scala b/src/swing/scala/swing/event/TableEvent.scala
deleted file mode 100644
index c420ea275d..0000000000
--- a/src/swing/scala/swing/event/TableEvent.scala
+++ /dev/null
@@ -1,46 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-abstract class TableEvent(override val source: Table) extends ComponentEvent
-
-abstract class TableChange(override val source: Table) extends TableEvent(source)
-
-/**
- * The most general table change. The table might have changed completely,
- * i.e., columns might have been reordered, rows added or removed, etc.
- * No other event indicates that the structure might have changed.
- */
-case class TableStructureChanged(override val source: Table) extends TableChange(source)
-/**
- * The table structure, i.e., the column order, names, and types stay the same,
- * but anything else might have changed.
- */
-case class TableChanged(override val source: Table) extends TableChange(source)
-/**
- * The size of the table stays the same, but the given range of rows might
- * have changed but only in the given column. A value of -1 for the column
- * denotes all columns.
- */
-case class TableUpdated(override val source: Table, range: Range, column: Int)
- extends TableChange(source)
-/**
- * Any change that caused the table to change it's size
- */
-class TableResized(override val source: Table) extends TableChange(source)
-case class TableRowsAdded(override val source: Table, range: Range) extends TableResized(source)
-case class TableRowsRemoved(override val source: Table, range: Range) extends TableResized(source)
-
-case class TableColumnsSelected(override val source: Table, range: Range, adjusting: Boolean)
- extends TableEvent(source) with AdjustingEvent with ListSelectionEvent
-case class TableRowsSelected(override val source: Table, range: Range, adjusting: Boolean)
- extends TableEvent(source) with AdjustingEvent with ListSelectionEvent
diff --git a/src/swing/scala/swing/event/UIEvent.scala b/src/swing/scala/swing/event/UIEvent.scala
deleted file mode 100644
index a4644b02b2..0000000000
--- a/src/swing/scala/swing/event/UIEvent.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-trait UIEvent extends Event {
- val source: UIElement
-}
-
-case class UIElementMoved(source: UIElement) extends UIEvent
-case class UIElementResized(source: UIElement) extends UIEvent
-case class UIElementShown(source: UIElement) extends UIEvent
-case class UIElementHidden(source: UIElement) extends UIEvent
diff --git a/src/swing/scala/swing/event/ValueChanged.scala b/src/swing/scala/swing/event/ValueChanged.scala
deleted file mode 100644
index ef08085705..0000000000
--- a/src/swing/scala/swing/event/ValueChanged.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-object ValueChanged {
- def unapply(a: ValueChanged): Option[Component] = Some(a.source)
-}
-
-class ValueChanged(override val source: Component) extends ComponentEvent
diff --git a/src/swing/scala/swing/event/WindowActivated.scala b/src/swing/scala/swing/event/WindowActivated.scala
deleted file mode 100644
index 1473242e5c..0000000000
--- a/src/swing/scala/swing/event/WindowActivated.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class WindowActivated(override val source: Window) extends WindowEvent(source)
diff --git a/src/swing/scala/swing/event/WindowClosed.scala b/src/swing/scala/swing/event/WindowClosed.scala
deleted file mode 100644
index 80afe1a99f..0000000000
--- a/src/swing/scala/swing/event/WindowClosed.scala
+++ /dev/null
@@ -1,4 +0,0 @@
-package scala.swing
-package event
-
-case class WindowClosed(override val source: Window) extends WindowEvent(source)
diff --git a/src/swing/scala/swing/event/WindowClosing.scala b/src/swing/scala/swing/event/WindowClosing.scala
deleted file mode 100644
index 3c64aeb0f5..0000000000
--- a/src/swing/scala/swing/event/WindowClosing.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class WindowClosing(override val source: Window) extends WindowEvent(source)
diff --git a/src/swing/scala/swing/event/WindowDeactivated.scala b/src/swing/scala/swing/event/WindowDeactivated.scala
deleted file mode 100644
index f0eec57913..0000000000
--- a/src/swing/scala/swing/event/WindowDeactivated.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class WindowDeactivated(override val source: Window) extends WindowEvent(source)
diff --git a/src/swing/scala/swing/event/WindowDeiconified.scala b/src/swing/scala/swing/event/WindowDeiconified.scala
deleted file mode 100644
index 6e07f8534b..0000000000
--- a/src/swing/scala/swing/event/WindowDeiconified.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class WindowDeiconified(override val source: Window) extends WindowEvent(source)
diff --git a/src/swing/scala/swing/event/WindowEvent.scala b/src/swing/scala/swing/event/WindowEvent.scala
deleted file mode 100644
index b8ca329a2a..0000000000
--- a/src/swing/scala/swing/event/WindowEvent.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-abstract class WindowEvent(override val source: Window) extends UIEvent
diff --git a/src/swing/scala/swing/event/WindowIconified.scala b/src/swing/scala/swing/event/WindowIconified.scala
deleted file mode 100644
index 3b5139f740..0000000000
--- a/src/swing/scala/swing/event/WindowIconified.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class WindowIconified(override val source: Window) extends WindowEvent(source)
diff --git a/src/swing/scala/swing/event/WindowOpened.scala b/src/swing/scala/swing/event/WindowOpened.scala
deleted file mode 100644
index f5854edc32..0000000000
--- a/src/swing/scala/swing/event/WindowOpened.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.swing
-package event
-
-case class WindowOpened(override val source: Window) extends WindowEvent(source)
diff --git a/src/swing/scala/swing/model/Matrix.scala b/src/swing/scala/swing/model/Matrix.scala
deleted file mode 100644
index 664d44a962..0000000000
--- a/src/swing/scala/swing/model/Matrix.scala
+++ /dev/null
@@ -1,121 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2007-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-package scala.swing
-package model
-
-// Dummy to keep ant from recompiling on every run.
-trait Matrix { }
-
-/*trait Matrix[A] extends Function2[Int, Int, A] {
-
- val width: Int
- val height: Int
-
- assert(width > 0 && height > 0)
-
- private val delegate = new Array[A](width * height)
-
- override def apply(col: Int, row: Int): A =
- delegate(col * height + row)
-
- def apply(coord: (Int, Int)): A =
- apply(coord._1, coord._2)
-
- def col(index: Int): Matrix.FlatSeq[A] =
- new Matrix.SubArray[A](delegate, index * height, height)
-
- def row(index: Int): Matrix.FlatSeq[A] =
- new Matrix.SparseArray[A](delegate, index, height)
-
- def update(xpos: Int, ypos: Int, elem: A) {
- delegate(xpos % width * height + ypos % height) = elem
- }
-
- def update(coord: (Int, Int), elem: A) {
- update(coord._1, coord._2, elem)
- }
-
- def initializeWith(f: (Int, Int) => A): this.type = {
- for (index <- 0 until (width * height))
- delegate(index) = f(index / height, index % height)
- this
- }
-
- def initializeTo(v: => A): this.type = {
- for (index <- 0 until (width * height))
- delegate(index) = v
- this
- }
-
- def size: (Int, Int) = (width, height)
-
- /** A flattened view of the matrix. The flattening is done on columns i.e.
- * the first values of the flattened sequence are the cells of the first
- * column. As this is a view of the matrix, any change to the matrix will
- * also be visible in the flattened array, and vice-versa. */
- def flat: Array[A] = delegate
-
-}
-
-object Matrix {
-
- def apply[A](columns: Int, rows: Int) = new Matrix[A] {
- val width = columns
- val height = rows
- }
-
- def apply[A](default: (Int, Int) => A, columns: Int, rows: Int) = new Matrix[A] {
- val width = columns
- val height = rows
- initializeWith(default)
- }
-
- def apply[A](default: => A, columns: Int, rows: Int) = new Matrix[A] {
- val width = columns
- val height = rows
- initializeTo(default)
- }
-
- trait FlatSeq[A] extends RandomAccessSeq[A] {
- def update (index: Int, elem: A): Unit
- }
-
- private class SubArray[A](delegate: Array[A], start: Int, val length: Int) extends FlatSeq[A] {
- def apply(index: Int): A =
- if (index < length)
- delegate(index + start)
- else throw new IndexOutOfBoundsException
- def update(index: Int, elem: A): Unit =
- if (index < length)
- delegate(index + start) = elem
- else throw new IndexOutOfBoundsException
- }
-
- private class SparseArray[A](delegate: Array[A], start: Int, span: Int) extends FlatSeq[A] {
- def apply(index: Int): A = {
- if (index < length)
- delegate((index * span) + start)
- else throw new IndexOutOfBoundsException
- }
- def length: Int = delegate.length / span
- def update(index: Int, elem: A): Unit =
- if (index < length)
- delegate((index * span) + start) = elem
- else throw new IndexOutOfBoundsException
- }
-
- implicit def MatrixToSeqs[A](matrix: Matrix[A]): Seq[Seq[A]] = {
- val result = new Array[SubArray[A]](matrix.width)
- for (col <- 0 until matrix.width)
- result(col) = new SubArray[A](matrix.delegate, col * matrix.height, matrix.height)
- result
- }
-
-}*/
diff --git a/src/swing/scala/swing/package.scala b/src/swing/scala/swing/package.scala
deleted file mode 100644
index d5095f021b..0000000000
--- a/src/swing/scala/swing/package.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-package scala
-
-/**
- * Useful imports that don't have wrappers.
- */
-package object swing {
- type Point = java.awt.Point
- type Dimension = java.awt.Dimension
- type Rectangle = java.awt.Rectangle
- type Insets = java.awt.Insets
-
- type Graphics2D = java.awt.Graphics2D
- type Color = java.awt.Color
- type Image = java.awt.Image
- type Font = java.awt.Font
-
- private[swing] def ifNull[A](o: Object, a: A): A = if(o eq null) a else o.asInstanceOf[A]
- private[swing] def toOption[A](o: Object): Option[A] = if(o eq null) None else Some(o.asInstanceOf[A])
- private[swing] def toAnyRef(x: Any): AnyRef = x.asInstanceOf[AnyRef]
-}
diff --git a/src/swing/swing.version.properties b/src/swing/swing.version.properties
deleted file mode 100644
index ba3675fa05..0000000000
--- a/src/swing/swing.version.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-version.major=0
-version.minor=4
diff --git a/test/disabled/continuations-neg/infer0.check b/test/disabled/continuations-neg/infer0.check
deleted file mode 100644
index 1dd072ef09..0000000000
--- a/test/disabled/continuations-neg/infer0.check
+++ /dev/null
@@ -1,4 +0,0 @@
-infer0.scala:11: error: cannot cps-transform expression 8: type arguments [Int(8),String,Int] do not conform to method shiftUnit's type parameter bounds [A,B,C >: B]
- test(8)
- ^
-one error found
diff --git a/test/disabled/continuations-neg/infer0.scala b/test/disabled/continuations-neg/infer0.scala
deleted file mode 100644
index 6d97d7504d..0000000000
--- a/test/disabled/continuations-neg/infer0.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def test(x: => Int @cpsParam[String,Int]) = 7
-
- def main(args: Array[String]) {
- test(8)
- }
-}
diff --git a/test/files/continuations-neg/function0.check b/test/files/continuations-neg/function0.check
deleted file mode 100644
index 0a66763a0f..0000000000
--- a/test/files/continuations-neg/function0.check
+++ /dev/null
@@ -1,6 +0,0 @@
-function0.scala:11: error: type mismatch;
- found : () => Int @scala.util.continuations.cpsParam[Int,Int]
- required: () => Int
- val g: () => Int = f
- ^
-one error found
diff --git a/test/files/continuations-neg/function0.scala b/test/files/continuations-neg/function0.scala
deleted file mode 100644
index 4112ee3835..0000000000
--- a/test/files/continuations-neg/function0.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Any = {
-
- val f = () => shift { k: (Int=>Int) => k(7) }
- val g: () => Int = f
-
- println(reset(g()))
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/function2.check b/test/files/continuations-neg/function2.check
deleted file mode 100644
index 4b1a6227bc..0000000000
--- a/test/files/continuations-neg/function2.check
+++ /dev/null
@@ -1,6 +0,0 @@
-function2.scala:11: error: type mismatch;
- found : () => Int
- required: () => Int @scala.util.continuations.cpsParam[Int,Int]
- val g: () => Int @cps[Int] = f
- ^
-one error found
diff --git a/test/files/continuations-neg/function2.scala b/test/files/continuations-neg/function2.scala
deleted file mode 100644
index ae0fda509d..0000000000
--- a/test/files/continuations-neg/function2.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Any = {
-
- val f = () => 7
- val g: () => Int @cps[Int] = f
-
- println(reset(g()))
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/function3.check b/test/files/continuations-neg/function3.check
deleted file mode 100644
index 4705ad9ed9..0000000000
--- a/test/files/continuations-neg/function3.check
+++ /dev/null
@@ -1,6 +0,0 @@
-function3.scala:10: error: type mismatch;
- found : Int @scala.util.continuations.cpsParam[Int,Int]
- required: Int
- val g: () => Int = () => shift { k: (Int=>Int) => k(7) }
- ^
-one error found
diff --git a/test/files/continuations-neg/function3.scala b/test/files/continuations-neg/function3.scala
deleted file mode 100644
index 0c3f1667e5..0000000000
--- a/test/files/continuations-neg/function3.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Any = {
-
- val g: () => Int = () => shift { k: (Int=>Int) => k(7) }
-
- println(reset(g()))
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/infer2.check b/test/files/continuations-neg/infer2.check
deleted file mode 100644
index d92bc9c572..0000000000
--- a/test/files/continuations-neg/infer2.check
+++ /dev/null
@@ -1,4 +0,0 @@
-infer2.scala:14: error: illegal answer type modification: scala.util.continuations.cpsParam[String,Int] andThen scala.util.continuations.cpsParam[String,Int]
- test { sym(); sym() }
- ^
-one error found
diff --git a/test/files/continuations-neg/infer2.scala b/test/files/continuations-neg/infer2.scala
deleted file mode 100644
index a890ac1fc4..0000000000
--- a/test/files/continuations-neg/infer2.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x: => Int @cpsParam[String,Int]) = 7
-
- def sym() = shift { k: (Int => String) => 9 }
-
-
- def main(args: Array[String]): Any = {
- test { sym(); sym() }
- }
-
-}
-
-
diff --git a/test/files/continuations-neg/lazy.check b/test/files/continuations-neg/lazy.check
deleted file mode 100644
index 3c460546be..0000000000
--- a/test/files/continuations-neg/lazy.check
+++ /dev/null
@@ -1,4 +0,0 @@
-lazy.scala:6: error: implementation restriction: cps annotations not allowed on lazy value definitions
- lazy val x = shift((k:Unit=>Unit)=>k())
- ^
-one error found
diff --git a/test/files/continuations-neg/lazy.scala b/test/files/continuations-neg/lazy.scala
deleted file mode 100644
index 3c8169dd46..0000000000
--- a/test/files/continuations-neg/lazy.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-import scala.util.continuations._
-
-object Test {
-
- def foo() = {
- lazy val x = shift((k:Unit=>Unit)=>k())
- println(x)
- }
-
- def main(args: Array[String]) {
- reset {
- foo()
- }
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/t1929.check b/test/files/continuations-neg/t1929.check
deleted file mode 100644
index b04a5b977d..0000000000
--- a/test/files/continuations-neg/t1929.check
+++ /dev/null
@@ -1,6 +0,0 @@
-t1929.scala:8: error: type mismatch;
- found : Int @scala.util.continuations.cpsParam[String,String] @scala.util.continuations.cpsSynth
- required: Int @scala.util.continuations.cpsParam[Int,String]
- reset {
- ^
-one error found
diff --git a/test/files/continuations-neg/t1929.scala b/test/files/continuations-neg/t1929.scala
deleted file mode 100644
index 02eda9170d..0000000000
--- a/test/files/continuations-neg/t1929.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def main(args : Array[String]) {
- reset {
- println("up")
- val x = shift((k:Int=>String) => k(8) + k(2))
- println("down " + x)
- val y = shift((k:Int=>String) => k(3))
- println("down2 " + y)
- y + x
- }
- }
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/t2285.check b/test/files/continuations-neg/t2285.check
deleted file mode 100644
index d5dff6a4f2..0000000000
--- a/test/files/continuations-neg/t2285.check
+++ /dev/null
@@ -1,6 +0,0 @@
-t2285.scala:9: error: type mismatch;
- found : Int @scala.util.continuations.cpsParam[String,String] @scala.util.continuations.cpsSynth
- required: Int @scala.util.continuations.cpsParam[Int,String]
- def foo() = reset { bar(); 7 }
- ^
-one error found
diff --git a/test/files/continuations-neg/t2285.scala b/test/files/continuations-neg/t2285.scala
deleted file mode 100644
index f3c7f4c89c..0000000000
--- a/test/files/continuations-neg/t2285.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def bar() = shift { k: (String => String) => k("1") }
-
- def foo() = reset { bar(); 7 }
-
-}
diff --git a/test/files/continuations-neg/t2949.check b/test/files/continuations-neg/t2949.check
deleted file mode 100644
index dd9768807c..0000000000
--- a/test/files/continuations-neg/t2949.check
+++ /dev/null
@@ -1,6 +0,0 @@
-t2949.scala:13: error: type mismatch;
- found : Int
- required: ? @scala.util.continuations.cpsParam[List[?],Any]
- x * y
- ^
-one error found
diff --git a/test/files/continuations-neg/t2949.scala b/test/files/continuations-neg/t2949.scala
deleted file mode 100644
index ce27c7c0e8..0000000000
--- a/test/files/continuations-neg/t2949.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def reflect[A,B](xs : List[A]) = shift{ xs.flatMap[B, List[B]] }
- def reify[A, B](x : A @cpsParam[List[A], B]) = reset{ List(x) }
-
- def main(args: Array[String]): Unit = println(reify {
- val x = reflect[Int, Int](List(1,2,3))
- val y = reflect[Int, Int](List(2,4,8))
- x * y
- })
-}
diff --git a/test/files/continuations-neg/t3628.check b/test/files/continuations-neg/t3628.check
deleted file mode 100644
index 6e390558ef..0000000000
--- a/test/files/continuations-neg/t3628.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t3628.scala:4: error: not found: type Actor
- val impl: Actor = actor {
- ^
-one error found
diff --git a/test/files/continuations-neg/t3628.scala b/test/files/continuations-neg/t3628.scala
deleted file mode 100644
index c56e7752c4..0000000000
--- a/test/files/continuations-neg/t3628.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-import scala.actors.Actor._
-
-object Test {
- val impl: Actor = actor {
- loop {
- react {
- case 1 => impl ! 2
- }
- }
- }
-}
diff --git a/test/files/continuations-neg/t3718.check b/test/files/continuations-neg/t3718.check
deleted file mode 100644
index 659104c1c6..0000000000
--- a/test/files/continuations-neg/t3718.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t3718.scala:2: error: cannot cps-transform malformed (possibly in shift/reset placement) expression
- scala.util.continuations.reset((_: Any).##)
- ^
-one error found
diff --git a/test/files/continuations-neg/t3718.scala b/test/files/continuations-neg/t3718.scala
deleted file mode 100644
index a0fcb9d869..0000000000
--- a/test/files/continuations-neg/t3718.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test {
- scala.util.continuations.reset((_: Any).##)
-}
diff --git a/test/files/continuations-neg/t5314-missing-result-type.check b/test/files/continuations-neg/t5314-missing-result-type.check
deleted file mode 100644
index 341e580cf3..0000000000
--- a/test/files/continuations-neg/t5314-missing-result-type.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t5314-missing-result-type.scala:6: error: method bar has return statement; needs result type
- def bar(x:Int) = return foo(x)
- ^
-one error found
diff --git a/test/files/continuations-neg/t5314-missing-result-type.scala b/test/files/continuations-neg/t5314-missing-result-type.scala
deleted file mode 100644
index d7c5043a86..0000000000
--- a/test/files/continuations-neg/t5314-missing-result-type.scala
+++ /dev/null
@@ -1,13 +0,0 @@
-import scala.util.continuations._
-
-object Test extends App {
- def foo(x:Int): Int @cps[Int] = x
-
- def bar(x:Int) = return foo(x)
-
- reset {
- val res = bar(8)
- println(res)
- res
- }
-}
diff --git a/test/files/continuations-neg/t5314-npe.check b/test/files/continuations-neg/t5314-npe.check
deleted file mode 100644
index b5f024aa89..0000000000
--- a/test/files/continuations-neg/t5314-npe.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t5314-npe.scala:2: error: method bar has return statement; needs result type
- def bar(x:Int) = { return x; x } // NPE
- ^
-one error found
diff --git a/test/files/continuations-neg/t5314-npe.scala b/test/files/continuations-neg/t5314-npe.scala
deleted file mode 100644
index 2b5966e07c..0000000000
--- a/test/files/continuations-neg/t5314-npe.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test extends App {
- def bar(x:Int) = { return x; x } // NPE
-}
diff --git a/test/files/continuations-neg/t5314-return-reset.check b/test/files/continuations-neg/t5314-return-reset.check
deleted file mode 100644
index 4c817ae14d..0000000000
--- a/test/files/continuations-neg/t5314-return-reset.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t5314-return-reset.scala:14: error: return expression not allowed, since method calls CPS method
- if (rnd.nextInt(100) > 50) return 5 // not allowed, since method is calling `reset`
- ^
-one error found
diff --git a/test/files/continuations-neg/t5314-return-reset.scala b/test/files/continuations-neg/t5314-return-reset.scala
deleted file mode 100644
index df9d58e4cb..0000000000
--- a/test/files/continuations-neg/t5314-return-reset.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-import scala.util.continuations._
-import scala.util.Random
-
-object Test extends App {
- val rnd = new Random
-
- def foo(x: Int): Int @cps[Int] = shift { k => k(x) }
-
- def bar(x: Int): Int @cps[Int] = return foo(x)
-
- def caller(): Int = {
- val v: Int = reset {
- val res: Int = bar(8)
- if (rnd.nextInt(100) > 50) return 5 // not allowed, since method is calling `reset`
- 42
- }
- v
- }
-
- caller()
-}
diff --git a/test/files/continuations-neg/t5314-type-error.check b/test/files/continuations-neg/t5314-type-error.check
deleted file mode 100644
index e66c9d833f..0000000000
--- a/test/files/continuations-neg/t5314-type-error.check
+++ /dev/null
@@ -1,6 +0,0 @@
-t5314-type-error.scala:7: error: type mismatch;
- found : Int @scala.util.continuations.cpsParam[Int,Int]
- required: Int @scala.util.continuations.cpsParam[String,String]
- def bar(x:Int): Int @cps[String] = return foo(x)
- ^
-one error found
diff --git a/test/files/continuations-neg/t5314-type-error.scala b/test/files/continuations-neg/t5314-type-error.scala
deleted file mode 100644
index e36ce6c203..0000000000
--- a/test/files/continuations-neg/t5314-type-error.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-import scala.util.continuations._
-
-object Test extends App {
- def foo(x:Int): Int @cps[Int] = shift { k => k(x) }
-
- // should be a type error
- def bar(x:Int): Int @cps[String] = return foo(x)
-
- def caller(): Unit = {
- val v: String = reset {
- val res: Int = bar(8)
- "hello"
- }
- }
-
- caller()
-}
diff --git a/test/files/continuations-neg/t5445.check b/test/files/continuations-neg/t5445.check
deleted file mode 100644
index eb2943b6a6..0000000000
--- a/test/files/continuations-neg/t5445.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t5445.scala:4: error: cps annotations not allowed on by-value parameters or value definitions
- def foo(block: Unit @suspendable ): Unit @suspendable = {}
- ^
-one error found
diff --git a/test/files/continuations-neg/t5445.scala b/test/files/continuations-neg/t5445.scala
deleted file mode 100644
index cb6f8f686d..0000000000
--- a/test/files/continuations-neg/t5445.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def foo(block: Unit @suspendable ): Unit @suspendable = {}
-}
diff --git a/test/files/continuations-neg/trycatch2.check b/test/files/continuations-neg/trycatch2.check
deleted file mode 100644
index 5ff2838bad..0000000000
--- a/test/files/continuations-neg/trycatch2.check
+++ /dev/null
@@ -1,7 +0,0 @@
-trycatch2.scala:11: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int])
- def foo1 = try {
- ^
-trycatch2.scala:19: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int])
- def foo2 = try {
- ^
-two errors found
diff --git a/test/files/continuations-neg/trycatch2.scala b/test/files/continuations-neg/trycatch2.scala
deleted file mode 100644
index ee0a180ed6..0000000000
--- a/test/files/continuations-neg/trycatch2.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def fatal[T]: T = throw new Exception
- def cpsIntStringInt = shift { k:(Int=>String) => k(3); 7 }
- def cpsIntIntString = shift { k:(Int=>Int) => k(3); "7" }
-
- def foo1 = try {
- fatal[Int]
- cpsIntStringInt
- } catch {
- case ex: Throwable =>
- cpsIntStringInt
- }
-
- def foo2 = try {
- fatal[Int]
- cpsIntStringInt
- } catch {
- case ex: Throwable =>
- cpsIntStringInt
- }
-
-
- def main(args: Array[String]): Unit = {
- println(reset { foo1; "3" })
- println(reset { foo2; "3" })
- }
-
-}
diff --git a/test/files/continuations-run/basics.check b/test/files/continuations-run/basics.check
deleted file mode 100755
index 54c059fdcb..0000000000
--- a/test/files/continuations-run/basics.check
+++ /dev/null
@@ -1,2 +0,0 @@
-28
-28 \ No newline at end of file
diff --git a/test/files/continuations-run/basics.scala b/test/files/continuations-run/basics.scala
deleted file mode 100755
index 07b3de5194..0000000000
--- a/test/files/continuations-run/basics.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def m0() = {
- shift((k:Int => Int) => k(k(7))) * 2
- }
-
- def m1() = {
- 2 * shift((k:Int => Int) => k(k(7)))
- }
-
- def main(args: Array[String]) {
-
- println(reset(m0()))
- println(reset(m1()))
-
- }
-
-}
diff --git a/test/files/continuations-run/function1.check b/test/files/continuations-run/function1.check
deleted file mode 100644
index 7f8f011eb7..0000000000
--- a/test/files/continuations-run/function1.check
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/test/files/continuations-run/function1.scala b/test/files/continuations-run/function1.scala
deleted file mode 100644
index 82dfe46c08..0000000000
--- a/test/files/continuations-run/function1.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Unit = {
-
- val f = () => shift { k: (Int=>Int) => k(7) }
- val g: () => Int @cps[Int] = f
-
- println(reset(g()))
- }
-
-}
diff --git a/test/files/continuations-run/function4.check b/test/files/continuations-run/function4.check
deleted file mode 100644
index c7930257df..0000000000
--- a/test/files/continuations-run/function4.check
+++ /dev/null
@@ -1 +0,0 @@
-7 \ No newline at end of file
diff --git a/test/files/continuations-run/function4.scala b/test/files/continuations-run/function4.scala
deleted file mode 100644
index ccb432fe93..0000000000
--- a/test/files/continuations-run/function4.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Unit = {
-
- val g: () => Int @cps[Int] = () => shift { k: (Int=>Int) => k(7) }
-
- println(reset(g()))
- }
-
-}
diff --git a/test/files/continuations-run/function5.check b/test/files/continuations-run/function5.check
deleted file mode 100644
index c7930257df..0000000000
--- a/test/files/continuations-run/function5.check
+++ /dev/null
@@ -1 +0,0 @@
-7 \ No newline at end of file
diff --git a/test/files/continuations-run/function5.scala b/test/files/continuations-run/function5.scala
deleted file mode 100644
index a83eb80d08..0000000000
--- a/test/files/continuations-run/function5.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Unit = {
-
- val g: () => Int @cps[Int] = () => 7
-
- println(reset(g()))
- }
-
-}
diff --git a/test/files/continuations-run/function6.check b/test/files/continuations-run/function6.check
deleted file mode 100644
index c7930257df..0000000000
--- a/test/files/continuations-run/function6.check
+++ /dev/null
@@ -1 +0,0 @@
-7 \ No newline at end of file
diff --git a/test/files/continuations-run/function6.scala b/test/files/continuations-run/function6.scala
deleted file mode 100644
index 13ef88bd9f..0000000000
--- a/test/files/continuations-run/function6.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Unit = {
-
- val g: PartialFunction[Int, Int @cps[Int]] = { case x => 7 }
-
- println(reset(g(2)))
-
- }
-
-}
diff --git a/test/files/continuations-run/ifelse0.scala b/test/files/continuations-run/ifelse0.scala
deleted file mode 100644
index cbff72c77c..0000000000
--- a/test/files/continuations-run/ifelse0.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x:Int) = if (x <= 7)
- shift { k: (Int=>Int) => k(k(k(x))) }
- else
- shift { k: (Int=>Int) => k(x) }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test(7)))
- println(reset(1 + test(8)))
- }
-
-}
diff --git a/test/files/continuations-run/ifelse1.check b/test/files/continuations-run/ifelse1.check
deleted file mode 100644
index 86a3fbc0c1..0000000000
--- a/test/files/continuations-run/ifelse1.check
+++ /dev/null
@@ -1,4 +0,0 @@
-10
-9
-8
-11 \ No newline at end of file
diff --git a/test/files/continuations-run/ifelse1.scala b/test/files/continuations-run/ifelse1.scala
deleted file mode 100644
index f8e3cf2ca3..0000000000
--- a/test/files/continuations-run/ifelse1.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test1(x:Int) = if (x <= 7)
- shift { k: (Int=>Int) => k(k(k(x))) }
- else
- x
-
- def test2(x:Int) = if (x <= 7)
- x
- else
- shift { k: (Int=>Int) => k(k(k(x))) }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test1(7)))
- println(reset(1 + test1(8)))
- println(reset(1 + test2(7)))
- println(reset(1 + test2(8)))
- }
-
-}
diff --git a/test/files/continuations-run/ifelse2.check b/test/files/continuations-run/ifelse2.check
deleted file mode 100644
index f97a95b08d..0000000000
--- a/test/files/continuations-run/ifelse2.check
+++ /dev/null
@@ -1,4 +0,0 @@
-abort
-()
-alive
-()
diff --git a/test/files/continuations-run/ifelse2.scala b/test/files/continuations-run/ifelse2.scala
deleted file mode 100644
index f5ec864a06..0000000000
--- a/test/files/continuations-run/ifelse2.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x:Int) = if (x <= 7)
- shift { k: (Unit=>Unit) => println("abort") }
-
- def main(args: Array[String]): Unit = {
- println(reset{ test(7); println("alive") })
- println(reset{ test(8); println("alive") })
- }
-
-}
diff --git a/test/files/continuations-run/ifelse3.check b/test/files/continuations-run/ifelse3.check
deleted file mode 100644
index 95b562c8e6..0000000000
--- a/test/files/continuations-run/ifelse3.check
+++ /dev/null
@@ -1,2 +0,0 @@
-6
-9
diff --git a/test/files/continuations-run/ifelse3.scala b/test/files/continuations-run/ifelse3.scala
deleted file mode 100644
index 2c5b5765db..0000000000
--- a/test/files/continuations-run/ifelse3.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def util(x: Boolean) = shift { k: (Boolean=>Int) => k(x) }
-
- def test(x:Int) = if (util(x <= 7))
- x - 1
- else
- x + 1
-
-
- def main(args: Array[String]): Unit = {
- println(reset(test(7)))
- println(reset(test(8)))
- }
-
-}
diff --git a/test/files/continuations-run/ifelse4.check b/test/files/continuations-run/ifelse4.check
deleted file mode 100644
index 2545dd49a0..0000000000
--- a/test/files/continuations-run/ifelse4.check
+++ /dev/null
@@ -1,4 +0,0 @@
-10
-10
-10
-10
diff --git a/test/files/continuations-run/ifelse4.scala b/test/files/continuations-run/ifelse4.scala
deleted file mode 100644
index 46ec15365e..0000000000
--- a/test/files/continuations-run/ifelse4.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def sh(x1:Int) = shift( (k: Int => Int) => k(k(k(x1))))
-
- def testA(x1: Int): Int @cps[Int] = {
- sh(x1)
- if (x1==42) x1 else sh(x1)
- }
-
- def testB(x1: Int): Int @cps[Int] = {
- if (sh(x1)==43) x1 else x1
- }
-
- def testC(x1: Int): Int @cps[Int] = {
- sh(x1)
- if (sh(x1)==44) x1 else x1
- }
-
- def testD(x1: Int): Int @cps[Int] = {
- sh(x1)
- if (sh(x1)==45) x1 else sh(x1)
- }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + testA(7)))
- println(reset(1 + testB(9)))
- println(reset(1 + testC(9)))
- println(reset(1 + testD(7)))
- }
-}
diff --git a/test/files/continuations-run/implicit-infer-annotations.check b/test/files/continuations-run/implicit-infer-annotations.check
deleted file mode 100644
index e8206c4319..0000000000
--- a/test/files/continuations-run/implicit-infer-annotations.check
+++ /dev/null
@@ -1,5 +0,0 @@
-Range(5, 6, 7, 8, 9, 10)
-Range(5, 6, 7, 8, 9, 10)
-15
-List(10, 1, 2, 3)
-Range(5, 6, 7, 8, 9, 10)
diff --git a/test/files/continuations-run/implicit-infer-annotations.scala b/test/files/continuations-run/implicit-infer-annotations.scala
deleted file mode 100644
index 3f0e959f60..0000000000
--- a/test/files/continuations-run/implicit-infer-annotations.scala
+++ /dev/null
@@ -1,59 +0,0 @@
-import annotation._
-
-object A {
- class foo[-B,+C] extends StaticAnnotation with TypeConstraint
-
- def shift[A, B, C](fun: (A => B) => C): A @foo[B, C] = ???
- def reset[A, C](ctx: => (A @foo[A, C])): C = ???
-
- def m1 = reset { shift { f: (Int => Range) => f(5) }.to(10) }
-}
-
-object B {
- import scala.util.continuations._
-
- def m1 = reset { shift { f: (Int => Range) => f(5) }.to(10) }
- def m2 = reset { val a = shift { f: (Int => Range) => f(5) } ; a.to(10) }
-
- val x1 = reset{
- shift{ cont: (Int => Range) =>
- cont(5)
- }.to(10)
- }
-
- val x2 = reset{
- val a = shift{ cont: (Int => Range) =>
- cont(5)
- }
- a.to(10)
- } // x is now Range(5, 6, 7, 8, 9, 10)
-
- val x3 = reset{
- shift{ cont: (Int => Int) =>
- cont(5)
- } + 10
- } // x is now 15
-
- val x4 = reset{
- 10 :: shift{ cont: (List[Int] => List[Int]) =>
- cont(List(1, 2, 3))
- }
- } // x is List(10, 1, 2, 3)
-
- val x5 = reset{
- new scala.runtime.RichInt(shift{ cont: (Int => Range) =>
- cont(5)
- }) to 10
- }
-}
-
-object Test {
- def main(args: Array[String]): Unit = {
- import B._
- println(x1)
- println(x2)
- println(x3)
- println(x4)
- println(x5)
- }
-}
diff --git a/test/files/continuations-run/infer1.scala b/test/files/continuations-run/infer1.scala
deleted file mode 100644
index 76f746da57..0000000000
--- a/test/files/continuations-run/infer1.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x: => Int @cpsParam[String,Int]) = 7
-
- def test2() = {
- val x = shift { k: (Int => String) => 9 }
- x
- }
-
- def test3(x: => Int @cpsParam[Int,Int]) = 7
-
-
- def util() = shift { k: (String => String) => "7" }
-
- def main(args: Array[String]): Unit = {
- test { shift { k: (Int => String) => 9 } }
- test { shift { k: (Int => String) => 9 }; 2 }
-// test { shift { k: (Int => String) => 9 }; util() } <-- doesn't work
- test { shift { k: (Int => String) => 9 }; util(); 2 }
-
-
- test { shift { k: (Int => String) => 9 }; { test3(0); 2 } }
-
- test3 { { test3(0); 2 } }
-
- }
-
-}
diff --git a/test/files/continuations-run/match0.check b/test/files/continuations-run/match0.check
deleted file mode 100644
index f8bc79860d..0000000000
--- a/test/files/continuations-run/match0.check
+++ /dev/null
@@ -1,2 +0,0 @@
-10
-9 \ No newline at end of file
diff --git a/test/files/continuations-run/match0.scala b/test/files/continuations-run/match0.scala
deleted file mode 100644
index 8769ed9fcb..0000000000
--- a/test/files/continuations-run/match0.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x:Int) = x match {
- case 7 => shift { k: (Int=>Int) => k(k(k(x))) }
- case 8 => shift { k: (Int=>Int) => k(x) }
- }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test(7)))
- println(reset(1 + test(8)))
- }
-
-}
diff --git a/test/files/continuations-run/match1.check b/test/files/continuations-run/match1.check
deleted file mode 100644
index 73053d3f4f..0000000000
--- a/test/files/continuations-run/match1.check
+++ /dev/null
@@ -1,2 +0,0 @@
-10
-9
diff --git a/test/files/continuations-run/match1.scala b/test/files/continuations-run/match1.scala
deleted file mode 100644
index b89fb706b0..0000000000
--- a/test/files/continuations-run/match1.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x:Int) = x match {
- case 7 => shift { k: (Int=>Int) => k(k(k(x))) }
- case _ => x
- }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test(7)))
- println(reset(1 + test(8)))
- }
-
-}
diff --git a/test/files/continuations-run/match2.check b/test/files/continuations-run/match2.check
deleted file mode 100644
index cbf91349cc..0000000000
--- a/test/files/continuations-run/match2.check
+++ /dev/null
@@ -1,2 +0,0 @@
-B
-B
diff --git a/test/files/continuations-run/match2.scala b/test/files/continuations-run/match2.scala
deleted file mode 100644
index 002d9b52dd..0000000000
--- a/test/files/continuations-run/match2.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test1() = {
- val (a, b) = shift { k: (((String,String)) => String) => k("A","B") }
- b
- }
-
- case class Elem[T,U](a: T, b: U)
-
- def test2() = {
- val Elem(a,b) = shift { k: (Elem[String,String] => String) => k(Elem("A","B")) }
- b
- }
-
-
- def main(args: Array[String]): Unit = {
- println(reset(test1()))
- println(reset(test2()))
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-run/patvirt.check b/test/files/continuations-run/patvirt.check
deleted file mode 100644
index b5fa014ad3..0000000000
--- a/test/files/continuations-run/patvirt.check
+++ /dev/null
@@ -1,2 +0,0 @@
-10
-11
diff --git a/test/files/continuations-run/patvirt.scala b/test/files/continuations-run/patvirt.scala
deleted file mode 100644
index cfbdda538d..0000000000
--- a/test/files/continuations-run/patvirt.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def sh(x1:Int) = shift( (k: Int => Int) => k(k(k(x1))))
-
- def test(x1: Int) = {
- val o7 = {
- val o6 = {
- val o3 =
- if (7 == x1) Some(x1)
- else None
-
- if (o3.isEmpty) None
- else Some(sh(x1))
- }
- if (o6.isEmpty) {
- val o5 =
- if (8 == x1) Some(x1)
- else None
-
- if (o5.isEmpty) None
- else Some(sh(x1))
- } else o6
- }
- o7.get
- }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test(7)))
- println(reset(1 + test(8)))
- }
-}
diff --git a/test/files/continuations-run/shift-pct.check b/test/files/continuations-run/shift-pct.check
deleted file mode 100644
index fb190e770a..0000000000
--- a/test/files/continuations-run/shift-pct.check
+++ /dev/null
@@ -1,25 +0,0 @@
-d = 1, d2 = 1.0, pct = 1.000
-d = 2, d2 = 4.0, pct = 0.500
-d = 3, d2 = 9.0, pct = 0.333
-d = 4, d2 = 16.0, pct = 0.250
-d = 5, d2 = 25.0, pct = 0.200
-d = 6, d2 = 36.0, pct = 0.167
-d = 7, d2 = 49.0, pct = 0.143
-d = 8, d2 = 64.0, pct = 0.125
-d = 9, d2 = 81.0, pct = 0.111
-d = 10, d2 = 100.0, pct = 0.100
-d = 11, d2 = 121.0, pct = 0.091
-d = 12, d2 = 144.0, pct = 0.083
-d = 13, d2 = 169.0, pct = 0.077
-d = 14, d2 = 196.0, pct = 0.071
-d = 15, d2 = 225.0, pct = 0.067
-d = 16, d2 = 256.0, pct = 0.063
-d = 17, d2 = 289.0, pct = 0.059
-d = 18, d2 = 324.0, pct = 0.056
-d = 19, d2 = 361.0, pct = 0.053
-d = 20, d2 = 400.0, pct = 0.050
-d = 21, d2 = 441.0, pct = 0.048
-d = 22, d2 = 484.0, pct = 0.045
-d = 23, d2 = 529.0, pct = 0.043
-d = 24, d2 = 576.0, pct = 0.042
-d = 25, d2 = 625.0, pct = 0.040
diff --git a/test/files/continuations-run/shift-pct.scala b/test/files/continuations-run/shift-pct.scala
deleted file mode 100644
index 7ef9922168..0000000000
--- a/test/files/continuations-run/shift-pct.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- abstract class IfReturnRepro {
- def s1: Double @cpsParam[Any, Unit]
- def s2: Double @cpsParam[Any, Unit]
-
- def p(i: Int): Double @cpsParam[Unit, Any] = {
- val px = s1
- val pct = if (px > 100) px else px / s2
- println("pct = %.3f".format(pct))
- pct
- }
- }
-
- def main(args: Array[String]) : Unit = {
- var d: Double = 0d
- def d2 = d * d
-
- val irr = new IfReturnRepro {
- def s1 = shift(f => f(d))
- def s2 = shift(f => f(d2))
- }
- 1 to 25 foreach { i =>
- d = i
- print("d = " + i + ", d2 = " + d2 + ", ")
- run(irr p i)
- }
- }
-}
diff --git a/test/files/continuations-run/t1807.check b/test/files/continuations-run/t1807.check
deleted file mode 100644
index 56a6051ca2..0000000000
--- a/test/files/continuations-run/t1807.check
+++ /dev/null
@@ -1 +0,0 @@
-1 \ No newline at end of file
diff --git a/test/files/continuations-run/t1807.scala b/test/files/continuations-run/t1807.scala
deleted file mode 100644
index 278b3a9936..0000000000
--- a/test/files/continuations-run/t1807.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def main(args: Array[String]): Unit = {
- val z = reset {
- val f: (() => Int @cps[Int]) = () => 1
- f()
- }
- println(z)
- }
-} \ No newline at end of file
diff --git a/test/files/continuations-run/t1808.scala b/test/files/continuations-run/t1808.scala
deleted file mode 100644
index 125c7c1cdf..0000000000
--- a/test/files/continuations-run/t1808.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def main(args: Array[String]): Unit = {
- reset0 { 0 }
- }
-} \ No newline at end of file
diff --git a/test/files/continuations-run/t1820.scala b/test/files/continuations-run/t1820.scala
deleted file mode 100644
index 7de6ccabef..0000000000
--- a/test/files/continuations-run/t1820.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def shifted: Unit @suspendable = shift { (k: Unit => Unit) => () }
- def test1(b: => Boolean) = {
- reset {
- if (b) shifted
- }
- }
- def main(args: Array[String]): Unit = test1(true)
-}
diff --git a/test/files/continuations-run/t1821.check b/test/files/continuations-run/t1821.check
deleted file mode 100644
index f7b76115db..0000000000
--- a/test/files/continuations-run/t1821.check
+++ /dev/null
@@ -1,4 +0,0 @@
-()
-()
-()
-() \ No newline at end of file
diff --git a/test/files/continuations-run/t1821.scala b/test/files/continuations-run/t1821.scala
deleted file mode 100644
index 55bf7b6f12..0000000000
--- a/test/files/continuations-run/t1821.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def suspended[A](x: A): A @suspendable = x
- def test1[A](x: A): A @suspendable = suspended(x) match { case x => x }
- def test2[A](x: List[A]): A @suspendable = suspended(x) match { case List(x) => x }
-
- def test3[A](x: A): A @suspendable = x match { case x => x }
- def test4[A](x: List[A]): A @suspendable = x match { case List(x) => x }
-
- def main(args: Array[String]) {
- println(reset(test1()))
- println(reset(test2(List(()))))
- println(reset(test3()))
- println(reset(test4(List(()))))
- }
-}
diff --git a/test/files/continuations-run/t2864.check b/test/files/continuations-run/t2864.check
deleted file mode 100644
index d411bb7c1a..0000000000
--- a/test/files/continuations-run/t2864.check
+++ /dev/null
@@ -1 +0,0 @@
-400
diff --git a/test/files/continuations-run/t2864.scala b/test/files/continuations-run/t2864.scala
deleted file mode 100644
index 7a2579e45c..0000000000
--- a/test/files/continuations-run/t2864.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-import scala.util.continuations._
-object Test {
-
- def double[B](n : Int)(k : Int => B) : B = k(n * 2)
-
- def main(args : Array[String]) {
- reset {
- val result1 = shift(double[Unit](100))
- val result2 = shift(double[Unit](result1))
- println(result2)
- }
- }
-
- def foo: Int @cps[Int] = {
- val a0 = shift((k:Int=>Int) => k(0))
- val x0 = 2
- val a1 = shift((k:Int=>Int) => x0)
- 0
- }
-
-/*
- def bar: ControlContext[Int,Int,Int] = {
- shiftR((k:Int=>Int) => k(0)).flatMap { a0 =>
- val x0 = 2
- shiftR((k:Int=>Int) => x0).map { a1 =>
- 0
- }}
- }
-*/
-} \ No newline at end of file
diff --git a/test/files/continuations-run/t2934.check b/test/files/continuations-run/t2934.check
deleted file mode 100644
index a92586538e..0000000000
--- a/test/files/continuations-run/t2934.check
+++ /dev/null
@@ -1 +0,0 @@
-List(3, 4, 5)
diff --git a/test/files/continuations-run/t2934.scala b/test/files/continuations-run/t2934.scala
deleted file mode 100644
index a1b8ca9e04..0000000000
--- a/test/files/continuations-run/t2934.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def main(args : Array[String]) {
- println(reset {
- val x = shift(List(1,2,3).flatMap[Int, List[Int]])
- List(x + 2)
- })
- }
-}
diff --git a/test/files/continuations-run/t3199.check b/test/files/continuations-run/t3199.check
deleted file mode 100644
index a065247b8c..0000000000
--- a/test/files/continuations-run/t3199.check
+++ /dev/null
@@ -1 +0,0 @@
-Right(7)
diff --git a/test/files/continuations-run/t3199.scala b/test/files/continuations-run/t3199.scala
deleted file mode 100644
index 2cb73c005a..0000000000
--- a/test/files/continuations-run/t3199.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-import _root_.scala.collection.Seq
-import _root_.scala.util.control.Exception
-import _root_.scala.util.continuations._
-
-object Test {
-
- trait AbstractResource[+R <: AnyRef] {
- def reflect[B] : R @cpsParam[B,Either[Throwable, B]] = shift(acquireFor)
- def acquireFor[B](f : R => B) : Either[Throwable, B] = {
- import Exception._
- catching(List(classOf[Throwable]) : _*) either (f(null.asInstanceOf[R]))
- }
- }
-
- def main(args: Array[String]) : Unit = {
- val x = new AbstractResource[String] { }
- val result = x.acquireFor( x => 7 )
- println(result)
- }
- }
diff --git a/test/files/continuations-run/t3223.check b/test/files/continuations-run/t3223.check
deleted file mode 100644
index ec635144f6..0000000000
--- a/test/files/continuations-run/t3223.check
+++ /dev/null
@@ -1 +0,0 @@
-9
diff --git a/test/files/continuations-run/t3223.scala b/test/files/continuations-run/t3223.scala
deleted file mode 100644
index 75613fe5c7..0000000000
--- a/test/files/continuations-run/t3223.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-import scala.util.continuations._
-object Test {
-
- def foo(x:Int) = {
- try {
- throw new Exception
- shiftUnit0[Int,Int](7)
- } catch {
- case ex: Throwable =>
- val g = (a:Int)=>a
- 9
- }
- }
-
- def main(args: Array[String]) {
- println(reset(foo(0)))
- }
-
-}
diff --git a/test/files/continuations-run/t3225.check b/test/files/continuations-run/t3225.check
deleted file mode 100644
index df1a8a9ce4..0000000000
--- a/test/files/continuations-run/t3225.check
+++ /dev/null
@@ -1,12 +0,0 @@
-8
-8
-9
-9
-8
-9
-8
-8
-9
-9
-8
-9
diff --git a/test/files/continuations-run/t3225.scala b/test/files/continuations-run/t3225.scala
deleted file mode 100644
index a0c9c91985..0000000000
--- a/test/files/continuations-run/t3225.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- class Bla {
- val x = 8
- def y[T] = 9
- }
-
-/*
- def bla[A] = shift { k:(Bla=>A) => k(new Bla) }
-*/
-
- def bla1 = shift { k:(Bla=>Bla) => k(new Bla) }
- def bla2 = shift { k:(Bla=>Int) => k(new Bla) }
-
- def fooA = bla2.x
- def fooB[T] = bla2.y[T]
-
- def testMono() = {
- println(reset(bla1).x)
- println(reset(bla2.x))
- println(reset(bla2.y[Int]))
- println(reset(bla2.y))
- println(reset(fooA))
- println(reset(fooB))
- 0
- }
-
- def blaX[A] = shift { k:(Bla=>A) => k(new Bla) }
-
- def fooX[A] = blaX[A].x
- def fooY[A] = blaX[A].y[A]
-
- def testPoly() = {
- println(reset(blaX[Bla]).x)
- println(reset(blaX[Int].x))
- println(reset(blaX[Int].y[Int]))
- println(reset(blaX[Int].y))
- println(reset(fooX[Int]))
- println(reset(fooY[Int]))
- 0
- }
-
-
- // TODO: check whether this also applies to a::shift { k => ... }
-
- def main(args: Array[String]) {
- testMono()
- testPoly()
- }
-
-}
diff --git a/test/files/continuations-run/t3501.check b/test/files/continuations-run/t3501.check
deleted file mode 100644
index 08adcfe27a..0000000000
--- a/test/files/continuations-run/t3501.check
+++ /dev/null
@@ -1,5 +0,0 @@
-42
-42
-42
-42
-42
diff --git a/test/files/continuations-run/t3501.scala b/test/files/continuations-run/t3501.scala
deleted file mode 100644
index c43b3322be..0000000000
--- a/test/files/continuations-run/t3501.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def capture(): Int @suspendable = 42
-
- def main(args: Array[String]): Unit = reset {
- var i = 0
- while (i < 5) {
- i += 1
- val y = capture()
- val s = y
- println(s)
- }
- }
-}
diff --git a/test/files/continuations-run/t5314-2.check b/test/files/continuations-run/t5314-2.check
deleted file mode 100644
index 35b3c93780..0000000000
--- a/test/files/continuations-run/t5314-2.check
+++ /dev/null
@@ -1,5 +0,0 @@
-8
-hi
-8
-from try
-8
diff --git a/test/files/continuations-run/t5314-2.scala b/test/files/continuations-run/t5314-2.scala
deleted file mode 100644
index e7e5d46f03..0000000000
--- a/test/files/continuations-run/t5314-2.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-import scala.util.continuations._
-
-class ReturnRepro {
- def s1: Int @cps[Any] = shift { k => k(5) }
- def caller = reset { println(p(3)) }
- def caller2 = reset { println(p2(3)) }
- def caller3 = reset { println(p3(3)) }
-
- def p(i: Int): Int @cps[Any] = {
- val v= s1 + 3
- return v
- }
-
- def p2(i: Int): Int @cps[Any] = {
- val v = s1 + 3
- if (v > 0) {
- println("hi")
- return v
- } else {
- println("hi")
- return 8
- }
- }
-
- def p3(i: Int): Int @cps[Any] = {
- val v = s1 + 3
- try {
- println("from try")
- return v
- } catch {
- case e: Exception =>
- println("from catch")
- return 7
- }
- }
-
-}
-
-object Test extends App {
- val repro = new ReturnRepro
- repro.caller
- repro.caller2
- repro.caller3
-}
diff --git a/test/files/continuations-run/t5314-3.check b/test/files/continuations-run/t5314-3.check
deleted file mode 100644
index 71489f097c..0000000000
--- a/test/files/continuations-run/t5314-3.check
+++ /dev/null
@@ -1,4 +0,0 @@
-enter return expr
-8
-hi
-8
diff --git a/test/files/continuations-run/t5314-3.scala b/test/files/continuations-run/t5314-3.scala
deleted file mode 100644
index c2fe8f6f87..0000000000
--- a/test/files/continuations-run/t5314-3.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-import scala.util.continuations._
-
-class ReturnRepro {
- def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) }
- def caller = reset { println(p(3)) }
- def caller2 = reset { println(p2(3)) }
-
- def p(i: Int): Int @cpsParam[Unit, Any] = {
- val v= s1 + 3
- return { println("enter return expr"); v }
- }
-
- def p2(i: Int): Int @cpsParam[Unit, Any] = {
- val v = s1 + 3
- if (v > 0) {
- return { println("hi"); v }
- } else {
- return { println("hi"); 8 }
- }
- }
-}
-
-object Test extends App {
- val repro = new ReturnRepro
- repro.caller
- repro.caller2
-}
diff --git a/test/files/continuations-run/t5314-with-if.check b/test/files/continuations-run/t5314-with-if.check
deleted file mode 100644
index 7f8f011eb7..0000000000
--- a/test/files/continuations-run/t5314-with-if.check
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/test/files/continuations-run/t5314-with-if.scala b/test/files/continuations-run/t5314-with-if.scala
deleted file mode 100644
index 5840199a3c..0000000000
--- a/test/files/continuations-run/t5314-with-if.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-import scala.util.continuations._
-
-object Test extends App {
-
- def foo(x:Int): Int @cps[Int] = 7
-
- def bar(x:Int): Int @cps[Int] = {
- val v = foo(x)
- if (v > 0)
- return v
- else
- return 10
- }
-
- println(reset { bar(10) })
-
-}
diff --git a/test/files/continuations-run/t5314.check b/test/files/continuations-run/t5314.check
deleted file mode 100644
index 61f5b25dc7..0000000000
--- a/test/files/continuations-run/t5314.check
+++ /dev/null
@@ -1,14 +0,0 @@
-t5314.scala:34: warning: expression 7 is cps-transformed unexpectedly
- def bar3(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else return foo2(x) }
- ^
-t5314.scala:35: warning: expression 7 is cps-transformed unexpectedly
- def bar4(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else foo2(x) }
- ^
-7
-7
-7
-8
-8
-hi
-8
-8
diff --git a/test/files/continuations-run/t5314.scala b/test/files/continuations-run/t5314.scala
deleted file mode 100644
index e448d8558d..0000000000
--- a/test/files/continuations-run/t5314.scala
+++ /dev/null
@@ -1,52 +0,0 @@
-import scala.util.continuations._
-
-class ReturnRepro {
- def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) }
- def caller = reset { println(p(3)) }
- def caller2 = reset { println(p2(3)) }
-
- def p(i: Int): Int @cpsParam[Unit, Any] = {
- val v= s1 + 3
- return v
- }
-
- def p2(i: Int): Int @cpsParam[Unit, Any] = {
- val v = s1 + 3
- if (v > 0) {
- println("hi")
- return v
- } else {
- println("hi")
- return 8
- }
- }
-}
-
-object Test extends App {
- def foo(x:Int): Int @cps[Int] = shift { k => k(x) }
-
- def bar(x:Int): Int @cps[Int] = return foo(x)
-
- def nocps(x: Int): Int = { return x; x }
-
- def foo2(x:Int): Int @cps[Int] = 7
- def bar2(x:Int): Int @cps[Int] = { foo2(x); return 7 }
- def bar3(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else return foo2(x) }
- def bar4(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else foo2(x) }
- def bar5(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else 8 }
- println(reset { bar2(10) })
- println(reset { bar3(10) })
- println(reset { bar4(10) })
- println(reset { bar5(10) })
-
- /* original test case */
- val repro = new ReturnRepro
- repro.caller
- repro.caller2
-
- reset {
- val res = bar(8)
- println(res)
- res
- }
-}
diff --git a/test/files/continuations-run/t5472.check b/test/files/continuations-run/t5472.check
deleted file mode 100644
index 2468b6b27d..0000000000
--- a/test/files/continuations-run/t5472.check
+++ /dev/null
@@ -1,25 +0,0 @@
-t5472.scala:12: warning: expression case4(){
- if (x1.ne(null))
- matchEnd3(true)
- else
- case5()
-} is cps-transformed unexpectedly
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- ^
-t5472.scala:12: warning: expression case5(){
- matchEnd3(false)
-} is cps-transformed unexpectedly
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- ^
-t5472.scala:12: warning: expression matchEnd3(x: Boolean){
- x
-} is cps-transformed unexpectedly
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- ^
-t5472.scala:12: warning: expression matchEnd3(x: Int){
- x
-} is cps-transformed unexpectedly
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- ^
-warning: there were 1 deprecation warning(s); re-run with -deprecation for details
-List(23, 23)
diff --git a/test/files/continuations-run/t5472.scala b/test/files/continuations-run/t5472.scala
deleted file mode 100644
index 060d267544..0000000000
--- a/test/files/continuations-run/t5472.scala
+++ /dev/null
@@ -1,91 +0,0 @@
-import scala.annotation._
-import scala.util.continuations._
-import java.util.concurrent.atomic._
-
-@deprecated("Suppress warnings", since="2.11")
-object Test {
- def main(args: Array[String]) {
- val map = Map("foo" -> 1, "bar" -> 2)
- reset {
- val mapped =
- for {
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- } yield {
- shiftUnit0[Int, Unit](23)
- }
- println(mapped.toList)
- }
- }
-
-final class ContinuationizedParallelIterable[+A](protected val underline: Iterable[A]) {
- def toList = underline.toList.sortBy(_.toString)
-
- final def filter(p: A => Boolean @suspendable): ContinuationizedParallelIterable[A] @suspendable =
- shift(
- new AtomicInteger(1) with ((ContinuationizedParallelIterable[A] => Unit) => Unit) {
- private val results = new AtomicReference[List[A]](Nil)
-
- @tailrec
- private def add(element: A) {
- val old = results.get
- if (!results.compareAndSet(old, element :: old)) {
- add(element)
- }
- }
-
- override final def apply(continue: ContinuationizedParallelIterable[A] => Unit) {
- for (element <- underline) {
- super.incrementAndGet()
- reset {
- val pass = p(element)
- if (pass) {
- add(element)
- }
- if (super.decrementAndGet() == 0) {
- continue(new ContinuationizedParallelIterable(results.get))
- }
- }
- }
- if (super.decrementAndGet() == 0) {
- continue(new ContinuationizedParallelIterable(results.get))
- }
- }
- })
-
- final def foreach[U](f: A => U @suspendable): Unit @suspendable =
- shift(
- new AtomicInteger(1) with ((Unit => Unit) => Unit) {
- override final def apply(continue: Unit => Unit) {
- for (element <- underline) {
- super.incrementAndGet()
- reset {
- f(element)
- if (super.decrementAndGet() == 0) {
- continue()
- }
- }
- }
- if (super.decrementAndGet() == 0) {
- continue()
- }
- }
- })
-
- final def map[B: Manifest](f: A => B @suspendable): ContinuationizedParallelIterable[B] @suspendable =
- shift(
- new AtomicInteger(underline.size) with ((ContinuationizedParallelIterable[B] => Unit) => Unit) {
- override final def apply(continue: ContinuationizedParallelIterable[B] => Unit) {
- val results = new Array[B](super.get)
- for ((element, i) <- underline.view.zipWithIndex) {
- reset {
- val result = f(element)
- results(i) = result
- if (super.decrementAndGet() == 0) {
- continue(new ContinuationizedParallelIterable(results))
- }
- }
- }
- }
- })
-}
-}
diff --git a/test/files/continuations-run/t5506.check b/test/files/continuations-run/t5506.check
deleted file mode 100644
index 38b76c63f1..0000000000
--- a/test/files/continuations-run/t5506.check
+++ /dev/null
@@ -1,7 +0,0 @@
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
diff --git a/test/files/continuations-run/t5506.scala b/test/files/continuations-run/t5506.scala
deleted file mode 100644
index 08f64c9db1..0000000000
--- a/test/files/continuations-run/t5506.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-import scala.util.continuations._
-
-object Test {
-
-def g: List[Int] @suspendable = List(1,2,3)
-
-def fp10: List[Int] @suspendable = {
-g.map(x => x)
-}
-
-def fp11: List[Int] @suspendable = {
-val z = g.map(x => x)
-z
-}
-
-
-def fp12: List[Int] @suspendable = {
-val z = List(1,2,3)
-z.map(x => x)
-}
-
-
-
-def fp20: List[Int] @suspendable = {
-g.map[Int,List[Int]](x => x)
-}
-
-
-def fp21: List[Int] @suspendable = {
-val z = g.map[Int,List[Int]](x => x)
-z
-}
-
-def fp22: List[Int] @suspendable = {
-val z = g.map[Int,List[Int]](x => x)(List.canBuildFrom[Int])
-z
-}
-
-def fp23: List[Int] @suspendable = {
-val z = g.map(x => x)(List.canBuildFrom[Int])
-z
-}
-
-
-def main(args: Array[String]) {
- reset {
- println(fp10)
- println(fp11)
- println(fp12)
-
- println(fp20)
- println(fp21)
- println(fp22)
- println(fp23)
- }
-}
-
-}
diff --git a/test/files/continuations-run/t5538.check b/test/files/continuations-run/t5538.check
deleted file mode 100644
index d9d873663d..0000000000
--- a/test/files/continuations-run/t5538.check
+++ /dev/null
@@ -1,2 +0,0 @@
-warning: there were 1 feature warning(s); re-run with -feature for details
-Future(Future(Future(Future(Future(List(1, 2, 3, 4, 5))))))
diff --git a/test/files/continuations-run/t5538.scala b/test/files/continuations-run/t5538.scala
deleted file mode 100644
index 9f01624da1..0000000000
--- a/test/files/continuations-run/t5538.scala
+++ /dev/null
@@ -1,52 +0,0 @@
-import scala.util.continuations._
-import scala.collection.generic.CanBuildFrom
-
-import scala.language.{ implicitConversions }
-
-object Test {
-
- class ExecutionContext
-
- implicit def defaultExecutionContext = new ExecutionContext
-
- case class Future[+T](x:T) {
- final def map[A](f: T => A): Future[A] = new Future[A](f(x))
- final def flatMap[A](f: T => Future[A]): Future[A] = f(x)
- }
-
- class PromiseStream[A] {
- override def toString = xs.toString
-
- var xs: List[A] = Nil
-
- final def +=(elem: A): this.type = { xs :+= elem; this }
-
- final def ++=(elem: Traversable[A]): this.type = { xs ++= elem; this }
-
- final def <<(elem: Future[A]): PromiseStream[A] @cps[Future[Any]] =
- shift { cont: (PromiseStream[A] => Future[Any]) => elem map (a => cont(this += a)) }
-
- final def <<(elem1: Future[A], elem2: Future[A], elems: Future[A]*): PromiseStream[A] @cps[Future[Any]] =
- shift { cont: (PromiseStream[A] => Future[Any]) => Future.flow(this << elem1 << elem2 <<< Future.sequence(elems.toSeq)) map cont }
-
- final def <<<(elems: Traversable[A]): PromiseStream[A] @cps[Future[Any]] =
- shift { cont: (PromiseStream[A] => Future[Any]) => cont(this ++= elems) }
-
- final def <<<(elems: Future[Traversable[A]]): PromiseStream[A] @cps[Future[Any]] =
- shift { cont: (PromiseStream[A] => Future[Any]) => elems map (as => cont(this ++= as)) }
- }
-
- object Future {
-
- def sequence[A, M[_] <: Traversable[_]](in: M[Future[A]])(implicit cbf: CanBuildFrom[M[Future[A]], A, M[A]], executor: ExecutionContext): Future[M[A]] =
- new Future(in.asInstanceOf[Traversable[Future[A]]].map((f:Future[A])=>f.x)(cbf.asInstanceOf[CanBuildFrom[Traversable[Future[A]], A, M[A]]]))
-
- def flow[A](body: => A @cps[Future[Any]])(implicit executor: ExecutionContext): Future[A] = reset(Future(body)).asInstanceOf[Future[A]]
-
- }
-
- def main(args: Array[String]) {
- val p = new PromiseStream[Int]
- println(Future.flow(p << (Future(1), Future(2), Future(3), Future(4), Future(5))))
- }
-}
diff --git a/test/files/continuations-run/trycatch0.check b/test/files/continuations-run/trycatch0.check
deleted file mode 100644
index 36806909d0..0000000000
--- a/test/files/continuations-run/trycatch0.check
+++ /dev/null
@@ -1,2 +0,0 @@
-10
-10 \ No newline at end of file
diff --git a/test/files/continuations-run/trycatch0.scala b/test/files/continuations-run/trycatch0.scala
deleted file mode 100644
index d0b4a52a30..0000000000
--- a/test/files/continuations-run/trycatch0.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def foo = try {
- shift((k: Int=>Int) => k(7))
- } catch {
- case ex: Throwable =>
- 9
- }
-
- def bar = try {
- 7
- } catch {
- case ex: Throwable =>
- shiftUnit0[Int,Int](9)
- }
-
- def main(args: Array[String]): Unit = {
- println(reset { foo + 3 })
- println(reset { bar + 3 })
- }
-}
diff --git a/test/files/continuations-run/trycatch1.check b/test/files/continuations-run/trycatch1.check
deleted file mode 100644
index 061ecdcd54..0000000000
--- a/test/files/continuations-run/trycatch1.check
+++ /dev/null
@@ -1,10 +0,0 @@
-trycatch1.scala:34: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
- 7
- ^
-trycatch1.scala:18: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
- shift((k: Int=>Int) => k(7))
- ^
-12
-12
-12
-12
diff --git a/test/files/continuations-run/trycatch1.scala b/test/files/continuations-run/trycatch1.scala
deleted file mode 100644
index 2a8db72a8b..0000000000
--- a/test/files/continuations-run/trycatch1.scala
+++ /dev/null
@@ -1,48 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def fatal: Int = throw new Exception()
-
- def foo1 = try {
- fatal
- shift((k: Int=>Int) => k(7))
- } catch {
- case ex: Throwable =>
- 9
- }
-
- def foo2 = try {
- shift((k: Int=>Int) => k(7))
- fatal
- } catch {
- case ex: Throwable =>
- 9
- }
-
- def bar1 = try {
- fatal
- 7
- } catch {
- case ex: Throwable =>
- shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner
- }
-
- def bar2 = try {
- 7
- fatal
- } catch {
- case ex: Throwable =>
- shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner
- }
-
- def main(args: Array[String]): Unit = {
- println(reset { foo1 + 3 })
- println(reset { foo2 + 3 })
- println(reset { bar1 + 3 })
- println(reset { bar2 + 3 })
- }
-
-}
diff --git a/test/files/continuations-run/while0.check b/test/files/continuations-run/while0.check
deleted file mode 100644
index d58c55a31d..0000000000
--- a/test/files/continuations-run/while0.check
+++ /dev/null
@@ -1 +0,0 @@
-9000
diff --git a/test/files/continuations-run/while0.scala b/test/files/continuations-run/while0.scala
deleted file mode 100644
index e21745374e..0000000000
--- a/test/files/continuations-run/while0.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def foo(): Int @cps[Unit] = 2
-
- def test(): Unit @cps[Unit] = {
- var x = 0
- while (x < 9000) { // pick number large enough to require tail-call opt
- x += foo()
- }
- println(x)
- }
-
- def main(args: Array[String]): Unit = {
- reset(test())
- }
-
-}
diff --git a/test/files/continuations-run/while1.check b/test/files/continuations-run/while1.check
deleted file mode 100644
index 3d5f0b9a46..0000000000
--- a/test/files/continuations-run/while1.check
+++ /dev/null
@@ -1,11 +0,0 @@
-up
-up
-up
-up
-up
-10
-down
-down
-down
-down
-down
diff --git a/test/files/continuations-run/while1.scala b/test/files/continuations-run/while1.scala
deleted file mode 100644
index 7ba9f94881..0000000000
--- a/test/files/continuations-run/while1.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def foo(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") }
-
- def test(): Unit @cps[Unit] = {
- var x = 0
- while (x < 9) {
- x += foo()
- }
- println(x)
- }
-
- def main(args: Array[String]): Unit = {
- reset(test())
- }
-
-}
diff --git a/test/files/continuations-run/while2.check b/test/files/continuations-run/while2.check
deleted file mode 100644
index 9fe515181b..0000000000
--- a/test/files/continuations-run/while2.check
+++ /dev/null
@@ -1,19 +0,0 @@
-up
-up
-up
-up
-up
-up
-up
-up
-up
-9000
-down
-down
-down
-down
-down
-down
-down
-down
-down
diff --git a/test/files/continuations-run/while2.scala b/test/files/continuations-run/while2.scala
deleted file mode 100644
index 3dbf2ad2fe..0000000000
--- a/test/files/continuations-run/while2.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def foo1(): Int @cps[Unit] = 2
- def foo2(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") }
-
- def test(): Unit @cps[Unit] = {
- var x = 0
- while (x < 9000) { // pick number large enough to require tail-call opt
- x += (if (x % 1000 != 0) foo1() else foo2())
- }
- println(x)
- }
-
- def main(args: Array[String]): Unit = {
- reset(test())
- }
-
-}
diff --git a/test/files/continuations-run/z1673.scala b/test/files/continuations-run/z1673.scala
deleted file mode 100644
index 716b374860..0000000000
--- a/test/files/continuations-run/z1673.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-import scala.util.continuations._
-
-class MatchRepro {
- def s: String @cps[Any] = shift { k => k("foo") }
-
- def p = {
- val k = s
- s match { case lit0 => }
- }
-
- def q = {
- val k = s
- k match { case lit1 => }
- }
-
- def r = {
- s match { case "FOO" => }
- }
-
- def t = {
- val k = s
- k match { case "FOO" => }
- }
-}
-
-object Test {
- def main(args: Array[String]): Unit = {
- val m = new MatchRepro
- ()
- }
-}
diff --git a/test/files/instrumented/InstrumentationTest.check b/test/files/instrumented/InstrumentationTest.check
index 0c570fa12c..c82d16bd34 100644
--- a/test/files/instrumented/InstrumentationTest.check
+++ b/test/files/instrumented/InstrumentationTest.check
@@ -1,3 +1,4 @@
+#partest !avian
true
Method call statistics:
1 Foo1.<init>()V
@@ -8,3 +9,6 @@ Method call statistics:
1 scala/Predef$.println(Ljava/lang/Object;)V
1 scala/io/AnsiColor$class.$init$(Lscala/io/AnsiColor;)V
1 scala/runtime/BoxesRunTime.boxToBoolean(Z)Ljava/lang/Boolean;
+#partest avian
+!!!TEST SKIPPED!!!
+Instrumentation is not supported on Avian.
diff --git a/test/files/instrumented/InstrumentationTest.scala b/test/files/instrumented/InstrumentationTest.scala
index 0e53f80857..458fd4974b 100644
--- a/test/files/instrumented/InstrumentationTest.scala
+++ b/test/files/instrumented/InstrumentationTest.scala
@@ -15,16 +15,21 @@ package instrumented {
/** Tests if instrumentation itself works correctly */
object Test {
def main(args: Array[String]) {
- // force predef initialization before profiling
- Predef
- startProfiling()
- val foo1 = new Foo1
- foo1.someMethod
- val foo2 = new instrumented.Foo2
- foo2.someMethod
- // should box the boolean
- println(true)
- stopProfiling()
- printStatistics()
+ if (scala.tools.partest.utils.Properties.isAvian) {
+ println("!!!TEST SKIPPED!!!")
+ println("Instrumentation is not supported on Avian.")
+ } else {
+ // force predef initialization before profiling
+ Predef
+ startProfiling()
+ val foo1 = new Foo1
+ foo1.someMethod
+ val foo2 = new instrumented.Foo2
+ foo2.someMethod
+ // should box the boolean
+ println(true)
+ stopProfiling()
+ printStatistics()
+ }
}
}
diff --git a/test/files/instrumented/inline-in-constructors.check b/test/files/instrumented/inline-in-constructors.check
index c6c9ae4e15..b58c1d77d5 100644
--- a/test/files/instrumented/inline-in-constructors.check
+++ b/test/files/instrumented/inline-in-constructors.check
@@ -1,3 +1,7 @@
+#partest !avian
Method call statistics:
1 instrumented/Bar.<init>(Z)V
1 instrumented/Foo.<init>(I)V
+#partest avian
+!!!TEST SKIPPED!!!
+Instrumentation is not supported on Avian.
diff --git a/test/files/instrumented/inline-in-constructors/test_3.scala b/test/files/instrumented/inline-in-constructors/test_3.scala
index c4d4cc5f37..949e9945e7 100644
--- a/test/files/instrumented/inline-in-constructors/test_3.scala
+++ b/test/files/instrumented/inline-in-constructors/test_3.scala
@@ -3,13 +3,18 @@ import instrumented._
object Test {
def main(args: Array[String]) {
- // force predef initialization before profiling
- Predef
- MyPredef
- startProfiling()
- val a = new Foo(2)
- val b = new Bar(true)
- stopProfiling()
- printStatistics()
+ if (scala.tools.partest.utils.Properties.isAvian) {
+ println("!!!TEST SKIPPED!!!")
+ println("Instrumentation is not supported on Avian.")
+ } else {
+ // force predef initialization before profiling
+ Predef
+ MyPredef
+ startProfiling()
+ val a = new Foo(2)
+ val b = new Bar(true)
+ stopProfiling()
+ printStatistics()
+ }
}
}
diff --git a/test/files/jvm/si5471.check b/test/files/jvm/t5471.check
index bb101b641b..bb101b641b 100644
--- a/test/files/jvm/si5471.check
+++ b/test/files/jvm/t5471.check
diff --git a/test/files/jvm/si5471.scala b/test/files/jvm/t5471.scala
index 2efd869b61..2efd869b61 100644
--- a/test/files/jvm/si5471.scala
+++ b/test/files/jvm/t5471.scala
diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check
index ef3aee5ee4..e5f1a38d96 100644
--- a/test/files/neg/checksensible.check
+++ b/test/files/neg/checksensible.check
@@ -28,9 +28,6 @@ checksensible.scala:27: warning: comparing values of types Int and Unit using `=
checksensible.scala:29: warning: comparing values of types Int and String using `==' will always yield false
1 == "abc"
^
-checksensible.scala:29: warning: Int and String are unrelated: they will most likely never compare equal
- 1 == "abc"
- ^
checksensible.scala:33: warning: comparing values of types Some[Int] and Int using `==' will always yield false
Some(1) == 1 // as above
^
@@ -64,18 +61,12 @@ checksensible.scala:51: warning: comparing values of types Int and Unit using `!
checksensible.scala:52: warning: comparing values of types Int and Symbol using `!=' will always yield true
(1 != 'sym)
^
-checksensible.scala:52: warning: Int and Symbol are unrelated: they will most likely always compare unequal
- (1 != 'sym)
- ^
checksensible.scala:58: warning: comparing a fresh object using `==' will always yield false
((x: Int) => x + 1) == null
^
checksensible.scala:59: warning: comparing a fresh object using `==' will always yield false
Bep == ((_: Int) + 1)
^
-checksensible.scala:59: warning: Bep.type and Int => Int are unrelated: they will most likely never compare equal
- Bep == ((_: Int) + 1)
- ^
checksensible.scala:61: warning: comparing a fresh object using `==' will always yield false
new Object == new Object
^
@@ -91,9 +82,6 @@ checksensible.scala:66: warning: comparing values of types Int and Null using `=
checksensible.scala:71: warning: comparing values of types Bip and Bop using `==' will always yield false
(x1 == x2)
^
-checksensible.scala:71: warning: Bip and Bop are unrelated: they will most likely never compare equal
- (x1 == x2)
- ^
checksensible.scala:81: warning: comparing values of types EqEqRefTest.this.C3 and EqEqRefTest.this.Z1 using `==' will always yield false
c3 == z1
^
@@ -106,12 +94,9 @@ checksensible.scala:83: warning: comparing values of types EqEqRefTest.this.Z1 a
checksensible.scala:84: warning: comparing values of types EqEqRefTest.this.C3 and String using `!=' will always yield true
c3 != "abc"
^
-checksensible.scala:84: warning: EqEqRefTest.this.C3 and String are unrelated: they will most likely always compare unequal
- c3 != "abc"
- ^
checksensible.scala:95: warning: comparing values of types Unit and Int using `!=' will always yield true
while ((c = in.read) != -1)
^
error: No warnings can be incurred under -Xfatal-warnings.
-38 warnings found
+33 warnings found
one error found
diff --git a/test/files/neg/compile-time-only-a.check b/test/files/neg/compile-time-only-a.check
index 1c4c72171f..9bc96f6b9b 100644
--- a/test/files/neg/compile-time-only-a.check
+++ b/test/files/neg/compile-time-only-a.check
@@ -1,49 +1,79 @@
-compile-time-only-a.scala:9: error: C3
+compile-time-only-a.scala:10: error: C3
@compileTimeOnly("C3") case class C3(x: Int)
^
-compile-time-only-a.scala:11: error: C4
+compile-time-only-a.scala:12: error: C4
@compileTimeOnly("C4") case class C4(x: Int)
^
-compile-time-only-a.scala:16: error: C5
+compile-time-only-a.scala:17: error: C5
implicit class C5(val x: Int) {
^
-compile-time-only-a.scala:28: error: C1
+compile-time-only-a.scala:32: error: C1
new C1()
^
-compile-time-only-a.scala:32: error: C2
+compile-time-only-a.scala:36: error: C2
C2
^
-compile-time-only-a.scala:34: error: C3
+compile-time-only-a.scala:38: error: C3
new C3(2)
^
-compile-time-only-a.scala:37: error: C4
+compile-time-only-a.scala:41: error: C4
new C4(2)
^
-compile-time-only-a.scala:41: error: C5
+compile-time-only-a.scala:45: error: C5
2.ext
^
-compile-time-only-a.scala:42: error: C5
+compile-time-only-a.scala:46: error: C5
C5(2)
^
-compile-time-only-a.scala:45: error: C6.x
+compile-time-only-a.scala:49: error: C6.x
val _ = c6.x
^
-compile-time-only-a.scala:46: error: C6.foo
+compile-time-only-a.scala:50: error: C6.foo
c6.foo
^
-compile-time-only-a.scala:48: error: C6.y
+compile-time-only-a.scala:51: error: C6.Foo
+ type Foo = c6.Foo
+ ^
+compile-time-only-a.scala:52: error: C6.y
c6.y = c6.y
^
-compile-time-only-a.scala:48: error: C6.y
+compile-time-only-a.scala:52: error: C6.y
c6.y = c6.y
^
-compile-time-only-a.scala:54: error: placebo
-@placebo
- ^
-compile-time-only-a.scala:56: error: placebo
+compile-time-only-a.scala:54: error: C7
+ val c701: (C7, C7) = ???
+ ^
+compile-time-only-a.scala:55: error: C7
+ val c702: (C7 => C7) = ???
+ ^
+compile-time-only-a.scala:56: error: C7
+ val c703: { val x: C7 } = ???
+ ^
+compile-time-only-a.scala:57: error: C7
+ val c704: AnyRef with C7 = ???
+ ^
+compile-time-only-a.scala:60: error: C7
+ val c706: C7 Either C7 = ???
+ ^
+compile-time-only-a.scala:61: error: C7
+ val c707a: List[C7] = ???
+ ^
+compile-time-only-a.scala:63: error: C7
+ val c708a: T forSome { type T <: C7 } = ???
+ ^
+compile-time-only-a.scala:66: error: C8
+ val c709: (C8[Int], C8[C7]) = ???
+ ^
+compile-time-only-a.scala:67: error: C8
+ val c710: (C8[_] => C8[_]) = ???
+ ^
+compile-time-only-a.scala:74: error: placebo
+class Test {
+ ^
+compile-time-only-a.scala:75: error: placebo
@placebo def x = (2: @placebo)
- ^
-compile-time-only-a.scala:56: error: placebo
+ ^
+compile-time-only-a.scala:75: error: placebo
@placebo def x = (2: @placebo)
^
-16 errors found
+26 errors found
diff --git a/test/files/neg/compile-time-only-a.scala b/test/files/neg/compile-time-only-a.scala
index 43d36dfab1..533175a699 100644
--- a/test/files/neg/compile-time-only-a.scala
+++ b/test/files/neg/compile-time-only-a.scala
@@ -1,4 +1,5 @@
import scala.annotation.compileTimeOnly
+import scala.language.existentials
@compileTimeOnly("C1") class C1
object C1
@@ -24,6 +25,9 @@ class C6(@compileTimeOnly("C6.x") val x: Int) {
@compileTimeOnly("C6.y") var y = 3
}
+@compileTimeOnly("C7") class C7
+@compileTimeOnly("C8") class C8[T]
+
object Test extends App {
new C1()
C1
@@ -46,6 +50,21 @@ object Test extends App {
c6.foo
type Foo = c6.Foo
c6.y = c6.y
+
+ val c701: (C7, C7) = ???
+ val c702: (C7 => C7) = ???
+ val c703: { val x: C7 } = ???
+ val c704: AnyRef with C7 = ???
+ // https://groups.google.com/forum/#!topic/scala-internals/5n07TiCnBZU
+ // val c705: ({ @compileTimeOnly("C7") type C7[T] = List[T] })#C7[_] = ???
+ val c706: C7 Either C7 = ???
+ val c707a: List[C7] = ???
+ val c707b = List[C7]()
+ val c708a: T forSome { type T <: C7 } = ???
+ // https://groups.google.com/forum/#!topic/scala-internals/5n07TiCnBZU
+ // val c708b: T forSome { @compileTimeOnly("C7") type T } = ???
+ val c709: (C8[Int], C8[C7]) = ???
+ val c710: (C8[_] => C8[_]) = ???
}
@compileTimeOnly("placebo")
diff --git a/test/files/neg/compile-time-only-b.check b/test/files/neg/compile-time-only-b.check
index 8292a0ddeb..50cdf57fb5 100644
--- a/test/files/neg/compile-time-only-b.check
+++ b/test/files/neg/compile-time-only-b.check
@@ -1,7 +1,13 @@
+compile-time-only-b.scala:9: error: splice must be enclosed within a reify {} block
+ val ignored1 = expr.splice
+ ^
+compile-time-only-b.scala:10: error: cannot use value except for signatures of macro implementations
+ val ignored2 = expr.value
+ ^
compile-time-only-b.scala:13: error: splice must be enclosed within a reify {} block
val ignored3 = reify(fortyTwo).splice
^
compile-time-only-b.scala:14: error: cannot use value except for signatures of macro implementations
val ignored4 = reify(fortyTwo).value
^
-two errors found
+four errors found
diff --git a/test/files/neg/macro-blackbox-extractor/Macros_1.scala b/test/files/neg/macro-blackbox-extractor/Macros_1.scala
index 5c7748bec9..f0bfe53aa2 100644
--- a/test/files/neg/macro-blackbox-extractor/Macros_1.scala
+++ b/test/files/neg/macro-blackbox-extractor/Macros_1.scala
@@ -2,7 +2,7 @@ import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Extractor {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
object Macros {
diff --git a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
index 08f1c21e89..f5e85d57ea 100644
--- a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
+++ b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
@@ -11,5 +11,5 @@ object Macros {
"""
}
- def foo = macro impl
+ def foo: Any = macro impl
} \ No newline at end of file
diff --git a/test/files/neg/macro-bundle-object.check b/test/files/neg/macro-bundle-object.check
index 293f40a178..78e7119fa7 100644
--- a/test/files/neg/macro-bundle-object.check
+++ b/test/files/neg/macro-bundle-object.check
@@ -1,5 +1,5 @@
macro-bundle-object.scala:10: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : : Nothing
number of parameter sections differ
diff --git a/test/files/neg/macro-invalidret.check b/test/files/neg/macro-invalidret.check
index ea003a17ec..6c5baf76b4 100644
--- a/test/files/neg/macro-invalidret.check
+++ b/test/files/neg/macro-invalidret.check
@@ -12,4 +12,24 @@ Macros_Test_2.scala:3: error: macro implementation has incompatible shape:
type mismatch for return type: reflect.runtime.universe.Literal does not conform to c.Expr[Any]
def foo2 = macro Impls.foo2
^
-two errors found
+Macros_Test_2.scala:6: error: macro defs must have explicitly specified return types
+ def foo5 = macro Impls.foo5
+ ^
+Macros_Test_2.scala:7: warning: macro defs must have explicitly specified return types (inference of Int from macro impl's c.Expr[Int] is deprecated and is going to stop working in 2.12)
+ def foo6 = macro Impls.foo6
+ ^
+Macros_Test_2.scala:14: error: exception during macro expansion:
+scala.NotImplementedError: an implementation is missing
+ at scala.Predef$.$qmark$qmark$qmark(Predef.scala:227)
+ at Impls$.foo3(Impls_1.scala:7)
+
+ foo3
+ ^
+Macros_Test_2.scala:15: error: macro implementation is missing
+ foo4
+ ^
+Macros_Test_2.scala:17: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
+ foo6
+ ^
+two warnings found
+5 errors found
diff --git a/test/files/neg/macro-invalidret.flags b/test/files/neg/macro-invalidret.flags
index cd66464f2f..946c53ec0e 100644
--- a/test/files/neg/macro-invalidret.flags
+++ b/test/files/neg/macro-invalidret.flags
@@ -1 +1,3 @@
--language:experimental.macros \ No newline at end of file
+-language:experimental.macros
+-Xfatal-warnings
+-deprecation \ No newline at end of file
diff --git a/test/files/neg/macro-invalidret/Impls_1.scala b/test/files/neg/macro-invalidret/Impls_1.scala
index d957b74512..b32463899e 100644
--- a/test/files/neg/macro-invalidret/Impls_1.scala
+++ b/test/files/neg/macro-invalidret/Impls_1.scala
@@ -4,4 +4,7 @@ import scala.reflect.runtime.{universe => ru}
object Impls {
def foo1(c: BlackboxContext) = 2
def foo2(c: BlackboxContext) = ru.Literal(ru.Constant(42))
+ def foo3(c: BlackboxContext) = ???
+ def foo5(c: BlackboxContext) = c.universe.Literal(c.universe.Constant(42))
+ def foo6(c: BlackboxContext) = c.Expr[Int](c.universe.Literal(c.universe.Constant(42)))
}
diff --git a/test/files/neg/macro-invalidret/Macros_Test_2.scala b/test/files/neg/macro-invalidret/Macros_Test_2.scala
index f8880fa023..8840f492ab 100644
--- a/test/files/neg/macro-invalidret/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidret/Macros_Test_2.scala
@@ -1,10 +1,18 @@
object Macros {
def foo1 = macro Impls.foo1
def foo2 = macro Impls.foo2
+ def foo3 = macro Impls.foo3
+ def foo4 = macro ???
+ def foo5 = macro Impls.foo5
+ def foo6 = macro Impls.foo6
}
object Test extends App {
import Macros._
foo1
foo2
+ foo3
+ foo4
+ foo5
+ foo6
} \ No newline at end of file
diff --git a/test/files/neg/macro-invalidsig-params-badtype.check b/test/files/neg/macro-invalidsig-params-badtype.check
index 6d72185ff2..d6b5c5521d 100644
--- a/test/files/neg/macro-invalidsig-params-badtype.check
+++ b/test/files/neg/macro-invalidsig-params-badtype.check
@@ -1,5 +1,5 @@
Impls_Macros_1.scala:8: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(x: Int): Nothing
type mismatch for parameter x: c.Expr[Int] does not conform to Int
diff --git a/test/files/neg/macro-invalidsig.check b/test/files/neg/macro-invalidsig.check
index e09d46146d..5ff4ed18cb 100644
--- a/test/files/neg/macro-invalidsig.check
+++ b/test/files/neg/macro-invalidsig.check
@@ -1,29 +1,29 @@
Macros_Test_2.scala:2: error: macro implementations cannot have implicit parameters other than WeakTypeTag evidences
- def foo[U] = macro Impls1.foo[U]
- ^
+ def foo[U]: Int = macro Impls1.foo[U]
+ ^
Macros_Test_2.scala:6: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : : Nothing
number of parameter sections differ
def foo = macro Impls2.foo
^
Macros_Test_2.scala:10: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : (c: scala.reflect.api.Universe): Nothing
type mismatch for parameter c: scala.reflect.macros.BlackboxContext does not conform to scala.reflect.api.Universe
def foo = macro Impls3.foo
^
Macros_Test_2.scala:14: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : (cs: scala.reflect.macros.BlackboxContext*): Nothing
types incompatible for parameter cs: corresponding is not a vararg parameter
def foo = macro Impls4.foo
^
Macros_Test_2.scala:18: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext): Nothing
number of parameter sections differ
@@ -33,35 +33,35 @@ Macros_Test_2.scala:22: error: macro implementations cannot have implicit parame
def foo[U](x: Int) = macro Impls6.foo[T, U]
^
Macros_Test_2.scala:26: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): Nothing
parameter lists have different length, found extra parameter y: c.Expr[Int]
def foo(x: Int) = macro Impls7.foo
^
Macros_Test_2.scala:30: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(x: c.universe.Symbol): Nothing
type mismatch for parameter x: c.Expr[Int] does not conform to c.universe.Symbol
def foo(x: Int) = macro Impls8.foo
^
Macros_Test_2.scala:34: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(xs: c.Expr[Int]*): Nothing
parameter lists have different length, required extra parameter y: c.Expr[Int]
def foo(x: Int, y: Int) = macro Impls9.foo
^
Macros_Test_2.scala:38: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(y: c.Expr[Int], x: c.Expr[Int]): Nothing
parameter names differ: x != y
def foo(x: Int, y: Int) = macro Impls10.foo
^
Macros_Test_2.scala:42: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(U: c.universe.Type): Nothing
number of parameter sections differ
@@ -77,9 +77,9 @@ Macros_Test_2.scala:54: error: macro implementation reference has too few type a
def foo = macro Impls14.foo
^
Macros_Test_2.scala:59: error: macro implementation reference has too few type arguments for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$5: c.WeakTypeTag[T], implicit evidence$6: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
- def foo15[V] = macro Impls15.foo
- ^
+ def foo15[V]: Unit = macro Impls15.foo
+ ^
Macros_Test_2.scala:60: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$7: c.WeakTypeTag[T], implicit evidence$8: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
- def foo16[V] = macro Impls16.foo[V]
- ^
+ def foo16[V]: Unit = macro Impls16.foo[V]
+ ^
16 errors found
diff --git a/test/files/neg/macro-invalidsig/Macros_Test_2.scala b/test/files/neg/macro-invalidsig/Macros_Test_2.scala
index 0a6a321431..89a5302d8a 100644
--- a/test/files/neg/macro-invalidsig/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidsig/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros1 {
- def foo[U] = macro Impls1.foo[U]
+ def foo[U]: Int = macro Impls1.foo[U]
}
object Macros2 {
@@ -56,8 +56,8 @@ object Macros14 {
class D[T] {
class C[U] {
- def foo15[V] = macro Impls15.foo
- def foo16[V] = macro Impls16.foo[V]
+ def foo15[V]: Unit = macro Impls15.foo
+ def foo16[V]: Unit = macro Impls16.foo[V]
}
}
diff --git a/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala
index 0b3ca0590b..cf8accf94f 100644
--- a/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala
@@ -1,4 +1,4 @@
-object Macros { def foo(x: Int) = macro Impls.foo }
+object Macros { def foo(x: Int): Int = macro Impls.foo }
import Macros._
object Test extends App {
diff --git a/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala
index 3139599108..76397701f9 100644
--- a/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo[U <: String] = macro Impls.foo[U]
+ def foo[U <: String]: Unit = macro Impls.foo[U]
}
object Test extends App {
diff --git a/test/files/neg/macro-invalidusage-badtargs.check b/test/files/neg/macro-invalidusage-badtargs.check
index 6a9e1d6e6b..722ec03765 100644
--- a/test/files/neg/macro-invalidusage-badtargs.check
+++ b/test/files/neg/macro-invalidusage-badtargs.check
@@ -1,16 +1,16 @@
-Macros_Test_2.scala:11: error: macro method foo1: (x: Int)Int does not take type parameters.
+Macros_Test_2.scala:13: error: macro method foo1: (x: Int)Int does not take type parameters.
foo1[String](42)
^
-Macros_Test_2.scala:12: error: wrong number of type parameters for macro method foo2: [T](x: Int)Int
+Macros_Test_2.scala:14: error: wrong number of type parameters for macro method foo2: [T](x: Int)Int
foo2[String, String](42)
^
-Macros_Test_2.scala:13: error: wrong number of type parameters for macro method foo3: [T, U](x: Int)Int
+Macros_Test_2.scala:15: error: wrong number of type parameters for macro method foo3: [T, U](x: Int)Int
foo3[String](42)
^
-Macros_Test_2.scala:14: error: String takes no type parameters, expected: one
+Macros_Test_2.scala:16: error: String takes no type parameters, expected: one
foo4[String](42)
^
-Macros_Test_2.scala:15: error: kinds of the type arguments (List) do not conform to the expected kinds of the type parameters (type T).
+Macros_Test_2.scala:17: error: kinds of the type arguments (List) do not conform to the expected kinds of the type parameters (type T).
List's type parameters do not match type T's expected parameters:
type A has no type parameters, but type U has one
foo5[List](42)
diff --git a/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala
index fd16d163c3..47e51bbf44 100644
--- a/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala
@@ -1,9 +1,11 @@
+import scala.language.higherKinds
+
object Macros {
- def foo1(x: Int) = macro Impls.foo
- def foo2[T](x: Int) = macro Impls.foo
- def foo3[T, U](x: Int) = macro Impls.foo
- def foo4[T[_]](x: Int) = macro Impls.foo
- def foo5[T[U[_]]](x: Int) = macro Impls.foo
+ def foo1(x: Int): Int = macro Impls.foo
+ def foo2[T](x: Int): Int = macro Impls.foo
+ def foo3[T, U](x: Int): Int = macro Impls.foo
+ def foo4[T[_]](x: Int): Int = macro Impls.foo
+ def foo5[T[U[_]]](x: Int): Int = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala
index 343cec99b5..578aa45867 100644
--- a/test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-a.check b/test/files/neg/macro-override-macro-overrides-abstract-method-a.check
index 8c8f039225..6b5d3013ba 100644
--- a/test/files/neg/macro-override-macro-overrides-abstract-method-a.check
+++ b/test/files/neg/macro-override-macro-overrides-abstract-method-a.check
@@ -1,5 +1,5 @@
Impls_Macros_1.scala:12: error: overriding method foo in trait Foo of type (x: Int)Int;
macro method foo cannot be used here - term macros cannot override abstract methods
- def foo(x: Int) = macro Impls.impl
+ def foo(x: Int): Int = macro Impls.impl
^
one error found
diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala b/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala
index 0e8a5f3b01..9c05db83e3 100644
--- a/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala
+++ b/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala
@@ -9,5 +9,5 @@ trait Foo {
}
object Macros extends Foo {
- def foo(x: Int) = macro Impls.impl
+ def foo(x: Int): Int = macro Impls.impl
}
diff --git a/test/files/neg/macro-override-method-overrides-macro.check b/test/files/neg/macro-override-method-overrides-macro.check
index e8cba5d029..e396d65ff1 100644
--- a/test/files/neg/macro-override-method-overrides-macro.check
+++ b/test/files/neg/macro-override-method-overrides-macro.check
@@ -1,5 +1,5 @@
Macros_Test_2.scala:8: error: overriding macro method foo in class B of type (x: String)Unit;
method foo cannot be used here - only term macros can override term macros
- override def foo(x: String) = println("fooDString")
+ override def foo(x: String): Unit = println("fooDString")
^
one error found
diff --git a/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala b/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala
index 36821b05d8..d47157766e 100644
--- a/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala
+++ b/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala
@@ -1,15 +1,15 @@
class B {
- def foo(x: String) = macro Impls.fooBString
- def foo(x: Int) = macro Impls.fooBInt
- def foo(x: Boolean) = println("fooBBoolean")
+ def foo(x: String): Unit = macro Impls.fooBString
+ def foo(x: Int): Unit = macro Impls.fooBInt
+ def foo(x: Boolean): Unit = println("fooBBoolean")
}
class D extends B {
- override def foo(x: String) = println("fooDString")
- override def foo(x: Int) = macro Impls.fooDInt
+ override def foo(x: String): Unit = println("fooDString")
+ override def foo(x: Int): Unit = macro Impls.fooDInt
}
class Z extends D {
- override def foo(x: String) = macro Impls.fooZString
- override def foo(x: Boolean) = println("fooZBoolean")
+ override def foo(x: String): Unit = macro Impls.fooZString
+ override def foo(x: Boolean): Unit = println("fooZBoolean")
}
diff --git a/test/files/neg/macro-quasiquotes.check b/test/files/neg/macro-quasiquotes.check
index 338ad42b23..c690b61fe1 100644
--- a/test/files/neg/macro-quasiquotes.check
+++ b/test/files/neg/macro-quasiquotes.check
@@ -1,8 +1,8 @@
Macros_1.scala:14: error: macro implementation has incompatible shape:
- required: (x: Impls.this.c.Expr[Int]): Impls.this.c.Expr[Any]
+ required: (x: Impls.this.c.Expr[Int]): Impls.this.c.Expr[Unit]
or : (x: Impls.this.c.Tree): Impls.this.c.Tree
found : (x: Impls.this.c.universe.Block): Impls.this.c.Tree
type mismatch for parameter x: Impls.this.c.Expr[Int] does not conform to Impls.this.c.universe.Block
- def m3(x: Int) = macro Impls.impl3
- ^
+ def m3(x: Int): Unit = macro Impls.impl3
+ ^
one error found
diff --git a/test/files/neg/macro-quasiquotes/Macros_1.scala b/test/files/neg/macro-quasiquotes/Macros_1.scala
index 7f0219e6ac..098e4b3b92 100644
--- a/test/files/neg/macro-quasiquotes/Macros_1.scala
+++ b/test/files/neg/macro-quasiquotes/Macros_1.scala
@@ -9,7 +9,7 @@ trait Impls extends BlackboxMacro {
}
object Macros {
- def m1(x: Int) = macro Impls.impl1
- def m2(x: Int) = macro Impls.impl2
- def m3(x: Int) = macro Impls.impl3
+ def m1(x: Int): Unit = macro Impls.impl1
+ def m2(x: Int): Unit = macro Impls.impl2
+ def m3(x: Int): Unit = macro Impls.impl3
} \ No newline at end of file
diff --git a/test/files/neg/macro-reify-splice-splice.check b/test/files/neg/macro-reify-splice-splice.check
new file mode 100644
index 0000000000..bd1ea7acee
--- /dev/null
+++ b/test/files/neg/macro-reify-splice-splice.check
@@ -0,0 +1,7 @@
+Macros_1.scala:8: error: the splice cannot be resolved statically, which means there is a cross-stage evaluation involved.
+cross-stage evaluations need to be invoked explicitly, so we're showing you this error.
+if you're sure this is not an oversight, add scala-compiler.jar to the classpath,
+import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.
+ { c.universe.reify(c.universe.reify("hello world")) }.splice.splice
+ ^
+one error found
diff --git a/test/files/run/macro-reify-splice-splice.flags b/test/files/neg/macro-reify-splice-splice.flags
index cd66464f2f..cd66464f2f 100644
--- a/test/files/run/macro-reify-splice-splice.flags
+++ b/test/files/neg/macro-reify-splice-splice.flags
diff --git a/test/files/run/macro-reify-splice-splice/Macros_1.scala b/test/files/neg/macro-reify-splice-splice/Macros_1.scala
index 691f22ad07..691f22ad07 100644
--- a/test/files/run/macro-reify-splice-splice/Macros_1.scala
+++ b/test/files/neg/macro-reify-splice-splice/Macros_1.scala
diff --git a/test/files/run/macro-reify-splice-splice/Test_2.scala b/test/files/neg/macro-reify-splice-splice/Test_2.scala
index f697da6020..f697da6020 100644
--- a/test/files/run/macro-reify-splice-splice/Test_2.scala
+++ b/test/files/neg/macro-reify-splice-splice/Test_2.scala
diff --git a/test/files/neg/patmat-classtag-compound.check b/test/files/neg/patmat-classtag-compound.check
new file mode 100644
index 0000000000..8a54c935bd
--- /dev/null
+++ b/test/files/neg/patmat-classtag-compound.check
@@ -0,0 +1,6 @@
+patmat-classtag-compound.scala:12: warning: abstract type pattern A is unchecked since it is eliminated by erasure
+ case b: A with Bar => true
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+one warning found
+one error found
diff --git a/test/files/neg/patmat-classtag-compound.flags b/test/files/neg/patmat-classtag-compound.flags
new file mode 100644
index 0000000000..144ddac9d3
--- /dev/null
+++ b/test/files/neg/patmat-classtag-compound.flags
@@ -0,0 +1 @@
+-unchecked -Xfatal-warnings
diff --git a/test/files/neg/patmat-classtag-compound.scala b/test/files/neg/patmat-classtag-compound.scala
new file mode 100644
index 0000000000..e2d0df0a02
--- /dev/null
+++ b/test/files/neg/patmat-classtag-compound.scala
@@ -0,0 +1,17 @@
+object Test extends App{
+ trait Bar
+ trait Foo
+ // Failed to give an unchecked warning pre: https://github.com/scala/scala/pull/2848
+ //
+ // Features interacting:
+ // - implicit class tags to enable type patterns on abstract types
+ // - type tests on compound types.
+ //
+ // We could try make these work together, but an unchecked warning is okay for now.
+ def x[A: reflect.ClassTag](a: Any): Boolean = a match{
+ case b: A with Bar => true
+ case _ => false
+ }
+ println(x[Foo](new Bar{}))
+ println(x[String](""))
+}
diff --git a/test/files/neg/quasiquotes-unliftable-not-found.check b/test/files/neg/quasiquotes-unliftable-not-found.check
new file mode 100644
index 0000000000..5594aa1b15
--- /dev/null
+++ b/test/files/neg/quasiquotes-unliftable-not-found.check
@@ -0,0 +1,4 @@
+quasiquotes-unliftable-not-found.scala:4: error: Can't find reflect.runtime.universe.Unliftable[Test.C], consider providing it
+ val q"${c: C}" = q"()"
+ ^
+one error found
diff --git a/test/files/neg/quasiquotes-unliftable-not-found.scala b/test/files/neg/quasiquotes-unliftable-not-found.scala
new file mode 100644
index 0000000000..6a5efae43b
--- /dev/null
+++ b/test/files/neg/quasiquotes-unliftable-not-found.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ import scala.reflect.runtime.universe._
+ class C
+ val q"${c: C}" = q"()"
+} \ No newline at end of file
diff --git a/test/files/neg/si7980.check b/test/files/neg/si7980.check
new file mode 100644
index 0000000000..b085cabf1d
--- /dev/null
+++ b/test/files/neg/si7980.check
@@ -0,0 +1,4 @@
+si7980.scala:7: error: Can't splice Nothing, bottom type values often indicate programmer mistake
+ println(q"class ${Name(X)} { }")
+ ^
+one error found
diff --git a/test/files/neg/si7980.scala b/test/files/neg/si7980.scala
new file mode 100644
index 0000000000..b21907de54
--- /dev/null
+++ b/test/files/neg/si7980.scala
@@ -0,0 +1,8 @@
+object Test extends App {
+ import scala.reflect.runtime.universe._
+ def Name[T:TypeTag](name:String): T = implicitly[TypeTag[T]] match {
+ case t => newTypeName(name).asInstanceOf[T]
+ }
+ val X = "ASDF"
+ println(q"class ${Name(X)} { }")
+}
diff --git a/test/files/neg/t4928.check b/test/files/neg/t4928.check
index 06d4f22522..18a5d57a62 100644
--- a/test/files/neg/t4928.check
+++ b/test/files/neg/t4928.check
@@ -1,5 +1,5 @@
t4928.scala:3: error: parameter 'a' is already specified at parameter position 1
-Note that that 'z' is not a parameter name of the invoked method.
+Note that 'z' is not a parameter name of the invoked method.
f(z = 0, a = 1)
^
one error found
diff --git a/test/files/neg/t5426.check b/test/files/neg/t5426.check
index c042cdcec3..98f3ddaaae 100644
--- a/test/files/neg/t5426.check
+++ b/test/files/neg/t5426.check
@@ -4,18 +4,12 @@ t5426.scala:2: warning: comparing values of types Some[Int] and Int using `==' w
t5426.scala:3: warning: comparing values of types Int and Some[Int] using `==' will always yield false
def f2 = 5 == Some(5)
^
-t5426.scala:3: warning: Int and Some[Int] are unrelated: they will most likely never compare equal
- def f2 = 5 == Some(5)
- ^
t5426.scala:8: warning: comparing values of types Int and Some[Int] using `==' will always yield false
(x1 == x2)
^
-t5426.scala:8: warning: Int and Some[Int] are unrelated: they will most likely never compare equal
- (x1 == x2)
- ^
t5426.scala:9: warning: comparing values of types Some[Int] and Int using `==' will always yield false
(x2 == x1)
^
error: No warnings can be incurred under -Xfatal-warnings.
-6 warnings found
+four warnings found
one error found
diff --git a/test/files/neg/t5663-badwarneq.check b/test/files/neg/t5663-badwarneq.check
index 4b7795585b..732e4f44d0 100644
--- a/test/files/neg/t5663-badwarneq.check
+++ b/test/files/neg/t5663-badwarneq.check
@@ -25,9 +25,6 @@ t5663-badwarneq.scala:72: warning: ValueClass1 and Int are unrelated: they will
t5663-badwarneq.scala:74: warning: comparing values of types Int and ValueClass1 using `==' will always yield false
println(5 == new ValueClass1(5)) // bad
^
-t5663-badwarneq.scala:74: warning: Int and ValueClass1 are unrelated: they will never compare equal
- println(5 == new ValueClass1(5)) // bad
- ^
t5663-badwarneq.scala:78: warning: ValueClass2[String] and String are unrelated: they will never compare equal
println(new ValueClass2("abc") == "abc") // bad
^
@@ -41,5 +38,5 @@ t5663-badwarneq.scala:82: warning: comparing values of types ValueClass3 and Int
println(ValueClass3(5) == 5) // bad
^
error: No warnings can be incurred under -Xfatal-warnings.
-14 warnings found
+13 warnings found
one error found
diff --git a/test/files/neg/t5753/Impls_Macros_1.scala b/test/files/neg/t5753/Impls_Macros_1.scala
index f93d731d40..0e81e21c77 100644
--- a/test/files/neg/t5753/Impls_Macros_1.scala
+++ b/test/files/neg/t5753/Impls_Macros_1.scala
@@ -1,6 +1,6 @@
import scala.reflect.macros.{BlackboxContext => Ctx}
trait Impls {
-def impl(c: Ctx)(x: c.Expr[Any]) = x
+ def impl(c: Ctx)(x: c.Expr[Any]) = x
}
diff --git a/test/files/neg/t5753/Test_2.scala b/test/files/neg/t5753/Test_2.scala
index f1cad67fed..150850a0eb 100644
--- a/test/files/neg/t5753/Test_2.scala
+++ b/test/files/neg/t5753/Test_2.scala
@@ -1,7 +1,7 @@
import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros extends Impls {
- def foo(x: Any) = macro impl
+ def foo(x: Any): Any = macro impl
}
object Test extends App {
diff --git a/test/files/neg/t5903a/Macros_1.scala b/test/files/neg/t5903a/Macros_1.scala
index 7888b888e1..ce1b035260 100644
--- a/test/files/neg/t5903a/Macros_1.scala
+++ b/test/files/neg/t5903a/Macros_1.scala
@@ -7,7 +7,7 @@ case object SomeTree extends Tree
object NewQuasiquotes {
implicit class QuasiquoteInterpolation(c: StringContext) {
object nq {
- def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl
+ def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl
}
}
}
diff --git a/test/files/neg/t5903b/Macros_1.scala b/test/files/neg/t5903b/Macros_1.scala
index 46f0eee0f1..dfe9d8d489 100644
--- a/test/files/neg/t5903b/Macros_1.scala
+++ b/test/files/neg/t5903b/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply[T](x: T) = macro Macros.unapplyImpl[T]
+ def unapply[T](x: T): Any = macro Macros.unapplyImpl[T]
}
}
}
diff --git a/test/files/neg/t5903c/Macros_1.scala b/test/files/neg/t5903c/Macros_1.scala
index 281a06e93c..d13c3c2ec2 100644
--- a/test/files/neg/t5903c/Macros_1.scala
+++ b/test/files/neg/t5903c/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply[T](x: T) = macro Macros.unapplyImpl[T]
+ def unapply[T](x: T): Any = macro Macros.unapplyImpl[T]
}
}
}
diff --git a/test/files/neg/t5903d/Macros_1.scala b/test/files/neg/t5903d/Macros_1.scala
index 5dd6220e1a..2d26e998a1 100644
--- a/test/files/neg/t5903d/Macros_1.scala
+++ b/test/files/neg/t5903d/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
}
}
diff --git a/test/files/neg/t5903e/Macros_1.scala b/test/files/neg/t5903e/Macros_1.scala
index 997e6fd073..5bdc25b832 100644
--- a/test/files/neg/t5903e/Macros_1.scala
+++ b/test/files/neg/t5903e/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
}
}
diff --git a/test/files/neg/t6231.check b/test/files/neg/t6231.check
deleted file mode 100644
index 2428bf66d0..0000000000
--- a/test/files/neg/t6231.check
+++ /dev/null
@@ -1,6 +0,0 @@
-t6231.scala:4: error: Implementation restriction: local trait Bug$X$1 is unable to automatically capture the
-free variable value ev$1 on behalf of <$anon: Function0>. You can manually assign it to a val inside the trait,
-and refer that that val in <$anon: Function0>. For more details, see SI-6231.
- def qux = { () => ev }
- ^
-one error found
diff --git a/test/files/neg/t6231.flags b/test/files/neg/t6231.flags
deleted file mode 100644
index ac96850b69..0000000000
--- a/test/files/neg/t6231.flags
+++ /dev/null
@@ -1 +0,0 @@
--Ydelambdafy:inline \ No newline at end of file
diff --git a/test/files/neg/t6355.check b/test/files/neg/t6355.check
deleted file mode 100644
index 607829d99a..0000000000
--- a/test/files/neg/t6355.check
+++ /dev/null
@@ -1,7 +0,0 @@
-t6355.scala:12: error: implementation restriction: applyDynamic cannot be overloaded except by methods with different numbers of type parameters, e.g. applyDynamic[T1](method: String)(arg: T1) and applyDynamic[T1, T2](method: String)(arg1: T1, arg2: T2)
- def applyDynamic(name: String)(x: Int): Int = 2
- ^
-t6355.scala:18: error: implementation restriction: applyDynamic cannot be overloaded except by methods with different numbers of type parameters, e.g. applyDynamic[T1](method: String)(arg: T1) and applyDynamic[T1, T2](method: String)(arg1: T1, arg2: T2)
- def applyDynamic[T1, T2](name: String)(x: String, y: T1, z: T2): Int = 3
- ^
-two errors found
diff --git a/test/files/neg/t6355a.check b/test/files/neg/t6355a.check
new file mode 100644
index 0000000000..5768d31f0b
--- /dev/null
+++ b/test/files/neg/t6355a.check
@@ -0,0 +1,7 @@
+t6355a.scala:12: error: implementation restriction: applyDynamic cannot be overloaded except by methods with different numbers of type parameters, e.g. applyDynamic[T1](method: String)(arg: T1) and applyDynamic[T1, T2](method: String)(arg1: T1, arg2: T2)
+ def applyDynamic(name: String)(x: Int): Int = 2
+ ^
+t6355a.scala:18: error: implementation restriction: applyDynamic cannot be overloaded except by methods with different numbers of type parameters, e.g. applyDynamic[T1](method: String)(arg: T1) and applyDynamic[T1, T2](method: String)(arg1: T1, arg2: T2)
+ def applyDynamic[T1, T2](name: String)(x: String, y: T1, z: T2): Int = 3
+ ^
+two errors found
diff --git a/test/files/neg/t6355.scala b/test/files/neg/t6355a.scala
index 0500ed04c6..0500ed04c6 100644
--- a/test/files/neg/t6355.scala
+++ b/test/files/neg/t6355a.scala
diff --git a/test/files/neg/t6355b.check b/test/files/neg/t6355b.check
new file mode 100644
index 0000000000..f827f07e53
--- /dev/null
+++ b/test/files/neg/t6355b.check
@@ -0,0 +1,11 @@
+t6355b.scala:14: error: value applyDynamic is not a member of A
+error after rewriting to x.<applyDynamic: error>("bippy")
+possible cause: maybe a wrong Dynamic method signature?
+ println(x.bippy(42))
+ ^
+t6355b.scala:15: error: value applyDynamic is not a member of A
+error after rewriting to x.<applyDynamic: error>("bippy")
+possible cause: maybe a wrong Dynamic method signature?
+ println(x.bippy("42"))
+ ^
+two errors found
diff --git a/test/files/neg/t6355b.scala b/test/files/neg/t6355b.scala
new file mode 100644
index 0000000000..5f3c97cb0c
--- /dev/null
+++ b/test/files/neg/t6355b.scala
@@ -0,0 +1,17 @@
+import scala.language.dynamics
+
+class A extends Dynamic {
+ def selectDynamic(method: String): B = new B(method)
+}
+class B(method: String) {
+ def apply(x: Int) = s"$method(x: Int) called with x = $x"
+ def apply(x: String) = s"""$method(x: String) called with x = "$x""""
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val x = new A
+ println(x.bippy(42))
+ println(x.bippy("42"))
+ }
+}
diff --git a/test/files/neg/t6446-missing.check b/test/files/neg/t6446-missing.check
index cd867289c3..029c8057c3 100755
--- a/test/files/neg/t6446-missing.check
+++ b/test/files/neg/t6446-missing.check
@@ -1,4 +1,4 @@
-Warning: class not found: t6446.Ploogin
+Error: unable to load class: t6446.Ploogin
phase name id description
---------- -- -----------
parser 1 parse source into ASTs, perform simple desugaring
diff --git a/test/files/neg/t6539.check b/test/files/neg/t6539.check
index b647636338..8c94a8ad4c 100644
--- a/test/files/neg/t6539.check
+++ b/test/files/neg/t6539.check
@@ -7,4 +7,10 @@ Test_2.scala:3: error: cto may only be used as an argument to m
Test_2.scala:5: error: cto may only be used as an argument to m
M.cto // error
^
-three errors found
+Test_2.scala:9: error: splice must be enclosed within a reify {} block
+ val splice = expr.splice
+ ^
+Test_2.scala:10: error: cannot use value except for signatures of macro implementations
+ val value = expr.value
+ ^
+5 errors found
diff --git a/test/files/neg/t6920.check b/test/files/neg/t6920.check
new file mode 100644
index 0000000000..ee4eafb83e
--- /dev/null
+++ b/test/files/neg/t6920.check
@@ -0,0 +1,6 @@
+t6920.scala:9: error: too many arguments for method applyDynamicNamed: (values: Seq[(String, Any)])String
+error after rewriting to CompilerError.this.test.applyDynamicNamed("crushTheCompiler")(scala.Tuple2("a", 1), scala.Tuple2("b", 2))
+possible cause: maybe a wrong Dynamic method signature?
+ test.crushTheCompiler(a = 1, b = 2)
+ ^
+one error found
diff --git a/test/files/neg/t6920.scala b/test/files/neg/t6920.scala
new file mode 100644
index 0000000000..b79d641698
--- /dev/null
+++ b/test/files/neg/t6920.scala
@@ -0,0 +1,10 @@
+import scala.language.dynamics
+
+class DynTest extends Dynamic {
+ def applyDynamicNamed(name: String)(values: Seq[(String, Any)]) = "test"
+}
+
+class CompilerError {
+ val test = new DynTest
+ test.crushTheCompiler(a = 1, b = 2)
+} \ No newline at end of file
diff --git a/test/files/neg/t712.check b/test/files/neg/t712.check
index 6819dc0ce9..831e943063 100644
--- a/test/files/neg/t712.check
+++ b/test/files/neg/t712.check
@@ -1,4 +1,5 @@
t712.scala:10: error: value self is not a member of B.this.ParentImpl
+ Note: implicit method coerce is not applicable here because it comes after the application point and it lacks an explicit result type
implicit def coerce(p : ParentImpl) = p.self;
^
one error found
diff --git a/test/files/neg/t7519-b.check b/test/files/neg/t7519-b.check
index 08d819eeec..bc8500b2b8 100644
--- a/test/files/neg/t7519-b.check
+++ b/test/files/neg/t7519-b.check
@@ -1,4 +1,4 @@
-Use_2.scala:6: error: type mismatch;
+Use_2.scala:8: error: type mismatch;
found : String
required: Q
val x: Q = ex.Mac.mac("asdf")
diff --git a/test/files/neg/t7519-b/Use_2.scala b/test/files/neg/t7519-b/Use_2.scala
index 413e40e25e..0d63eeed5b 100644
--- a/test/files/neg/t7519-b/Use_2.scala
+++ b/test/files/neg/t7519-b/Use_2.scala
@@ -1,3 +1,5 @@
+import scala.language.implicitConversions
+
trait Q
trait K
diff --git a/test/files/neg/t7756b.check b/test/files/neg/t7756b.check
index e764783241..2817a7e230 100644
--- a/test/files/neg/t7756b.check
+++ b/test/files/neg/t7756b.check
@@ -1,9 +1,6 @@
t7756b.scala:3: warning: comparing values of types Int and String using `==' will always yield false
case _ => 0 == ""
^
-t7756b.scala:3: warning: Int and String are unrelated: they will most likely never compare equal
- case _ => 0 == ""
- ^
error: No warnings can be incurred under -Xfatal-warnings.
-two warnings found
+one warning found
one error found
diff --git a/test/files/neg/t8006.check b/test/files/neg/t8006.check
new file mode 100644
index 0000000000..fbac26e3ad
--- /dev/null
+++ b/test/files/neg/t8006.check
@@ -0,0 +1,6 @@
+t8006.scala:3: error: too many arguments for method applyDynamicNamed: (value: (String, Any))String
+error after rewriting to X.this.d.applyDynamicNamed("meth")(scala.Tuple2("value1", 10), scala.Tuple2("value2", 100))
+possible cause: maybe a wrong Dynamic method signature?
+ d.meth(value1 = 10, value2 = 100) // two arguments here, but only one is allowed
+ ^
+one error found
diff --git a/test/files/neg/t8006.scala b/test/files/neg/t8006.scala
new file mode 100644
index 0000000000..b2f71c1587
--- /dev/null
+++ b/test/files/neg/t8006.scala
@@ -0,0 +1,8 @@
+object X {
+ val d = new D
+ d.meth(value1 = 10, value2 = 100) // two arguments here, but only one is allowed
+}
+import language.dynamics
+class D extends Dynamic {
+ def applyDynamicNamed(name: String)(value: (String, Any)) = name
+} \ No newline at end of file
diff --git a/test/files/neg/t8024.check b/test/files/neg/t8024.check
new file mode 100644
index 0000000000..bd551aa591
--- /dev/null
+++ b/test/files/neg/t8024.check
@@ -0,0 +1,6 @@
+t8024.scala:13: error: reference to sqrt is ambiguous;
+it is both defined in package object p and imported subsequently by
+import java.lang.Math.sqrt
+ sqrt(0d)
+ ^
+one error found
diff --git a/test/files/neg/t8024.scala b/test/files/neg/t8024.scala
new file mode 100644
index 0000000000..b4c2c5ebb9
--- /dev/null
+++ b/test/files/neg/t8024.scala
@@ -0,0 +1,14 @@
+package p
+
+trait NRoot[A]
+
+object `package` {
+ final def sqrt(x: Double): Double = Math.sqrt(x)
+ final def sqrt[A](a: A)(implicit ev: NRoot[A]): A = ???
+}
+
+object FastComplex {
+ import java.lang.Math.sqrt
+
+ sqrt(0d)
+}
diff --git a/test/files/neg/t8024b.check b/test/files/neg/t8024b.check
new file mode 100644
index 0000000000..9cd89bca53
--- /dev/null
+++ b/test/files/neg/t8024b.check
@@ -0,0 +1,6 @@
+t8024b.scala:15: error: reference to sqrt is ambiguous;
+it is both defined in object FastComplex and imported subsequently by
+import java.lang.Math.sqrt
+ sqrt(0d)
+ ^
+one error found
diff --git a/test/files/neg/t8024b.scala b/test/files/neg/t8024b.scala
new file mode 100644
index 0000000000..cf3d496365
--- /dev/null
+++ b/test/files/neg/t8024b.scala
@@ -0,0 +1,17 @@
+package p
+
+trait NRoot[A]
+
+object FastComplex {
+ final def sqrt(x: Double): Double = Math.sqrt(x)
+ final def sqrt[A](a: A)(implicit ev: NRoot[A]): A = ???
+
+ object Inner {
+ import java.lang.Math.sqrt
+
+ // wrong message:
+ // error: reference to sqrt is ambiguous;
+ // it is both defined in object FastComplex and imported subsequently by
+ sqrt(0d)
+ }
+}
diff --git a/test/files/neg/t8104.check b/test/files/neg/t8104.check
new file mode 100644
index 0000000000..69b3461bd5
--- /dev/null
+++ b/test/files/neg/t8104.check
@@ -0,0 +1,4 @@
+Test_2.scala:20: error: could not find implicit value for parameter e: Generic.Aux[Test.C,(Int, Int)]
+ implicitly[Generic.Aux[C, (Int, Int)]]
+ ^
+one error found
diff --git a/test/files/neg/t8104/Macros_1.scala b/test/files/neg/t8104/Macros_1.scala
new file mode 100644
index 0000000000..21d81a3687
--- /dev/null
+++ b/test/files/neg/t8104/Macros_1.scala
@@ -0,0 +1,11 @@
+import scala.reflect.macros.WhiteboxContext
+
+object Macros {
+ def impl[T](c: WhiteboxContext)(implicit T: c.WeakTypeTag[T]) = {
+ import c.universe._
+ import definitions._
+ val fields = T.tpe.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x }
+ val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.typeSignature))
+ q"new Generic[$T]{ type Repr = $Repr }"
+ }
+} \ No newline at end of file
diff --git a/test/files/neg/t8104/Test_2.scala b/test/files/neg/t8104/Test_2.scala
new file mode 100644
index 0000000000..585f76c00f
--- /dev/null
+++ b/test/files/neg/t8104/Test_2.scala
@@ -0,0 +1,21 @@
+trait Generic[T] { type Repr }
+object Generic {
+ type Aux[T, Repr0] = Generic[T] { type Repr = Repr0 }
+ import scala.language.experimental.macros
+ implicit def materializeGeneric[T]: Generic[T] = macro Macros.impl[T]
+}
+
+object Test extends App {
+ case class C(x: Int, y: Int)
+
+ import scala.reflect.runtime.universe._
+ def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: TypeTag[Repr]) = println(tag)
+ reprify(C(40, 2))
+
+ // this is a compilation error at the moment as explained in SI-8104
+ // because matchesPt in implicit search says that depoly(<type of materializeGeneric>) isn't a subtype of Generic.Aux[C, (Int, Int)]
+ // which is rightfully so, because depoly only replaces type parameters, not type members with wildcard types
+ // however in the future we might want to relax the matchesPt check, so this might start compiling
+ // therefore, if you've broken this test, then you should be happy, because most likely you've just enabled an interesting use case!
+ implicitly[Generic.Aux[C, (Int, Int)]]
+}
diff --git a/test/files/pos/attachments-typed-another-ident/Impls_1.scala b/test/files/pos/attachments-typed-another-ident/Impls_1.scala
index f84e56d714..6271359921 100644
--- a/test/files/pos/attachments-typed-another-ident/Impls_1.scala
+++ b/test/files/pos/attachments-typed-another-ident/Impls_1.scala
@@ -8,7 +8,7 @@ object Macros {
import c.universe._
val ident = Ident(TermName("bar")) updateAttachment MyAttachment
assert(ident.attachments.get[MyAttachment.type].isDefined, ident.attachments)
- val typed = c.typeCheck(ident)
+ val typed = c.typecheck(ident)
assert(typed.attachments.get[MyAttachment.type].isDefined, typed.attachments)
c.Expr[Int](typed)
}
diff --git a/test/files/pos/attachments-typed-ident/Impls_1.scala b/test/files/pos/attachments-typed-ident/Impls_1.scala
index 11d0f65844..f24ea88a5d 100644
--- a/test/files/pos/attachments-typed-ident/Impls_1.scala
+++ b/test/files/pos/attachments-typed-ident/Impls_1.scala
@@ -8,7 +8,7 @@ object Macros {
import c.universe._
val ident = Ident(TermName("bar")) updateAttachment MyAttachment
assert(ident.attachments.get[MyAttachment.type].isDefined, ident.attachments)
- val typed = c.typeCheck(ident)
+ val typed = c.typecheck(ident)
assert(typed.attachments.get[MyAttachment.type].isDefined, typed.attachments)
c.Expr[Int](typed)
}
diff --git a/test/files/pos/macro-implicit-invalidate-on-error.scala b/test/files/pos/macro-implicit-invalidate-on-error.scala
index 22cd2d34b4..f9756d965f 100644
--- a/test/files/pos/macro-implicit-invalidate-on-error.scala
+++ b/test/files/pos/macro-implicit-invalidate-on-error.scala
@@ -1,23 +1,20 @@
-package scala.reflect
-package api
-
import scala.language.experimental.macros
import scala.reflect.macros.Context
-trait Liftable[T] {
- def apply(universe: api.Universe, value: T): universe.Tree
+trait LegacyLiftable[T] {
+ def apply(universe: scala.reflect.api.Universe, value: T): universe.Tree
}
-object Liftable {
- implicit def liftCaseClass[T <: Product]: Liftable[T] = macro liftCaseClassImpl[T]
+object LegacyLiftable {
+ implicit def liftCaseClass[T <: Product]: LegacyLiftable[T] = macro liftCaseClassImpl[T]
- def liftCaseClassImpl[T: c.WeakTypeTag](c: Context): c.Expr[Liftable[T]] = {
+ def liftCaseClassImpl[T: c.WeakTypeTag](c: Context): c.Expr[LegacyLiftable[T]] = {
import c.universe._
val tpe = weakTypeOf[T]
if (!tpe.typeSymbol.asClass.isCaseClass) c.abort(c.enclosingPosition, "denied")
val p = List(q"Literal(Constant(1))")
- c.Expr[Liftable[T]] { q"""
- new scala.reflect.api.Liftable[$tpe] {
+ c.Expr[LegacyLiftable[T]] { q"""
+ new LegacyLiftable[$tpe] {
def apply(universe: scala.reflect.api.Universe, value: $tpe): universe.Tree = {
import universe._
Apply(Select(Ident(TermName("C")), TermName("apply")), List(..$p))
diff --git a/test/files/pos/t5508-min-okay.scala b/test/files/pos/t5508-min-okay.scala
new file mode 100644
index 0000000000..3a38b9c5ea
--- /dev/null
+++ b/test/files/pos/t5508-min-okay.scala
@@ -0,0 +1,6 @@
+object Test {
+ trait NestedTrait { // must be nested and a trait
+ private val _st : Int = 0 // crashes if changed to private[this]
+ val escape = { () => _st }
+ }
+}
diff --git a/test/files/pos/t5508-min-okay2.scala b/test/files/pos/t5508-min-okay2.scala
new file mode 100644
index 0000000000..935f28609c
--- /dev/null
+++ b/test/files/pos/t5508-min-okay2.scala
@@ -0,0 +1,4 @@
+trait TopTrait { // must be nested and a trait
+ private[this] val _st : Int = 0 // crashes if TopTrait is not top level
+ val escape = { () => _st }
+}
diff --git a/test/files/pos/t5508-min.scala b/test/files/pos/t5508-min.scala
new file mode 100644
index 0000000000..f59d2bd6ad
--- /dev/null
+++ b/test/files/pos/t5508-min.scala
@@ -0,0 +1,6 @@
+object Test {
+ trait NestedTrait { // must be nested and a trait
+ private[this] val _st : Int = 0 // must be private[this]
+ val escape = { () => _st }
+ }
+}
diff --git a/test/files/pos/t5508.scala b/test/files/pos/t5508.scala
new file mode 100644
index 0000000000..2b49758045
--- /dev/null
+++ b/test/files/pos/t5508.scala
@@ -0,0 +1,83 @@
+package TestTestters
+
+trait Test1 {
+ private[this] var _st : Int = 0
+ def close : PartialFunction[Any,Any] = {
+ case x : Int =>
+ _st = identity(_st)
+ }
+}
+
+object Base1 {
+ trait Test2 {
+ private[this] var _st : Int = 0
+ def close : PartialFunction[Any,Any] = {
+ case x : Int =>
+ _st = identity(_st)
+ }
+ }
+}
+
+class Test3 {
+ private[this] var _st : Int = 0
+ def close : PartialFunction[Any,Any] = {
+ case x : Int =>
+ _st = 1
+ }
+}
+
+object Base2 {
+ class Test4 {
+ private[this] var _st : Int = 0
+ def close : PartialFunction[Any,Any] = {
+ case x : Int =>
+ _st = 1
+ }
+ }
+}
+
+class Base3 {
+ trait Test5 {
+ private[this] var _st : Int = 0
+ def close : PartialFunction[Any,Any] = {
+ case x : Int =>
+ _st = 1
+ }
+ }
+}
+
+object Base4 {
+ trait Test6 {
+ private[this] var _st : Int = 0
+ def close : PartialFunction[Any,Any] = {
+ case x : Int => ()
+ }
+ }
+}
+
+object Base5 {
+ trait Test7 {
+ private[this] var _st : Int = 0
+ def close = () => {
+ _st = 1
+ }
+ }
+}
+
+object Base6 {
+ class Test8 {
+ private[this] var _st : Int = 0
+ def close = () => {
+ _st = 1
+ }
+ }
+}
+
+object Base7 {
+ trait Test9 {
+ var st : Int = 0
+ def close = () => {
+ st = 1
+ }
+ }
+}
diff --git a/test/files/neg/t6231.scala b/test/files/pos/t6231.scala
index 1e5b4e0e1a..1e5b4e0e1a 100644
--- a/test/files/neg/t6231.scala
+++ b/test/files/pos/t6231.scala
diff --git a/test/files/pos/t6231b.scala b/test/files/pos/t6231b.scala
new file mode 100644
index 0000000000..b4ddfe785b
--- /dev/null
+++ b/test/files/pos/t6231b.scala
@@ -0,0 +1,8 @@
+class Test {
+ def f1(t: String) = {
+ trait T {
+ def xs = Nil map (_ => t)
+ }
+ ()
+ }
+}
diff --git a/test/files/pos/t6780.scala b/test/files/pos/t6780.scala
new file mode 100644
index 0000000000..4a358046c6
--- /dev/null
+++ b/test/files/pos/t6780.scala
@@ -0,0 +1,20 @@
+object O {
+ implicit def i: Int = 0
+}
+
+import O._
+
+trait Foo {
+ implicit val v1: Any
+ implicit def d1: Any
+ val v2: Any
+ implicit val v3: Any
+}
+
+trait Bar1 extends Foo {
+ implicit val v1 = {implicitly[Int]; ()} // failed due to cycle in Context#implicits being broken with Nil.
+ def d1 = {implicitly[Int]; ()} // okay
+ implicit val v2 = {implicitly[Int]; ()} // okay
+ implicit val v3: Any = {implicitly[Int]; ()} // okay
+
+}
diff --git a/test/files/pos/t7377/Macro_1.scala b/test/files/pos/t7377/Macro_1.scala
index bb7ffb0f10..7280cfeaf5 100644
--- a/test/files/pos/t7377/Macro_1.scala
+++ b/test/files/pos/t7377/Macro_1.scala
@@ -2,6 +2,6 @@ import language.experimental._
import reflect.macros.BlackboxContext
object M {
- def noopImpl[A](c: BlackboxContext)(expr: c.Expr[A]): c.Expr[A] = c.Expr(c.typeCheck(c.resetLocalAttrs(expr.tree)))
+ def noopImpl[A](c: BlackboxContext)(expr: c.Expr[A]): c.Expr[A] = c.Expr(c.typecheck(c.resetLocalAttrs(expr.tree)))
def noop[A](expr: A): A = macro noopImpl[A]
}
diff --git a/test/files/pos/t7461/Macros_1.scala b/test/files/pos/t7461/Macros_1.scala
index 126e9c067a..89ae7c70e3 100644
--- a/test/files/pos/t7461/Macros_1.scala
+++ b/test/files/pos/t7461/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Macros {
def impl(c: BlackboxContext) = {
import c.universe._
- val wut = c.typeCheck(Select(Literal(Constant(10)), newTermName("$minus")), silent = true)
+ val wut = c.typecheck(Select(Literal(Constant(10)), newTermName("$minus")), silent = true)
// println(showRaw(wut, printIds = true, printTypes = true))
c.Expr[Unit](q"()")
}
diff --git a/test/files/pos/t8001/Macros_1.scala b/test/files/pos/t8001/Macros_1.scala
index 1f8dab51c1..fd26016d4b 100644
--- a/test/files/pos/t8001/Macros_1.scala
+++ b/test/files/pos/t8001/Macros_1.scala
@@ -2,7 +2,7 @@ import scala.language.experimental.macros
import scala.reflect.macros.BlackboxContext
object Macros {
- def foo = macro impl
+ def foo: Unit = macro impl
def impl(c: BlackboxContext) = {
import c.universe._
q"()"
diff --git a/test/files/pos/t8013.flags b/test/files/pos/t8013.flags
new file mode 100644
index 0000000000..954eaba352
--- /dev/null
+++ b/test/files/pos/t8013.flags
@@ -0,0 +1 @@
+-Xfatal-warnings -Xlint
diff --git a/test/files/pos/t8013/inpervolated_2.scala b/test/files/pos/t8013/inpervolated_2.scala
new file mode 100644
index 0000000000..90e571b42c
--- /dev/null
+++ b/test/files/pos/t8013/inpervolated_2.scala
@@ -0,0 +1,11 @@
+/*
+ * scalac: -Xfatal-warnings -Xlint
+ */
+package t8013
+
+// unsuspecting user of perverse macro
+trait User {
+ import Perverse.Impervolator
+ val foo = "bar"
+ Console println p"Hello, $foo"
+}
diff --git a/test/files/pos/t8013/inpervolator_1.scala b/test/files/pos/t8013/inpervolator_1.scala
new file mode 100644
index 0000000000..fb71571afc
--- /dev/null
+++ b/test/files/pos/t8013/inpervolator_1.scala
@@ -0,0 +1,33 @@
+
+package t8013
+
+// perverse macro to confuse Xlint
+
+import scala.language.experimental.macros
+import scala.reflect.macros.{ BlackboxContext => Context }
+
+object Perverse {
+
+ implicit class Impervolator(sc: StringContext) {
+ def p(args: Any*): String = macro pImpl
+ }
+
+ // turn a nice interpolation into something that looks
+ // nothing like an interpolation or anything we might
+ // recognize, but which includes a "$id" in an apply.
+ def pImpl(c: Context)(args: c.Expr[Any]*): c.Expr[String] = {
+ import c.universe._
+ val macroPos = c.macroApplication.pos
+ val text = macroPos.lineContent substring macroPos.column
+ val tt = Literal(Constant(text))
+ val tree = q"t8013.Perverse.pervert($tt)"
+ c.Expr[String](tree)
+ }
+
+ // identity doesn't seem very perverse in this context
+ //def pervert(text: String): String = text
+ def pervert(text: String): String = {
+ Console println s"Perverting [$text]"
+ text
+ }
+}
diff --git a/test/files/pos/t8054.scala b/test/files/pos/t8054.scala
new file mode 100644
index 0000000000..a7bb44b1ed
--- /dev/null
+++ b/test/files/pos/t8054.scala
@@ -0,0 +1,31 @@
+trait D {
+ trait Manifest {
+ class Entry
+ }
+
+ val M: Manifest
+
+ def m: M.Entry = ???
+}
+
+object D1 extends D {
+ object M extends Manifest
+}
+
+object D2 extends D {
+ val M: Manifest = ???
+}
+
+object Hello {
+
+ def main(args: Array[String]) {
+ // 2.10.3 - ok
+ // 2.11.0-M7 - type mismatch; found : Seq[DB1.MANIFEST.Entry]
+ // required: Seq[DB1.MANIFEST.Entry]
+ val t1: D1.M.Entry = D1.m
+
+ // 2.10.3 - ok
+ // 2.11.0-M7 - ok
+ val t2: D2.M.Entry = D2.m
+ }
+}
diff --git a/test/files/pos/t8060.scala b/test/files/pos/t8060.scala
new file mode 100644
index 0000000000..90e014d74b
--- /dev/null
+++ b/test/files/pos/t8060.scala
@@ -0,0 +1,11 @@
+trait M[F[_]]
+
+trait P[A] {
+ type CC[X] = P[X]
+ def f(p: A => Boolean): M[CC]
+}
+
+trait Other {
+ // was infinite loop trying to dealias `x$1.CC`
+ def g[A](p: A => Boolean): P[A] => M[P] = _ f p
+}
diff --git a/test/files/presentation/ide-t1001326.check b/test/files/presentation/ide-t1001326.check
deleted file mode 100644
index 0ac15faed4..0000000000
--- a/test/files/presentation/ide-t1001326.check
+++ /dev/null
@@ -1,4 +0,0 @@
-Unique OK
-Unattributed OK
-NeverModify OK
-AlwaysParseTree OK \ No newline at end of file
diff --git a/test/files/presentation/ide-t1001326/src/a/A.scala b/test/files/presentation/ide-t1001326/src/a/A.scala
deleted file mode 100644
index c82ca02231..0000000000
--- a/test/files/presentation/ide-t1001326/src/a/A.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-package a
-
-class A {
- def foo(s: String) = s + s
-} \ No newline at end of file
diff --git a/test/files/presentation/parse-invariants.check b/test/files/presentation/parse-invariants.check
new file mode 100644
index 0000000000..32e9c846ab
--- /dev/null
+++ b/test/files/presentation/parse-invariants.check
@@ -0,0 +1,5 @@
+NoNewSymbolsEntered OK
+Unique OK
+Unattributed OK
+NeverModify OK
+AlwaysParseTree OK
diff --git a/test/files/presentation/ide-t1001326/Test.scala b/test/files/presentation/parse-invariants/Test.scala
index ff63b9770a..128896ccaa 100644
--- a/test/files/presentation/ide-t1001326/Test.scala
+++ b/test/files/presentation/parse-invariants/Test.scala
@@ -6,16 +6,32 @@ object Test extends InteractiveTest {
override def execute(): Unit = {
val sf = sourceFiles.find(_.file.name == "A.scala").head
- uniqueParseTree_t1001326(sf)
- unattributedParseTree_t1001326(sf)
- neverModifyParseTree_t1001326(sf)
- shouldAlwaysReturnParseTree_t1001326(sf)
+ noNewSymbols(sf)
+ uniqueParseTree(sf)
+ unattributedParseTree(sf)
+ neverModifyParseTree(sf)
+ shouldAlwaysReturnParseTree(sf)
+ }
+
+ /**
+ * Asking for a parseTree should not enter any new symbols.
+ */
+ private def noNewSymbols(sf: SourceFile) {
+ def nextId() = compiler.NoSymbol.newTermSymbol(compiler.TermName("dummy"), compiler.NoPosition, compiler.NoFlags).id
+ val id = nextId()
+ val tree = compiler.parseTree(sf)
+ val id2 = nextId()
+ if (id2 == id + 1) {
+ reporter.println("NoNewSymbolsEntered OK")
+ } else {
+ reporter.println("NoNewSymbolsEntered FAILED")
+ }
}
/**
* Asking twice for a parseTree on the same source should always return a new tree
*/
- private def uniqueParseTree_t1001326(sf: SourceFile) {
+ private def uniqueParseTree(sf: SourceFile) {
val parseTree1 = compiler.parseTree(sf)
val parseTree2 = compiler.parseTree(sf)
if (parseTree1 != parseTree2) {
@@ -28,7 +44,7 @@ object Test extends InteractiveTest {
/**
* A parseTree should never contain any symbols or types
*/
- private def unattributedParseTree_t1001326(sf: SourceFile) {
+ private def unattributedParseTree(sf: SourceFile) {
if (noSymbolsOrTypes(compiler.parseTree(sf))) {
reporter.println("Unattributed OK")
} else {
@@ -39,7 +55,7 @@ object Test extends InteractiveTest {
/**
* Once you have obtained a parseTree it should never change
*/
- private def neverModifyParseTree_t1001326(sf: SourceFile) {
+ private def neverModifyParseTree(sf: SourceFile) {
val parsedTree = compiler.parseTree(sf)
loadSourceAndWaitUntilTypechecked(sf)
if (noSymbolsOrTypes(parsedTree)) {
@@ -52,7 +68,7 @@ object Test extends InteractiveTest {
/**
* Should always return a parse tree
*/
- private def shouldAlwaysReturnParseTree_t1001326(sf: SourceFile) {
+ private def shouldAlwaysReturnParseTree(sf: SourceFile) {
loadSourceAndWaitUntilTypechecked(sf)
if (noSymbolsOrTypes(compiler.parseTree(sf))) {
reporter.println("AlwaysParseTree OK")
diff --git a/test/files/presentation/parse-invariants/src/a/A.scala b/test/files/presentation/parse-invariants/src/a/A.scala
new file mode 100644
index 0000000000..1ae78cad05
--- /dev/null
+++ b/test/files/presentation/parse-invariants/src/a/A.scala
@@ -0,0 +1,138 @@
+package syntax
+
+object Terms {
+ object Literals {
+ 0
+ 0l
+ 0f
+ 0d
+ 0xb33f
+ 'c'
+ "string"
+ """
+ multi-line
+ string
+ """
+ 'symbol
+ true
+ false
+ null
+ ()
+ }
+
+ object Patterns {
+ 0 match { case 0 => }
+ 1 match { case (0 | 1) => }
+ 2 match { case _: Int => }
+ 3 match { case _ => }
+ Some(0) match { case Some(0) => }
+ Some(0) match { case name @ Some(_) => }
+ Some(Some(0)) match { case nested @ Some(deeper @ Some(_)) => }
+ List(1, 2, 3) match { case unapplySeq @ List(1, 2, _*) => }
+ 0 match { case i if i > 0 => }
+ List(1) match { case _: List[t] => List.empty[t] }
+ }
+
+ object New {
+ class Foo
+ trait Bar
+ new Foo
+ new Foo { selfie => }
+ new Foo with Bar
+ new { val early = 1 } with Bar
+ new { val name = "anon "}
+ }
+
+ def tuple = (1, 'two, "three")
+ def lambda = (x: Int, y: Int) => x + y
+ def lambda2 = (_: Int) + (_: Int)
+ def blocks = { { {}; {} }; {} }
+ def ascription = (1: Int)
+ def select = Nil.size
+ def method1 = "s".replace("foo", "bar")
+ def method2 = "s" + "s"
+ def method3 = Nil.foreach { e => }
+ def method4 = 1 :: 2 :: 3 :: Nil
+ def if1 = if (true) true else false
+ def if2 = if (true) true
+ def `return`: Int = { return 0 }
+ def `throw` = throw new Exception
+ def `match` = 0 match { case 0 => case _ => }
+ def `try` = try 0 catch { case _ => } finally 0
+ def `while` = while(true) 0
+ def `do while` = do 0 while(true)
+ def `for` = for (i <- 1 to 10; if i % 2 == 0; j = i + 1) j
+ def `for yield` = for (a <- List(List(1)); b <- a; c = b * 2) yield b
+ def interpolation = s"$tuple and maybe also $blocks"
+ def assign = { var x = 1; x = 2 }
+ def assign2 = { object o { var x = 1 }; o.x = 2 }
+ def update = { val v = collection.mutable.Seq(1); v(0) = 2 }
+ def `this` = this
+}
+
+object Types {
+ type Reference = scala.App
+ type Tuple = (Int, String, Double)
+ type Function = (Int, String) => Double
+ type Refined = Int { val meta: Any }
+ type Lambda = ({ type F[T] = List[T] })#F[_]
+ type Infix = Int Either String
+ type Application = List[Int]
+ type Existential = List[T] forSome { type T }
+ object O { type T = Int }
+ type Dependent = O.T
+ class O { type T = Int }
+ type Selection = O#T
+}
+
+object Definitions {
+ private val x1 = 0
+ private[this] val x2 = 0
+ private[Definitions] val x3 = 0
+ protected val x4 = 0
+ protected[AcessManagement] val x5 = 0
+ val x1 = 1
+ val x2: Int = 1
+ val x3, y3 = 1
+ lazy val x4 = 1
+ implicit val x5 = 1
+ final val x6 = 1
+ lazy final val x7 = 1
+ val Some(x8) = Some(0)
+ var x9 = 1
+ var x10, y10 = 1
+ var x11: Int = 1
+
+ implicit def implicitView: Option[Int] = None
+ def implicitArg1(implicit i: Int) = i + 2
+ def implicitArg2[T: Fooable] = implicitly[Fooable[T]]
+ def bound1[T <: Int](x: T): T = x
+ def bound2[T >: Any](x: T): T = x
+ def bound3[T <% Int](x: T): Int = x
+ def vararg(args: Int*) = args.toList
+ def sum(x: Int, y: Int) = x + y
+ def multipleArgLists(x: Int)(y: Int) = x + y
+
+ type _0 = Int
+ type _1[T] = List[T]
+ type _2[A, B] = Either[A, B]
+
+ class Val(value: Int) extends AnyVal
+ implicit class Impl(value: Int) { def foo = "foo" }
+ abstract class Abs
+ sealed class Sealed
+ class Child extends Sealed
+ case class Point(x: Int, y: Int)
+
+ trait Fooable[T]
+ trait Barable with Fooable[Barable]
+
+ object Foo
+ object Foo with Fooable[Foo]
+ case object Zero
+}
+
+package Packages {
+ package object PackageObject
+ package Nested { package Deeper { } }
+}
diff --git a/test/files/presentation/scope-completion-2.check b/test/files/presentation/scope-completion-2.check
index 3a1dbd7cff..d94f7a4b56 100644
--- a/test/files/presentation/scope-completion-2.check
+++ b/test/files/presentation/scope-completion-2.check
@@ -1,12 +1,11 @@
reload: Completions.scala
-askScopeCompletion at Completions.scala(16,4)
+askScopeCompletion at Completions.scala(15,2)
================================================================================
-[response] askScopeCompletion at (16,4)
-retrieved 11 members
+[response] askScopeCompletion at (15,2)
+retrieved 10 members
class Completion1 extends AnyRef
def <init>(): test.Completion1
-def test: Unit
object Completion1
private class Cc1 extends AnyRef
private class Co1 extends AnyRef
@@ -17,19 +16,18 @@ private[this] val vc1: Int
private[this] val vo1: Int
================================================================================
-askScopeCompletion at Completions.scala(32,4)
+askScopeCompletion at Completions.scala(29,2)
================================================================================
-[response] askScopeCompletion at (32,4)
-retrieved 11 members
-[inaccessible] private[this] val vc1: Int
+[response] askScopeCompletion at (29,2)
+retrieved 10 members
class Completion1 extends AnyRef
def <init>(): test.Completion1.type
-def test: Unit
object Completion1
private class Cc1 extends AnyRef
private class Co1 extends AnyRef
private def fc1: Int
private def fo1: Int
private[this] val c: test.Completion1
+private[this] val vc1: Int
private[this] val vo1: Int
================================================================================
diff --git a/test/files/presentation/scope-completion-2/src/Completions.scala b/test/files/presentation/scope-completion-2/src/Completions.scala
index 96d38f1b85..f8d7cd6ba8 100644
--- a/test/files/presentation/scope-completion-2/src/Completions.scala
+++ b/test/files/presentation/scope-completion-2/src/Completions.scala
@@ -9,12 +9,10 @@ class Completion1 {
private val vc1 = 0
private def fc1 = 0
- private class Cc1
-
- def test {
- // needs to be done in a method, because of SI-7280
- /*_*/
+ private class Cc1 {
}
+
+ /*_*/
}
object Completion1 {
@@ -25,11 +23,9 @@ object Completion1 {
private val vo1 = 0
private def fo1 = 0
- private class Co1
-
- def test {
- // needs to be done in a method, because of SI-7280
- /*_*/
+ private class Co1 {
}
+
+ /*_*/
}
diff --git a/test/files/presentation/scope-completion-3.check b/test/files/presentation/scope-completion-3.check
index cf73e89a3b..df3007ab4e 100644
--- a/test/files/presentation/scope-completion-3.check
+++ b/test/files/presentation/scope-completion-3.check
@@ -12,13 +12,9 @@ retrieved 49 members
[inaccessible] private object Ot2
[inaccessible] private type tb2 = Completion1.this.tb2
[inaccessible] private type tt2 = Completion1.this.tt2
-[inaccessible] private[this] val vb1: Int
[inaccessible] private[this] val vb2: Int
-[inaccessible] private[this] val vt1: Int
[inaccessible] private[this] val vt2: Int
-[inaccessible] private[this] var rb1: Int
[inaccessible] private[this] var rb2: Int
-[inaccessible] private[this] var rt1: Int
[inaccessible] private[this] var rt2: Int
abstract class Base1 extends AnyRef
abstract trait Trait1 extends AnyRef
@@ -42,13 +38,17 @@ private class Cc2 extends AnyRef
private def fc2: Int
private object Oc2
private type tc2 = Completion1.this.tc2
+private[this] val vb1: Int
private[this] val vb3: Int
private[this] val vc1: Int
private[this] val vc2: Int
+private[this] val vt1: Int
private[this] val vt3: Int
+private[this] var rb1: Int
private[this] var rb3: Int
private[this] var rc1: Int
private[this] var rc2: Int
+private[this] var rt1: Int
private[this] var rt3: Int
type tb1 = Completion1.this.tb1
type tc1 = Completion1.this.tc1
@@ -67,13 +67,9 @@ retrieved 49 members
[inaccessible] private object Ot2
[inaccessible] private type tb2 = test.Completion2.tb2
[inaccessible] private type tt2 = test.Completion2.tt2
-[inaccessible] private[this] val vb1: Int
[inaccessible] private[this] val vb2: Int
-[inaccessible] private[this] val vt1: Int
[inaccessible] private[this] val vt2: Int
-[inaccessible] private[this] var rb1: Int
[inaccessible] private[this] var rb2: Int
-[inaccessible] private[this] var rt1: Int
[inaccessible] private[this] var rt2: Int
abstract class Base1 extends AnyRef
abstract trait Trait1 extends AnyRef
@@ -97,13 +93,17 @@ private class Co2 extends AnyRef
private def fo2: Int
private object Oo2
private type to2 = test.Completion2.to2
+private[this] val vb1: Int
private[this] val vb3: Int
private[this] val vo1: Int
private[this] val vo2: Int
+private[this] val vt1: Int
private[this] val vt3: Int
+private[this] var rb1: Int
private[this] var rb3: Int
private[this] var ro1: Int
private[this] var ro2: Int
+private[this] var rt1: Int
private[this] var rt3: Int
type tb1 = test.Completion2.tb1
type to1 = test.Completion2.to1
diff --git a/test/files/presentation/scope-completion-import.check b/test/files/presentation/scope-completion-import.check
index d518b0c37a..220ffc399b 100644
--- a/test/files/presentation/scope-completion-import.check
+++ b/test/files/presentation/scope-completion-import.check
@@ -1,9 +1,13 @@
reload: Completions.scala
-askScopeCompletion at Completions.scala(15,4)
-================================================================================
-[response] askScopeCompletion at (15,4)
-retrieved 10 members
+askScopeCompletion at Completions.scala(23,4)
+================================================================================
+[response] askScopeCompletion at (23,4)
+retrieved 18 members
+[inaccessible] private[this] val pVCCC: Int
+[inaccessible] private[this] val pVOOO: Int
+[inaccessible] private[this] var pRCCC: Int
+[inaccessible] private[this] var pROOO: Int
class C extends AnyRef
class Foo extends AnyRef
class Foo_1 extends AnyRef
@@ -13,13 +17,21 @@ def <init>(): test.Foo
def fCCC: Int
def fOOO: Int
object O
+private[this] val vCCC: Int
+private[this] val vOOO: Int
+private[this] var rCCC: Int
+private[this] var rOOO: Int
val o: test.O.type
================================================================================
-askScopeCompletion at Completions.scala(19,4)
-================================================================================
-[response] askScopeCompletion at (19,4)
-retrieved 9 members
+askScopeCompletion at Completions.scala(27,4)
+================================================================================
+[response] askScopeCompletion at (27,4)
+retrieved 17 members
+[inaccessible] private[this] val pVCCC: Int
+[inaccessible] private[this] val pVOOO: Int
+[inaccessible] private[this] var pRCCC: Int
+[inaccessible] private[this] var pROOO: Int
class C extends AnyRef
class Foo extends AnyRef
class Foo_1 extends AnyRef
@@ -29,12 +41,18 @@ def <init>(): test.Foo
def fCCC: Int
def fOOO: Int
object O
+private[this] val vCCC: Int
+private[this] val vOOO: Int
+private[this] var rCCC: Int
+private[this] var rOOO: Int
================================================================================
-askScopeCompletion at Completions.scala(24,4)
+askScopeCompletion at Completions.scala(32,4)
================================================================================
-[response] askScopeCompletion at (24,4)
-retrieved 9 members
+[response] askScopeCompletion at (32,4)
+retrieved 13 members
+[inaccessible] private[this] val pVCCC: Int
+[inaccessible] private[this] var pRCCC: Int
class C extends AnyRef
class Foo extends AnyRef
class Foo_1 extends AnyRef
@@ -43,12 +61,14 @@ class Foo_3 extends AnyRef
def <init>(): test.Foo
def fCCC: Int
object O
+private[this] val vCCC: Int
+private[this] var rCCC: Int
val c: test.C
================================================================================
-askScopeCompletion at Completions.scala(27,5)
+askScopeCompletion at Completions.scala(35,5)
================================================================================
-[response] askScopeCompletion at (27,5)
+[response] askScopeCompletion at (35,5)
retrieved 8 members
class C extends AnyRef
class Foo extends AnyRef
@@ -60,10 +80,12 @@ object O
val c: test.C
================================================================================
-askScopeCompletion at Completions.scala(30,5)
+askScopeCompletion at Completions.scala(38,5)
================================================================================
-[response] askScopeCompletion at (30,5)
-retrieved 9 members
+[response] askScopeCompletion at (38,5)
+retrieved 13 members
+[inaccessible] private[this] val pVCCC: Int
+[inaccessible] private[this] var pRCCC: Int
class C extends AnyRef
class Foo extends AnyRef
class Foo_1 extends AnyRef
@@ -72,13 +94,19 @@ class Foo_3 extends AnyRef
def <init>(): test.Foo
def fCCC: Int
object O
+private[this] val vCCC: Int
+private[this] var rCCC: Int
val c: test.C
================================================================================
-askScopeCompletion at Completions.scala(32,5)
-================================================================================
-[response] askScopeCompletion at (32,5)
-retrieved 10 members
+askScopeCompletion at Completions.scala(40,5)
+================================================================================
+[response] askScopeCompletion at (40,5)
+retrieved 18 members
+[inaccessible] private[this] val pVCCC: Int
+[inaccessible] private[this] val pVOOO: Int
+[inaccessible] private[this] var pRCCC: Int
+[inaccessible] private[this] var pROOO: Int
class C extends AnyRef
class Foo extends AnyRef
class Foo_1 extends AnyRef
@@ -88,13 +116,21 @@ def <init>(): test.Foo
def fCCC: Int
def fOOO: Int
object O
+private[this] val vCCC: Int
+private[this] val vOOO: Int
+private[this] var rCCC: Int
+private[this] var rOOO: Int
val c: test.C
================================================================================
-askScopeCompletion at Completions.scala(41,4)
-================================================================================
-[response] askScopeCompletion at (41,4)
-retrieved 10 members
+askScopeCompletion at Completions.scala(49,4)
+================================================================================
+[response] askScopeCompletion at (49,4)
+retrieved 18 members
+[inaccessible] private[this] val pVCCC: Int
+[inaccessible] private[this] val pVOOO: Int
+[inaccessible] private[this] var pRCCC: Int
+[inaccessible] private[this] var pROOO: Int
class C extends AnyRef
class Foo extends AnyRef
class Foo_1 extends AnyRef
@@ -105,12 +141,20 @@ def bar: Unit
def fCCC: Int
def fOOO: Int
object O
+private[this] val vCCC: Int
+private[this] val vOOO: Int
+private[this] var rCCC: Int
+private[this] var rOOO: Int
================================================================================
-askScopeCompletion at Completions.scala(51,4)
-================================================================================
-[response] askScopeCompletion at (51,4)
-retrieved 11 members
+askScopeCompletion at Completions.scala(59,4)
+================================================================================
+[response] askScopeCompletion at (59,4)
+retrieved 19 members
+[inaccessible] private[this] val pVCCC: Int
+[inaccessible] private[this] val pVOOO: Int
+[inaccessible] private[this] var pRCCC: Int
+[inaccessible] private[this] var pROOO: Int
class C extends AnyRef
class Foo extends AnyRef
class Foo_1 extends AnyRef
@@ -122,12 +166,18 @@ def fCCC: Int
def fOOO: Int
object O
private[this] val o: test.O.type
+private[this] val vCCC: Int
+private[this] val vOOO: Int
+private[this] var rCCC: Int
+private[this] var rOOO: Int
================================================================================
-askScopeCompletion at Completions.scala(61,4)
+askScopeCompletion at Completions.scala(69,4)
================================================================================
-[response] askScopeCompletion at (61,4)
-retrieved 10 members
+[response] askScopeCompletion at (69,4)
+retrieved 14 members
+[inaccessible] private[this] val pVCCC: Int
+[inaccessible] private[this] var pRCCC: Int
class C extends AnyRef
class Foo extends AnyRef
class Foo_1 extends AnyRef
@@ -138,4 +188,6 @@ def bar: Unit
def fCCC: Int
object O
private[this] val c: test.C
+private[this] val vCCC: Int
+private[this] var rCCC: Int
================================================================================
diff --git a/test/files/presentation/scope-completion-import/src/Completions.scala b/test/files/presentation/scope-completion-import/src/Completions.scala
index 6e08321283..d30aa0b4e3 100644
--- a/test/files/presentation/scope-completion-import/src/Completions.scala
+++ b/test/files/presentation/scope-completion-import/src/Completions.scala
@@ -1,10 +1,18 @@
package test
class C {
+ val vCCC : Int = 0
+ var rCCC : Int = 0
+ private val pVCCC : Int = 0
+ private var pRCCC : Int = 0
def fCCC : Int = 0
}
object O extends C {
+ val vOOO : Int = 0
+ var rOOO : Int = 0
+ private val pVOOO : Int = 0
+ private var pROOO : Int = 0
def fOOO : Int = 0
}
diff --git a/test/files/run/idempotency-case-classes.scala b/test/files/run/idempotency-case-classes.scala
index 4da8393cb6..81e119582b 100644
--- a/test/files/run/idempotency-case-classes.scala
+++ b/test/files/run/idempotency-case-classes.scala
@@ -10,7 +10,7 @@ object Test extends App {
}
println(casee.eval)
val tb = cm.mkToolBox()
- val tcasee = tb.typeCheck(casee.tree)
+ val tcasee = tb.typecheck(casee.tree)
println(tcasee)
val rtcasee = tb.resetAllAttrs(tcasee)
try {
diff --git a/test/files/run/idempotency-extractors.scala b/test/files/run/idempotency-extractors.scala
index fe033295f5..b66b043be1 100644
--- a/test/files/run/idempotency-extractors.scala
+++ b/test/files/run/idempotency-extractors.scala
@@ -10,7 +10,7 @@ object Test extends App {
}
println(extractor.eval)
val tb = cm.mkToolBox()
- val textractor = tb.typeCheck(extractor.tree)
+ val textractor = tb.typecheck(extractor.tree)
println(textractor)
val rtextractor = tb.resetAllAttrs(textractor)
try {
diff --git a/test/files/run/idempotency-labels.scala b/test/files/run/idempotency-labels.scala
index 82d009751a..f1a185d3d0 100644
--- a/test/files/run/idempotency-labels.scala
+++ b/test/files/run/idempotency-labels.scala
@@ -11,7 +11,7 @@ object Test extends App {
}
println(label.eval)
val tb = cm.mkToolBox()
- val tlabel = tb.typeCheck(label.tree)
+ val tlabel = tb.typecheck(label.tree)
println(tlabel)
val rtlabel = tb.resetAllAttrs(tlabel)
try {
diff --git a/test/files/run/idempotency-lazy-vals.scala b/test/files/run/idempotency-lazy-vals.scala
index 3531f9ff4b..e763f2f3f4 100644
--- a/test/files/run/idempotency-lazy-vals.scala
+++ b/test/files/run/idempotency-lazy-vals.scala
@@ -15,7 +15,7 @@ object Test extends App {
}
println(lazee.eval)
val tb = cm.mkToolBox()
- val tlazee = tb.typeCheck(lazee.tree)
+ val tlazee = tb.typecheck(lazee.tree)
println(tlazee)
val rtlazee = tb.resetAllAttrs(tlazee)
try {
diff --git a/test/files/run/idempotency-this.scala b/test/files/run/idempotency-this.scala
index 5cd4226326..2db1efd2d1 100644
--- a/test/files/run/idempotency-this.scala
+++ b/test/files/run/idempotency-this.scala
@@ -9,7 +9,7 @@ object Test extends App {
}
println(thiss.eval)
val tb = cm.mkToolBox()
- val tthiss = tb.typeCheck(thiss.tree)
+ val tthiss = tb.typecheck(thiss.tree)
println(tthiss)
println(showRaw(tthiss))
val rtthiss = tb.resetAllAttrs(tthiss)
diff --git a/test/files/run/iq.check b/test/files/run/iq.check
index 81114ea181..311bf83ed4 100644
--- a/test/files/run/iq.check
+++ b/test/files/run/iq.check
@@ -1,4 +1,8 @@
Empty
+q2: Queue(42, 0)
+qa: Queue(42, 0)
+qb: Queue(42, 0)
+qc: Queue(42, 0)
Head: 42
q5: Queue(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
q5[5]: 5
diff --git a/test/files/run/iq.scala b/test/files/run/iq.scala
index 31859cf867..1eb1d40e37 100644
--- a/test/files/run/iq.scala
+++ b/test/files/run/iq.scala
@@ -16,10 +16,21 @@ object iq {
Console.println("Empty")
}
- /* Test infix enqueing. */
- //val q2 = q + 42 + 0 // deprecated
+ /* Test enqueing. */
val q2 = q.enqueue(42).enqueue(0)
+ val qa = q :+ 42 :+ 0
+ assert(q2 == qa)
+
+ val qb = 42 +: 0 +: q
+ assert(q2 == qb)
+ val qc = 42 +: q :+ 0
+ assert(q2 == qc)
+ Console.println("q2: " + q2)
+ Console.println("qa: " + qa)
+ Console.println("qb: " + qb)
+ Console.println("qc: " + qc)
+
/* Test is empty and dequeue.
* Expected: Head: 42
*/
@@ -37,7 +48,7 @@ object iq {
/* Test sequence enqueing. */
val q5: Queue[Any] = q4.enqueue(List(1,2,3,4,5,6,7,8,9))
/* Test toString.
- * Expected: Head: q5: Queue(0,1,2,3,4,5,6,7,8,9)
+ * Expected: q5: Queue(0,1,2,3,4,5,6,7,8,9)
*/
Console.println("q5: " + q5)
/* Test apply
diff --git a/test/files/run/literals.check b/test/files/run/literals.check
index 5f948762b7..ed7c6ca5b3 100644
--- a/test/files/run/literals.check
+++ b/test/files/run/literals.check
@@ -1,4 +1,4 @@
-warning: there were 18 deprecation warning(s); re-run with -deprecation for details
+warning: there were 5 deprecation warning(s); re-run with -deprecation for details
test '\u0024' == '$' was successful
test '\u005f' == '_' was successful
test 65.asInstanceOf[Char] == 'A' was successful
@@ -7,28 +7,19 @@ test "\0x61\0x62".trim() == "x61\0x62" was successful
test (65 : Byte) == 'A' was successful
-test 01 == 1 was successful
-test 010 == 8 was successful
test 0X01 == 1 was successful
test 0x01 == 1 was successful
test 0x10 == 16 was successful
test 0xa == 10 was successful
test 0x0a == 10 was successful
-test +01 == 1 was successful
-test +010 == 8 was successful
test +0x01 == 1 was successful
test +0x10 == 16 was successful
test +0xa == 10 was successful
test +0x0a == 10 was successful
-test -01 == -1 was successful
-test -010 == -8 was successful
test -0x01 == -1 was successful
test -0x10 == -16 was successful
test -0xa == -10 was successful
test -0x0a == -10 was successful
-test 017777777777 == 2147483647 was successful
-test 020000000000 == -2147483648 was successful
-test 037777777777 == -1 was successful
test 0x7fffffff == 2147483647 was successful
test 0x80000000 == -2147483648 was successful
test 0xffffffff == -1 was successful
@@ -36,9 +27,6 @@ test 0xffffffff == -1 was successful
test 1l == 1L was successful
test 1L == 1l was successful
test 1.asInstanceOf[Long] == 1l was successful
-test 0777777777777777777777L == 9223372036854775807L was successful
-test 01000000000000000000000L == -9223372036854775808L was successful
-test 01777777777777777777777L == -1L was successful
test 0x7fffffffffffffffL == 9223372036854775807L was successful
test 0x8000000000000000L == -9223372036854775808L was successful
test 0xffffffffffffffffL == -1L was successful
@@ -46,6 +34,7 @@ test 0xffffffffffffffffL == -1L was successful
test 1e1f == 10.0f was successful
test .3f == 0.3f was successful
test 0f == 0.0f was successful
+test 01.23f == 1.23f was successful
test 3.14f == 3.14f was successful
test 6.022e23f == 6.022e23f was successful
test 09f == 9.0f was successful
@@ -56,6 +45,8 @@ test 1e1 == 10.0 was successful
test .3 == 0.3 was successful
test 0.0 == 0.0 was successful
test 0d == 0.0 was successful
+test 01.23 == 1.23 was successful
+test 01.23d == 1.23d was successful
test 3.14 == 3.14 was successful
test 1e-9d == 1.0e-9 was successful
test 1e137 == 1.0e137 was successful
diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala
index 7676125339..5f23e6b492 100644
--- a/test/files/run/literals.scala
+++ b/test/files/run/literals.scala
@@ -47,32 +47,22 @@ object Test {
println
// int
- check_success("01 == 1", 01, 1)
- check_success("010 == 8", 010, 8)
check_success("0X01 == 1", 0X01, 1)
check_success("0x01 == 1", 0x01, 1)
check_success("0x10 == 16", 0x10, 16)
check_success("0xa == 10", 0xa, 10)
check_success("0x0a == 10", 0x0a, 10)
- check_success("+01 == 1", +01, 1)
- check_success("+010 == 8", +010, 8)
check_success("+0x01 == 1", +0x01, 1)
check_success("+0x10 == 16", +0x10, 16)
check_success("+0xa == 10", +0xa, 10)
check_success("+0x0a == 10", +0x0a, 10)
- check_success("-01 == -1", -01, -1)
- check_success("-010 == -8", -010, -8)
check_success("-0x01 == -1", -0x01, -1)
check_success("-0x10 == -16", -0x10, -16)
check_success("-0xa == -10", -0xa, -10)
check_success("-0x0a == -10", -0x0a, -10)
- check_success("017777777777 == 2147483647", 017777777777, 2147483647)
- check_success("020000000000 == -2147483648", 020000000000, -2147483648)
- check_success("037777777777 == -1", 037777777777, -1)
-
check_success("0x7fffffff == 2147483647", 0x7fffffff, 2147483647)
check_success("0x80000000 == -2147483648", 0x80000000, -2147483648)
check_success("0xffffffff == -1", 0xffffffff, -1)
@@ -84,13 +74,6 @@ object Test {
check_success("1L == 1l", 1L, 1l)
check_success("1.asInstanceOf[Long] == 1l", 1.asInstanceOf[Long], 1l)
- check_success("0777777777777777777777L == 9223372036854775807L",
- 0777777777777777777777L, 9223372036854775807L)
- check_success("01000000000000000000000L == -9223372036854775808L",
- 01000000000000000000000L, -9223372036854775808L)
- check_success("01777777777777777777777L == -1L",
- 01777777777777777777777L, -1L)
-
check_success("0x7fffffffffffffffL == 9223372036854775807L",
0x7fffffffffffffffL, 9223372036854775807L)
check_success("0x8000000000000000L == -9223372036854775808L",
@@ -105,9 +88,9 @@ object Test {
// float
check_success("1e1f == 10.0f", 1e1f, 10.0f)
- //check_success("2.f == 2.0f", 2.f, 2.0f)
check_success(".3f == 0.3f", .3f, 0.3f)
check_success("0f == 0.0f", 0f, 0.0f)
+ check_success("01.23f == 1.23f", 01.23f, 1.23f)
check_success("3.14f == 3.14f", 3.14f, 3.14f)
check_success("6.022e23f == 6.022e23f", 6.022e23f, 6.022e23f)
check_success("09f == 9.0f", 09f, 9.0f)
@@ -118,11 +101,11 @@ object Test {
// double
check_success("1e1 == 10.0", 1e1, 10.0)
- //check_success("2. == 2.0", 2., 2.0)
- //check_success("2.d == 2.0", 2.d, 2.0)
check_success(".3 == 0.3", .3, 0.3)
check_success("0.0 == 0.0", 0.0, 0.0)
check_success("0d == 0.0", 0d, 0.0)
+ check_success("01.23 == 1.23", 01.23, 1.23)
+ check_success("01.23d == 1.23d", 01.23d, 1.23d)
check_success("3.14 == 3.14", 3.14, 3.14)
check_success("1e-9d == 1.0e-9", 1e-9d, 1.0e-9)
check_success("1e137 == 1.0e137", 1e137, 1.0e137)
diff --git a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
index 0a9f9a0ced..8506239952 100644
--- a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
+++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
@@ -4,7 +4,7 @@ import scala.reflect.macros.{BlackboxContext, WhiteboxContext}
object Impls {
def foo(c: BlackboxContext)(x: c.Expr[Int]) = x
- def refToFoo(dummy: Int) = macro refToFoo_impl
+ def refToFoo(dummy: Int): Int = macro refToFoo_impl
def refToFoo_impl(c: WhiteboxContext)(dummy: c.Expr[Int]) = {
import c.universe._
val body = Select(Ident(TermName("Impls")), TermName("foo"))
diff --git a/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala b/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala
index cfcb59c17b..486e1de090 100644
--- a/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala
+++ b/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala
@@ -1,7 +1,7 @@
import scala.language.experimental.macros
object Macros {
- def foo(x: Int) = macro Impls.refToFoo(42)
+ def foo(x: Int): Int = macro Impls.refToFoo(42)
}
object Test extends App {
diff --git a/test/files/run/macro-bundle-repl.check b/test/files/run/macro-bundle-repl.check
index 795debded7..8487042d66 100644
--- a/test/files/run/macro-bundle-repl.check
+++ b/test/files/run/macro-bundle-repl.check
@@ -7,7 +7,7 @@ import scala.language.experimental.macros
scala> import scala.reflect.macros.BlackboxMacro
import scala.reflect.macros.BlackboxMacro
-scala> trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
+scala> trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
defined trait Bar
defined term macro bar: Unit
@@ -16,7 +16,7 @@ scala> bar
scala> trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
defined trait Foo
-scala> def foo = macro Foo.impl
+scala> def foo: Unit = macro Foo.impl
defined term macro foo: Unit
scala> foo
diff --git a/test/files/run/macro-bundle-repl.scala b/test/files/run/macro-bundle-repl.scala
index 50811cdb65..db64f05943 100644
--- a/test/files/run/macro-bundle-repl.scala
+++ b/test/files/run/macro-bundle-repl.scala
@@ -4,10 +4,10 @@ object Test extends ReplTest {
def code = """
import scala.language.experimental.macros
import scala.reflect.macros.BlackboxMacro
-trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
+trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
bar
trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
-def foo = macro Foo.impl
+def foo: Unit = macro Foo.impl
foo
"""
}
diff --git a/test/files/run/macro-def-infer-return-type.check b/test/files/run/macro-def-infer-return-type.check
deleted file mode 100644
index fbd164f139..0000000000
--- a/test/files/run/macro-def-infer-return-type.check
+++ /dev/null
@@ -1,8 +0,0 @@
-42
-reflective compilation has failed:
-
-exception during macro expansion:
-java.lang.Error: an implementation is missing
- at Impls2$.foo(Impls_1.scala:9)
-
-42
diff --git a/test/files/run/macro-def-infer-return-type.flags b/test/files/run/macro-def-infer-return-type.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-def-infer-return-type.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-def-infer-return-type/Impls_1.scala b/test/files/run/macro-def-infer-return-type/Impls_1.scala
deleted file mode 100644
index c670b1e57e..0000000000
--- a/test/files/run/macro-def-infer-return-type/Impls_1.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-import scala.reflect.macros.BlackboxContext
-
-object Impls1 {
- def foo(c: BlackboxContext)(x: c.Expr[Int]) = x
-}
-
-object Impls2 {
- def foo[T](c: BlackboxContext)(x: c.Expr[T]) =
- throw new Error("an implementation is missing")
-}
-
-object Impls3 {
- def foo[T](c: BlackboxContext)(x: c.Expr[T]): c.Expr[T] = x
-}
diff --git a/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala b/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala
deleted file mode 100644
index f579586b7f..0000000000
--- a/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-object Macros1 {
- def foo(x: Int) = macro Impls1.foo
-}
-
-object Macros2 {
- def foo[T](x: T) = macro Impls2.foo[T]
-}
-
-object Macros3 {
- def foo[T](x: T) = macro Impls3.foo[T]
-}
-
-object Test extends App {
- println(Macros1.foo(42))
-
- import scala.reflect.runtime.universe._
- import scala.reflect.runtime.{currentMirror => cm}
- import scala.tools.reflect.ToolBox
- val tree = Apply(Select(Ident(TermName("Macros2")), TermName("foo")), List(Literal(Constant(42))))
- try cm.mkToolBox().eval(tree)
- catch { case ex: Throwable => println(ex.getMessage) }
-
- println(Macros3.foo(42))
-}
diff --git a/test/files/run/macro-def-path-dependent/Test_1.scala b/test/files/run/macro-def-path-dependent/Test_1.scala
index f9aa13c334..bba97fcae1 100644
--- a/test/files/run/macro-def-path-dependent/Test_1.scala
+++ b/test/files/run/macro-def-path-dependent/Test_1.scala
@@ -1,23 +1,25 @@
-package test1
-
-import scala.reflect.macros.{BlackboxContext => Ctx}
-
-trait Exprs {
- self: Universe =>
-
- class Expr[T]
-}
-
-trait Reifiers {
- self: Universe =>
-
- type Expr[T]
-
- def reify[T](expr: T) = macro Impls.reify[T]
-}
-
-trait Universe extends Exprs with Reifiers
-
-object Impls {
- def reify[T](cc: Ctx{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
-}
+// NOTE: blocked by SI-8049
+
+// package test1
+//
+// import scala.reflect.macros.{BlackboxContext => Ctx}
+//
+// trait Exprs {
+// self: Universe =>
+//
+// class Expr[T]
+// }
+//
+// trait Reifiers {
+// self: Universe =>
+//
+// type Expr[T]
+//
+// def reify[T](expr: T): Expr[T] = macro Impls.reify[T]
+// }
+//
+// trait Universe extends Exprs with Reifiers
+//
+// object Impls {
+// def reify[T](cc: Ctx{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
+// }
diff --git a/test/files/run/macro-def-path-dependent/Test_2.scala b/test/files/run/macro-def-path-dependent/Test_2.scala
index cdedaf2732..c884ab9d0b 100644
--- a/test/files/run/macro-def-path-dependent/Test_2.scala
+++ b/test/files/run/macro-def-path-dependent/Test_2.scala
@@ -14,7 +14,7 @@ trait Reifiers {
}
trait Universe extends Exprs with Reifiers {
- def reify[T](expr: T) = macro Impls.reify[T]
+ def reify[T](expr: T): Expr[T] = macro Impls.reify[T]
}
object Impls {
diff --git a/test/files/run/macro-def-path-dependent/Test_4.scala b/test/files/run/macro-def-path-dependent/Test_4.scala
index e8a8cf3909..6562802013 100644
--- a/test/files/run/macro-def-path-dependent/Test_4.scala
+++ b/test/files/run/macro-def-path-dependent/Test_4.scala
@@ -5,7 +5,7 @@ import scala.reflect.macros.BlackboxContext
import scala.reflect.api.Universe
object Test {
- def materializeTypeTag[T](u: Universe)(e: T) = macro materializeTypeTag_impl[T]
+ def materializeTypeTag[T](u: Universe)(e: T): u.TypeTag[T] = macro materializeTypeTag_impl[T]
def materializeTypeTag_impl[T: c.WeakTypeTag](c: BlackboxContext)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ???
} \ No newline at end of file
diff --git a/test/files/run/macro-def-path-dependent/Test_6.scala b/test/files/run/macro-def-path-dependent/Test_6.scala
index c8ddffc143..011e726b3f 100644
--- a/test/files/run/macro-def-path-dependent/Test_6.scala
+++ b/test/files/run/macro-def-path-dependent/Test_6.scala
@@ -5,5 +5,5 @@ import scala.reflect.macros.BlackboxContext
import scala.reflect.api.Universe
object Macros {
- def materializeTypeTag[T](u: Universe)(e: T) = macro Impls.materializeTypeTag_impl[T]
+ def materializeTypeTag[T](u: Universe)(e: T): u.TypeTag[T] = macro Impls.materializeTypeTag_impl[T]
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala
index ffb04dc80b..fec914632f 100644
--- a/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Test extends App {
implicit val x = 42
- def foo(implicit x: Int) = macro Impls.foo
+ def foo(implicit x: Int): Unit = macro Impls.foo
foo
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala
index b91b1016c9..2f21785bae 100644
--- a/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Test extends App {
- implicit def foo = macro Impls.foo
+ implicit def foo: Int = macro Impls.foo
def bar(implicit x: Int) = println(x)
bar
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala b/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala
index fa4504b0ea..54b959983b 100644
--- a/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala
@@ -1,4 +1,4 @@
object Test extends App {
- def foo(x: Int)(y: Int) = macro Impls.foo
+ def foo(x: Int)(y: Int): Unit = macro Impls.foo
foo(40)(2)
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala b/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala
index 2d5cf53c3c..edd9051754 100644
--- a/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala
@@ -1,8 +1,8 @@
object Macros {
- def foo1[T] = macro Impls.fooNullary[T]
- def foo2[T]() = macro Impls.fooEmpty[T]
- def bar1[T](x: Int) = macro Impls.barNullary[T]
- def bar2[T](x: Int)() = macro Impls.barEmpty[T]
+ def foo1[T]: Unit = macro Impls.fooNullary[T]
+ def foo2[T](): Unit = macro Impls.fooEmpty[T]
+ def bar1[T](x: Int): Unit = macro Impls.barNullary[T]
+ def bar2[T](x: Int)(): Unit = macro Impls.barEmpty[T]
}
object Test extends App {
diff --git a/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala b/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala
index 1f6d717956..51915dfb27 100644
--- a/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala
@@ -1,8 +1,8 @@
object Macros {
- def foo1 = macro Impls.fooNullary
- def foo2() = macro Impls.fooEmpty
- def bar1(x: Int) = macro Impls.barNullary
- def bar2(x: Int)() = macro Impls.barEmpty
+ def foo1: Unit = macro Impls.fooNullary
+ def foo2(): Unit = macro Impls.fooEmpty
+ def bar1(x: Int): Unit = macro Impls.barNullary
+ def bar2(x: Int)(): Unit = macro Impls.barEmpty
}
object Test extends App {
diff --git a/test/files/run/macro-expand-overload/Macros_Test_2.scala b/test/files/run/macro-expand-overload/Macros_Test_2.scala
index 7f61f85184..87cff2ecbd 100644
--- a/test/files/run/macro-expand-overload/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-overload/Macros_Test_2.scala
@@ -1,13 +1,13 @@
object Macros {
- def foo(x: String) = macro Impls.fooObjectString
- def foo(x: Int) = macro Impls.fooObjectInt
- def foo(x: Boolean) = println("fooObjectBoolean")
+ def foo(x: String): Unit = macro Impls.fooObjectString
+ def foo(x: Int): Unit = macro Impls.fooObjectInt
+ def foo(x: Boolean): Unit = println("fooObjectBoolean")
}
class Macros {
- def foo(x: String) = macro Impls.fooClassString
- def foo(x: Int) = macro Impls.fooClassInt
- def foo(x: Boolean) = println("fooClassBoolean")
+ def foo(x: String): Unit = macro Impls.fooClassString
+ def foo(x: Int): Unit = macro Impls.fooClassInt
+ def foo(x: Boolean): Unit = println("fooClassBoolean")
}
object Test extends App {
diff --git a/test/files/run/macro-expand-override/Macros_Test_2.scala b/test/files/run/macro-expand-override/Macros_Test_2.scala
index f162773c95..160831c54e 100644
--- a/test/files/run/macro-expand-override/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-override/Macros_Test_2.scala
@@ -1,17 +1,17 @@
class B {
- def foo(x: String) = macro Impls.fooBString
- def foo(x: Int) = macro Impls.fooBInt
- def foo(x: Boolean) = println("fooBBoolean")
+ def foo(x: String): Unit = macro Impls.fooBString
+ def foo(x: Int): Unit = macro Impls.fooBInt
+ def foo(x: Boolean): Unit = println("fooBBoolean")
}
class D extends B {
- //override def foo(x: String) = println("fooDString") => method cannot override a macro
- override def foo(x: Int) = macro Impls.fooDInt
+ //override def foo(x: String): Unit = println("fooDString") => method cannot override a macro
+ override def foo(x: Int): Unit = macro Impls.fooDInt
}
class Z extends D {
- override def foo(x: String) = macro Impls.fooZString
- override def foo(x: Boolean) = println("fooZBoolean")
+ override def foo(x: String): Unit = macro Impls.fooZString
+ override def foo(x: Boolean): Unit = println("fooZBoolean")
}
object Test extends App {
diff --git a/test/files/run/macro-expand-recursive/Macros_Test_2.scala b/test/files/run/macro-expand-recursive/Macros_Test_2.scala
index 6ff691bdb1..5332fdacee 100644
--- a/test/files/run/macro-expand-recursive/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-recursive/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Macros {
- def foo = macro Impls.foo
- def fooFoo = macro Impls.fooFoo
+ def foo: Unit = macro Impls.foo
+ def fooFoo: Unit = macro Impls.fooFoo
}
object Test extends App {
diff --git a/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala
index 37a4bcb2b9..6cb2b53465 100644
--- a/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala
@@ -1,9 +1,9 @@
object Macros1 {
- def foo[U <: String] = macro Impls1.foo[U]
+ def foo[U <: String]: Unit = macro Impls1.foo[U]
}
object Macros2 {
- def foo[T <: D] = macro Impls2.foo[T]
+ def foo[T <: D]: Unit = macro Impls2.foo[T]
}
object Test extends App {
diff --git a/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala
index e72c27881a..2cf7b19d2a 100644
--- a/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala
@@ -1,4 +1,4 @@
object Test extends App {
- def foo[U] = macro Impls.foo[U]
+ def foo[U]: Unit = macro Impls.foo[U]
foo[Int]
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala
index f8c573f509..1192931931 100644
--- a/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Test extends App {
- def foo[U](x: U) = macro Impls.foo[U]
+ def foo[U](x: U): Unit = macro Impls.foo[U]
foo(42)
foo("42")
} \ No newline at end of file
diff --git a/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala
index 2b1730d36e..c8f68b4aff 100644
--- a/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala
@@ -1,19 +1,19 @@
object Macros1 {
class C[T] {
- def foo[U](x: U) = macro Impls1.foo[U]
+ def foo[U](x: U): Unit = macro Impls1.foo[U]
}
}
object Macros2 {
class C[T] {
- def foo[U](x: U) = macro Impls2.foo[T, U]
+ def foo[U](x: U): Unit = macro Impls2.foo[T, U]
}
}
object Macros3 {
class D[T] {
class C[U] {
- def foo[V] = macro Impls345.foo[T, U, V]
+ def foo[V]: Unit = macro Impls345.foo[T, U, V]
}
}
}
@@ -23,7 +23,7 @@ object Macros3 {
object Macros5 {
class D[T] {
class C[U] {
- def foo[V] = macro Impls345.foo[T, U, V]
+ def foo[V]: Unit = macro Impls345.foo[T, U, V]
foo[Boolean]
}
}
diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala
index b844012d53..6d79b13419 100644
--- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala
index f127ebcde7..13d7cd5d5d 100644
--- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala
index f127ebcde7..13d7cd5d5d 100644
--- a/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala
index 2311ca0b95..9ab1be9e23 100644
--- a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala
index 2311ca0b95..9ab1be9e23 100644
--- a/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala
+++ b/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala b/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala
index 218c7aec7f..4901e24481 100644
--- a/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala
+++ b/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo = macro Impls.foo[String]
+ def foo: Unit = macro Impls.foo[String]
}
object Test extends App {
diff --git a/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala b/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala
index e72c27881a..2cf7b19d2a 100644
--- a/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala
+++ b/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala
@@ -1,4 +1,4 @@
object Test extends App {
- def foo[U] = macro Impls.foo[U]
+ def foo[U]: Unit = macro Impls.foo[U]
foo[Int]
} \ No newline at end of file
diff --git a/test/files/run/macro-quasiquotes/Macros_1.scala b/test/files/run/macro-quasiquotes/Macros_1.scala
index c42baafdf4..81775d98e8 100644
--- a/test/files/run/macro-quasiquotes/Macros_1.scala
+++ b/test/files/run/macro-quasiquotes/Macros_1.scala
@@ -9,7 +9,7 @@ trait Impls extends BlackboxMacro {
}
object Macros {
- def m1 = macro Impls.impl1
- def m2 = macro Impls.impl2
- def m3 = macro Impls.impl3
+ def m1: Unit = macro Impls.impl1
+ def m2: Unit = macro Impls.impl2
+ def m3: Int = macro Impls.impl3
} \ No newline at end of file
diff --git a/test/files/run/macro-reflective-mamd-normal-mi.check b/test/files/run/macro-reflective-mamd-normal-mi.check
index f77196b2db..920a139664 100644
--- a/test/files/run/macro-reflective-mamd-normal-mi.check
+++ b/test/files/run/macro-reflective-mamd-normal-mi.check
@@ -1,2 +1 @@
-warning: there were 1 deprecation warning(s); re-run with -deprecation for details
43
diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
index 13cd953bde..ba12fb05e6 100644
--- a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
+++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
@@ -10,9 +10,9 @@ object Test extends App {
val macrobody = Select(Ident(TermName("Impls")), TermName("foo"))
val macroparam = ValDef(NoMods, TermName("x"), TypeTree(definitions.IntClass.toType), EmptyTree)
- val macrodef = DefDef(Modifiers(MACRO), TermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody)
+ val macrodef = DefDef(Modifiers(MACRO), TermName("foo"), Nil, List(List(macroparam)), Ident(TypeName("Int")), macrobody)
val modulector = DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(()))))
- val module = ModuleDef(NoMods, TermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef)))
+ val module = ModuleDef(NoMods, TermName("Macros"), Template(Nil, noSelfType, List(modulector, macrodef)))
val macroapp = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42))))
val tree = Block(List(macrodef, module), macroapp)
val toolbox = cm.mkToolBox(options = "-language:experimental.macros")
diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala
index ebd80c02ba..8f7a34a10a 100644
--- a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala
+++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala
@@ -26,7 +26,7 @@ object QueryableMacros{
import treeBuild._
val element_type = implicitly[c.WeakTypeTag[S]].tpe
val foo = c.Expr[ru.Expr[Queryable[S]]](
- c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck(
+ c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typecheck(
Utils[c.type](c).removeDoubleReify(
Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree ))
).asInstanceOf[Tree]
diff --git a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala
index ebd80c02ba..8f7a34a10a 100644
--- a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala
+++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala
@@ -26,7 +26,7 @@ object QueryableMacros{
import treeBuild._
val element_type = implicitly[c.WeakTypeTag[S]].tpe
val foo = c.Expr[ru.Expr[Queryable[S]]](
- c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck(
+ c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typecheck(
Utils[c.type](c).removeDoubleReify(
Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree ))
).asInstanceOf[Tree]
diff --git a/test/files/run/macro-reify-ref-to-packageless/Test_2.scala b/test/files/run/macro-reify-ref-to-packageless/Test_2.scala
index 9d475f756d..c167b160be 100644
--- a/test/files/run/macro-reify-ref-to-packageless/Test_2.scala
+++ b/test/files/run/macro-reify-ref-to-packageless/Test_2.scala
@@ -1,4 +1,4 @@
object Test extends App {
- def foo = macro Impls.foo
+ def foo: Int = macro Impls.foo
println(foo)
} \ No newline at end of file
diff --git a/test/files/run/macro-reify-splice-splice.check b/test/files/run/macro-reify-splice-splice.check
deleted file mode 100644
index 3b18e512db..0000000000
--- a/test/files/run/macro-reify-splice-splice.check
+++ /dev/null
@@ -1 +0,0 @@
-hello world
diff --git a/test/files/run/macro-reify-unreify/Macros_1.scala b/test/files/run/macro-reify-unreify/Macros_1.scala
index d1e71b3311..055959018a 100644
--- a/test/files/run/macro-reify-unreify/Macros_1.scala
+++ b/test/files/run/macro-reify-unreify/Macros_1.scala
@@ -9,7 +9,7 @@ object Macros {
import treeBuild._
val world = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, s.tree)
- val greeting = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, c.typeCheck(Apply(Select(Literal(Constant("hello ")), TermName("$plus")), List(c.unreifyTree(world)))))
+ val greeting = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, c.typecheck(Apply(Select(Literal(Constant("hello ")), TermName("$plus")), List(c.unreifyTree(world)))))
val typedGreeting = c.Expr[String](greeting)
c.universe.reify {
diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check
index 3ba877b59d..9f538c04b6 100644
--- a/test/files/run/macro-repl-dontexpand.check
+++ b/test/files/run/macro-repl-dontexpand.check
@@ -5,12 +5,12 @@ scala> def bar1(c: scala.reflect.macros.BlackboxContext) = ???
bar1: (c: scala.reflect.macros.BlackboxContext)Nothing
scala> def foo1 = macro bar1
-defined term macro foo1: Any
+defined term macro foo1: Nothing
scala> def bar2(c: scala.reflect.macros.WhiteboxContext) = ???
bar2: (c: scala.reflect.macros.WhiteboxContext)Nothing
scala> def foo2 = macro bar2
-defined term macro foo2: Any
+defined term macro foo2: Nothing
scala>
diff --git a/test/files/run/macro-subpatterns.check b/test/files/run/macro-subpatterns.check
new file mode 100644
index 0000000000..b34d4bf4a1
--- /dev/null
+++ b/test/files/run/macro-subpatterns.check
@@ -0,0 +1,3 @@
+List((a @ Extractor((b @ Extractor((c @ _))))))
+List((b @ Extractor((c @ _))))
+List((c @ _))
diff --git a/test/files/run/macro-subpatterns/Macro_1.scala b/test/files/run/macro-subpatterns/Macro_1.scala
new file mode 100644
index 0000000000..d8e86e27c6
--- /dev/null
+++ b/test/files/run/macro-subpatterns/Macro_1.scala
@@ -0,0 +1,18 @@
+import scala.reflect.macros.WhiteboxContext
+import language.experimental.macros
+
+object Extractor {
+ def unapply(x: Any): Any = macro unapplyImpl
+ def unapplyImpl(c: WhiteboxContext)(x: c.Tree) = {
+ val st = c.universe.asInstanceOf[reflect.internal.SymbolTable]
+ import st._
+ val subpatterns = x.attachments.get[SubpatternsAttachment].get.patterns
+ q"""
+ new {
+ def isEmpty = false
+ def get = ${subpatterns.toString}
+ def unapply(x: Any) = this
+ }.unapply(${x.asInstanceOf[st.Tree]})
+ """.asInstanceOf[c.Tree]
+ }
+}
diff --git a/test/files/run/macro-subpatterns/Test_2.scala b/test/files/run/macro-subpatterns/Test_2.scala
new file mode 100644
index 0000000000..dc6e668877
--- /dev/null
+++ b/test/files/run/macro-subpatterns/Test_2.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ 42 match {
+ case Extractor(a @ Extractor(b @ Extractor(c))) => println(a); println(b); println(c)
+ }
+}
diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check
index ea4c5a664a..ceed1079b2 100644
--- a/test/files/run/macro-system-properties.check
+++ b/test/files/run/macro-system-properties.check
@@ -9,7 +9,7 @@ scala> object GrabContext {
def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context])
// System.properties lets you stash true globals (unlike statics which are classloader scoped)
def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
- def grab() = macro impl
+ def grab(): Unit = macro impl
}
defined object GrabContext
diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala
index 73a3ef5910..3325c1747a 100644
--- a/test/files/run/macro-system-properties.scala
+++ b/test/files/run/macro-system-properties.scala
@@ -8,7 +8,7 @@ object Test extends ReplTest {
def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context])
// System.properties lets you stash true globals (unlike statics which are classloader scoped)
def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
- def grab() = macro impl
+ def grab(): Unit = macro impl
}
object Test { class C(implicit a: Any) { GrabContext.grab } }
object Test { class C(implicit a: Any) { GrabContext.grab } }
diff --git a/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala
index 88cd29ae4f..5039dffd5f 100644
--- a/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala
@@ -1,6 +1,6 @@
import scala.language.reflectiveCalls
object Test extends App {
- val macros = new { def foo = macro Impls.foo }
+ val macros = new { def foo: Unit = macro Impls.foo }
macros.foo
}
diff --git a/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala
index 69088e24bc..80bfc44bee 100644
--- a/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Test extends App {
{
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
foo
}
} \ No newline at end of file
diff --git a/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala
index 871857a97f..d6b1f9fab1 100644
--- a/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala
@@ -1,6 +1,6 @@
class Macros {
class Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
}
diff --git a/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala
index 994f9fe935..957f666bb0 100644
--- a/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala
@@ -1,6 +1,6 @@
class Macros {
object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
}
diff --git a/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala
index 1b9d13e775..5898d94dc1 100644
--- a/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala
@@ -1,5 +1,5 @@
class Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala
index 356029e63e..16bd95b1e6 100644
--- a/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Test extends App {
- def foo(bar: String = { def foo = macro Impls.foo; foo }) = println(bar)
+ def foo(bar: String = { def foo: String = macro Impls.foo; foo }) = println(bar)
foo()
foo("it works")
diff --git a/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala
index ed5c8b7c43..523989df13 100644
--- a/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Test extends App {
def bar() = {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
foo
}
diff --git a/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala
index 204deed61c..fe9dbef255 100644
--- a/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Macros {
class Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
}
diff --git a/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala
index e261a50f3d..4ba7551818 100644
--- a/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Macros {
object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
}
diff --git a/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala
index a5a4862ba0..9ebf5d7dba 100644
--- a/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala
index 54a5962e80..1f378b8bfd 100644
--- a/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala
@@ -1,5 +1,5 @@
package object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Test extends App {
diff --git a/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala
index ff9a66d58a..b38616b71a 100644
--- a/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala
@@ -1,9 +1,8 @@
-
import scala.language.reflectiveCalls
class Base
object Test extends App {
- val macros = new Base { def foo = macro Impls.foo }
+ val macros = new Base { def foo: Unit = macro Impls.foo }
macros.foo
}
diff --git a/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala
index f75906b636..09c60df351 100644
--- a/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala
+++ b/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala
@@ -1,5 +1,5 @@
trait Base {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Macros extends Base
diff --git a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala
index 9f7d6f641c..ce937671cc 100644
--- a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala
@@ -5,7 +5,7 @@ object Macros {
import c.universe._
val tree1 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2))))
- val ttree1 = c.typeCheck(tree1, withImplicitViewsDisabled = false)
+ val ttree1 = c.typecheck(tree1, withImplicitViewsDisabled = false)
c.Expr[String](Literal(Constant(ttree1.toString)))
}
@@ -16,7 +16,7 @@ object Macros {
try {
val tree2 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2))))
- val ttree2 = c.typeCheck(tree2, withImplicitViewsDisabled = true)
+ val ttree2 = c.typecheck(tree2, withImplicitViewsDisabled = true)
c.Expr[String](Literal(Constant(ttree2.toString)))
} catch {
case ex: Throwable =>
diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check
index e0e880ab66..0579a4f4c8 100644
--- a/test/files/run/macro-typecheck-macrosdisabled.check
+++ b/test/files/run/macro-typecheck-macrosdisabled.check
@@ -1,4 +1,4 @@
-{
+({
val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(this.getClass().getClassLoader());
$u.Expr.apply[Int(2)]($m, {
@@ -28,5 +28,5 @@
};
new $typecreator2()
}))
-}
+}: reflect.runtime.universe.Expr[Int])
ru.reify[Int](2)
diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
index 41e58e0e4d..45b9a4fcc8 100644
--- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala
@@ -6,7 +6,7 @@ object Macros {
val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe"))
val tree1 = Apply(Select(ru, TermName("reify")), List(Literal(Constant(2))))
- val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false)
+ val ttree1 = c.typecheck(tree1, withMacrosDisabled = false)
c.Expr[String](Literal(Constant(ttree1.toString)))
}
@@ -22,7 +22,7 @@ object Macros {
build.setTypeSignature(ru, rutpe)
val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2))))
- val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true)
+ val ttree2 = c.typecheck(tree2, withMacrosDisabled = true)
c.Expr[String](Literal(Constant(ttree2.toString)))
}
diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check
index 347dfec1dc..c6e1c08d5d 100644
--- a/test/files/run/macro-typecheck-macrosdisabled2.check
+++ b/test/files/run/macro-typecheck-macrosdisabled2.check
@@ -1,4 +1,4 @@
-{
+({
val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(this.getClass().getClassLoader());
$u.Expr.apply[Array[Int]]($m, {
@@ -28,5 +28,5 @@
};
new $typecreator2()
}))
-}
+}: reflect.runtime.universe.Expr[Array[Int]])
ru.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
index 3d12020109..d37a654957 100644
--- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
+++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala
@@ -6,7 +6,7 @@ object Macros {
val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe"))
val tree1 = Apply(Select(ru, TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2))))))
- val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false)
+ val ttree1 = c.typecheck(tree1, withMacrosDisabled = false)
c.Expr[String](Literal(Constant(ttree1.toString)))
}
@@ -22,7 +22,7 @@ object Macros {
build.setTypeSignature(ru, rutpe)
val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2))))))
- val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true)
+ val ttree2 = c.typecheck(tree2, withMacrosDisabled = true)
c.Expr[String](Literal(Constant(ttree2.toString)))
}
diff --git a/test/files/run/macro-vampire-false-warning/Macros_1.scala b/test/files/run/macro-vampire-false-warning/Macros_1.scala
index 5907461c84..bf75e924e8 100644
--- a/test/files/run/macro-vampire-false-warning/Macros_1.scala
+++ b/test/files/run/macro-vampire-false-warning/Macros_1.scala
@@ -22,7 +22,7 @@ object Macros {
// val fields = kvps map { case (k, v) => q"@body($v) def ${TermName(k)} = macro Macros.selFieldImpl" }
val fields = kvps map { case (k, v) => DefDef(
Modifiers(MACRO, tpnme.EMPTY, List(Apply(Select(New(Ident(TypeName("body"))), nme.CONSTRUCTOR), List(v)))),
- TermName(k), Nil, Nil, TypeTree(), Select(Ident(TermName("Macros")), TermName("selFieldImpl"))) }
+ TermName(k), Nil, Nil, Ident(TypeName("Any")), Select(Ident(TermName("Macros")), TermName("selFieldImpl"))) }
// q"import scala.language.experimental.macros; class Workaround { ..$fields }; new Workaround{}"
c.Expr[Any](Block(
List(
@@ -48,5 +48,5 @@ object Macros {
}
object mkObject {
- def apply(xs: Any*) = macro Macros.mkObjectImpl
+ def apply(xs: Any*): Any = macro Macros.mkObjectImpl
}
diff --git a/test/files/run/macro-whitebox-extractor/Macros_1.scala b/test/files/run/macro-whitebox-extractor/Macros_1.scala
index 4a1138fc9d..64053b8a24 100644
--- a/test/files/run/macro-whitebox-extractor/Macros_1.scala
+++ b/test/files/run/macro-whitebox-extractor/Macros_1.scala
@@ -2,7 +2,7 @@ import scala.reflect.macros.WhiteboxContext
import language.experimental.macros
object Extractor {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
object Macros {
diff --git a/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
index 1b975ca850..b8d0c042be 100644
--- a/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
+++ b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
@@ -12,5 +12,5 @@ object Macros {
"""
}
- def foo = macro impl
+ def foo: Any = macro impl
} \ No newline at end of file
diff --git a/test/files/run/reflection-mem-typecheck.scala b/test/files/run/reflection-mem-typecheck.scala
index a312c2c893..e3cabf689d 100644
--- a/test/files/run/reflection-mem-typecheck.scala
+++ b/test/files/run/reflection-mem-typecheck.scala
@@ -21,6 +21,6 @@ object Test extends MemoryTest {
foo(List(new A {}, new B {}))
""".trim
snippet = snippet + "\n" + (List.fill(50)(snippet.split("\n").last) mkString "\n")
- tb.typeCheck(tb.parse(snippet))
+ tb.typecheck(tb.parse(snippet))
}
} \ No newline at end of file
diff --git a/test/files/run/reify_ann1a.scala b/test/files/run/reify_ann1a.scala
index c23048e463..e3ff9e532d 100644
--- a/test/files/run/reify_ann1a.scala
+++ b/test/files/run/reify_ann1a.scala
@@ -20,7 +20,7 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(tree)
+ val ttree = toolbox.typecheck(tree)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann1b.scala b/test/files/run/reify_ann1b.scala
index 29ce6021a2..30bafadf75 100644
--- a/test/files/run/reify_ann1b.scala
+++ b/test/files/run/reify_ann1b.scala
@@ -20,7 +20,7 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(tree)
+ val ttree = toolbox.typecheck(tree)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann2a.scala b/test/files/run/reify_ann2a.scala
index 53423e12c3..515fba015f 100644
--- a/test/files/run/reify_ann2a.scala
+++ b/test/files/run/reify_ann2a.scala
@@ -20,7 +20,7 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(tree)
+ val ttree = toolbox.typecheck(tree)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann3.scala b/test/files/run/reify_ann3.scala
index 4162fa532f..7098e928a7 100644
--- a/test/files/run/reify_ann3.scala
+++ b/test/files/run/reify_ann3.scala
@@ -14,7 +14,7 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(tree)
+ val ttree = toolbox.typecheck(tree)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann4.scala b/test/files/run/reify_ann4.scala
index 0aedb77b5e..f6426213df 100644
--- a/test/files/run/reify_ann4.scala
+++ b/test/files/run/reify_ann4.scala
@@ -18,7 +18,7 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(tree)
+ val ttree = toolbox.typecheck(tree)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann5.scala b/test/files/run/reify_ann5.scala
index d27be3b6d5..5e2f058a39 100644
--- a/test/files/run/reify_ann5.scala
+++ b/test/files/run/reify_ann5.scala
@@ -15,7 +15,7 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(tree)
+ val ttree = toolbox.typecheck(tree)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_classfileann_a.scala b/test/files/run/reify_classfileann_a.scala
index 1d51688e78..9ae12bff82 100644
--- a/test/files/run/reify_classfileann_a.scala
+++ b/test/files/run/reify_classfileann_a.scala
@@ -14,7 +14,7 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(tree)
+ val ttree = toolbox.typecheck(tree)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_classfileann_b.scala b/test/files/run/reify_classfileann_b.scala
index ef19e9240b..a0cb8f0b49 100644
--- a/test/files/run/reify_classfileann_b.scala
+++ b/test/files/run/reify_classfileann_b.scala
@@ -18,7 +18,7 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(tree)
+ val ttree = toolbox.typecheck(tree)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_renamed_term_si5841.check b/test/files/run/reify_renamed_term_t5841.check
index 6031277b76..6031277b76 100644
--- a/test/files/run/reify_renamed_term_si5841.check
+++ b/test/files/run/reify_renamed_term_t5841.check
diff --git a/test/files/run/reify_renamed_term_si5841.scala b/test/files/run/reify_renamed_term_t5841.scala
index ef18d650bf..ef18d650bf 100644
--- a/test/files/run/reify_renamed_term_si5841.scala
+++ b/test/files/run/reify_renamed_term_t5841.scala
diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check
index 64c46392a3..f73abb5dc3 100644
--- a/test/files/run/repl-term-macros.check
+++ b/test/files/run/repl-term-macros.check
@@ -12,7 +12,7 @@ scala>
scala> def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
impl1: (c: scala.reflect.macros.BlackboxContext)c.Expr[Unit]
-scala> def foo1 = macro impl1
+scala> def foo1: Unit = macro impl1
defined term macro foo1: Unit
scala> foo1
@@ -22,7 +22,7 @@ scala>
scala> def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") }
impl2: (c: scala.reflect.macros.BlackboxContext)()c.Expr[Unit]
-scala> def foo2() = macro impl2
+scala> def foo2(): Unit = macro impl2
defined term macro foo2: ()Unit
scala> foo2()
@@ -32,7 +32,7 @@ scala>
scala> def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
impl3: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit]
-scala> def foo3(x: Int)(y: Int) = macro impl3
+scala> def foo3(x: Int)(y: Int): Unit = macro impl3
defined term macro foo3: (x: Int)(y: Int)Unit
scala> foo3(2)(3)
diff --git a/test/files/run/repl-term-macros.scala b/test/files/run/repl-term-macros.scala
index a779638c00..b4660e258e 100644
--- a/test/files/run/repl-term-macros.scala
+++ b/test/files/run/repl-term-macros.scala
@@ -6,15 +6,15 @@ object Test extends ReplTest {
import language.experimental.macros
def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
-def foo1 = macro impl1
+def foo1: Unit = macro impl1
foo1
def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") }
-def foo2() = macro impl2
+def foo2(): Unit = macro impl2
foo2()
def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
-def foo3(x: Int)(y: Int) = macro impl3
+def foo3(x: Int)(y: Int): Unit = macro impl3
foo3(2)(3)
"""
} \ No newline at end of file
diff --git a/test/files/run/resetattrs-this.scala b/test/files/run/resetattrs-this.scala
index 2a55437273..6150a4e265 100644
--- a/test/files/run/resetattrs-this.scala
+++ b/test/files/run/resetattrs-this.scala
@@ -5,7 +5,7 @@ import scala.tools.reflect.ToolBox
object Test extends App {
val tb = cm.mkToolBox()
val tree = Select(This(cm.staticPackage("scala").moduleClass), TermName("Predef"))
- val ttree = tb.typeCheck(tree)
+ val ttree = tb.typecheck(tree)
val rttree = tb.resetAllAttrs(ttree)
println(tb.eval(rttree) == Predef)
}
diff --git a/test/files/run/showraw_aliases.scala b/test/files/run/showraw_aliases.scala
index 65b4fcb1cd..56bd13707d 100644
--- a/test/files/run/showraw_aliases.scala
+++ b/test/files/run/showraw_aliases.scala
@@ -7,7 +7,7 @@ object Test extends App {
import scala.reflect.runtime.{universe => ru}
ru
""")
- val ttree = tb.typeCheck(tree)
+ val ttree = tb.typecheck(tree)
def stabilizeIds(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>")
def stabilizePositions(s: String) = """\d+""".r.replaceAllIn(s, "<offset>")
diff --git a/test/files/run/showraw_tree_types_ids.scala b/test/files/run/showraw_tree_types_ids.scala
index 198729e705..883af0110a 100644
--- a/test/files/run/showraw_tree_types_ids.scala
+++ b/test/files/run/showraw_tree_types_ids.scala
@@ -6,6 +6,6 @@ object Test extends App {
val tree1 = reify(new collection.immutable.HashMap[String, String])
val tree2 = reify(new collection.mutable.HashMap[String, String])
def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>")
- println(stabilize(showRaw(tb.typeCheck(tree1.tree), printIds = true, printTypes = true)))
- println(stabilize(showRaw(tb.typeCheck(tree2.tree), printIds = true, printTypes = true)))
+ println(stabilize(showRaw(tb.typecheck(tree1.tree), printIds = true, printTypes = true)))
+ println(stabilize(showRaw(tb.typecheck(tree2.tree), printIds = true, printTypes = true)))
} \ No newline at end of file
diff --git a/test/files/run/showraw_tree_types_typed.scala b/test/files/run/showraw_tree_types_typed.scala
index d7ccc84ea3..3dd696c77e 100644
--- a/test/files/run/showraw_tree_types_typed.scala
+++ b/test/files/run/showraw_tree_types_typed.scala
@@ -5,6 +5,6 @@ object Test extends App {
val tb = runtimeMirror(getClass.getClassLoader).mkToolBox()
val tree1 = reify(new collection.immutable.HashMap[String, String])
val tree2 = reify(new collection.mutable.HashMap[String, String])
- println(showRaw(tb.typeCheck(tree1.tree), printTypes = true))
- println(showRaw(tb.typeCheck(tree2.tree), printTypes = true))
+ println(showRaw(tb.typecheck(tree1.tree), printTypes = true))
+ println(showRaw(tb.typecheck(tree2.tree), printTypes = true))
} \ No newline at end of file
diff --git a/test/files/run/showraw_tree_ultimate.scala b/test/files/run/showraw_tree_ultimate.scala
index a8507623bc..e0d36e6bb7 100644
--- a/test/files/run/showraw_tree_ultimate.scala
+++ b/test/files/run/showraw_tree_ultimate.scala
@@ -6,6 +6,6 @@ object Test extends App {
val tree1 = reify(new collection.immutable.HashMap[String, String])
val tree2 = reify(new collection.mutable.HashMap[String, String])
def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>")
- println(stabilize(showRaw(tb.typeCheck(tree1.tree), printIds = true, printKinds = true, printTypes = true)))
- println(stabilize(showRaw(tb.typeCheck(tree2.tree), printIds = true, printKinds = true, printTypes = true)))
+ println(stabilize(showRaw(tb.typecheck(tree1.tree), printIds = true, printKinds = true, printTypes = true)))
+ println(stabilize(showRaw(tb.typecheck(tree2.tree), printIds = true, printKinds = true, printTypes = true)))
} \ No newline at end of file
diff --git a/test/files/continuations-run/t3199b.check b/test/files/run/t3199b.check
index b5d8bb58d9..b5d8bb58d9 100644
--- a/test/files/continuations-run/t3199b.check
+++ b/test/files/run/t3199b.check
diff --git a/test/files/continuations-run/t3199b.scala b/test/files/run/t3199b.scala
index 5010f2b085..5010f2b085 100644
--- a/test/files/continuations-run/t3199b.scala
+++ b/test/files/run/t3199b.scala
diff --git a/test/files/run/si4750.check b/test/files/run/t4750.check
index bf55f70df3..bf55f70df3 100644
--- a/test/files/run/si4750.check
+++ b/test/files/run/t4750.check
diff --git a/test/files/run/si4750.scala b/test/files/run/t4750.scala
index 96d2c4fec7..96d2c4fec7 100644
--- a/test/files/run/si4750.scala
+++ b/test/files/run/t4750.scala
diff --git a/test/files/run/t4841-isolate-plugins.check b/test/files/run/t4841-isolate-plugins.check
new file mode 100644
index 0000000000..a6462b424b
--- /dev/null
+++ b/test/files/run/t4841-isolate-plugins.check
@@ -0,0 +1,2 @@
+My phase name is ploogin1_1
+My phase name is ploogin1_2
diff --git a/test/files/run/t4841-isolate-plugins/ploogin.scala b/test/files/run/t4841-isolate-plugins/ploogin.scala
new file mode 100644
index 0000000000..bd8c7275ec
--- /dev/null
+++ b/test/files/run/t4841-isolate-plugins/ploogin.scala
@@ -0,0 +1,30 @@
+
+package t4841
+
+import scala.tools.nsc.{ Global, Phase }
+import scala.tools.nsc.plugins.{ Plugin, PluginComponent }
+import scala.reflect.io.Path
+import scala.reflect.io.File
+
+/** A test plugin. */
+class Ploogin(val global: Global, val name: String = "ploogin") extends Plugin {
+ import global._
+
+ val description = "A sample plugin for testing."
+ val components = List[PluginComponent](TestComponent)
+
+ private object TestComponent extends PluginComponent {
+ val global: Ploogin.this.global.type = Ploogin.this.global
+ //override val runsBefore = List("refchecks")
+ val runsAfter = List("jvm")
+ val phaseName = Ploogin.this.name
+ override def description = "A sample phase that does so many things it's kind of hard to describe briefly."
+ def newPhase(prev: Phase) = new TestPhase(prev)
+ class TestPhase(prev: Phase) extends StdPhase(prev) {
+ override def description = TestComponent.this.description
+ def apply(unit: CompilationUnit) {
+ if (settings.developer) inform(s"My phase name is $phaseName")
+ }
+ }
+ }
+}
diff --git a/test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala b/test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala
new file mode 100644
index 0000000000..5421922c9c
--- /dev/null
+++ b/test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala
@@ -0,0 +1,39 @@
+
+import tools.nsc.plugins.PluginDescription
+import tools.partest.DirectTest
+
+import java.io.File
+
+// show that plugins are on isolated class loaders
+object Test extends DirectTest {
+ override def code = "class Code"
+
+ override def extraSettings = s"-usejavacp"
+
+ // plugin named ploogin1_1 or ploogin1_2, but not ploogin2_x
+ // Although the samples are in different classloaders, the plugin
+ // loader checks for distinctness by class name, so the names must differ.
+ def pluginCode(index: Int) = s"""
+ |package t4841 {
+ | class SamplePloogin$index(global: scala.tools.nsc.Global) extends Ploogin(global, s"$${PlooginCounter.named}_$index")
+ | object PlooginCounter {
+ | val count = new java.util.concurrent.atomic.AtomicInteger
+ | def named = s"ploogin$${count.incrementAndGet}"
+ | }
+ |}""".stripMargin.trim
+
+ def compilePlugin(i: Int) = {
+ val out = (testOutput / s"p$i").createDirectory()
+ val args = Seq("-usejavacp", "-d", out.path)
+ compileString(newCompiler(args: _*))(pluginCode(i))
+ val xml = PluginDescription(s"p$i", s"t4841.SamplePloogin$i").toXML
+ (out / "scalac-plugin.xml").toFile writeAll xml
+ out
+ }
+
+ override def show() = {
+ val dirs = 1 to 2 map (compilePlugin(_))
+ compile("-Xdev", s"-Xplugin:${dirs mkString ","}", "-usejavacp", "-d", testOutput.path)
+ }
+}
+
diff --git a/test/files/run/t4841-no-plugin.check b/test/files/run/t4841-no-plugin.check
new file mode 100644
index 0000000000..4338f0ce23
--- /dev/null
+++ b/test/files/run/t4841-no-plugin.check
@@ -0,0 +1 @@
+warning: No plugin in path t4841-no-plugin-run.obj/plugins.partest
diff --git a/test/files/run/t4841-no-plugin.scala b/test/files/run/t4841-no-plugin.scala
new file mode 100644
index 0000000000..d91bf7ee21
--- /dev/null
+++ b/test/files/run/t4841-no-plugin.scala
@@ -0,0 +1,17 @@
+
+import tools.partest.DirectTest
+
+import java.io.File
+
+// warn only if no plugin on Xplugin path
+object Test extends DirectTest {
+ override def code = "class Code"
+
+ override def extraSettings = s"-usejavacp -d ${testOutput.path}"
+
+ override def show() = {
+ val tmp = new File(testOutput.jfile, "plugins.partest").getAbsolutePath
+ compile("-Xdev", s"-Xplugin:$tmp", "-Xpluginsdir", tmp)
+ }
+}
+
diff --git a/test/files/run/si5045.check b/test/files/run/t5045.check
index 7e9c1961b7..7e9c1961b7 100644
--- a/test/files/run/si5045.check
+++ b/test/files/run/t5045.check
diff --git a/test/files/run/si5045.scala b/test/files/run/t5045.scala
index b0c3a4ddc4..b0c3a4ddc4 100644
--- a/test/files/run/si5045.scala
+++ b/test/files/run/t5045.scala
diff --git a/test/files/run/t5415.scala b/test/files/run/t5415.scala
index c12e209bb7..65de86245b 100644
--- a/test/files/run/t5415.scala
+++ b/test/files/run/t5415.scala
@@ -8,5 +8,5 @@ object Test extends App{
import scala.reflect.runtime.{currentMirror => cm}
import scala.tools.reflect.ToolBox
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(code.tree)
+ val ttree = toolbox.typecheck(code.tree)
}
diff --git a/test/files/run/t5418b.scala b/test/files/run/t5418b.scala
index 08e8bb163b..c6172613d5 100644
--- a/test/files/run/t5418b.scala
+++ b/test/files/run/t5418b.scala
@@ -5,7 +5,7 @@ import scala.tools.reflect.ToolBox
object Test extends App {
val tb = cm.mkToolBox()
val untyped = reify(new Object().getClass).tree
- val typed = tb.typeCheck(untyped)
+ val typed = tb.typecheck(untyped)
println(typed)
println(showRaw(typed.tpe))
} \ No newline at end of file
diff --git a/test/files/run/t5704.scala b/test/files/run/t5704.scala
index ddcbcc27b3..495a82e4f0 100644
--- a/test/files/run/t5704.scala
+++ b/test/files/run/t5704.scala
@@ -8,7 +8,7 @@ object Test extends App {
def findUserByName( name:String ) = {
val tree = reify{ "test" == name }.tree
val toolbox = cm.mkToolBox()
- toolbox.typeCheck(tree) match{
+ toolbox.typecheck(tree) match{
case Apply(Select(lhs,op),rhs::Nil) =>
println(rhs.tpe)
}
diff --git a/test/files/run/t5816.scala b/test/files/run/t5816.scala
index f0279e5703..e8367ea81e 100644
--- a/test/files/run/t5816.scala
+++ b/test/files/run/t5816.scala
@@ -6,7 +6,7 @@ object Test extends App {
val toolbox = cm.mkToolBox()
def printSource[T](expr: Expr[T]) {
- val ttree = toolbox typeCheck expr.tree
+ val ttree = toolbox typecheck expr.tree
println(ttree.toString)
}
diff --git a/test/files/run/t5894.scala b/test/files/run/t5894.scala
index 55767d8889..5d482333f5 100644
--- a/test/files/run/t5894.scala
+++ b/test/files/run/t5894.scala
@@ -3,7 +3,7 @@ import language.experimental.macros
class Test
object Test {
- def foo = macro fooImpl
+ def foo: Unit = macro fooImpl
def fooImpl(c: reflect.macros.BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
def main(args: Array[String]) {
diff --git a/test/files/run/t5903a/Macros_1.scala b/test/files/run/t5903a/Macros_1.scala
index 7888b888e1..ce1b035260 100644
--- a/test/files/run/t5903a/Macros_1.scala
+++ b/test/files/run/t5903a/Macros_1.scala
@@ -7,7 +7,7 @@ case object SomeTree extends Tree
object NewQuasiquotes {
implicit class QuasiquoteInterpolation(c: StringContext) {
object nq {
- def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl
+ def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl
}
}
}
diff --git a/test/files/run/t5903b/Macros_1.scala b/test/files/run/t5903b/Macros_1.scala
index 8c03e5579d..97f15cec3b 100644
--- a/test/files/run/t5903b/Macros_1.scala
+++ b/test/files/run/t5903b/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply[T](x: T) = macro Macros.unapplyImpl[T]
+ def unapply[T](x: T): Any = macro Macros.unapplyImpl[T]
}
}
}
diff --git a/test/files/run/t5903c/Macros_1.scala b/test/files/run/t5903c/Macros_1.scala
index c9dfe9d60c..979284a263 100644
--- a/test/files/run/t5903c/Macros_1.scala
+++ b/test/files/run/t5903c/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply[T](x: T) = macro Macros.unapplyImpl[T]
+ def unapply[T](x: T): Any = macro Macros.unapplyImpl[T]
}
}
}
diff --git a/test/files/run/t5903d/Macros_1.scala b/test/files/run/t5903d/Macros_1.scala
index 8a57e27602..dc1989462b 100644
--- a/test/files/run/t5903d/Macros_1.scala
+++ b/test/files/run/t5903d/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
}
}
diff --git a/test/files/run/t5912.scala b/test/files/run/t5912.scala
index 9418e946d0..fc879a0537 100644
--- a/test/files/run/t5912.scala
+++ b/test/files/run/t5912.scala
@@ -3,5 +3,5 @@ object Test extends App{
import scala.reflect.runtime.{currentMirror=>cm}
import scala.tools.reflect._
import scala.reflect.runtime.universe._
- val tree = cm.mkToolBox().typeCheck( Literal(Constant("test")) )
+ val tree = cm.mkToolBox().typecheck( Literal(Constant("test")) )
}
diff --git a/test/files/run/t5940.scala b/test/files/run/t5940.scala
index d98f267123..062f11c467 100644
--- a/test/files/run/t5940.scala
+++ b/test/files/run/t5940.scala
@@ -13,7 +13,7 @@ object Test extends DirectTest {
object Macros {
//import Impls._
def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
- def foo = macro impl
+ def foo: Unit = macro impl
}
"""
def compileMacros() = {
diff --git a/test/files/run/t5943a1.scala b/test/files/run/t5943a1.scala
index 00f4afa808..6bb828de85 100644
--- a/test/files/run/t5943a1.scala
+++ b/test/files/run/t5943a1.scala
@@ -5,5 +5,5 @@ import scala.tools.reflect.ToolBox
object Test extends App {
val tb = cm.mkToolBox()
val expr = tb.parse("1 to 3 map (_+1)")
- println(tb.typeCheck(expr))
+ println(tb.typecheck(expr))
} \ No newline at end of file
diff --git a/test/files/run/t6023.scala b/test/files/run/t6023.scala
index 07af3685a5..2753b93ac4 100644
--- a/test/files/run/t6023.scala
+++ b/test/files/run/t6023.scala
@@ -9,7 +9,7 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
- val ttree = toolbox.typeCheck(tree)
+ val ttree = toolbox.typecheck(tree)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/t6355.check b/test/files/run/t6355.check
new file mode 100644
index 0000000000..ce74ab38a2
--- /dev/null
+++ b/test/files/run/t6355.check
@@ -0,0 +1,2 @@
+bippy(x: Int) called with x = 42
+bippy(x: String) called with x = "42"
diff --git a/test/files/run/t6355.scala b/test/files/run/t6355.scala
new file mode 100644
index 0000000000..f1921391a3
--- /dev/null
+++ b/test/files/run/t6355.scala
@@ -0,0 +1,17 @@
+import scala.language.dynamics
+
+class A extends Dynamic {
+ def applyDynamic(method: String): B = new B(method)
+}
+class B(method: String) {
+ def apply(x: Int) = s"$method(x: Int) called with x = $x"
+ def apply(x: String) = s"""$method(x: String) called with x = "$x""""
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val x = new A
+ println(x.bippy(42))
+ println(x.bippy("42"))
+ }
+}
diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check
index dfc9d44850..ef08d0da09 100644
--- a/test/files/run/t6381.check
+++ b/test/files/run/t6381.check
@@ -10,7 +10,7 @@ scala> def pos_impl(c: reflect.macros.BlackboxContext): c.Expr[String] = {
}
pos_impl: (c: scala.reflect.macros.BlackboxContext)c.Expr[String]
-scala> def pos = macro pos_impl
+scala> def pos: String = macro pos_impl
defined term macro pos: String
scala> pos
diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala
index 0e2264d8fa..c78dc13ed7 100644
--- a/test/files/run/t6381.scala
+++ b/test/files/run/t6381.scala
@@ -7,7 +7,7 @@ object Test extends ReplTest {
| import c.universe._
| c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString)))
|}
- |def pos = macro pos_impl
+ |def pos: String = macro pos_impl
|pos
|""".stripMargin.trim
diff --git a/test/files/run/t6392b.scala b/test/files/run/t6392b.scala
index f69a5aaf45..e43c1a2b03 100644
--- a/test/files/run/t6392b.scala
+++ b/test/files/run/t6392b.scala
@@ -5,5 +5,5 @@ import scala.tools.reflect.ToolBox
object Test extends App {
val tb = cm.mkToolBox()
val c = tb.parse("object C")
- println(showRaw(tb.typeCheck(c), printKinds = true))
+ println(showRaw(tb.typecheck(c), printKinds = true))
} \ No newline at end of file
diff --git a/test/files/run/t6992.check b/test/files/run/t6992.check
new file mode 100644
index 0000000000..1a0684c995
--- /dev/null
+++ b/test/files/run/t6992.check
@@ -0,0 +1,3 @@
+Int
+42
+42
diff --git a/test/files/run/t6992/Macros_1.scala b/test/files/run/t6992/Macros_1.scala
new file mode 100644
index 0000000000..25566dddbf
--- /dev/null
+++ b/test/files/run/t6992/Macros_1.scala
@@ -0,0 +1,75 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.Context
+
+object Macros {
+ def foo(name: String): Any = macro foo_impl
+ def foo_impl(c: Context)(name: c.Expr[String]) = {
+ import c.universe._
+
+ val Literal(Constant(lit: String)) = name.tree
+ val anon = newTypeName(c.fresh)
+
+ c.Expr(Block(
+ ClassDef(
+ Modifiers(Flag.FINAL), anon, Nil, Template(
+ Nil, noSelfType, List(
+ DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))),
+ TypeDef(Modifiers(), TypeName(lit), Nil, TypeTree(typeOf[Int]))
+ )
+ )
+ ),
+ Apply(Select(New(Ident(anon)), nme.CONSTRUCTOR), Nil)
+ ))
+ }
+
+ def bar(name: String): Any = macro bar_impl
+ def bar_impl(c: Context)(name: c.Expr[String]) = {
+ import c.universe._
+
+ val Literal(Constant(lit: String)) = name.tree
+ val anon = newTypeName(c.fresh)
+
+ c.Expr(Block(
+ ClassDef(
+ Modifiers(Flag.FINAL), anon, Nil, Template(
+ Nil, noSelfType, List(
+ DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))),
+ DefDef(
+ Modifiers(), TermName(lit), Nil, Nil, TypeTree(),
+ c.literal(42).tree
+ )
+ )
+ )
+ ),
+ Apply(Select(New(Ident(anon)), nme.CONSTRUCTOR), Nil)
+ ))
+ }
+
+ def baz(name: String): Any = macro baz_impl
+ def baz_impl(c: Context)(name: c.Expr[String]) = {
+ import c.universe._
+
+ val Literal(Constant(lit: String)) = name.tree
+ val anon = newTypeName(c.fresh)
+ val wrapper = newTypeName(c.fresh)
+
+ c.Expr(Block(
+ ClassDef(
+ Modifiers(), anon, Nil, Template(
+ Nil, emptyValDef, List(
+ DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))),
+ DefDef(
+ Modifiers(), TermName(lit), Nil, Nil, TypeTree(),
+ c.literal(42).tree
+ )
+ )
+ )
+ ),
+ ClassDef(
+ Modifiers(Flag.FINAL), wrapper, Nil,
+ Template(Ident(anon) :: Nil, noSelfType, DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))) :: Nil)
+ ),
+ Apply(Select(New(Ident(wrapper)), nme.CONSTRUCTOR), Nil)
+ ))
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t6992/Test_2.scala b/test/files/run/t6992/Test_2.scala
new file mode 100644
index 0000000000..05282d6f5b
--- /dev/null
+++ b/test/files/run/t6992/Test_2.scala
@@ -0,0 +1,12 @@
+import scala.language.reflectiveCalls
+
+object Test extends App {
+ val foo = Macros.foo("T")
+ println(scala.reflect.runtime.universe.weakTypeOf[foo.T].typeSymbol.typeSignature)
+
+ val bar = Macros.bar("test")
+ println(bar.test)
+
+ val baz = Macros.baz("test")
+ println(baz.test)
+} \ No newline at end of file
diff --git a/test/files/run/t7185.check b/test/files/run/t7185.check
index 38449b3497..ebf85b731f 100644
--- a/test/files/run/t7185.check
+++ b/test/files/run/t7185.check
@@ -21,7 +21,7 @@ tree: reflect.runtime.universe.Apply =
}
}()
-scala> {val tb = reflect.runtime.currentMirror.mkToolBox(); tb.typeCheck(tree): Any}
+scala> {val tb = reflect.runtime.currentMirror.mkToolBox(); tb.typecheck(tree): Any}
res0: Any =
{
{
diff --git a/test/files/run/t7185.scala b/test/files/run/t7185.scala
index d9d913e78a..62d64246bc 100644
--- a/test/files/run/t7185.scala
+++ b/test/files/run/t7185.scala
@@ -7,6 +7,6 @@ import scala.reflect.runtime.universe._
object O { def apply() = 0 }
val ORef = reify { O }.tree
val tree = Apply(Block(Nil, Block(Nil, ORef)), Nil)
-{val tb = reflect.runtime.currentMirror.mkToolBox(); tb.typeCheck(tree): Any}
+{val tb = reflect.runtime.currentMirror.mkToolBox(); tb.typecheck(tree): Any}
"""
}
diff --git a/test/files/continuations-run/ifelse0.check b/test/files/run/t7406.check
index f8bc79860d..f599e28b8a 100644
--- a/test/files/continuations-run/ifelse0.check
+++ b/test/files/run/t7406.check
@@ -1,2 +1 @@
10
-9 \ No newline at end of file
diff --git a/test/files/run/t7406.scala b/test/files/run/t7406.scala
new file mode 100644
index 0000000000..a8b35c91c9
--- /dev/null
+++ b/test/files/run/t7406.scala
@@ -0,0 +1,14 @@
+class Arne[@specialized(Long) T](x: T) {
+ val regularVal = x
+ lazy val lazyVal = x
+
+ def apply(f: (T, T) => T): T = f(regularVal, lazyVal)
+}
+
+object Test {
+ val arne = new Arne(5L)
+ def f = arne(_ + _)
+ def main(args: Array[String]): Unit = {
+ println(f)
+ }
+}
diff --git a/test/files/run/t7617b/Test_2.scala b/test/files/run/t7617b/Test_2.scala
index e27f650e80..e1d9acdc31 100644
--- a/test/files/run/t7617b/Test_2.scala
+++ b/test/files/run/t7617b/Test_2.scala
@@ -2,7 +2,7 @@ import scala.language.dynamics
import language.experimental.macros
class C extends Dynamic {
- def updateDynamic(name: String)(value: Any) = macro Macros.impl
+ def updateDynamic(name: String)(value: Any): Unit = macro Macros.impl
}
object Test extends App {
diff --git a/test/files/run/t7777.check b/test/files/run/t7777.check
new file mode 100644
index 0000000000..162ff2d2a2
--- /dev/null
+++ b/test/files/run/t7777.check
@@ -0,0 +1,7 @@
+foo(1, 2)
+bar(4, 5)
+foo(3)
+bar(7)
+apply(6)
+apply(9)
+foo(8)
diff --git a/test/files/run/t7777/Macros_1.scala b/test/files/run/t7777/Macros_1.scala
new file mode 100644
index 0000000000..459ab3edbb
--- /dev/null
+++ b/test/files/run/t7777/Macros_1.scala
@@ -0,0 +1,17 @@
+import scala.language.experimental.macros
+import scala.language.dynamics
+import scala.reflect.macros.WhiteboxContext
+
+class DynMacro extends Dynamic {
+ def applyDynamic(s: String)(xs: Any*): DynMacro =
+ macro DynMacro.applyDynamicMacro
+}
+
+object DynMacro extends DynMacro {
+ def applyDynamicMacro(c: WhiteboxContext)(s: c.Expr[String])(xs: c.Expr[Any]*): c.Expr[DynMacro] = {
+ import c.universe._
+ val Literal(Constant(n: String)) = s.tree
+ val args = xs.map(_.tree.toString).mkString("(", ", ", ")")
+ c.Expr(q"println(${ n + args }); ${c.prefix.tree}")
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t7777/Test_2.scala b/test/files/run/t7777/Test_2.scala
new file mode 100644
index 0000000000..1fe8b63bab
--- /dev/null
+++ b/test/files/run/t7777/Test_2.scala
@@ -0,0 +1,6 @@
+object Test extends App {
+ DynMacro.foo(1, 2) // prints "foo(1, 2)"
+ DynMacro.foo(3).bar(4, 5) // prints "bar(4, 5)", then "foo(3)"
+ DynMacro(6).bar(7) // prints "bar(7)", then "apply(6)"
+ DynMacro.foo(8)(9) // Fails!
+} \ No newline at end of file
diff --git a/test/files/run/t7871/Macros_1.scala b/test/files/run/t7871/Macros_1.scala
index 778068deb3..801a6af4e7 100644
--- a/test/files/run/t7871/Macros_1.scala
+++ b/test/files/run/t7871/Macros_1.scala
@@ -7,7 +7,7 @@ case object SomeTree extends Tree
object NewQuasiquotes {
implicit class QuasiquoteInterpolation(c: StringContext) {
object nq {
- def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl
+ def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl
}
}
}
diff --git a/test/files/run/t7912.scala b/test/files/run/t7912.scala
new file mode 100644
index 0000000000..3d603e0e97
--- /dev/null
+++ b/test/files/run/t7912.scala
@@ -0,0 +1,16 @@
+case object A { override def toString = ??? }
+
+object Test {
+ def foo: Int = (A: Any) match {
+ case 0 => 0
+ }
+ def main(args: Array[String]): Unit = {
+ try {
+ foo
+ sys.error("no exception")
+ } catch {
+ case me: MatchError => assert(me.getMessage == "an instance of class A$", me.getMessage)
+ case ex: Throwable => sys.error("not a match error: " + ex.getClass)
+ }
+ }
+}
diff --git a/test/files/run/t8010.scala b/test/files/run/t8010.scala
new file mode 100644
index 0000000000..8636bbd12e
--- /dev/null
+++ b/test/files/run/t8010.scala
@@ -0,0 +1,22 @@
+trait Base {
+ def t = 1
+ def t(n: Int) = n
+ def bt = 2
+ def bt(n: Int) = n
+}
+trait Derived extends Base {
+ // was: double defintion error
+ override def t = 1 + super.t
+ override def t(n: Int) = 1 + super.t(n)
+ override def bt = 1 + super.bt
+ override def bt(n: Int) = 1 + super.bt(n)
+}
+
+object Test extends App {
+ val d = new Derived {}
+ // not the focus of thie bug, but let's just check the runtime behaviour while we're here.
+ assert(d.t == 2)
+ assert(d.t(1) == 2)
+ assert(d.bt == 3)
+ assert(d.bt(1) == 2)
+}
diff --git a/test/files/run/t8017.flags b/test/files/run/t8017.flags
new file mode 100644
index 0000000000..48b438ddf8
--- /dev/null
+++ b/test/files/run/t8017.flags
@@ -0,0 +1 @@
+-Ydelambdafy:method
diff --git a/test/files/run/t8017/value-class-lambda.scala b/test/files/run/t8017/value-class-lambda.scala
new file mode 100644
index 0000000000..370023b194
--- /dev/null
+++ b/test/files/run/t8017/value-class-lambda.scala
@@ -0,0 +1,40 @@
+object Test {
+ def testC {
+ val f1 = (c: C) => c.value
+ val f2 = (x: Int) => new C(x)
+ val f3 = (c1: C) => (c2: C) => (c1, c2)
+ val r1 = f2(2)
+ val r2 = f2(2)
+ val r3 = f3(r1)(r2)
+ val result = f1(r3._2)
+ assert(result == 2)
+ }
+
+ def testD {
+ val f1 = (c: D) => c.value
+ val f2 = (x: String) => new D(x)
+ val f3 = (c1: D) => (c2: D) => (c1, c2)
+ val r1 = f2("2")
+ val r2 = f2("2")
+ val r3 = f3(r1)(r2)
+ val result = f1(r3._2)
+ assert(result == "2")
+ }
+
+ def testE {
+ val f1 = (c: E[Int]) => c.value
+ val f2 = (x: Int) => new E(x)
+ val f3 = (c1: E[Int]) => (c2: E[Int]) => (c1, c2)
+ val r1 = f2(2)
+ val r2 = f2(2)
+ val r3 = f3(r1)(r2)
+ val result = f1(r3._2)
+ assert(result == 2)
+ }
+
+ def main(args: Array[String]) {
+ testC
+ testD
+ testE
+ }
+}
diff --git a/test/files/run/t8017/value-class.scala b/test/files/run/t8017/value-class.scala
new file mode 100644
index 0000000000..821239305f
--- /dev/null
+++ b/test/files/run/t8017/value-class.scala
@@ -0,0 +1,3 @@
+class C(val value: Int) extends AnyVal
+class D(val value: String) extends AnyVal
+class E[A](val value: A) extends AnyVal
diff --git a/test/files/run/t8029.scala b/test/files/run/t8029.scala
new file mode 100644
index 0000000000..dbd5c41387
--- /dev/null
+++ b/test/files/run/t8029.scala
@@ -0,0 +1,57 @@
+import scala.tools.partest._
+import scala.tools.nsc._
+
+object Test extends DirectTest {
+
+ override def extraSettings: String = "-usejavacp -nowarn -Ystop-after:typer"
+
+ override def code = "" // not used
+
+ def code1 = """
+package object p1 {
+ trait A
+ object A
+}
+ """
+
+ def code2 = """
+package object p2 {
+ class A
+ object A
+}
+ """
+
+ def code3 = """
+package object p3 {
+ object A
+ trait A
+}
+ """
+
+ def code4 = """
+package object p4 {
+ object A
+ trait A
+}
+ """
+
+ def show() {
+ val global = newCompiler()
+ import global._
+ def typecheck(code: String): Unit = {
+ val r = new Run
+ val sourceFile = newSources(code).head
+ global.reporter.reset()
+ r.compileSources(sourceFile :: Nil)
+ assert(!global.reporter.hasErrors)
+ }
+
+ def typecheckTwice(code: String): Unit = {
+ typecheck(code)
+ typecheck(code)
+ }
+
+ // was: illegal cyclic reference involving package ...
+ Seq(code1, code2, code3, code4) foreach typecheckTwice
+ }
+}
diff --git a/test/files/run/t8047.check b/test/files/run/t8047.check
new file mode 100644
index 0000000000..a6b83a4a16
--- /dev/null
+++ b/test/files/run/t8047.check
@@ -0,0 +1,7 @@
+doWhile$1(){
+ 1;
+ if (true)
+ doWhile$1()
+ else
+ ()
+}
diff --git a/test/files/run/t8047.scala b/test/files/run/t8047.scala
new file mode 100644
index 0000000000..f5660541e8
--- /dev/null
+++ b/test/files/run/t8047.scala
@@ -0,0 +1,31 @@
+object Test extends App {
+ import scala.reflect.runtime.universe._
+ //
+ // x's owner is outer Test scope. Previosly the quasiquote expansion
+ // looked like:
+ //
+ // object Test {
+ // build.withFreshTermName("doWhile")(n =>
+ // LabelDef(n, List(),
+ // Block(
+ // List({ val x = 1; x }),
+ // If(Literal(Constant(true)), Apply(Ident(n), List()), Literal(Constant(())))))
+ // }
+ //
+ // Here the proper owner is anonymous function, not the Test. Hence
+ // symbol corruption. In new encoding this is represented as:
+ //
+ // object Test {
+ // {
+ // val n = build.freshTermName("doWhile")
+ // LabelDef(n, List(),
+ // Block(
+ // List({ val x = 1; x }),
+ // If(Literal(Constant(true)), Apply(Ident(n), List()), Literal(Constant(()))))
+ // }
+ // }
+ //
+ // Owner stays the same and life is good again.
+ //
+ println(q"do ${ val x = 1; x } while(true)")
+}
diff --git a/test/files/run/t8048a.check b/test/files/run/t8048a.check
new file mode 100644
index 0000000000..8fb9e26e84
--- /dev/null
+++ b/test/files/run/t8048a.check
@@ -0,0 +1 @@
+Some(2)
diff --git a/test/files/run/t8048a/Macros_1.scala b/test/files/run/t8048a/Macros_1.scala
new file mode 100644
index 0000000000..f48e84f1de
--- /dev/null
+++ b/test/files/run/t8048a/Macros_1.scala
@@ -0,0 +1,11 @@
+import scala.reflect.macros.WhiteboxContext
+import scala.language.experimental.macros
+
+object Macros {
+ def impl(c: WhiteboxContext) = {
+ import c.universe._
+ q"if (true) Some(2) else None"
+ }
+
+ def foo: Any = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/t8048a/Test_2.scala b/test/files/run/t8048a/Test_2.scala
new file mode 100644
index 0000000000..4e1c8b16b0
--- /dev/null
+++ b/test/files/run/t8048a/Test_2.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ val x: Option[Int] = Macros.foo
+ println(x)
+} \ No newline at end of file
diff --git a/test/files/run/t8048b.check b/test/files/run/t8048b.check
new file mode 100644
index 0000000000..083edaac24
--- /dev/null
+++ b/test/files/run/t8048b.check
@@ -0,0 +1,3 @@
+2
+2
+2
diff --git a/test/files/run/t8048b/Macros_1.scala b/test/files/run/t8048b/Macros_1.scala
new file mode 100644
index 0000000000..b113af86ea
--- /dev/null
+++ b/test/files/run/t8048b/Macros_1.scala
@@ -0,0 +1,37 @@
+// see the following discussions to understand what's being tested here:
+// * https://issues.scala-lang.org/browse/SI-6992
+// * https://issues.scala-lang.org/browse/SI-8048
+// * http://stackoverflow.com/questions/14370842/getting-a-structural-type-with-an-anonymous-classs-methods-from-a-macro
+// * http://stackoverflow.com/questions/18480707/method-cannot-be-accessed-in-macro-generated-class/18485004#18485004
+// * https://groups.google.com/forum/#!topic/scala-internals/eXQt-BPm4i8
+
+import scala.language.experimental.macros
+import scala.reflect.macros.WhiteboxContext
+
+object Macros {
+ def impl1(c: WhiteboxContext) = {
+ import c.universe._
+ q"""
+ trait Foo { def x = 2 }
+ new Foo {}
+ """
+ }
+ def foo1: Any = macro impl1
+
+ def impl2(c: WhiteboxContext) = {
+ import c.universe._
+ q"""
+ class Foo { def x = 2 }
+ new Foo
+ """
+ }
+ def foo2: Any = macro impl2
+
+ def impl3(c: WhiteboxContext) = {
+ import c.universe._
+ q"""
+ new { def x = 2 }
+ """
+ }
+ def foo3: Any = macro impl3
+} \ No newline at end of file
diff --git a/test/files/run/t8048b/Test_2.scala b/test/files/run/t8048b/Test_2.scala
new file mode 100644
index 0000000000..fb410dab7a
--- /dev/null
+++ b/test/files/run/t8048b/Test_2.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ println(Macros.foo1.x)
+ println(Macros.foo2.x)
+ println(Macros.foo3.x)
+} \ No newline at end of file
diff --git a/test/files/run/t8091.check b/test/files/run/t8091.check
new file mode 100644
index 0000000000..4c4e91774f
--- /dev/null
+++ b/test/files/run/t8091.check
@@ -0,0 +1 @@
+b&#x00f6;rk b&#x00f6;rk
diff --git a/test/files/run/t8091.scala b/test/files/run/t8091.scala
new file mode 100644
index 0000000000..cd412d4c2a
--- /dev/null
+++ b/test/files/run/t8091.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ val result = "börk börk" flatMap (ch ⇒ if (ch > 127) f"&#x${ch}%04x;" else "" + ch)
+ println(result)
+} \ No newline at end of file
diff --git a/test/files/run/t8104.check b/test/files/run/t8104.check
new file mode 100644
index 0000000000..c2593eb199
--- /dev/null
+++ b/test/files/run/t8104.check
@@ -0,0 +1 @@
+TypeTag[(Int, Int)]
diff --git a/test/files/run/t8104/Macros_1.scala b/test/files/run/t8104/Macros_1.scala
new file mode 100644
index 0000000000..21d81a3687
--- /dev/null
+++ b/test/files/run/t8104/Macros_1.scala
@@ -0,0 +1,11 @@
+import scala.reflect.macros.WhiteboxContext
+
+object Macros {
+ def impl[T](c: WhiteboxContext)(implicit T: c.WeakTypeTag[T]) = {
+ import c.universe._
+ import definitions._
+ val fields = T.tpe.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x }
+ val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.typeSignature))
+ q"new Generic[$T]{ type Repr = $Repr }"
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t8104/Test_2.scala b/test/files/run/t8104/Test_2.scala
new file mode 100644
index 0000000000..630176f175
--- /dev/null
+++ b/test/files/run/t8104/Test_2.scala
@@ -0,0 +1,16 @@
+trait Generic[T] { type Repr }
+object Generic {
+ type Aux[T, Repr0] = Generic[T] { type Repr = Repr0 }
+ import scala.language.experimental.macros
+ implicit def materializeGeneric[T, Repr]: Generic.Aux[T, Repr] = macro Macros.impl[T]
+}
+
+object Test extends App {
+ case class C(x: Int, y: Int)
+
+ import scala.reflect.runtime.universe._
+ def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: TypeTag[Repr]) = println(tag)
+ reprify(C(40, 2))
+
+ implicitly[Generic.Aux[C, (Int, Int)]]
+}
diff --git a/test/files/run/toolbox_current_run_compiles.scala b/test/files/run/toolbox_current_run_compiles.scala
index bc6a9d343e..31e0a45eea 100644
--- a/test/files/run/toolbox_current_run_compiles.scala
+++ b/test/files/run/toolbox_current_run_compiles.scala
@@ -9,7 +9,7 @@ package pkg {
val g = c.universe.asInstanceOf[scala.tools.nsc.Global]
c.Expr[Boolean](Literal(Constant(g.currentRun.compiles(sym.asInstanceOf[g.Symbol]))))
}
- def compiles[T] = macro impl[T]
+ def compiles[T]: Boolean = macro impl[T]
}
}
diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.scala b/test/files/run/toolbox_typecheck_implicitsdisabled.scala
index 95a7056279..8c1a6e580c 100644
--- a/test/files/run/toolbox_typecheck_implicitsdisabled.scala
+++ b/test/files/run/toolbox_typecheck_implicitsdisabled.scala
@@ -10,7 +10,7 @@ object Test extends App {
Import(Select(Ident(TermName("scala")), TermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))),
Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2))))
)
- val ttree1 = toolbox.typeCheck(tree1, withImplicitViewsDisabled = false)
+ val ttree1 = toolbox.typecheck(tree1, withImplicitViewsDisabled = false)
println(ttree1)
try {
@@ -18,7 +18,7 @@ object Test extends App {
Import(Select(Ident(TermName("scala")), TermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))),
Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2))))
)
- val ttree2 = toolbox.typeCheck(tree2, withImplicitViewsDisabled = true)
+ val ttree2 = toolbox.typecheck(tree2, withImplicitViewsDisabled = true)
println(ttree2)
} catch {
case ex: Throwable =>
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check
index 3de296f1ad..d9e79cdd19 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled.check
+++ b/test/files/run/toolbox_typecheck_macrosdisabled.check
@@ -1,4 +1,4 @@
-{
+({
val $u: ru.type = ru;
val $m: $u.Mirror = ru.runtimeMirror({
final class $anon extends scala.AnyRef {
@@ -37,5 +37,5 @@
};
new $typecreator2()
}))
-}
+}: ru.Expr[Int])
ru.reify[Int](2)
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala
index 1f7fda8575..4cbeefd6e0 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled.scala
+++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala
@@ -16,10 +16,10 @@ object Test extends App {
build.setTypeSignature(ru, rutpe)
val tree1 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2))))
- val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false)
+ val ttree1 = toolbox.typecheck(tree1, withMacrosDisabled = false)
println(ttree1)
val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2))))
- val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true)
+ val ttree2 = toolbox.typecheck(tree2, withMacrosDisabled = true)
println(ttree2)
}
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check
index 9810946024..8e554a6c8f 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled2.check
+++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check
@@ -1,4 +1,4 @@
-{
+({
val $u: ru.type = ru;
val $m: $u.Mirror = ru.runtimeMirror({
final class $anon extends scala.AnyRef {
@@ -37,5 +37,5 @@
};
new $typecreator2()
}))
-}
+}: ru.Expr[Array[Int]])
ru.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala
index 7bfe3ba8a4..2fbd8f7c7a 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled2.scala
+++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala
@@ -16,10 +16,10 @@ object Test extends App {
build.setTypeSignature(ru, rutpe)
val tree1 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2))))))
- val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false)
+ val ttree1 = toolbox.typecheck(tree1, withMacrosDisabled = false)
println(ttree1)
val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2))))))
- val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true)
+ val ttree2 = toolbox.typecheck(tree2, withMacrosDisabled = true)
println(ttree2)
}
diff --git a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
index 7905a2ca15..c5cac3ea45 100644
--- a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
+++ b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala
@@ -1,5 +1,4 @@
import org.scalacheck._, Prop._, Gen._, Arbitrary._
-import scala.reflect.api.{Liftable, Universe}
import scala.reflect.runtime.universe._, Flag._
trait ArbitraryTreesAndNames {
@@ -265,14 +264,8 @@ trait ArbitraryTreesAndNames {
def genTreeIsTypeWrapped(size: Int) =
for(tit <- genTreeIsType(size)) yield TreeIsType(tit)
- implicit object liftTreeIsTerm extends Liftable[TreeIsTerm] {
- def apply(universe: Universe, value: TreeIsTerm): universe.Tree =
- value.tree.asInstanceOf[universe.Tree]
- }
- implicit object liftTreeIsType extends Liftable[TreeIsType] {
- def apply(universe: Universe, value: TreeIsType): universe.Tree =
- value.tree.asInstanceOf[universe.Tree]
- }
+ implicit val liftTreeIsTerm = Liftable[TreeIsTerm] { _.tree }
+ implicit val liftTreeIsType = Liftable[TreeIsType] { _.tree }
implicit def treeIsTerm2tree(tit: TreeIsTerm): Tree = tit.tree
implicit def treeIsType2tree(tit: TreeIsType): Tree = tit.tree
diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala
index 2ec679e78b..2af656c7c9 100644
--- a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala
@@ -2,12 +2,25 @@ import org.scalacheck._, Prop._, Gen._, Arbitrary._
import scala.reflect.runtime.universe._, Flag._, build.ScalaDot
object DefinitionConstructionProps
- extends QuasiquoteProperties("definition construction")
- with ClassConstruction
- with TraitConstruction
- with TypeDefConstruction
- with ValDefConstruction
- with PackageConstruction
+ extends QuasiquoteProperties("definition construction")
+ with ClassConstruction
+ with TraitConstruction
+ with TypeDefConstruction
+ with ValDefConstruction
+ with PackageConstruction {
+ property("SI-6842") = test {
+ val x: Tree = q"val x: Int"
+ assertEqAst(q"def f($x) = 0", "def f(x: Int) = 0")
+ assertEqAst(q"class C($x)", "class C(val x: Int)")
+ assertEqAst(q"class C { $x => }", "class C { x: Int => }")
+ assertEqAst(q"trait B { $x => }", "trait B { x: Int => }")
+ assertEqAst(q"object A { $x => }", "object A { x: Int => }")
+ val t: Tree = q"type T"
+ assertEqAst(q"def f[$t] = 0", "def f[T] = 0")
+ assertEqAst(q"class C[$t]", "class C[T]")
+ assertEqAst(q"trait B[$t]", "trait B[T]")
+ }
+}
trait ClassConstruction { self: QuasiquoteProperties =>
val anyRef = ScalaDot(TypeName("AnyRef"))
@@ -283,7 +296,7 @@ trait MethodConstruction { self: QuasiquoteProperties =>
assertEqAst(q"@$a def foo", "@Foo[A,B] def foo")
}
- property("splice annotation with multiple argument lists") = test{
+ property("splice annotation with multiple argument lists") = test {
val a = q"new Foo(a)(b)"
assertEqAst(q"@$a def foo", "@Foo(a)(b) def foo")
}
diff --git a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
index dbd26bf72a..94465930ed 100644
--- a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
@@ -88,6 +88,22 @@ trait ClassDeconstruction { self: QuasiquoteProperties =>
matches("class Foo { self => bar(self) }")
matches("case class Foo(x: Int)")
}
+
+ property("SI-7979") = test {
+ val PARAMACCESSOR = (1 << 29).toLong.asInstanceOf[FlagSet]
+ assertThrows[MatchError] {
+ val build.SyntacticClassDef(_, _, _, _, _, _, _, _, _) =
+ ClassDef(
+ Modifiers(), TypeName("Foo"), List(),
+ Template(
+ List(Select(Ident(TermName("scala")), TypeName("AnyRef"))),
+ noSelfType,
+ List(
+ //ValDef(Modifiers(PRIVATE | LOCAL | PARAMACCESSOR), TermName("x"), Ident(TypeName("Int")), EmptyTree),
+ DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List(ValDef(Modifiers(PARAM | PARAMACCESSOR), TermName("x"),
+ Ident(TypeName("Int")), EmptyTree))), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))))))
+ }
+ }
}
trait ModsDeconstruction { self: QuasiquoteProperties =>
diff --git a/test/files/scalacheck/quasiquotes/ErrorProps.scala b/test/files/scalacheck/quasiquotes/ErrorProps.scala
index cb46a60dbe..92d299bede 100644
--- a/test/files/scalacheck/quasiquotes/ErrorProps.scala
+++ b/test/files/scalacheck/quasiquotes/ErrorProps.scala
@@ -105,13 +105,6 @@ object ErrorProps extends QuasiquoteProperties("errors") {
q"f($sb)"
""")
- property("casedef expected") = fails(
- "reflect.runtime.universe.CaseDef expected but reflect.runtime.universe.Tree found",
- """
- val t = EmptyTree
- q"_ { case $t }"
- """)
-
property("can't splice with ... card here") = fails(
"Can't splice with ... here",
"""
@@ -179,6 +172,20 @@ object ErrorProps extends QuasiquoteProperties("errors") {
val q"$m1 $m2 def foo" = EmptyTree
""")
+ property("can't splice values of Null") = fails(
+ "Can't splice Null, bottom type values often indicate programmer mistake",
+ """
+ val n = null
+ q"$n"
+ """)
+
+ property("can't splice values of Nothing") = fails(
+ "Can't splice Nothing, bottom type values often indicate programmer mistake",
+ """
+ def n = ???
+ q"$n"
+ """)
+
// // Make sure a nice error is reported in this case
// { import Flag._; val mods = NoMods; q"lazy $mods val x: Int" }
} \ No newline at end of file
diff --git a/test/files/scalacheck/quasiquotes/LiftableProps.scala b/test/files/scalacheck/quasiquotes/LiftableProps.scala
index 1271e1accd..539375d905 100644
--- a/test/files/scalacheck/quasiquotes/LiftableProps.scala
+++ b/test/files/scalacheck/quasiquotes/LiftableProps.scala
@@ -76,4 +76,39 @@ object LiftableProps extends QuasiquoteProperties("liftable") {
val const = Constant(0)
assert(q"$const" ≈ q"0")
}
+
+ property("lift list variants") = test {
+ val lst = List(1, 2)
+ val immutable = q"$scalapkg.collection.immutable"
+ assert(q"$lst" ≈ q"$immutable.List(1, 2)")
+ assert(q"f(..$lst)" ≈ q"f(1, 2)")
+ val llst = List(List(1), List(2))
+ assert(q"f(..$llst)" ≈ q"f($immutable.List(1), $immutable.List(2))")
+ assert(q"f(...$llst)" ≈ q"f(1)(2)")
+ }
+
+ property("lift tuple") = test {
+ assert(q"${Tuple1(1)}" ≈ q"scala.Tuple1(1)")
+ assert(q"${(1, 2)}" ≈ q"(1, 2)")
+ assert(q"${(1, 2, 3)}" ≈ q"(1, 2, 3)")
+ assert(q"${(1, 2, 3, 4)}" ≈ q"(1, 2, 3, 4)")
+ assert(q"${(1, 2, 3, 4, 5)}" ≈ q"(1, 2, 3, 4, 5)")
+ assert(q"${(1, 2, 3, 4, 5, 6)}" ≈ q"(1, 2, 3, 4, 5, 6)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7)}" ≈ q"(1, 2, 3, 4, 5, 6, 7)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)")
+ assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)")
+ }
} \ No newline at end of file
diff --git a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
index b331c4b6b6..e4ee5dfcae 100644
--- a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
+++ b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
@@ -81,7 +81,7 @@ trait Helpers {
val compile = toolbox.compile(_)
val eval = toolbox.eval(_)
- def typecheck(tree: Tree) = toolbox.typeCheck(tree)
+ def typecheck(tree: Tree) = toolbox.typecheck(tree)
def typecheckTyp(tree: Tree) = {
val q"type $_ = $res" = typecheck(q"type T = $tree")
@@ -120,4 +120,6 @@ trait Helpers {
def annot(name: TypeName): Tree = annot(name, Nil)
def annot(name: String, args: List[Tree]): Tree = annot(TypeName(name), args)
def annot(name: TypeName, args: List[Tree]): Tree = q"new $name(..$args)"
-} \ No newline at end of file
+
+ val scalapkg = build.setSymbol(Ident(TermName("scala")), definitions.ScalaPackage)
+}
diff --git a/test/files/scalacheck/quasiquotes/RuntimeErrorProps.scala b/test/files/scalacheck/quasiquotes/RuntimeErrorProps.scala
new file mode 100644
index 0000000000..a3b6137f68
--- /dev/null
+++ b/test/files/scalacheck/quasiquotes/RuntimeErrorProps.scala
@@ -0,0 +1,75 @@
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
+
+object RuntimeErrorProps extends QuasiquoteProperties("errors") {
+ def testFails[T](block: =>T) = test {
+ assertThrows[IllegalArgumentException] {
+ block
+ }
+ }
+
+ property("default param anon function") = testFails {
+ val param = q"val x: Int = 1"
+ q"{ $param => x + 1 }"
+ }
+
+ property("non-casedef case") = testFails {
+ val x = q"x"
+ q"foo match { case $x }"
+ }
+
+ property("non-new annotation") = testFails {
+ val annot = q"foo"
+ q"@$annot def foo"
+ }
+
+ property("non-valdef param") = testFails {
+ val param = q"foo"
+ q"def foo($param)"
+ }
+
+ property("non-valdef class param") = testFails {
+ val param = q"foo"
+ q"class Foo($param)"
+ }
+
+ property("non-typedef type param") = testFails {
+ val tparam = tq"T"
+ q"class C[$tparam]"
+ }
+
+ property("non-definition refine stat") = testFails {
+ val stat = q"foo"
+ tq"Foo { $stat }"
+ }
+
+ property("non-definition early def") = testFails {
+ val stat = q"foo"
+ q"class Foo extends { $stat } with Bar"
+ }
+
+ property("type apply for definition") = testFails {
+ val defn = q"def foo"
+ q"$defn[foo]"
+ }
+
+ property("non-val selftype") = testFails {
+ val foo = q"foo"
+ q"class Foo { $foo => }"
+ }
+
+ property("for empty enums") = testFails {
+ val enums = List.empty[Tree]
+ q"for(..$enums) 0"
+ }
+
+ property("for starts with non-from enum") = testFails {
+ val enums = fq"foo = bar" :: Nil
+ q"for(..$enums) 0"
+ }
+
+ property("for inlalid enum") = testFails {
+ val enums = q"foo" :: Nil
+ q"for(..$enums) 0"
+ }
+}
diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
index cdd96205de..6fb05ff9a4 100644
--- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
@@ -203,4 +203,25 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
assert(q"f(..${l1 ++ l2}, $baz)" ≈ q"f(foo, bar, baz)")
assert(q"f(${if (true) q"a" else q"b"})" ≈ q"f(a)")
}
+
+ property("splice iterable of non-parametric type") = test {
+ object O extends Iterable[Tree] { def iterator = List(q"foo").iterator }
+ q"f(..$O)"
+ }
+
+ property("SI-8016") = test {
+ val xs = q"1" :: q"2" :: Nil
+ assertEqAst(q"..$xs", "{1; 2}")
+ assertEqAst(q"{..$xs}", "{1; 2}")
+ }
+
+ property("SI-6842") = test {
+ val cases: List[Tree] = cq"a => b" :: cq"_ => c" :: Nil
+ assertEqAst(q"1 match { case ..$cases }", "1 match { case a => b case _ => c }")
+ assertEqAst(q"try 1 catch { case ..$cases }", "try 1 catch { case a => b case _ => c }")
+ }
+
+ property("SI-8009") = test {
+ q"`foo`".asInstanceOf[reflect.internal.SymbolTable#Ident].isBackquoted
+ }
}
diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
index bd81afa125..8d1ada342a 100644
--- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
@@ -3,8 +3,10 @@ import scala.reflect.runtime.universe._, Flag._
object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction") {
property("f(..x) = f") = test {
- val q"f(..$args)" = q"f"
- assert(args ≈ Nil)
+ // see SI-8008
+ assertThrows[MatchError] {
+ val q"f(..$args)" = q"f"
+ }
}
property("f(x)") = forAll { (x: Tree) =>
diff --git a/test/files/scalacheck/quasiquotes/Test.scala b/test/files/scalacheck/quasiquotes/Test.scala
index 8b1e779ab2..7a26fa4923 100644
--- a/test/files/scalacheck/quasiquotes/Test.scala
+++ b/test/files/scalacheck/quasiquotes/Test.scala
@@ -8,7 +8,9 @@ object Test extends Properties("quasiquotes") {
include(PatternConstructionProps)
include(PatternDeconstructionProps)
include(LiftableProps)
+ include(UnliftableProps)
include(ErrorProps)
+ include(RuntimeErrorProps)
include(DefinitionConstructionProps)
include(DefinitionDeconstructionProps)
include(DeprecationProps)
diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
index f443330e0b..2f501435e3 100644
--- a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
+++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
@@ -50,4 +50,29 @@ object TypecheckedProps extends QuasiquoteProperties("typechecked") {
assert(enums1 ≈ enums)
assert(body1 ≈ body)
}
+
+ property("extract UnApply (1)") = test {
+ val q"object $_ { $_; $_; $m }" = typecheck(q"""
+ object Test {
+ class Cell(val x: Int)
+ object Cell { def unapply(c: Cell) = Some(c.x) }
+ new Cell(0) match { case Cell(v) => v }
+ }
+ """)
+ val q"$_ match { case $f(..$args) => $_ }" = m
+ assert(f ≈ pq"Test.this.Cell")
+ assert(args ≈ List(pq"v"))
+ }
+
+ property("extract UnApply (2)") = test {
+ val q"object $_ { $_; $_; $m }" = typecheck(q"""
+ object Test {
+ case class Cell(val x: Int)
+ new Cell(0) match { case Cell(v) => v }
+ }
+ """)
+ val q"$_ match { case ${f: TypeTree}(..$args) => $_ }" = m
+ assert(f.original ≈ pq"Test.this.Cell")
+ assert(args ≈ List(pq"v"))
+ }
} \ No newline at end of file
diff --git a/test/files/scalacheck/quasiquotes/UnliftableProps.scala b/test/files/scalacheck/quasiquotes/UnliftableProps.scala
new file mode 100644
index 0000000000..8b827c98ff
--- /dev/null
+++ b/test/files/scalacheck/quasiquotes/UnliftableProps.scala
@@ -0,0 +1,160 @@
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._
+
+object UnliftableProps extends QuasiquoteProperties("unliftable") {
+ property("unlift name") = test {
+ val termname0 = TermName("foo")
+ val typename0 = TypeName("foo")
+ val q"${termname1: TermName}" = Ident(termname0)
+ assert(termname1 == termname0)
+ val q"${typename1: TypeName}" = Ident(typename0)
+ assert(typename1 == typename0)
+ val q"${name1: Name}" = Ident(termname0)
+ assert(name1 == termname0)
+ val q"${name2: Name}" = Ident(typename0)
+ assert(name2 == typename0)
+ }
+
+ property("unlift type") = test {
+ val q"${tpe: Type}" = TypeTree(typeOf[Int])
+ assert(tpe =:= typeOf[Int])
+ }
+
+ property("unlift constant") = test {
+ val q"${const: Constant}" = Literal(Constant("foo"))
+ assert(const == Constant("foo"))
+ }
+
+ property("unlift char") = test {
+ val q"${c: Char}" = Literal(Constant('0'))
+ assert(c.isInstanceOf[Char] && c == '0')
+ }
+
+ property("unlift byte") = test {
+ val q"${b: Byte}" = Literal(Constant(0: Byte))
+ assert(b.isInstanceOf[Byte] && b == 0)
+ }
+
+ property("unlift short") = test {
+ val q"${s: Short}" = Literal(Constant(0: Short))
+ assert(s.isInstanceOf[Short] && s == 0)
+ }
+
+ property("unlift int") = test {
+ val q"${i: Int}" = Literal(Constant(0: Int))
+ assert(i.isInstanceOf[Int] && i == 0)
+ }
+
+ property("unlift long") = test {
+ val q"${l: Long}" = Literal(Constant(0L: Long))
+ assert(l.isInstanceOf[Long] && l == 0L)
+ }
+
+ property("unlift float") = test {
+ val q"${f: Float}" = Literal(Constant(0.0f: Float))
+ assert(f.isInstanceOf[Float] && f == 0.0f)
+ }
+
+ property("unlift double") = test {
+ val q"${d: Double}" = Literal(Constant(0.0: Double))
+ assert(d.isInstanceOf[Double] && d == 0.0)
+ }
+
+ property("unlift bool") = test {
+ val q"${b: Boolean}" = q"true"
+ assert(b.isInstanceOf[Boolean] && b == true)
+ }
+
+ property("unlift string") = test {
+ val q"${s: String}" = q""" "foo" """
+ assert(s.isInstanceOf[String] && s == "foo")
+ }
+
+ property("unlift scala.symbol") = test {
+ val q"${s: scala.Symbol}" = q"'foo"
+ assert(s.isInstanceOf[scala.Symbol] && s == 'foo)
+ }
+
+ implicit def unliftList[T: Unliftable]: Unliftable[List[T]] = Unliftable {
+ case q"scala.collection.immutable.List(..$args)" if args.forall { implicitly[Unliftable[T]].unapply(_).nonEmpty } =>
+ val ut = implicitly[Unliftable[T]]
+ args.flatMap { ut.unapply(_) }
+ }
+
+ property("unlift list (1)") = test {
+ val orig = List(1, 2)
+ val q"${l1: List[Int]}" = q"$orig" // q"List(1, 2)"
+ assert(l1 == orig)
+ val q"f(..${l2: List[Int]})" = q"f(..$orig)" // q"f(1, 2)
+ assert(l2 == orig)
+ }
+
+ property("unlift list (2)") = test {
+ val orig2 = List(List(1, 2), List(3))
+ val q"f(${l3: List[List[Int]]})" = q"f($orig2)" // q"f(List(List(1, 2), List(3)))
+ assert(l3 == orig2)
+ val q"f(..${l4: List[List[Int]]})" = q"f(..$orig2)" // q"f(List(1, 2), List(3))"
+ assert(l4 == orig2)
+ val q"f(...${l5: List[List[Int]]})" = q"f(...$orig2)" // q"f(1, 2)(3)
+ assert(l5 == orig2)
+ }
+
+ property("don't unlift non-tree splicee (1)") = test {
+ val q"${a: TermName}.${b: TermName}" = q"a.b"
+ assert(a == TermName("a"))
+ assert(b == TermName("b"))
+ }
+
+ property("don't unlift non-tree splicee (2)") = test {
+ val q"${mods: Modifiers} def foo" = q"def foo"
+ assert(mods == Modifiers(DEFERRED))
+ }
+
+ property("unlift tuple") = test {
+ // fails due to SI-8045
+ // val q"${t1: Tuple1[Int]}" = q"_root_.scala.Tuple1(1)"
+ val q"${t2: (Int, Int)}" = q"(1, 2)"
+ val q"${t3: (Int, Int, Int)}" = q"(1, 2, 3)"
+ val q"${t4: (Int, Int, Int, Int)}" = q"(1, 2, 3, 4)"
+ val q"${t5: (Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5)"
+ val q"${t6: (Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6)"
+ val q"${t7: (Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7)"
+ val q"${t8: (Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8)"
+ val q"${t9: (Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9)"
+ val q"${t10: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)"
+ val q"${t11: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)"
+ val q"${t12: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)"
+ val q"${t13: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)"
+ val q"${t14: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)"
+ val q"${t15: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)"
+ val q"${t16: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)"
+ val q"${t17: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)"
+ val q"${t18: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)"
+ val q"${t19: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)"
+ val q"${t20: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)"
+ val q"${t21: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)"
+ val q"${t22: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)"
+ // assert(t1 == Tuple1(1))
+ assert(t2 == (1, 2))
+ assert(t3 == (1, 2, 3))
+ assert(t4 == (1, 2, 3, 4))
+ assert(t5 == (1, 2, 3, 4, 5))
+ assert(t6 == (1, 2, 3, 4, 5, 6))
+ assert(t7 == (1, 2, 3, 4, 5, 6, 7))
+ assert(t8 == (1, 2, 3, 4, 5, 6, 7, 8))
+ assert(t9 == (1, 2, 3, 4, 5, 6, 7, 8, 9))
+ assert(t10 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
+ assert(t11 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))
+ assert(t12 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))
+ assert(t13 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13))
+ assert(t14 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14))
+ assert(t15 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15))
+ assert(t16 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16))
+ assert(t17 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17))
+ assert(t18 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18))
+ assert(t19 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19))
+ assert(t20 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20))
+ assert(t21 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21))
+ assert(t22 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22))
+ }
+}
diff --git a/test/files/scalacheck/si4147.scala b/test/files/scalacheck/t4147.scala
index 72f6e9afd5..72f6e9afd5 100644
--- a/test/files/scalacheck/si4147.scala
+++ b/test/files/scalacheck/t4147.scala
diff --git a/test/junit/scala/collection/QueueTest.scala b/test/junit/scala/collection/QueueTest.scala
new file mode 100644
index 0000000000..9a40d8fc90
--- /dev/null
+++ b/test/junit/scala/collection/QueueTest.scala
@@ -0,0 +1,28 @@
+package scala.collection.immutable
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+
+@RunWith(classOf[JUnit4])
+/* Tests for collection.immutable.Queue */
+class QueueTest {
+ val emptyQueue = Queue.empty[Int]
+ val oneAdded = emptyQueue.enqueue(1)
+ val threeAdded = emptyQueue.enqueue(1 to 3)
+
+ @Test
+ def dequeueOptionOnEmpty() {
+ assert( emptyQueue.dequeueOption == None )
+ }
+
+ @Test
+ def dequeueOptionOneAdded() {
+ assert( oneAdded.dequeueOption == Some((1,emptyQueue)) )
+ }
+
+ @Test
+ def dequeueOptionThreeAdded() {
+ assert( threeAdded.dequeueOption == Some((1,Queue(2 to 3:_*))) )
+ }
+}
diff --git a/test/junit/scala/reflect/internal/MirrorsTest.scala b/test/junit/scala/reflect/internal/MirrorsTest.scala
new file mode 100644
index 0000000000..9108af139f
--- /dev/null
+++ b/test/junit/scala/reflect/internal/MirrorsTest.scala
@@ -0,0 +1,18 @@
+package scala.reflect.internal
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class MirrorsTest {
+ @Test def rootCompanionsAreConnected(): Unit = {
+ val cm = scala.reflect.runtime.currentMirror
+ import cm._
+ assertEquals("RootPackage.moduleClass == RootClass", RootClass, RootPackage.moduleClass)
+ assertEquals("RootClass.module == RootPackage", RootPackage, RootClass.module)
+ assertEquals("EmptyPackage.moduleClass == EmptyPackageClass", EmptyPackageClass, EmptyPackage.moduleClass)
+ assertEquals("EmptyPackageClass.module == EmptyPackage", EmptyPackage, EmptyPackageClass.module)
+ }
+} \ No newline at end of file
diff --git a/test/junit/scala/reflect/internal/util/StringOpsTest.scala b/test/junit/scala/reflect/internal/util/StringOpsTest.scala
new file mode 100644
index 0000000000..13d3a6435e
--- /dev/null
+++ b/test/junit/scala/reflect/internal/util/StringOpsTest.scala
@@ -0,0 +1,52 @@
+package scala.reflect.internal.util
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class StringOpsTest {
+ @Test
+ def prefixOfNone(): Unit = {
+ val so = new StringOps { }
+ val ss = Nil
+ val lcp = so longestCommonPrefix ss
+ assert(lcp == "")
+ }
+ @Test
+ def prefixWithEmpty(): Unit = {
+ val so = new StringOps { }
+ val ss = List("abc", "", "abd")
+ val lcp = so longestCommonPrefix ss
+ assert(lcp == "")
+ }
+ @Test
+ def prefixOfOne(): Unit = {
+ val so = new StringOps { }
+ val ss = List("abc")
+ val lcp = so longestCommonPrefix ss
+ assert(lcp == "abc")
+ }
+ @Test
+ def prefixOfMany(): Unit = {
+ val so = new StringOps { }
+ val ss = List("abc", "abd", "abe")
+ val lcp = so longestCommonPrefix ss
+ assert(lcp == "ab")
+ }
+ @Test
+ def prefixOfPrefix(): Unit = {
+ val so = new StringOps { }
+ val ss = List("abc", "abcd")
+ val lcp = so longestCommonPrefix ss
+ assert(lcp == "abc")
+ }
+ @Test
+ def prefixOfPrefixMiddling(): Unit = {
+ val so = new StringOps { }
+ val ss = List("abce", "abc", "abcd")
+ val lcp = so longestCommonPrefix ss
+ assert(lcp == "abc")
+ }
+}
diff --git a/test/pending/continuations-pos/t3620.scala b/test/pending/continuations-pos/t3620.scala
deleted file mode 100644
index 8496ae2858..0000000000
--- a/test/pending/continuations-pos/t3620.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-import scala.collection.mutable.HashMap
-import scala.util.continuations._
-
-object Test extends Application {
-
- class Store[K,V] {
-
- trait Waiting {
- def key: K
- def inform(value: V): Unit
- }
-
- private val map = new HashMap[K, V]
- private var waiting: List[Waiting] = Nil
-
- def waitFor(k: K, f: (V => Unit)) {
- map.get(k) match {
- case Some(v) => f(v)
- case None => {
- val w = new Waiting {
- def key = k
- def inform(v: V) = f(v)
- }
- waiting = w :: waiting
- }
- }
- }
-
-
- def add(key: K, value: V) {
- map(key) = value
- val p = waiting.partition(_.key == key)
- waiting = p._2
- p._1.foreach(_.inform(value))
- }
-
- def required(key: K) = {
- shift {
- c: (V => Unit) => {
- waitFor(key, c)
- }
- }
- }
-
- def option(key: Option[K]) = {
- shift {
- c: (Option[V] => Unit) => {
- key match {
- case Some(key) => waitFor(key, (v: V) => c(Some(v)))
- case None => c(None)
- }
-
- }
- }
- }
-
- }
-
- val store = new Store[String, Int]
-
- def test(p: Option[String]): Unit = {
- reset {
- // uncommenting the following two lines makes the compiler happy!
-// val o = store.option(p)
-// println(o)
- val i = store.option(p).getOrElse(1)
- println(i)
- }
- }
-
- test(Some("a"))
-
-}
diff --git a/test/pending/continuations-run/example0.scala b/test/pending/continuations-run/example0.scala
deleted file mode 100644
index de5ea54e9d..0000000000
--- a/test/pending/continuations-run/example0.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test0.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example1.scala b/test/pending/continuations-run/example1.scala
deleted file mode 100644
index e31d6af88c..0000000000
--- a/test/pending/continuations-run/example1.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test1.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example16.scala b/test/pending/continuations-run/example16.scala
deleted file mode 100644
index 561f0ab0eb..0000000000
--- a/test/pending/continuations-run/example16.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test16Printf.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example2.scala b/test/pending/continuations-run/example2.scala
deleted file mode 100644
index 730f7cc63e..0000000000
--- a/test/pending/continuations-run/example2.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test2.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example3.scala b/test/pending/continuations-run/example3.scala
deleted file mode 100644
index 41cf1cce0c..0000000000
--- a/test/pending/continuations-run/example3.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test3.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example4.scala b/test/pending/continuations-run/example4.scala
deleted file mode 100644
index adcc7aa90e..0000000000
--- a/test/pending/continuations-run/example4.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test4.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example5.scala b/test/pending/continuations-run/example5.scala
deleted file mode 100644
index 241e8cd069..0000000000
--- a/test/pending/continuations-run/example5.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test5.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example6.scala b/test/pending/continuations-run/example6.scala
deleted file mode 100644
index 00f84fcd6c..0000000000
--- a/test/pending/continuations-run/example6.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test6.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example7.scala b/test/pending/continuations-run/example7.scala
deleted file mode 100644
index 64abc6d9a6..0000000000
--- a/test/pending/continuations-run/example7.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test7.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example8.scala b/test/pending/continuations-run/example8.scala
deleted file mode 100644
index a5f953d3fc..0000000000
--- a/test/pending/continuations-run/example8.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test8.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example9.scala b/test/pending/continuations-run/example9.scala
deleted file mode 100644
index 09d792c427..0000000000
--- a/test/pending/continuations-run/example9.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test9Monads.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/foreach.check b/test/pending/continuations-run/foreach.check
deleted file mode 100644
index 9bab7a2eed..0000000000
--- a/test/pending/continuations-run/foreach.check
+++ /dev/null
@@ -1,4 +0,0 @@
-1
-2
-3
-enough is enough \ No newline at end of file
diff --git a/test/pending/continuations-run/foreach.scala b/test/pending/continuations-run/foreach.scala
deleted file mode 100644
index 76823e7604..0000000000
--- a/test/pending/continuations-run/foreach.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-import scala.util.continuations.Loops._
-
-object Test {
-
- def main(args: Array[String]): Any = {
-
-
- reset {
-
- val list = List(1,2,3,4,5)
-
- for (x <- list.suspendable) {
-
- shift { k: (Unit => Unit) =>
- println(x)
- if (x < 3)
- k()
- else
- println("enough is enough")
- }
-
- }
-
- }
-
-
- }
-
-} \ No newline at end of file
diff --git a/test/pending/run/idempotency-partial-functions.scala b/test/pending/run/idempotency-partial-functions.scala
index bc0ca706dd..e673da5a29 100644
--- a/test/pending/run/idempotency-partial-functions.scala
+++ b/test/pending/run/idempotency-partial-functions.scala
@@ -20,7 +20,7 @@ object Test extends App {
case e: ToolBoxError => println(e)
}
val tb = cm.mkToolBox()
- val tpartials = tb.typeCheck(partials.tree)
+ val tpartials = tb.typecheck(partials.tree)
println(tpartials)
val rtpartials = tb.resetAllAttrs(tpartials)
println(tb.eval(rtpartials))
diff --git a/test/pending/run/t5943b1.scala b/test/pending/run/t5943b1.scala
index 0d54718753..79c638fedc 100644
--- a/test/pending/run/t5943b1.scala
+++ b/test/pending/run/t5943b1.scala
@@ -6,5 +6,5 @@ import scala.tools.reflect.ToolBox
object Test extends App {
val tb = cm.mkToolBox()
val expr = tb.parse("math.sqrt(4.0)")
- println(tb.typeCheck(expr))
+ println(tb.typecheck(expr))
} \ No newline at end of file
diff --git a/test/scaladoc/run/SI-6812.scala b/test/scaladoc/run/SI-6812.scala
index fbd9588ede..059c327e7e 100644
--- a/test/scaladoc/run/SI-6812.scala
+++ b/test/scaladoc/run/SI-6812.scala
@@ -5,12 +5,12 @@ import language._
object Test extends ScaladocModelTest {
override def code = """
- import scala.reflect.macros.Context
+ import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Macros {
- def impl(c: Context) = c.literalUnit
- def foo = macro impl
+ def impl(c: BlackboxContext) = c.literalUnit
+ def foo: Unit = macro impl
}
class C {
diff --git a/tools/partest-ack b/tools/partest-ack
index c88793c2b5..ab722e3b1c 100755
--- a/tools/partest-ack
+++ b/tools/partest-ack
@@ -5,16 +5,17 @@
declare quiet failed update partest_debug
declare cotouched since sortCommand
declare -a ack_args partest_args scalac_args
+declare -r standard_ack_args="--noenv -s --java --scala --type-add=scala:ext:flags,check --files-with-matches"
partest_args=( --show-diff )
-base="$(cd "$(dirname "$0")"/.. && pwd)"
+bindir="$(cd "$(dirname "$0")" && pwd)"
+base="$bindir/.."
cd "$base" || { echo "Could not change to base directory $base" && exit 1; }
filesdir="test/files"
sortCommand="sort -u"
+partestPaths="$bindir/partest-paths"
-# have to enumerate good test dirs since partest chokes and fails
-# on continuations, bench, etc. tests
-pathRegex="$filesdir/(pos|neg|jvm|run|scalap|presentation)/[^/.]+([.]scala)?\$"
+[[ -x "$partestPaths" ]] || { echo "Cannot find partest-paths in $partestPaths" && exit 1; }
[[ $# -gt 0 ]] || {
cat <<EOM
@@ -32,7 +33,7 @@ runs all the tests for which any associated file matches the regex. Associated
files include .check and .flags files. Tests in directories will match if any
file matches. A file can match the regex by its contents or by its name.
-You must have ack installed: http://betterthangrep.com/ack-standalone
+You must have ack version 2.12+ installed: http://beyondgrep.com/ack-2.12-single-file
Examples:
@@ -79,24 +80,12 @@ done
shift $((OPTIND-1))
ack_args=( "${ack_args[@]}" "$@" )
-# Echo the argument only if it matches our idea of a test and exists.
-isPath () { [[ "$1" =~ $pathRegex ]] && [[ -e "$1" ]]; }
-
-# Filter stdin down to actual test paths.
-asTestPaths () {
- while read p; do
- p1="${p%.*}"
- isPath "$p1" && echo "$p1"
- isPath "$p1.scala" && echo "$p1.scala"
- done
-}
-
# These methods all just create paths which may or may not be tests
-# all are filtered through "asTestPaths" which limits the output to actual tests
+# all are filtered through partest-paths which limits the output to actual tests
regexPathTests () { find "$filesdir" | ack --noenv "$@"; }
failedTests () { for p in $(find "$filesdir" -name '*.log'); do p1=${p%.log} && p2=${p1%-*} && echo "$p2"; done; }
sinceTests() { git log --since="$@" --name-only --pretty="format:" -- "$filesdir"; }
-regexCodeTests () { ack --noenv --text --files-with-matches "$@" -- "$filesdir"; }
+regexCodeTests () { ack $standard_ack_args "$@" -- "$filesdir"; }
sameCommitTests() { for rev in $(git rev-list HEAD -- "$@"); do git --no-pager show --pretty="format:" --name-only "$rev" -- "$filesdir"; done; }
countStdout () {
@@ -115,7 +104,7 @@ randomSort () {
testRun () {
local description="$1" && shift
printf >&2 "%% tests %-25s ... " "$description"
- "$@" | asTestPaths | sort -u | countStdout | egrep -v '^[ ]*$'
+ "$@" | "$partestPaths" | countStdout | egrep -v '^[ ]*$'
}
allMatches() {
diff --git a/tools/partest-paths b/tools/partest-paths
new file mode 100755
index 0000000000..6ce403a04e
--- /dev/null
+++ b/tools/partest-paths
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Given a list of files on stdin, translates them into a set
+# of tests covering those files. That means paths which aren't
+# part of a test are dropped and the rest are rewritten to the
+# primary test path, with duplicates dropped.
+
+cd "$(dirname "$0")/.."
+
+# We have to enumerate good test dirs since partest chokes and fails
+# on continuations, bench, etc. tests
+pathRegex="test/files/(pos|neg|jvm|run|scalap|presentation)/[^/.]+([.]scala)?\$"
+
+# Echo the argument only if it matches our idea of a test and exists.
+isPath () { [[ "$1" =~ $pathRegex ]] && [[ -e "$1" ]]; }
+
+# Filter stdin down to actual test paths.
+asTestPaths() {
+ while read -r p; do
+ # Matched file at the standard test depth
+ p1="${p%.*}" && isPath "$p1.scala" && echo "$p1.scala" && continue
+ # Or, matched file may be in a test subdirectory, so strip the last path segment and check
+ p2="${p1%/*}" && isPath "$p2" && echo "$p2" && continue
+ done
+}
+
+asTestPaths | sort -u
diff --git a/versions.properties b/versions.properties
index 76eea52681..90448dc49a 100644
--- a/versions.properties
+++ b/versions.properties
@@ -4,9 +4,16 @@ starr.use.released=1
# These are the versions of the modules that go with this release.
# These properties are used during PR validation and in dbuild builds.
scala.binary.version=2.11.0-M7
-partest.version.number=1.0.0-RC8
+
+# external modules shipped with distribution:
scala-xml.version.number=1.0.0-RC7
scala-parser-combinators.version.number=1.0.0-RC5
+scala-continuations-plugin.version.number=1.0.0-RC2
+scala-continuations-library.version.number=1.0.0-RC2
+scala-swing.version.number=1.0.0-RC2
+
+# external modules, used internally (not shipped)
+partest.version.number=1.0.0-RC8
scalacheck.version.number=1.11.1
# TODO: modularize the compiler