diff options
Diffstat (limited to 'test')
3235 files changed, 24223 insertions, 18064 deletions
diff --git a/test/attic/files/cli/test1/Main.check.j9vm5 b/test/attic/files/cli/test1/Main.check.j9vm5 deleted file mode 100644 index de454ef478..0000000000 --- a/test/attic/files/cli/test1/Main.check.j9vm5 +++ /dev/null @@ -1,4 +0,0 @@ -env: -cpp: No such file or directory -env: test1.Main: No such file or directory -env: -cp: No such file or directory -1: test 3 passed diff --git a/test/attic/files/cli/test1/Main.check.java b/test/attic/files/cli/test1/Main.check.java deleted file mode 100644 index 64410de98f..0000000000 --- a/test/attic/files/cli/test1/Main.check.java +++ /dev/null @@ -1,6 +0,0 @@ -Unrecognized option: -cpp -Could not create the Java virtual machine. -1: test 1 passed (1) -1: test 2 passed (1) -1: test 3 passed (1) -1: test 4 passed (2) diff --git a/test/attic/files/cli/test1/Main.check.java5 b/test/attic/files/cli/test1/Main.check.java5 deleted file mode 100644 index 64410de98f..0000000000 --- a/test/attic/files/cli/test1/Main.check.java5 +++ /dev/null @@ -1,6 +0,0 @@ -Unrecognized option: -cpp -Could not create the Java virtual machine. -1: test 1 passed (1) -1: test 2 passed (1) -1: test 3 passed (1) -1: test 4 passed (2) diff --git a/test/attic/files/cli/test1/Main.check.java5_api b/test/attic/files/cli/test1/Main.check.java5_api deleted file mode 100644 index 8693a5d92f..0000000000 --- a/test/attic/files/cli/test1/Main.check.java5_api +++ /dev/null @@ -1,19 +0,0 @@ -|-- allclasses-frame.html -|-- allclasses-noframe.html -|-- constant-values.html -|-- deprecated-list.html -|-- help-doc.html -|-- index-all.html -|-- index.html -|-- overview-tree.html -|-- package-list -|-- resources -| `-- inherit.gif -|-- stylesheet.css -`-- test1 - |-- Main.html - |-- package-frame.html - |-- package-summary.html - `-- package-tree.html - -2 directories, 15 files diff --git a/test/attic/files/cli/test1/Main.check.java5_j9 b/test/attic/files/cli/test1/Main.check.java5_j9 deleted file mode 100644 index de454ef478..0000000000 --- a/test/attic/files/cli/test1/Main.check.java5_j9 +++ /dev/null @@ -1,4 +0,0 @@ -env: -cpp: No such file or directory -env: test1.Main: No such file or directory -env: -cp: No such file or directory -1: test 3 passed diff --git a/test/attic/files/cli/test1/Main.check.javac b/test/attic/files/cli/test1/Main.check.javac deleted file mode 100644 index ba25d9b6ca..0000000000 --- a/test/attic/files/cli/test1/Main.check.javac +++ /dev/null @@ -1,19 +0,0 @@ -javac: invalid flag: -dd -Usage: javac <options> <source files> -where possible options include: - -g Generate all debugging info - -g:none Generate no debugging info - -g:{lines,vars,source} Generate only some debugging info - -nowarn Generate no warnings - -verbose Output messages about what the compiler is doing - -deprecation Output source locations where deprecated APIs are used - -classpath <path> Specify where to find user class files - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -d <directory> Specify where to place generated class files - -encoding <encoding> Specify character encoding used by source files - -source <release> Provide source compatibility with specified release - -target <release> Generate class files for specific VM version - -help Print a synopsis of standard options - diff --git a/test/attic/files/cli/test1/Main.check.javac5 b/test/attic/files/cli/test1/Main.check.javac5 deleted file mode 100644 index 0cb29d31ff..0000000000 --- a/test/attic/files/cli/test1/Main.check.javac5 +++ /dev/null @@ -1,24 +0,0 @@ -javac: invalid flag: -dd -Usage: javac <options> <source files> -where possible options include: - -g Generate all debugging info - -g:none Generate no debugging info - -g:{lines,vars,source} Generate only some debugging info - -nowarn Generate no warnings - -verbose Output messages about what the compiler is doing - -deprecation Output source locations where deprecated APIs are used - -classpath <path> Specify where to find user class files - -cp <path> Specify where to find user class files - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -endorseddirs <dirs> Override location of endorsed standards path - -d <directory> Specify where to place generated class files - -encoding <encoding> Specify character encoding used by source files - -source <release> Provide source compatibility with specified release - -target <release> Generate class files for specific VM version - -version Version information - -help Print a synopsis of standard options - -X Print a synopsis of nonstandard options - -J<flag> Pass <flag> directly to the runtime system - diff --git a/test/attic/files/cli/test1/Main.check.javac6 b/test/attic/files/cli/test1/Main.check.javac6 deleted file mode 100644 index 8f37a05bcb..0000000000 --- a/test/attic/files/cli/test1/Main.check.javac6 +++ /dev/null @@ -1,29 +0,0 @@ -javac: invalid flag: -dd -Usage: javac <options> <source files> -where possible options include: - -g Generate all debugging info - -g:none Generate no debugging info - -g:{lines,vars,source} Generate only some debugging info - -nowarn Generate no warnings - -verbose Output messages about what the compiler is doing - -deprecation Output source locations where deprecated APIs are used - -classpath <path> Specify where to find user class files and annotation processors - -cp <path> Specify where to find user class files and annotation processors - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -endorseddirs <dirs> Override location of endorsed standards path - -proc:{none, only} Control whether annotation processing and/or compilation is done. - -processor <class> Name of the annotation processor to run; bypasses default discovery process - -processorpath <path> Specify where to find annotation processors - -d <directory> Specify where to place generated class files - -s <directory> Specify where to place generated source files - -encoding <encoding> Specify character encoding used by source files - -source <release> Provide source compatibility with specified release - -target <release> Generate class files for specific VM version - -version Version information - -help Print a synopsis of standard options - -A[key[=value]] Options to pass to annotation processors - -X Print a synopsis of nonstandard options - -J<flag> Pass <flag> directly to the runtime system - diff --git a/test/attic/files/cli/test1/Main.check.jikes b/test/attic/files/cli/test1/Main.check.jikes deleted file mode 100644 index cd891689db..0000000000 --- a/test/attic/files/cli/test1/Main.check.jikes +++ /dev/null @@ -1,3 +0,0 @@ -Error: "-dd" is an invalid option. -use: jikes [options] [@files] file.java... -For more help, try -help or -version. diff --git a/test/attic/files/cli/test1/Main.check.jikes5 b/test/attic/files/cli/test1/Main.check.jikes5 deleted file mode 100644 index cd891689db..0000000000 --- a/test/attic/files/cli/test1/Main.check.jikes5 +++ /dev/null @@ -1,3 +0,0 @@ -Error: "-dd" is an invalid option. -use: jikes [options] [@files] file.java... -For more help, try -help or -version. diff --git a/test/attic/files/cli/test1/Main.check.scala b/test/attic/files/cli/test1/Main.check.scala deleted file mode 100644 index 43b200ae02..0000000000 --- a/test/attic/files/cli/test1/Main.check.scala +++ /dev/null @@ -1,24 +0,0 @@ -unknown option: '-cpp' -scala [ <option> ]... [<torun> <arguments>] - -All options to scalac are allowed. See scalac -help. - -<torun>, if present, is an object or script file to run. -If no <torun> is present, run an interactive interpreter. - -Option -howtorun allows explicitly specifying how to run <torun>: - script: it is a script file - object: it is an object name - guess: (the default) try to guess - -Option -savecompiled requests that the compiled script be saved -for future use. - -Option -nocompdaemon requests that the fsc offline compiler not be used. - -Option -Dproperty=value sets a Java system property. - -1: test 1 passed (1) -1: test 2 passed (1) -1: test 3 passed (1) -1: test 4 passed (2) diff --git a/test/attic/files/cli/test1/Main.check.scala_api b/test/attic/files/cli/test1/Main.check.scala_api deleted file mode 100644 index 6fac39d3f0..0000000000 --- a/test/attic/files/cli/test1/Main.check.scala_api +++ /dev/null @@ -1,33 +0,0 @@ -|-- all-classes.html -|-- index.html -|-- modules.html -|-- nav-classes.html -|-- root-content.html -|-- scala -| |-- Any.html -| |-- AnyRef.html -| |-- AnyVal.html -| |-- Boolean.html -| |-- Byte.html -| |-- Char.html -| |-- Double.html -| |-- Float.html -| |-- Int.html -| |-- Long.html -| |-- Nothing.html -| |-- Null.html -| |-- Short.html -| |-- Unit.html -| `-- runtime -| |-- BoxedFloat.html -| |-- BoxedInt.html -| |-- BoxedLong.html -| `-- BoxedNumber.html -|-- script.js -|-- style.css -|-- test1 -| `-- Main$object.html -|-- test1$content.html -`-- test1$package.html - -3 directories, 28 files diff --git a/test/attic/files/cli/test1/Main.check.scala_j9 b/test/attic/files/cli/test1/Main.check.scala_j9 deleted file mode 100644 index 65d5ddaac4..0000000000 --- a/test/attic/files/cli/test1/Main.check.scala_j9 +++ /dev/null @@ -1,15 +0,0 @@ -unknown option: '-cpp' -scala [ <compiler-option> | -howtorun:how ]... [<torun> <arguments>] - -<compiler-option>'s are as for scalac; see scalac -help. -<torun>, if present, is an object or script file to run. -If no <torun> is present, run an interactive interpreter. --howtorun allows explicitly specifying how to run <torun>: - script: it is a script file - object: it is an object name - guess: (the default) try to guess - -1: test 1 passed (1) -1: test 2 passed (1) -1: test 3 passed (1) -1: test 4 passed (2) diff --git a/test/attic/files/cli/test1/Main.check.scalac b/test/attic/files/cli/test1/Main.check.scalac deleted file mode 100644 index 8465810d0b..0000000000 --- a/test/attic/files/cli/test1/Main.check.scalac +++ /dev/null @@ -1,63 +0,0 @@ -scalac error: bad option: '-dd' - scalac -help gives more information -Usage: scalac <options | source files> -where possible options include: - -doc Generate documentation - -g:<g> Generate debugging info (none,source,line,vars,notc) - -nowarn Generate no warnings - -noassert Generate no assertions and assumptions - -verbose Output messages about what the compiler is doing - -classpath <path> Specify where to find user class files - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -d <directory> Specify where to place generated class files - -encoding <encoding> Specify character encoding used by source files - -windowtitle <windowtitle> Specify window title of generated HTML documentation - -documenttitle <documenttitle> Specify document title of generated HTML documentation - -target:<target> Specify which backend to use (jvm-1.5,msil) - -migrate Assist in migrating from Scala version 1.0 - -o <file> Name of the output assembly (only relevant with -target:msil) - -r <path> List of assemblies referenced by the program (only relevant with -target:msil) - -debug Output debugging messages - -deprecation enable detailed deprecation warnings - -unchecked enable detailed unchecked warnings - -statistics Print compiler statistics - -explaintypes Explain type errors in more detail - -resident Compiler stays resident, files to compile are read from standard input - -uniqid Print identifiers with unique names (debugging option) - -printtypes Print tree types (debugging option) - -prompt Display a prompt after each error (debugging option) - -noimports Compile without any implicit imports - -nopredefs Compile without any implicit predefined values - -skip:<phase> Skip <phase> - -check:<phase> Check the tree at start of <phase> - -print:<phase> Print out program after <phase> - -printer:<printer> Printer to use (text,html) - -printfile <file> Specify file in which to print trees - -graph:<phase> Graph the program after <phase> - -browse:<phase> Browse the abstract syntax tree after <phase> - -stop:<phase> Stop after phase <phase> - -log:<phase> Log operations in <phase> - -logall Log all operations - -version Print product version and exit - -help Print a synopsis of standard options - -nouescape disables handling of \u unicode escapes - -Xinline Perform inlining when possible - -XO Optimize. implies -Xinline, -Xcloselim and -Xdce - -Xcloselim Perform closure elimination - -Xdce Perform dead code elimination - -Xwarndeadcode Emit warnings for dead code - -XbytecodeRead Enable bytecode reader. - -Xdetach Perform detaching of remote closures - -Xshowcls <class> Show class info - -Xshowobj <object> Show object info - -Xlinearizer:<Xlinearizer> Linearizer to use (normal,dfs,rpo,dump) - -Xgenerics Use generic Java types - -Xprintpos Print tree positions (as offsets) - -Xscript compile script file - -Xexperimental enable experimental extensions - -Xplugtypes parse but ignore annotations in more locations - -Xkilloption optimizes option types - -one error found diff --git a/test/attic/files/cli/test1/Main.check.scalaint b/test/attic/files/cli/test1/Main.check.scalaint deleted file mode 100644 index 88345d1874..0000000000 --- a/test/attic/files/cli/test1/Main.check.scalaint +++ /dev/null @@ -1,45 +0,0 @@ -unknown option: '-cpp' -scala [ <option> ]... [<torun> <arguments>] - -All options to scalac are allowed. See scalac -help. - -<torun>, if present, is an object or script file to run. -If no <torun> is present, run an interactive interpreter. - -Option -howtorun allows explicitly specifying how to run <torun>: - script: it is a script file - object: it is an object name - guess: (the default) try to guess - -Option -savecompiled requests that the compiled script be saved -for future use. - -Option -nocompdaemon requests that the fsc offline compiler not be used. - -Option -Dproperty=value sets a Java system property. - - -This is an interpreter for Scala. -Type in expressions to have them evaluated. -Type :help for more information. - -scala> 1: test 1 passed (1) -unnamed0: scala.Unit = () - -scala> -This is an interpreter for Scala. -Type in expressions to have them evaluated. -Type :help for more information. - -scala> 1: test 2 passed (1) -unnamed0: scala.Unit = () - -scala> -This is an interpreter for Scala. -Type in expressions to have them evaluated. -Type :help for more information. - -scala> 1: test 3 passed (1) -unnamed0: scala.Unit = () - -scala> diff --git a/test/attic/files/cli/test1/Main.java b/test/attic/files/cli/test1/Main.java deleted file mode 100644 index 8850b87517..0000000000 --- a/test/attic/files/cli/test1/Main.java +++ /dev/null @@ -1,8 +0,0 @@ -// @info no dependency -package test1; -public class Main { - public static void main(String args[]) { - String arg = (args.length > 0) ? args[0] : "?"; - System.out.println("1: test " + arg + " passed (" + args.length + ")"); - } -} diff --git a/test/attic/files/cli/test1/Main.scala b/test/attic/files/cli/test1/Main.scala deleted file mode 100644 index f7dd8a0a36..0000000000 --- a/test/attic/files/cli/test1/Main.scala +++ /dev/null @@ -1,8 +0,0 @@ -// @info no dependency -package test1 -object Main { - def main(args: Array[String]) = { - val arg = if (args != null && args.length > 0) args(0) else "?" - Console.println("1: test " + arg + " passed (" + args.length + ")") - } -} diff --git a/test/attic/files/cli/test2/Main.check.j9vm5 b/test/attic/files/cli/test2/Main.check.j9vm5 deleted file mode 100644 index 8f4fdf8aa1..0000000000 --- a/test/attic/files/cli/test2/Main.check.j9vm5 +++ /dev/null @@ -1,4 +0,0 @@ -env: -cpp: No such file or directory -env: test2.Main: No such file or directory -env: -cp: No such file or directory -2: 1: test 3 passed diff --git a/test/attic/files/cli/test2/Main.check.java b/test/attic/files/cli/test2/Main.check.java deleted file mode 100644 index aca383de3e..0000000000 --- a/test/attic/files/cli/test2/Main.check.java +++ /dev/null @@ -1,6 +0,0 @@ -Unrecognized option: -cpp -Could not create the Java virtual machine. -2: 1: test 1 passed (1) -2: 1: test 2 passed (1) -2: 1: test 3 passed (1) -2: 1: test 4 passed (2) diff --git a/test/attic/files/cli/test2/Main.check.java5 b/test/attic/files/cli/test2/Main.check.java5 deleted file mode 100644 index aca383de3e..0000000000 --- a/test/attic/files/cli/test2/Main.check.java5 +++ /dev/null @@ -1,6 +0,0 @@ -Unrecognized option: -cpp -Could not create the Java virtual machine. -2: 1: test 1 passed (1) -2: 1: test 2 passed (1) -2: 1: test 3 passed (1) -2: 1: test 4 passed (2) diff --git a/test/attic/files/cli/test2/Main.check.java5_api b/test/attic/files/cli/test2/Main.check.java5_api deleted file mode 100644 index 4ff775c3da..0000000000 --- a/test/attic/files/cli/test2/Main.check.java5_api +++ /dev/null @@ -1,24 +0,0 @@ -|-- allclasses-frame.html -|-- allclasses-noframe.html -|-- constant-values.html -|-- deprecated-list.html -|-- help-doc.html -|-- index-all.html -|-- index.html -|-- overview-tree.html -|-- package-list -|-- resources -| `-- inherit.gif -|-- stylesheet.css -|-- test1 -| |-- Main.html -| |-- package-frame.html -| |-- package-summary.html -| `-- package-tree.html -`-- test2 - |-- Main.html - |-- package-frame.html - |-- package-summary.html - `-- package-tree.html - -3 directories, 19 files diff --git a/test/attic/files/cli/test2/Main.check.java5_j9 b/test/attic/files/cli/test2/Main.check.java5_j9 deleted file mode 100644 index 2dcb6e892a..0000000000 --- a/test/attic/files/cli/test2/Main.check.java5_j9 +++ /dev/null @@ -1,36 +0,0 @@ -JVMJ9VM007E Command-line option unrecognised: -cpp -Could not create the Java virtual machine. - -Usage: java [-options] class [args...] - (to execute a class) - or java [-jar] [-options] jarfile [args...] - (to execute a jar file) - -where options include: - -cp -classpath <directories and zip/jar files separated by :> - set search path for application classes and resources - -D<name>=<value> - set a system property - -verbose[:class|gc|jni] - enable verbose output - -version print product version - -version:<value> - require the specified version to run - -showversion print product version and continue - -jre-restrict-search | -no-jre-restrict-search - include/exclude user private JREs in the version search - -agentlib:<libname>[=<options>] - load native agent library <libname>, e.g. -agentlib:hprof - see also, -agentlib:jdwp=help and -agentlib:hprof=help - -agentpath:<pathname>[=<options>] - load native agent library by full pathname - -javaagent:<jarpath>[=<options>] - load Java programming language agent, see java.lang.instrument - -? -help print this help message - -X print help on non-standard options - -assert print help on assert options - -The java class is not found: test2.Main -The java class is not found: test2.Main -The java class is not found: test2.Main -The java class is not found: test2.Main diff --git a/test/attic/files/cli/test2/Main.check.javac b/test/attic/files/cli/test2/Main.check.javac deleted file mode 100644 index c40c0a7a89..0000000000 --- a/test/attic/files/cli/test2/Main.check.javac +++ /dev/null @@ -1,27 +0,0 @@ -javac: invalid flag: -dd -Usage: javac <options> <source files> -where possible options include: - -g Generate all debugging info - -g:none Generate no debugging info - -g:{lines,vars,source} Generate only some debugging info - -nowarn Generate no warnings - -verbose Output messages about what the compiler is doing - -deprecation Output source locations where deprecated APIs are used - -classpath <path> Specify where to find user class files - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -d <directory> Specify where to place generated class files - -encoding <encoding> Specify character encoding used by source files - -source <release> Provide source compatibility with specified release - -target <release> Generate class files for specific VM version - -help Print a synopsis of standard options - -files/cli/test2/Main.java:6: package test1 does not exist - test1.Main.main(args); - ^ -1 error -files/cli/test2/Main.java:6: package test1 does not exist - test1.Main.main(args); - ^ -1 error diff --git a/test/attic/files/cli/test2/Main.check.javac5 b/test/attic/files/cli/test2/Main.check.javac5 deleted file mode 100644 index 0ac32b056e..0000000000 --- a/test/attic/files/cli/test2/Main.check.javac5 +++ /dev/null @@ -1,28 +0,0 @@ -javac: invalid flag: -dd -Usage: javac <options> <source files> -where possible options include: - -g Generate all debugging info - -g:none Generate no debugging info - -g:{lines,vars,source} Generate only some debugging info - -nowarn Generate no warnings - -verbose Output messages about what the compiler is doing - -deprecation Output source locations where deprecated APIs are used - -classpath <path> Specify where to find user class files - -cp <path> Specify where to find user class files - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -endorseddirs <dirs> Override location of endorsed standards path - -d <directory> Specify where to place generated class files - -encoding <encoding> Specify character encoding used by source files - -source <release> Provide source compatibility with specified release - -target <release> Generate class files for specific VM version - -version Version information - -help Print a synopsis of standard options - -X Print a synopsis of nonstandard options - -J<flag> Pass <flag> directly to the runtime system - -files/cli/test2/Main.java:6: package test1 does not exist - test1.Main.main(args); - ^ -1 error diff --git a/test/attic/files/cli/test2/Main.check.javac6 b/test/attic/files/cli/test2/Main.check.javac6 deleted file mode 100644 index 350d3253bc..0000000000 --- a/test/attic/files/cli/test2/Main.check.javac6 +++ /dev/null @@ -1,33 +0,0 @@ -javac: invalid flag: -dd -Usage: javac <options> <source files> -where possible options include: - -g Generate all debugging info - -g:none Generate no debugging info - -g:{lines,vars,source} Generate only some debugging info - -nowarn Generate no warnings - -verbose Output messages about what the compiler is doing - -deprecation Output source locations where deprecated APIs are used - -classpath <path> Specify where to find user class files and annotation processors - -cp <path> Specify where to find user class files and annotation processors - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -endorseddirs <dirs> Override location of endorsed standards path - -proc:{none, only} Control whether annotation processing and/or compilation is done. - -processor <class> Name of the annotation processor to run; bypasses default discovery process - -processorpath <path> Specify where to find annotation processors - -d <directory> Specify where to place generated class files - -s <directory> Specify where to place generated source files - -encoding <encoding> Specify character encoding used by source files - -source <release> Provide source compatibility with specified release - -target <release> Generate class files for specific VM version - -version Version information - -help Print a synopsis of standard options - -A[key[=value]] Options to pass to annotation processors - -X Print a synopsis of nonstandard options - -J<flag> Pass <flag> directly to the runtime system - -files/cli/test2/Main.java:5: package test1 does not exist - test1.Main.main(args); - ^ -1 error diff --git a/test/attic/files/cli/test2/Main.check.jikes b/test/attic/files/cli/test2/Main.check.jikes deleted file mode 100644 index 97943e8347..0000000000 --- a/test/attic/files/cli/test2/Main.check.jikes +++ /dev/null @@ -1,9 +0,0 @@ -Error: "-dd" is an invalid option. -use: jikes [options] [@files] file.java... -For more help, try -help or -version. - -Found 1 semantic error compiling "files/cli/test2/Main.java": - - 6. test1.Main.main(args); - ^---^ -*** Semantic Error: No accessible field named "test1" was found in type "test2.Main". diff --git a/test/attic/files/cli/test2/Main.check.jikes5 b/test/attic/files/cli/test2/Main.check.jikes5 deleted file mode 100644 index 97943e8347..0000000000 --- a/test/attic/files/cli/test2/Main.check.jikes5 +++ /dev/null @@ -1,9 +0,0 @@ -Error: "-dd" is an invalid option. -use: jikes [options] [@files] file.java... -For more help, try -help or -version. - -Found 1 semantic error compiling "files/cli/test2/Main.java": - - 6. test1.Main.main(args); - ^---^ -*** Semantic Error: No accessible field named "test1" was found in type "test2.Main". diff --git a/test/attic/files/cli/test2/Main.check.scala b/test/attic/files/cli/test2/Main.check.scala deleted file mode 100644 index 7e5f17625b..0000000000 --- a/test/attic/files/cli/test2/Main.check.scala +++ /dev/null @@ -1,24 +0,0 @@ -unknown option: '-cpp' -scala [ <option> ]... [<torun> <arguments>] - -All options to scalac are allowed. See scalac -help. - -<torun>, if present, is an object or script file to run. -If no <torun> is present, run an interactive interpreter. - -Option -howtorun allows explicitly specifying how to run <torun>: - script: it is a script file - object: it is an object name - guess: (the default) try to guess - -Option -savecompiled requests that the compiled script be saved -for future use. - -Option -nocompdaemon requests that the fsc offline compiler not be used. - -Option -Dproperty=value sets a Java system property. - -2: 1: test 1 passed (1) -2: 1: test 2 passed (1) -2: 1: test 3 passed (1) -2: 1: test 4 passed (2) diff --git a/test/attic/files/cli/test2/Main.check.scala_api b/test/attic/files/cli/test2/Main.check.scala_api deleted file mode 100644 index bcb0f0c7fb..0000000000 --- a/test/attic/files/cli/test2/Main.check.scala_api +++ /dev/null @@ -1,37 +0,0 @@ -|-- all-classes.html -|-- index.html -|-- modules.html -|-- nav-classes.html -|-- root-content.html -|-- scala -| |-- Any.html -| |-- AnyRef.html -| |-- AnyVal.html -| |-- Boolean.html -| |-- Byte.html -| |-- Char.html -| |-- Double.html -| |-- Float.html -| |-- Int.html -| |-- Long.html -| |-- Nothing.html -| |-- Null.html -| |-- Short.html -| |-- Unit.html -| `-- runtime -| |-- BoxedFloat.html -| |-- BoxedInt.html -| |-- BoxedLong.html -| `-- BoxedNumber.html -|-- script.js -|-- style.css -|-- test1 -| `-- Main$object.html -|-- test1$content.html -|-- test1$package.html -|-- test2 -| `-- Main$object.html -|-- test2$content.html -`-- test2$package.html - -4 directories, 31 files diff --git a/test/attic/files/cli/test2/Main.check.scala_j9 b/test/attic/files/cli/test2/Main.check.scala_j9 deleted file mode 100644 index 80cbb50fa9..0000000000 --- a/test/attic/files/cli/test2/Main.check.scala_j9 +++ /dev/null @@ -1,15 +0,0 @@ -unknown option: '-cpp' -scala [ <compiler-option> | -howtorun:how ]... [<torun> <arguments>] - -<compiler-option>'s are as for scalac; see scalac -help. -<torun>, if present, is an object or script file to run. -If no <torun> is present, run an interactive interpreter. --howtorun allows explicitly specifying how to run <torun>: - script: it is a script file - object: it is an object name - guess: (the default) try to guess - -2: 1: test 1 passed (1) -2: 1: test 2 passed (1) -2: 1: test 3 passed (1) -2: 1: test 4 passed (2) diff --git a/test/attic/files/cli/test2/Main.check.scalac b/test/attic/files/cli/test2/Main.check.scalac deleted file mode 100644 index 8465810d0b..0000000000 --- a/test/attic/files/cli/test2/Main.check.scalac +++ /dev/null @@ -1,63 +0,0 @@ -scalac error: bad option: '-dd' - scalac -help gives more information -Usage: scalac <options | source files> -where possible options include: - -doc Generate documentation - -g:<g> Generate debugging info (none,source,line,vars,notc) - -nowarn Generate no warnings - -noassert Generate no assertions and assumptions - -verbose Output messages about what the compiler is doing - -classpath <path> Specify where to find user class files - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -d <directory> Specify where to place generated class files - -encoding <encoding> Specify character encoding used by source files - -windowtitle <windowtitle> Specify window title of generated HTML documentation - -documenttitle <documenttitle> Specify document title of generated HTML documentation - -target:<target> Specify which backend to use (jvm-1.5,msil) - -migrate Assist in migrating from Scala version 1.0 - -o <file> Name of the output assembly (only relevant with -target:msil) - -r <path> List of assemblies referenced by the program (only relevant with -target:msil) - -debug Output debugging messages - -deprecation enable detailed deprecation warnings - -unchecked enable detailed unchecked warnings - -statistics Print compiler statistics - -explaintypes Explain type errors in more detail - -resident Compiler stays resident, files to compile are read from standard input - -uniqid Print identifiers with unique names (debugging option) - -printtypes Print tree types (debugging option) - -prompt Display a prompt after each error (debugging option) - -noimports Compile without any implicit imports - -nopredefs Compile without any implicit predefined values - -skip:<phase> Skip <phase> - -check:<phase> Check the tree at start of <phase> - -print:<phase> Print out program after <phase> - -printer:<printer> Printer to use (text,html) - -printfile <file> Specify file in which to print trees - -graph:<phase> Graph the program after <phase> - -browse:<phase> Browse the abstract syntax tree after <phase> - -stop:<phase> Stop after phase <phase> - -log:<phase> Log operations in <phase> - -logall Log all operations - -version Print product version and exit - -help Print a synopsis of standard options - -nouescape disables handling of \u unicode escapes - -Xinline Perform inlining when possible - -XO Optimize. implies -Xinline, -Xcloselim and -Xdce - -Xcloselim Perform closure elimination - -Xdce Perform dead code elimination - -Xwarndeadcode Emit warnings for dead code - -XbytecodeRead Enable bytecode reader. - -Xdetach Perform detaching of remote closures - -Xshowcls <class> Show class info - -Xshowobj <object> Show object info - -Xlinearizer:<Xlinearizer> Linearizer to use (normal,dfs,rpo,dump) - -Xgenerics Use generic Java types - -Xprintpos Print tree positions (as offsets) - -Xscript compile script file - -Xexperimental enable experimental extensions - -Xplugtypes parse but ignore annotations in more locations - -Xkilloption optimizes option types - -one error found diff --git a/test/attic/files/cli/test2/Main.check.scalaint b/test/attic/files/cli/test2/Main.check.scalaint deleted file mode 100644 index 89b6766bb5..0000000000 --- a/test/attic/files/cli/test2/Main.check.scalaint +++ /dev/null @@ -1,45 +0,0 @@ -unknown option: '-cpp' -scala [ <option> ]... [<torun> <arguments>] - -All options to scalac are allowed. See scalac -help. - -<torun>, if present, is an object or script file to run. -If no <torun> is present, run an interactive interpreter. - -Option -howtorun allows explicitly specifying how to run <torun>: - script: it is a script file - object: it is an object name - guess: (the default) try to guess - -Option -savecompiled requests that the compiled script be saved -for future use. - -Option -nocompdaemon requests that the fsc offline compiler not be used. - -Option -Dproperty=value sets a Java system property. - - -This is an interpreter for Scala. -Type in expressions to have them evaluated. -Type :help for more information. - -scala> 2: 1: test 1 passed (1) -unnamed0: scala.Unit = () - -scala> -This is an interpreter for Scala. -Type in expressions to have them evaluated. -Type :help for more information. - -scala> 2: 1: test 2 passed (1) -unnamed0: scala.Unit = () - -scala> -This is an interpreter for Scala. -Type in expressions to have them evaluated. -Type :help for more information. - -scala> 2: 1: test 3 passed (1) -unnamed0: scala.Unit = () - -scala> diff --git a/test/attic/files/cli/test2/Main.java b/test/attic/files/cli/test2/Main.java deleted file mode 100644 index f6797632bf..0000000000 --- a/test/attic/files/cli/test2/Main.java +++ /dev/null @@ -1,8 +0,0 @@ -// @info 1 dependency -package test2; -public class Main { - public static void main(String args[]) { - System.out.print("2: "); - test1.Main.main(args); - } -} diff --git a/test/attic/files/cli/test2/Main.scala b/test/attic/files/cli/test2/Main.scala deleted file mode 100644 index 11c878b9c0..0000000000 --- a/test/attic/files/cli/test2/Main.scala +++ /dev/null @@ -1,8 +0,0 @@ -// @info 1 dependency -package test2 -object Main { - def main(args: Array[String]) = { - Console.print("2: ") - test1.Main.main(args) - } -} diff --git a/test/attic/files/cli/test3/Main.check.j9vm5 b/test/attic/files/cli/test3/Main.check.j9vm5 deleted file mode 100644 index a094dc8daf..0000000000 --- a/test/attic/files/cli/test3/Main.check.j9vm5 +++ /dev/null @@ -1,5 +0,0 @@ -env: -cpp: No such file or directory -env: test3.Main: No such file or directory -env: -cp: No such file or directory -3: 1: test 3 passed -3: 2: 1: test 3 passed diff --git a/test/attic/files/cli/test3/Main.check.java b/test/attic/files/cli/test3/Main.check.java deleted file mode 100644 index de3eb7b136..0000000000 --- a/test/attic/files/cli/test3/Main.check.java +++ /dev/null @@ -1,10 +0,0 @@ -Unrecognized option: -cpp -Could not create the Java virtual machine. -3: 1: test 1 passed (1) -3: 2: 1: test 1 passed (1) -3: 1: test 2 passed (1) -3: 2: 1: test 2 passed (1) -3: 1: test 3 passed (1) -3: 2: 1: test 3 passed (1) -3: 1: test 4 passed (2) -3: 2: 1: test 4 passed (2) diff --git a/test/attic/files/cli/test3/Main.check.java5 b/test/attic/files/cli/test3/Main.check.java5 deleted file mode 100644 index de3eb7b136..0000000000 --- a/test/attic/files/cli/test3/Main.check.java5 +++ /dev/null @@ -1,10 +0,0 @@ -Unrecognized option: -cpp -Could not create the Java virtual machine. -3: 1: test 1 passed (1) -3: 2: 1: test 1 passed (1) -3: 1: test 2 passed (1) -3: 2: 1: test 2 passed (1) -3: 1: test 3 passed (1) -3: 2: 1: test 3 passed (1) -3: 1: test 4 passed (2) -3: 2: 1: test 4 passed (2) diff --git a/test/attic/files/cli/test3/Main.check.java5_api b/test/attic/files/cli/test3/Main.check.java5_api deleted file mode 100644 index f6112211f0..0000000000 --- a/test/attic/files/cli/test3/Main.check.java5_api +++ /dev/null @@ -1,29 +0,0 @@ -|-- allclasses-frame.html -|-- allclasses-noframe.html -|-- constant-values.html -|-- deprecated-list.html -|-- help-doc.html -|-- index-all.html -|-- index.html -|-- overview-tree.html -|-- package-list -|-- resources -| `-- inherit.gif -|-- stylesheet.css -|-- test1 -| |-- Main.html -| |-- package-frame.html -| |-- package-summary.html -| `-- package-tree.html -|-- test2 -| |-- Main.html -| |-- package-frame.html -| |-- package-summary.html -| `-- package-tree.html -`-- test3 - |-- Main.html - |-- package-frame.html - |-- package-summary.html - `-- package-tree.html - -4 directories, 23 files diff --git a/test/attic/files/cli/test3/Main.check.java5_j9 b/test/attic/files/cli/test3/Main.check.java5_j9 deleted file mode 100644 index 9e228d7649..0000000000 --- a/test/attic/files/cli/test3/Main.check.java5_j9 +++ /dev/null @@ -1,36 +0,0 @@ -JVMJ9VM007E Command-line option unrecognised: -cpp -Could not create the Java virtual machine. - -Usage: java [-options] class [args...] - (to execute a class) - or java [-jar] [-options] jarfile [args...] - (to execute a jar file) - -where options include: - -cp -classpath <directories and zip/jar files separated by :> - set search path for application classes and resources - -D<name>=<value> - set a system property - -verbose[:class|gc|jni] - enable verbose output - -version print product version - -version:<value> - require the specified version to run - -showversion print product version and continue - -jre-restrict-search | -no-jre-restrict-search - include/exclude user private JREs in the version search - -agentlib:<libname>[=<options>] - load native agent library <libname>, e.g. -agentlib:hprof - see also, -agentlib:jdwp=help and -agentlib:hprof=help - -agentpath:<pathname>[=<options>] - load native agent library by full pathname - -javaagent:<jarpath>[=<options>] - load Java programming language agent, see java.lang.instrument - -? -help print this help message - -X print help on non-standard options - -assert print help on assert options - -The java class is not found: test3.Main -The java class is not found: test3.Main -The java class is not found: test3.Main -The java class is not found: test3.Main diff --git a/test/attic/files/cli/test3/Main.check.javac b/test/attic/files/cli/test3/Main.check.javac deleted file mode 100644 index 8d235b647b..0000000000 --- a/test/attic/files/cli/test3/Main.check.javac +++ /dev/null @@ -1,33 +0,0 @@ -javac: invalid flag: -dd -Usage: javac <options> <source files> -where possible options include: - -g Generate all debugging info - -g:none Generate no debugging info - -g:{lines,vars,source} Generate only some debugging info - -nowarn Generate no warnings - -verbose Output messages about what the compiler is doing - -deprecation Output source locations where deprecated APIs are used - -classpath <path> Specify where to find user class files - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -d <directory> Specify where to place generated class files - -encoding <encoding> Specify character encoding used by source files - -source <release> Provide source compatibility with specified release - -target <release> Generate class files for specific VM version - -help Print a synopsis of standard options - -files/cli/test3/Main.java:6: package test1 does not exist - test1.Main.main(args); - ^ -files/cli/test3/Main.java:8: package test2 does not exist - test2.Main.main(args); - ^ -2 errors -files/cli/test3/Main.java:6: package test1 does not exist - test1.Main.main(args); - ^ -files/cli/test3/Main.java:8: package test2 does not exist - test2.Main.main(args); - ^ -2 errors diff --git a/test/attic/files/cli/test3/Main.check.javac5 b/test/attic/files/cli/test3/Main.check.javac5 deleted file mode 100644 index 3a48fa000e..0000000000 --- a/test/attic/files/cli/test3/Main.check.javac5 +++ /dev/null @@ -1,31 +0,0 @@ -javac: invalid flag: -dd -Usage: javac <options> <source files> -where possible options include: - -g Generate all debugging info - -g:none Generate no debugging info - -g:{lines,vars,source} Generate only some debugging info - -nowarn Generate no warnings - -verbose Output messages about what the compiler is doing - -deprecation Output source locations where deprecated APIs are used - -classpath <path> Specify where to find user class files - -cp <path> Specify where to find user class files - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -endorseddirs <dirs> Override location of endorsed standards path - -d <directory> Specify where to place generated class files - -encoding <encoding> Specify character encoding used by source files - -source <release> Provide source compatibility with specified release - -target <release> Generate class files for specific VM version - -version Version information - -help Print a synopsis of standard options - -X Print a synopsis of nonstandard options - -J<flag> Pass <flag> directly to the runtime system - -files/cli/test3/Main.java:6: package test1 does not exist - test1.Main.main(args); - ^ -files/cli/test3/Main.java:8: package test2 does not exist - test2.Main.main(args); - ^ -2 errors diff --git a/test/attic/files/cli/test3/Main.check.javac6 b/test/attic/files/cli/test3/Main.check.javac6 deleted file mode 100644 index 677b950aed..0000000000 --- a/test/attic/files/cli/test3/Main.check.javac6 +++ /dev/null @@ -1,36 +0,0 @@ -javac: invalid flag: -dd -Usage: javac <options> <source files> -where possible options include: - -g Generate all debugging info - -g:none Generate no debugging info - -g:{lines,vars,source} Generate only some debugging info - -nowarn Generate no warnings - -verbose Output messages about what the compiler is doing - -deprecation Output source locations where deprecated APIs are used - -classpath <path> Specify where to find user class files and annotation processors - -cp <path> Specify where to find user class files and annotation processors - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -endorseddirs <dirs> Override location of endorsed standards path - -proc:{none, only} Control whether annotation processing and/or compilation is done. - -processor <class> Name of the annotation processor to run; bypasses default discovery process - -processorpath <path> Specify where to find annotation processors - -d <directory> Specify where to place generated class files - -s <directory> Specify where to place generated source files - -encoding <encoding> Specify character encoding used by source files - -source <release> Provide source compatibility with specified release - -target <release> Generate class files for specific VM version - -version Version information - -help Print a synopsis of standard options - -A[key[=value]] Options to pass to annotation processors - -X Print a synopsis of nonstandard options - -J<flag> Pass <flag> directly to the runtime system - -files/cli/test3/Main.java:5: package test1 does not exist - test1.Main.main(args); - ^ -files/cli/test3/Main.java:7: package test2 does not exist - test2.Main.main(args); - ^ -2 errors diff --git a/test/attic/files/cli/test3/Main.check.jikes b/test/attic/files/cli/test3/Main.check.jikes deleted file mode 100644 index 604333e81a..0000000000 --- a/test/attic/files/cli/test3/Main.check.jikes +++ /dev/null @@ -1,14 +0,0 @@ -Error: "-dd" is an invalid option. -use: jikes [options] [@files] file.java... -For more help, try -help or -version. - -Found 2 semantic errors compiling "files/cli/test3/Main.java": - - 6. test1.Main.main(args); - ^---^ -*** Semantic Error: No accessible field named "test1" was found in type "test3.Main". - - - 8. test2.Main.main(args); - ^---^ -*** Semantic Error: No accessible field named "test2" was found in type "test3.Main". diff --git a/test/attic/files/cli/test3/Main.check.jikes5 b/test/attic/files/cli/test3/Main.check.jikes5 deleted file mode 100644 index 604333e81a..0000000000 --- a/test/attic/files/cli/test3/Main.check.jikes5 +++ /dev/null @@ -1,14 +0,0 @@ -Error: "-dd" is an invalid option. -use: jikes [options] [@files] file.java... -For more help, try -help or -version. - -Found 2 semantic errors compiling "files/cli/test3/Main.java": - - 6. test1.Main.main(args); - ^---^ -*** Semantic Error: No accessible field named "test1" was found in type "test3.Main". - - - 8. test2.Main.main(args); - ^---^ -*** Semantic Error: No accessible field named "test2" was found in type "test3.Main". diff --git a/test/attic/files/cli/test3/Main.check.scala b/test/attic/files/cli/test3/Main.check.scala deleted file mode 100644 index f78729b9a2..0000000000 --- a/test/attic/files/cli/test3/Main.check.scala +++ /dev/null @@ -1,28 +0,0 @@ -unknown option: '-cpp' -scala [ <option> ]... [<torun> <arguments>] - -All options to scalac are allowed. See scalac -help. - -<torun>, if present, is an object or script file to run. -If no <torun> is present, run an interactive interpreter. - -Option -howtorun allows explicitly specifying how to run <torun>: - script: it is a script file - object: it is an object name - guess: (the default) try to guess - -Option -savecompiled requests that the compiled script be saved -for future use. - -Option -nocompdaemon requests that the fsc offline compiler not be used. - -Option -Dproperty=value sets a Java system property. - -3: 1: test 1 passed (1) -3: 2: 1: test 1 passed (1) -3: 1: test 2 passed (1) -3: 2: 1: test 2 passed (1) -3: 1: test 3 passed (1) -3: 2: 1: test 3 passed (1) -3: 1: test 4 passed (2) -3: 2: 1: test 4 passed (2) diff --git a/test/attic/files/cli/test3/Main.check.scala_api b/test/attic/files/cli/test3/Main.check.scala_api deleted file mode 100644 index 4552819b5b..0000000000 --- a/test/attic/files/cli/test3/Main.check.scala_api +++ /dev/null @@ -1,41 +0,0 @@ -|-- all-classes.html -|-- index.html -|-- modules.html -|-- nav-classes.html -|-- root-content.html -|-- scala -| |-- Any.html -| |-- AnyRef.html -| |-- AnyVal.html -| |-- Boolean.html -| |-- Byte.html -| |-- Char.html -| |-- Double.html -| |-- Float.html -| |-- Int.html -| |-- Long.html -| |-- Nothing.html -| |-- Null.html -| |-- Short.html -| |-- Unit.html -| `-- runtime -| |-- BoxedFloat.html -| |-- BoxedInt.html -| |-- BoxedLong.html -| `-- BoxedNumber.html -|-- script.js -|-- style.css -|-- test1 -| `-- Main$object.html -|-- test1$content.html -|-- test1$package.html -|-- test2 -| `-- Main$object.html -|-- test2$content.html -|-- test2$package.html -|-- test3 -| `-- Main$object.html -|-- test3$content.html -`-- test3$package.html - -5 directories, 34 files diff --git a/test/attic/files/cli/test3/Main.check.scala_j9 b/test/attic/files/cli/test3/Main.check.scala_j9 deleted file mode 100644 index 3804c17636..0000000000 --- a/test/attic/files/cli/test3/Main.check.scala_j9 +++ /dev/null @@ -1,19 +0,0 @@ -unknown option: '-cpp' -scala [ <compiler-option> | -howtorun:how ]... [<torun> <arguments>] - -<compiler-option>'s are as for scalac; see scalac -help. -<torun>, if present, is an object or script file to run. -If no <torun> is present, run an interactive interpreter. --howtorun allows explicitly specifying how to run <torun>: - script: it is a script file - object: it is an object name - guess: (the default) try to guess - -3: 1: test 1 passed (1) -3: 2: 1: test 1 passed (1) -3: 1: test 2 passed (1) -3: 2: 1: test 2 passed (1) -3: 1: test 3 passed (1) -3: 2: 1: test 3 passed (1) -3: 1: test 4 passed (2) -3: 2: 1: test 4 passed (2) diff --git a/test/attic/files/cli/test3/Main.check.scalac b/test/attic/files/cli/test3/Main.check.scalac deleted file mode 100644 index 8465810d0b..0000000000 --- a/test/attic/files/cli/test3/Main.check.scalac +++ /dev/null @@ -1,63 +0,0 @@ -scalac error: bad option: '-dd' - scalac -help gives more information -Usage: scalac <options | source files> -where possible options include: - -doc Generate documentation - -g:<g> Generate debugging info (none,source,line,vars,notc) - -nowarn Generate no warnings - -noassert Generate no assertions and assumptions - -verbose Output messages about what the compiler is doing - -classpath <path> Specify where to find user class files - -sourcepath <path> Specify where to find input source files - -bootclasspath <path> Override location of bootstrap class files - -extdirs <dirs> Override location of installed extensions - -d <directory> Specify where to place generated class files - -encoding <encoding> Specify character encoding used by source files - -windowtitle <windowtitle> Specify window title of generated HTML documentation - -documenttitle <documenttitle> Specify document title of generated HTML documentation - -target:<target> Specify which backend to use (jvm-1.5,msil) - -migrate Assist in migrating from Scala version 1.0 - -o <file> Name of the output assembly (only relevant with -target:msil) - -r <path> List of assemblies referenced by the program (only relevant with -target:msil) - -debug Output debugging messages - -deprecation enable detailed deprecation warnings - -unchecked enable detailed unchecked warnings - -statistics Print compiler statistics - -explaintypes Explain type errors in more detail - -resident Compiler stays resident, files to compile are read from standard input - -uniqid Print identifiers with unique names (debugging option) - -printtypes Print tree types (debugging option) - -prompt Display a prompt after each error (debugging option) - -noimports Compile without any implicit imports - -nopredefs Compile without any implicit predefined values - -skip:<phase> Skip <phase> - -check:<phase> Check the tree at start of <phase> - -print:<phase> Print out program after <phase> - -printer:<printer> Printer to use (text,html) - -printfile <file> Specify file in which to print trees - -graph:<phase> Graph the program after <phase> - -browse:<phase> Browse the abstract syntax tree after <phase> - -stop:<phase> Stop after phase <phase> - -log:<phase> Log operations in <phase> - -logall Log all operations - -version Print product version and exit - -help Print a synopsis of standard options - -nouescape disables handling of \u unicode escapes - -Xinline Perform inlining when possible - -XO Optimize. implies -Xinline, -Xcloselim and -Xdce - -Xcloselim Perform closure elimination - -Xdce Perform dead code elimination - -Xwarndeadcode Emit warnings for dead code - -XbytecodeRead Enable bytecode reader. - -Xdetach Perform detaching of remote closures - -Xshowcls <class> Show class info - -Xshowobj <object> Show object info - -Xlinearizer:<Xlinearizer> Linearizer to use (normal,dfs,rpo,dump) - -Xgenerics Use generic Java types - -Xprintpos Print tree positions (as offsets) - -Xscript compile script file - -Xexperimental enable experimental extensions - -Xplugtypes parse but ignore annotations in more locations - -Xkilloption optimizes option types - -one error found diff --git a/test/attic/files/cli/test3/Main.check.scalaint b/test/attic/files/cli/test3/Main.check.scalaint deleted file mode 100644 index cffa02c5b6..0000000000 --- a/test/attic/files/cli/test3/Main.check.scalaint +++ /dev/null @@ -1,48 +0,0 @@ -unknown option: '-cpp' -scala [ <option> ]... [<torun> <arguments>] - -All options to scalac are allowed. See scalac -help. - -<torun>, if present, is an object or script file to run. -If no <torun> is present, run an interactive interpreter. - -Option -howtorun allows explicitly specifying how to run <torun>: - script: it is a script file - object: it is an object name - guess: (the default) try to guess - -Option -savecompiled requests that the compiled script be saved -for future use. - -Option -nocompdaemon requests that the fsc offline compiler not be used. - -Option -Dproperty=value sets a Java system property. - - -This is an interpreter for Scala. -Type in expressions to have them evaluated. -Type :help for more information. - -scala> 3: 1: test 1 passed (1) -3: 2: 1: test 1 passed (1) -unnamed0: scala.Unit = () - -scala> -This is an interpreter for Scala. -Type in expressions to have them evaluated. -Type :help for more information. - -scala> 3: 1: test 2 passed (1) -3: 2: 1: test 2 passed (1) -unnamed0: scala.Unit = () - -scala> -This is an interpreter for Scala. -Type in expressions to have them evaluated. -Type :help for more information. - -scala> 3: 1: test 3 passed (1) -3: 2: 1: test 3 passed (1) -unnamed0: scala.Unit = () - -scala> diff --git a/test/attic/files/cli/test3/Main.java b/test/attic/files/cli/test3/Main.java deleted file mode 100644 index 208863d012..0000000000 --- a/test/attic/files/cli/test3/Main.java +++ /dev/null @@ -1,10 +0,0 @@ -// @info 2 dependency -package test3; -public class Main { - public static void main(String args[]) { - System.out.print("3: "); - test1.Main.main(args); - System.out.print("3: "); - test2.Main.main(args); - } -} diff --git a/test/attic/files/cli/test3/Main.scala b/test/attic/files/cli/test3/Main.scala deleted file mode 100644 index 63fc11b771..0000000000 --- a/test/attic/files/cli/test3/Main.scala +++ /dev/null @@ -1,10 +0,0 @@ -// @info 2 dependencies -package test3 -object Main { - def main(args: Array[String]) = { - Console.print("3: ") - test1.Main.main(args) - Console.print("3: ") - test2.Main.main(args) - } -} diff --git a/test/build-partest.xml b/test/build-partest.xml new file mode 100755 index 0000000000..22ad85ac03 --- /dev/null +++ b/test/build-partest.xml @@ -0,0 +1,20 @@ +<project name="partest" basedir="."> + <dirname property="partest.basedir" file="${ant.file.partest}"/> + <property file="${partest.basedir}/included.properties"/> + + <macrodef name="testSuite"> + <attribute name="dir" default="${partest.basedir}/test"/> + <attribute name="srcdir" default="files"/> <!-- TODO: make targets for `pending` and other subdirs --> + <attribute name="colors" default="${partest.colors}"/> + <attribute name="scalacOpts" default="${scalac.args.optimise}"/> + <attribute name="kinds"/> + <sequential> + <property name="partest.dir" value="@{dir}" /> + <partest srcdir="@{srcdir}" + kinds="@{kinds}" + colors="@{colors}" + scalacOpts="@{scalacOpts}" + compilationpathref="partest.compilation.path"/> + </sequential> + </macrodef> +</project> diff --git a/test/files/disabled/A.scala b/test/disabled/buildmanager/overloaded_1/A.scala index c070faf978..c070faf978 100644 --- a/test/files/disabled/A.scala +++ b/test/disabled/buildmanager/overloaded_1/A.scala diff --git a/test/files/disabled/overloaded_1.check b/test/disabled/buildmanager/overloaded_1/overloaded_1.check index 4d643ce6b4..4d643ce6b4 100644 --- a/test/files/disabled/overloaded_1.check +++ b/test/disabled/buildmanager/overloaded_1/overloaded_1.check diff --git a/test/files/disabled/overloaded_1.test b/test/disabled/buildmanager/overloaded_1/overloaded_1.test index 392e0d365f..392e0d365f 100644 --- a/test/files/disabled/overloaded_1.test +++ b/test/disabled/buildmanager/overloaded_1/overloaded_1.test diff --git a/test/files/disabled/t4245/A.scala b/test/disabled/buildmanager/t4245/A.scala index 7c4efe1b4b..7c4efe1b4b 100644 --- a/test/files/disabled/t4245/A.scala +++ b/test/disabled/buildmanager/t4245/A.scala diff --git a/test/files/disabled/t4245/t4245.check b/test/disabled/buildmanager/t4245/t4245.check index 3d3898c671..3d3898c671 100644 --- a/test/files/disabled/t4245/t4245.check +++ b/test/disabled/buildmanager/t4245/t4245.check diff --git a/test/files/disabled/t4245/t4245.test b/test/disabled/buildmanager/t4245/t4245.test index 392e0d365f..392e0d365f 100644 --- a/test/files/disabled/t4245/t4245.test +++ b/test/disabled/buildmanager/t4245/t4245.test diff --git a/test/disabled/pos/spec-List.scala b/test/disabled/pos/spec-List.scala index 81e55f46cb..b31e035c1b 100644 --- a/test/disabled/pos/spec-List.scala +++ b/test/disabled/pos/spec-List.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** diff --git a/test/disabled/presentation/akka.flags b/test/disabled/presentation/akka.flags index 56d026a62d..9bf2878f62 100644 --- a/test/disabled/presentation/akka.flags +++ b/test/disabled/presentation/akka.flags @@ -12,7 +12,7 @@ # running partest from. Run it from the root scala checkout for these files to resolve correctly # (by default when running 'ant test', or 'test/partest'). Paths use Unix separators, the test # framework translates them to the platform dependent representation. -# -bootclasspath lib/scala-compiler.jar:lib/scala-library.jar:lib/fjbg.jar +# -bootclasspath lib/scala-compiler.jar:lib/scala-library.jar # the following line would test using the quick compiler -# -bootclasspath build/quick/classes/compiler:build/quick/classes/library:lib/fjbg.jar +# -bootclasspath build/quick/classes/compiler:build/quick/classes/library diff --git a/test/disabled/presentation/akka/src/akka/dispatch/Dispatchers.scala b/test/disabled/presentation/akka/src/akka/dispatch/Dispatchers.scala index 7dd1bf6218..a567d0bcb0 100644 --- a/test/disabled/presentation/akka/src/akka/dispatch/Dispatchers.scala +++ b/test/disabled/presentation/akka/src/akka/dispatch/Dispatchers.scala @@ -89,7 +89,7 @@ object Dispatchers { new ThreadBasedDispatcher(actor, mailboxCapacity, pushTimeOut) /** - * Creates a executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. * <p/> * Has a fluent builder interface for configuring its semantics. */ @@ -97,7 +97,7 @@ object Dispatchers { ThreadPoolConfigDispatcherBuilder(config => new ExecutorBasedEventDrivenDispatcher(name, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. * <p/> * Has a fluent builder interface for configuring its semantics. */ @@ -106,7 +106,7 @@ object Dispatchers { new ExecutorBasedEventDrivenDispatcher(name, throughput, THROUGHPUT_DEADLINE_TIME_MILLIS, mailboxType, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher serving multiple (millions) of actors through a thread pool. * <p/> * Has a fluent builder interface for configuring its semantics. */ @@ -115,7 +115,7 @@ object Dispatchers { new ExecutorBasedEventDrivenDispatcher(name, throughput, throughputDeadlineMs, mailboxType, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. * <p/> * Has a fluent builder interface for configuring its semantics. */ @@ -123,7 +123,7 @@ object Dispatchers { ThreadPoolConfigDispatcherBuilder(config => new ExecutorBasedEventDrivenWorkStealingDispatcher(name, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. * <p/> * Has a fluent builder interface for configuring its semantics. */ @@ -132,7 +132,7 @@ object Dispatchers { new ExecutorBasedEventDrivenWorkStealingDispatcher(name, throughput, THROUGHPUT_DEADLINE_TIME_MILLIS, MAILBOX_TYPE, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. * <p/> * Has a fluent builder interface for configuring its semantics. */ @@ -141,7 +141,7 @@ object Dispatchers { new ExecutorBasedEventDrivenWorkStealingDispatcher(name, throughput, THROUGHPUT_DEADLINE_TIME_MILLIS, mailboxType, config), ThreadPoolConfig()) /** - * Creates a executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. + * Creates an executor-based event-driven dispatcher, with work-stealing, serving multiple (millions) of actors through a thread pool. * <p/> * Has a fluent builder interface for configuring its semantics. */ @@ -224,4 +224,4 @@ class ExecutorBasedEventDrivenWorkStealingDispatcherConfigurator extends Message mailboxType(config), threadPoolConfig)).build } -}
\ No newline at end of file +} diff --git a/test/disabled/presentation/simple-tests.check b/test/disabled/presentation/simple-tests.check index cdb80ed987..0f72cb5ab9 100644 --- a/test/disabled/presentation/simple-tests.check +++ b/test/disabled/presentation/simple-tests.check @@ -187,8 +187,6 @@ TypeMember(value Xshowobj,Tester.this.settings.StringSetting,false,true,<none>) TypeMember(value Xshowtrees,Tester.this.settings.BooleanSetting,false,true,<none>) TypeMember(value Xwarnfatal,Tester.this.settings.BooleanSetting,false,true,<none>) TypeMember(value Xwarninit,Tester.this.settings.BooleanSetting,false,true,<none>) -TypeMember(value Ybuilderdebug,Tester.this.settings.ChoiceSetting,false,true,<none>) -TypeMember(value Ybuildmanagerdebug,Tester.this.settings.BooleanSetting,false,true,<none>) TypeMember(value Ycompacttrees,Tester.this.settings.BooleanSetting,false,true,<none>) TypeMember(value Ycompletion,Tester.this.settings.BooleanSetting,false,true,<none>) TypeMember(value YdepMethTpes,Tester.this.settings.BooleanSetting,false,true,<none>) diff --git a/test/disabled/presentation/simple-tests.opts b/test/disabled/presentation/simple-tests.opts index 8529bbf1a0..d651316984 100644 --- a/test/disabled/presentation/simple-tests.opts +++ b/test/disabled/presentation/simple-tests.opts @@ -12,7 +12,7 @@ # running partest from. Run it from the root scala checkout for these files to resolve correctly # (by default when running 'ant test', or 'test/partest'). Paths use Unix separators, the test # framework translates them to the platform dependent representation. --bootclasspath lib/scala-compiler.jar:lib/scala-library.jar:lib/fjbg.jar +-bootclasspath lib/scala-compiler.jar:lib/scala-library.jar # the following line would test using the quick compiler -# -bootclasspath build/quick/classes/compiler:build/quick/classes/library:lib/fjbg.jar +# -bootclasspath build/quick/classes/compiler:build/quick/classes/library diff --git a/test/files/run/t4146.scala b/test/disabled/run/t4146.scala index 93ce22b519..a17de50ee1 100644 --- a/test/files/run/t4146.scala +++ b/test/disabled/run/t4146.scala @@ -1,4 +1,4 @@ -object bob extends Application { +object bob extends App { var name = "Bob" } diff --git a/test/disabled/run/t7843-jsr223-service.check b/test/disabled/run/t7843-jsr223-service.check new file mode 100644 index 0000000000..a668df3567 --- /dev/null +++ b/test/disabled/run/t7843-jsr223-service.check @@ -0,0 +1,2 @@ +n: Object = 10 +12345678910 diff --git a/test/disabled/run/t7843-jsr223-service.scala b/test/disabled/run/t7843-jsr223-service.scala new file mode 100644 index 0000000000..e2ea850698 --- /dev/null +++ b/test/disabled/run/t7843-jsr223-service.scala @@ -0,0 +1,18 @@ +/*DISABLED: + For Paul, it steals focus when it runs. + + For me, it fails with some platform specific extra output: + + -ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider apple.applescript.AppleScriptEngin + n: Object = 10 + 12345678910 +*/ +import javax.script._ +import scala.tools.nsc.interpreter.IMain + +object Test extends App { + val engine = new ScriptEngineManager getEngineByName "scala" + engine.asInstanceOf[IMain].settings.usejavacp.value = true + engine put ("n", 10) + engine eval "1 to n.asInstanceOf[Int] foreach print" +} diff --git a/test/files/ant/README b/test/files/ant/README deleted file mode 100644 index 8cd8745970..0000000000 --- a/test/files/ant/README +++ /dev/null @@ -1,42 +0,0 @@ -README -====== - -Test cases in directory test/files/ant/ are executed by invoking an -Ant script whose name ends with "build.xml" (eg. "fsc001-build.xml"). - -The Scala Ant tasks fsc/scalac/scaladoc are instantiated from various -binaries (quick/pack/latest/installed) and are executed with different -combinations of Ant attributes/elements: - - +---------------------------+--------------------------+ - | Attributes | Nested elements | -------------+---------------------------+--------------------------+ -fsc001 | srcdir,classpath (1) | compilerarg | -fsc002 | srcref,classpathref (1) | compilerarg | -fsc003 | (2) | compilerarg,src,include | -------------+---------------------------+--------------------------+ -scalac001 | srcdir,classpath (1) | | -scalac002 | srcref,classpathref (1) | | -scalac003 | (2) | src,include | -scalac004 | deprecation,unchecked (3) | | -------------+---------------------------+--------------------------+ -scaladoc | srcdir,classpathref | | -------------+---------------------------+--------------------------+ - -Other attributes: -(1) includes,destdir -(2) destdir,classpathref -(3) srcdir,includes,destdir,classpath - - -The above test cases can also be run from the command prompt using one of -the following shell commands: - -1) For quick/pack/latest binaries (-Dbinary=quick|pack|latest) - -$ ant -Dbinary=quick -Dproject.dir=$HOME/workspace/scala -f scalac001-build.xml - -2) For installed binaries (-Dbinary=installed) - -$ ant -Dbinary=installed -Dinstalled.dir=/opt/scala -f scalac001-build.xml - diff --git a/test/files/ant/fsc001-build.check b/test/files/ant/fsc001-build.check deleted file mode 100644 index b5141f587b..0000000000 --- a/test/files/ant/fsc001-build.check +++ /dev/null @@ -1,14 +0,0 @@ - -quick.init: - -pack.init: - -latest.init: - -installed.init: - -init: - -build: - [mkdir] Created dir: [...]/files/ant/fsc001-ant.obj - [fsc] Compiling 1 source file to [...]/files/ant/fsc001-ant.obj diff --git a/test/files/ant/fsc001-build.xml b/test/files/ant/fsc001-build.xml deleted file mode 100644 index 0130f3615c..0000000000 --- a/test/files/ant/fsc001-build.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<project name="fsc001" default="run"> - - <import file="${basedir}/imported.xml"/> - -<!-- =========================================================================== -BUILD -============================================================================ --> - - <target name="build" depends="init"> - <echo level="verbose" message="build.dir=${build.dir}"/> - <mkdir dir="${build.dir}"/> - <pathconvert property="classpath" refid="build.classpath"/> - <fsc - srcdir="${source.dir}" - includes="**/${ant.project.name}*.scala" - destdir="${build.dir}" - classpath="${classpath}"> - </fsc> - <echo level="verbose" message="log.file=${log.file}"/> - <replace file="${log.file}" token="${log.dir}" value="[...]/files/ant"/> - </target> - -</project> - diff --git a/test/files/ant/fsc001.scala b/test/files/ant/fsc001.scala deleted file mode 100644 index 6ede5981ce..0000000000 --- a/test/files/ant/fsc001.scala +++ /dev/null @@ -1,7 +0,0 @@ -package test - -object Main { - def main(args: Array[String]) { - println(args mkString " ") - } -} diff --git a/test/files/ant/fsc002-build.check b/test/files/ant/fsc002-build.check deleted file mode 100644 index 0c9c30dbfa..0000000000 --- a/test/files/ant/fsc002-build.check +++ /dev/null @@ -1,14 +0,0 @@ - -quick.init: - -pack.init: - -latest.init: - -installed.init: - -init: - -build: - [mkdir] Created dir: [...]/files/ant/fsc002-ant.obj - [fsc] Compiling 1 source file to [...]/files/ant/fsc002-ant.obj diff --git a/test/files/ant/fsc002-build.xml b/test/files/ant/fsc002-build.xml deleted file mode 100644 index db91070fa1..0000000000 --- a/test/files/ant/fsc002-build.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<project name="fsc002" default="run"> - - <import file="${basedir}/imported.xml"/> - -<!-- =========================================================================== -BUILD -============================================================================ --> - - <target name="build" depends="init"> - <echo level="verbose" message="build.dir=${build.dir}"/> - <mkdir dir="${build.dir}"/> - <path id="source.ref"> - <pathelement location="${source.dir}"/> - </path> - <fsc - srcref="source.ref" - includes="**/${ant.project.name}*.scala" - destdir="${build.dir}" - classpathref="build.classpath"> - </fsc> - <echo level="verbose" message="log.file=${log.file}"/> - <replace file="${log.file}" token="${log.dir}" value="[...]/files/ant"/> - </target> - -</project> - diff --git a/test/files/ant/fsc002.scala b/test/files/ant/fsc002.scala deleted file mode 100644 index 47131daac6..0000000000 --- a/test/files/ant/fsc002.scala +++ /dev/null @@ -1,6 +0,0 @@ -package test - -object Main { - def main(args: Array[String]): Unit = - Console.println(args.toList) -} diff --git a/test/files/ant/fsc003-build.check b/test/files/ant/fsc003-build.check deleted file mode 100644 index c8c9ed857e..0000000000 --- a/test/files/ant/fsc003-build.check +++ /dev/null @@ -1,14 +0,0 @@ - -quick.init: - -pack.init: - -latest.init: - -installed.init: - -init: - -build: - [mkdir] Created dir: [...]/files/ant/fsc003-ant.obj - [fsc] Compiling 1 source file to [...]/files/ant/fsc003-ant.obj diff --git a/test/files/ant/fsc003-build.xml b/test/files/ant/fsc003-build.xml deleted file mode 100644 index 5f71770bf2..0000000000 --- a/test/files/ant/fsc003-build.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<project name="fsc003" default="run"> - - <import file="${basedir}/imported.xml"/> - -<!-- =========================================================================== -BUILD -============================================================================ --> - - <target name="build" depends="init"> - <echo level="verbose" message="build.dir=${build.dir}"/> - <mkdir dir="${build.dir}"/> - <fsc - destdir="${build.dir}" - classpathref="build.classpath"> - <src path="${source.dir}"/> - <include name="**/${ant.project.name}*.scala"/> - </fsc> - <echo level="verbose" message="log.file=${log.file}"/> - <replace file="${log.file}" token="${log.dir}" value="[...]/files/ant"/> - </target> - -</project> - diff --git a/test/files/ant/fsc003.scala b/test/files/ant/fsc003.scala deleted file mode 100644 index 6ede5981ce..0000000000 --- a/test/files/ant/fsc003.scala +++ /dev/null @@ -1,7 +0,0 @@ -package test - -object Main { - def main(args: Array[String]) { - println(args mkString " ") - } -} diff --git a/test/files/ant/imported.xml b/test/files/ant/imported.xml deleted file mode 100644 index 5a4dfc319b..0000000000 --- a/test/files/ant/imported.xml +++ /dev/null @@ -1,155 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<project name="imported"> - - <!-- This file is imported by the main Ant script. --> - - <!-- Prevents system classpath from being used --> - <property name="build.sysclasspath" value="ignore"/> - -<!-- =========================================================================== -PROPERTIES -============================================================================ --> - - <property name="source.dir" value="${basedir}"/> - - <property file="${basedir}/build.properties"/> - - <property name="build.dir" location="${source.dir}/${ant.project.name}-ant.obj"/> - <property name="log.dir" location="${source.dir}"/> - <property name="log.file" value="${log.dir}/${ant.project.name}-build-ant.log"/> - <property name="project.dir" value="../../.."/> - - <condition property="quick.binary"> - <equals arg1="${binary}" arg2="quick"/> - </condition> - <condition property="pack.binary"> - <equals arg1="${binary}" arg2="pack"/> - </condition> - <condition property="latest.binary"> - <equals arg1="${binary}" arg2="latest"/> - </condition> - <condition property="installed.binary"> - <equals arg1="${binary}" arg2="installed"/> - </condition> - - <fail message="Property 'binary' must be set to either 'quick', 'pack', 'latest' or 'installed'."> - <condition><not><or> - <isset property="quick.binary"/> - <isset property="pack.binary"/> - <isset property="latest.binary"/> - <isset property="installed.binary"/> - </or></not></condition> - </fail> - <echo level="verbose" message="binary=${binary}"/> - <echo level="verbose" message="build.dir=${build.dir}"/> - -<!-- =========================================================================== -INITIALISATION -============================================================================ --> - - <target name="quick.init" if="quick.binary"> - <property name="quick.dir" value="${project.dir}/build/quick"/> - <fail message="Quick build could not be found."> - <condition><not><available file="${quick.dir}"/></not></condition> - </fail> - <property name="scala.dir" value="${quick.dir}"/> - <property name="scala-library.lib" value="${scala.dir}/classes/library/"/> - <property name="scala-compiler.lib" value="${scala.dir}/classes/compiler/"/> - <property name="fjbg.lib" value="${project.dir}/lib/fjbg.jar"/> - </target> - - <target name="pack.init" if="pack.binary"> - <property name="pack.dir" value="${project.dir}/build/pack"/> - <fail message="Pack build could not be found."> - <condition><not><available file="${pack.dir}"/></not></condition> - </fail> - <property name="scala.dir" value="${pack.dir}"/> - <property name="scala-library.lib" value="${scala.dir}/lib/scala-library.jar"/> - <property name="scala-compiler.lib" value="${scala.dir}/lib/scala-compiler.jar"/> - <property name="fjbg.lib" value=""/> - </target> - - <target name="latest.init" if="latest.binary"> - <property name="latest.dir" value="${project.dir}/dists/latest"/> - <fail message="Latest build could not be found."> - <condition><not><available file="${latest.dir}"/></not></condition> - </fail> - <property name="scala.dir" value="${latest.dir}"/> - <property name="scala-library.lib" value="${scala.dir}/lib/scala-library.jar"/> - <property name="scala-compiler.lib" value="${scala.dir}/lib/scala-compiler.jar"/> - <property name="fjbg.lib" value=""/> - </target> - - <target name="installed.init" if="installed.binary"> - <property name="installed.dir" value="/opt/scala"/> - <fail message="Installed distribution could not be found."> - <condition><not><available file="${installed.dir}"/></not></condition> - </fail> - <property name="scala.dir" value="${installed.dir}"/> - <property name="scala-library.lib" value="${scala.dir}/lib/scala-library.jar"/> - <property name="scala-compiler.lib" value="${scala.dir}/lib/scala-compiler.jar"/> - <property name="fjbg.lib" value=""/> - </target> - - <target name="init" depends="quick.init, pack.init, latest.init, installed.init"> - <echo level="verbose" message="scala.dir=${scala.dir}"/> - - <path id="scala.classpath"> - <pathelement location="${scala-library.lib}"/> - <pathelement location="${scala-compiler.lib}"/> - <pathelement location="${fjbg.lib}"/> <!-- only present for 'quick' --> - </path> - - <fail message="Scala library '${scala-library.lib}' or '${scala-compiler.lib}' is missing/broken"> - <condition><not><and> - <available classname="scala.Predef" - classpathref="scala.classpath"/> - <available classname="scala.Option" - classpathref="scala.classpath"/> - <available classname="scala.runtime.ObjectRef" - classpathref="scala.classpath"/> - <available classname="scala.tools.ant.Scalac" - classpathref="scala.classpath"/> - <available classname="scala.tools.nsc.Main" - classpathref="scala.classpath"/> - <available classname="scala.tools.util.StringOps" - classpathref="scala.classpath"/> - </and></not></condition> - </fail> - <taskdef resource="scala/tools/ant/antlib.xml" classpathref="scala.classpath"/> - - <path id="build.classpath"> - <!--<pathelement location="${scala-actors.lib}"/>--> - <pathelement location="${scala-library.lib}"/> - <pathelement location="${build.dir}"/> - </path> - - <!-- make sure the log file exists when the Ant build scripts --> - <!-- are run manually from the command prompt --> - <touch file="${log.file}"/> - </target> - -<!-- =========================================================================== -RUN -============================================================================ --> - - <target name="run" depends="build, clean"/> - -<!-- =========================================================================== -CLEAN -============================================================================ --> - - <macrodef name="remove"> - <attribute name="dir"/> - <sequential> - <delete dir="@{dir}" includeemptydirs="yes" quiet="yes" failonerror="no"/> - </sequential> - </macrodef> - - <target name="clean"> - <remove dir="${build.dir}"/> - </target> - -</project> - diff --git a/test/files/ant/scalac001-build.check b/test/files/ant/scalac001-build.check deleted file mode 100644 index 05a43ba572..0000000000 --- a/test/files/ant/scalac001-build.check +++ /dev/null @@ -1,14 +0,0 @@ - -quick.init: - -pack.init: - -latest.init: - -installed.init: - -init: - -build: - [mkdir] Created dir: [...]/files/ant/scalac001-ant.obj - [scalac] Compiling 1 source file to [...]/files/ant/scalac001-ant.obj diff --git a/test/files/ant/scalac001-build.xml b/test/files/ant/scalac001-build.xml deleted file mode 100644 index 4ec7fc833c..0000000000 --- a/test/files/ant/scalac001-build.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<project name="scalac001" default="run"> - - <import file="${basedir}/imported.xml"/> - -<!-- =========================================================================== -BUILD -============================================================================ --> - - <target name="build" depends="init"> - <echo level="verbose" message="build.dir=${build.dir}"/> - <mkdir dir="${build.dir}"/> - <pathconvert property="classpath" refid="build.classpath"/> - <scalac - srcdir="${source.dir}" - includes="**/${ant.project.name}*.scala" - destdir="${build.dir}" - classpath="${classpath}" - /> - <echo level="verbose" message="log.file=${log.file}"/> - <replace file="${log.file}" token="${log.dir}" value="[...]/files/ant"/> - </target> - -</project> - diff --git a/test/files/ant/scalac001.scala b/test/files/ant/scalac001.scala deleted file mode 100644 index 47131daac6..0000000000 --- a/test/files/ant/scalac001.scala +++ /dev/null @@ -1,6 +0,0 @@ -package test - -object Main { - def main(args: Array[String]): Unit = - Console.println(args.toList) -} diff --git a/test/files/ant/scalac002-build.check b/test/files/ant/scalac002-build.check deleted file mode 100644 index e7b3670a0c..0000000000 --- a/test/files/ant/scalac002-build.check +++ /dev/null @@ -1,14 +0,0 @@ - -quick.init: - -pack.init: - -latest.init: - -installed.init: - -init: - -build: - [mkdir] Created dir: [...]/files/ant/scalac002-ant.obj - [scalac] Compiling 1 source file to [...]/files/ant/scalac002-ant.obj diff --git a/test/files/ant/scalac002-build.xml b/test/files/ant/scalac002-build.xml deleted file mode 100644 index 07628afa64..0000000000 --- a/test/files/ant/scalac002-build.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<project name="scalac002" default="run"> - - <import file="${basedir}/imported.xml"/> - -<!-- =========================================================================== -BUILD -============================================================================ --> - - <target name="build" depends="init"> - <echo level="verbose" message="build.dir=${build.dir}"/> - <mkdir dir="${build.dir}"/> - <path id="source.ref"> - <pathelement location="${source.dir}"/> - </path> - <scalac - srcref="source.ref" - includes="**/${ant.project.name}*.scala" - destdir="${build.dir}" - classpathref="build.classpath" - /> - <echo level="verbose" message="log.file=${log.file}"/> - <replace file="${log.file}" token="${log.dir}" value="[...]/files/ant"/> - </target> - -</project> - diff --git a/test/files/ant/scalac002.scala b/test/files/ant/scalac002.scala deleted file mode 100644 index 6ede5981ce..0000000000 --- a/test/files/ant/scalac002.scala +++ /dev/null @@ -1,7 +0,0 @@ -package test - -object Main { - def main(args: Array[String]) { - println(args mkString " ") - } -} diff --git a/test/files/ant/scalac003-build.check b/test/files/ant/scalac003-build.check deleted file mode 100644 index 7b0d3367ed..0000000000 --- a/test/files/ant/scalac003-build.check +++ /dev/null @@ -1,14 +0,0 @@ - -quick.init: - -pack.init: - -latest.init: - -installed.init: - -init: - -build: - [mkdir] Created dir: [...]/files/ant/scalac003-ant.obj - [scalac] Compiling 1 source file to [...]/files/ant/scalac003-ant.obj diff --git a/test/files/ant/scalac003-build.xml b/test/files/ant/scalac003-build.xml deleted file mode 100644 index 1d70aa115e..0000000000 --- a/test/files/ant/scalac003-build.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<project name="scalac003" default="run"> - - <import file="${basedir}/imported.xml"/> - -<!-- =========================================================================== -BUILD -============================================================================ --> - - <target name="build" depends="init"> - <echo level="verbose" message="build.dir=${build.dir}"/> - <mkdir dir="${build.dir}"/> - <scalac - destdir="${build.dir}" - classpathref="build.classpath"> - <src path="${source.dir}"/> - <include name="**/${ant.project.name}*.scala"/> - </scalac> - <echo level="verbose" message="log.file=${log.file}"/> - <replace file="${log.file}" token="${log.dir}" value="[...]/files/ant"/> - </target> - -</project> - diff --git a/test/files/ant/scalac003.scala b/test/files/ant/scalac003.scala deleted file mode 100644 index 6ede5981ce..0000000000 --- a/test/files/ant/scalac003.scala +++ /dev/null @@ -1,7 +0,0 @@ -package test - -object Main { - def main(args: Array[String]) { - println(args mkString " ") - } -} diff --git a/test/files/ant/scalac004-build.check b/test/files/ant/scalac004-build.check deleted file mode 100644 index ffe9e8c79a..0000000000 --- a/test/files/ant/scalac004-build.check +++ /dev/null @@ -1,24 +0,0 @@ - -quick.init: - -pack.init: - -latest.init: - -installed.init: - -init: - -build: - [mkdir] Created dir: [...]/files/ant/scalac004-ant.obj - [scalac] Compiling 1 source file to [...]/files/ant/scalac004-ant.obj - [scalac] [...]/files/ant/scalac004.scala:9: warning: method exit in object Predef is deprecated: Use sys.exit(status) instead - [scalac] Predef.exit(0) //deprecated in 2.9.0 - [scalac] ^ - [scalac] [...]/files/ant/scalac004.scala:6: warning: match is not exhaustive! - [scalac] missing combination Nil - [scalac] - [scalac] xs match { //(xs: @unchecked) match { - [scalac] ^ - [scalac] two warnings found - [scalac] Compile succeeded with 2 warnings; see the compiler output for details. diff --git a/test/files/ant/scalac004-build.xml b/test/files/ant/scalac004-build.xml deleted file mode 100644 index 66c19a39fb..0000000000 --- a/test/files/ant/scalac004-build.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<project name="scalac004" default="run"> - - <import file="${basedir}/imported.xml"/> - -<!-- =========================================================================== -BUILD -============================================================================ --> - - <target name="build" depends="init"> - <echo level="verbose" message="build.dir=${build.dir}"/> - <mkdir dir="${build.dir}"/> - <scalac - deprecation="yes" unchecked="yes" - srcdir="${source.dir}" - includes="**/${ant.project.name}*.scala" - destdir="${build.dir}" - classpathref="build.classpath" - /> - <echo level="verbose" message="log.file=${log.file}"/> - <replace file="${log.file}" token="${log.dir}" value="[...]/files/ant"/> - </target> - -</project> - diff --git a/test/files/ant/scalac004.scala b/test/files/ant/scalac004.scala deleted file mode 100644 index 66b2ba7985..0000000000 --- a/test/files/ant/scalac004.scala +++ /dev/null @@ -1,11 +0,0 @@ -package test - -object Main { - def main(args: Array[String]) { - val xs = List(1, 2, 3, 4) - xs match { //(xs: @unchecked) match { - case x::xs => println(x) - } - Predef.exit(0) //deprecated in 2.9.0 - } -} diff --git a/test/files/ant/scaladoc-build.check b/test/files/ant/scaladoc-build.check deleted file mode 100644 index 1c82456ad0..0000000000 --- a/test/files/ant/scaladoc-build.check +++ /dev/null @@ -1,15 +0,0 @@ - -quick.init: - -pack.init: - -latest.init: - -installed.init: - -init: - -build: - [mkdir] Created dir: [...]/files/ant/scaladoc-ant.obj - [scaladoc] Documenting 1 source file to [...]/files/ant/scaladoc-ant.obj - [scaladoc] model contains 3 documentable templates diff --git a/test/files/ant/scaladoc-build.xml b/test/files/ant/scaladoc-build.xml deleted file mode 100644 index fb4dc6fe69..0000000000 --- a/test/files/ant/scaladoc-build.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<project name="scaladoc" default="run"> - - <import file="${basedir}/imported.xml"/> - -<!-- =========================================================================== -BUILD -============================================================================ --> - - <target name="build" depends="init"> - <echo level="verbose" message="build.dir=${build.dir}"/> - <mkdir dir="${build.dir}"/> - <scaladoc - srcdir="${source.dir}" - includes="**/${ant.project.name}*.scala" - deprecation="yes" unchecked="yes" - destdir="${build.dir}" - classpathref="build.classpath" - /> - <echo level="verbose" message="log.file=${log.file}"/> - <replace file="${log.file}" token="${log.dir}" value="[...]/files/ant"/> - </target> - -</project> - diff --git a/test/files/ant/scaladoc.scala b/test/files/ant/scaladoc.scala deleted file mode 100644 index 6ede5981ce..0000000000 --- a/test/files/ant/scaladoc.scala +++ /dev/null @@ -1,7 +0,0 @@ -package test - -object Main { - def main(args: Array[String]) { - println(args mkString " ") - } -} diff --git a/test/files/bench/equality/eqeq.eqlog b/test/files/bench/equality/eqeq.eqlog index d1e27aceed..55a5eb430a 100644 --- a/test/files/bench/equality/eqeq.eqlog +++ b/test/files/bench/equality/eqeq.eqlog @@ -1,42 +1,42 @@ -Banchmark results for testing equality operations:
-eq.scala: Base case, use eq equality only
-eqeq.scala: Test case, use == instead of eq.
-All tests run on Thinkpad T400, 1.6.0_12 client VM.
-Test command: java eq 5 5
- java eqeq 5 5
-eq.scala, no -optimise
-eq$ 109 78 79 63 63
-eq$ 94 63 63 78 78
-eq$ 94 62 62 62 78
-eq$ 94 78 78 78 78
-eq$ 94 78 78 78 78
-eq.scala, with -optimise
-eq$ 421 63 62 47 63
-eq$ 406 62 62 63 62
-eq$ 407 62 62 78 63
-eq$ 406 63 63 62 62
-eq$ 407 62 62 63 47
-eqeq.scala with version of BoxesRuntime as of Nov 13th, no -optimise
-eqeq$ 562 516 516 516 515
-eqeq$ 547 515 515 531 532
-eqeq$ 532 516 516 515 516
-eqeq$ 547 531 531 516 531
-eqeq$ 547 515 515 516 516
-eqeq.scala with version of BoxesRuntime as of Nov 13th, with -optimise
-eqeq$ 1031 390 391 391 391
-eqeq$ 1031 391 391 391 390
-eqeq$ 1031 390 390 391 391
-eqeq$ 1031 406 407 391 390
-eqeq$ 1031 390 390 391 391
-eqeq.scala with 1st optimized of Nov 14th, no -optimise
-eqeq$ 484 421 438 438 437
-eqeq$ 484 438 437 437 438
-eqeq$ 469 437 453 454 438
-eqeq$ 468 437 438 468 438
-eqeq$ 485 437 437 422 438
-eqeq.scala with 1st optimized of Nov 14th, with -optimise
-eqeq$ 1016 375 391 375 375
-eqeq$ 1016 375 391 390 375
-eqeq$ 1016 390 391 375 375
-eqeq$ 1015 375 391 390 375
-eqeq$ 1016 390 375 375 375
+Banchmark results for testing equality operations: +eq.scala: Base case, use eq equality only +eqeq.scala: Test case, use == instead of eq. +All tests run on Thinkpad T400, 1.6.0_12 client VM. +Test command: java eq 5 5 + java eqeq 5 5 +eq.scala, no -optimise +eq$ 109 78 79 63 63 +eq$ 94 63 63 78 78 +eq$ 94 62 62 62 78 +eq$ 94 78 78 78 78 +eq$ 94 78 78 78 78 +eq.scala, with -optimise +eq$ 421 63 62 47 63 +eq$ 406 62 62 63 62 +eq$ 407 62 62 78 63 +eq$ 406 63 63 62 62 +eq$ 407 62 62 63 47 +eqeq.scala with version of BoxesRuntime as of Nov 13th, no -optimise +eqeq$ 562 516 516 516 515 +eqeq$ 547 515 515 531 532 +eqeq$ 532 516 516 515 516 +eqeq$ 547 531 531 516 531 +eqeq$ 547 515 515 516 516 +eqeq.scala with version of BoxesRuntime as of Nov 13th, with -optimise +eqeq$ 1031 390 391 391 391 +eqeq$ 1031 391 391 391 390 +eqeq$ 1031 390 390 391 391 +eqeq$ 1031 406 407 391 390 +eqeq$ 1031 390 390 391 391 +eqeq.scala with 1st optimized of Nov 14th, no -optimise +eqeq$ 484 421 438 438 437 +eqeq$ 484 438 437 437 438 +eqeq$ 469 437 453 454 438 +eqeq$ 468 437 438 468 438 +eqeq$ 485 437 437 422 438 +eqeq.scala with 1st optimized of Nov 14th, with -optimise +eqeq$ 1016 375 391 375 375 +eqeq$ 1016 375 391 390 375 +eqeq$ 1016 390 391 375 375 +eqeq$ 1015 375 391 390 375 +eqeq$ 1016 390 375 375 375 diff --git a/test/files/buildmanager/annotated/A.scala b/test/files/buildmanager/annotated/A.scala deleted file mode 100644 index 4130cf21ec..0000000000 --- a/test/files/buildmanager/annotated/A.scala +++ /dev/null @@ -1 +0,0 @@ -case class A[T](x: String, y: T) diff --git a/test/files/buildmanager/annotated/annotated.check b/test/files/buildmanager/annotated/annotated.check deleted file mode 100644 index ce92c9a294..0000000000 --- a/test/files/buildmanager/annotated/annotated.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > A.scala -compiling Set(A.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(), object A -> List()) diff --git a/test/files/buildmanager/annotated/annotated.test b/test/files/buildmanager/annotated/annotated.test deleted file mode 100644 index 392e0d365f..0000000000 --- a/test/files/buildmanager/annotated/annotated.test +++ /dev/null @@ -1,2 +0,0 @@ ->>compile A.scala ->>compile A.scala diff --git a/test/files/buildmanager/freshnames/A.scala b/test/files/buildmanager/freshnames/A.scala deleted file mode 100644 index e8ab26ca1e..0000000000 --- a/test/files/buildmanager/freshnames/A.scala +++ /dev/null @@ -1,16 +0,0 @@ -abstract class A { - - var t: List[B] - - def foo(n: String): Option[B] = { - t.reverse find (_.names contains n) - } - - def bar(n: Int): Option[B] = { - t.reverse find (_.names contains n) - } -} - -//class A -case class B(names: List[String]) - diff --git a/test/files/buildmanager/freshnames/B.scala b/test/files/buildmanager/freshnames/B.scala deleted file mode 100644 index d700225c08..0000000000 --- a/test/files/buildmanager/freshnames/B.scala +++ /dev/null @@ -1,4 +0,0 @@ -abstract class C extends A { - def test(n: Int) = bar(n) -} - diff --git a/test/files/buildmanager/freshnames/freshnames.check b/test/files/buildmanager/freshnames/freshnames.check deleted file mode 100644 index 9f05fb8a36..0000000000 --- a/test/files/buildmanager/freshnames/freshnames.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > B.scala A.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(), class B -> List(), object B -> List()) diff --git a/test/files/buildmanager/freshnames/freshnames.test b/test/files/buildmanager/freshnames/freshnames.test deleted file mode 100644 index 20b20298f9..0000000000 --- a/test/files/buildmanager/freshnames/freshnames.test +++ /dev/null @@ -1,2 +0,0 @@ ->>compile B.scala A.scala ->>compile A.scala diff --git a/test/files/buildmanager/infer/A.scala b/test/files/buildmanager/infer/A.scala deleted file mode 100644 index 46b5391609..0000000000 --- a/test/files/buildmanager/infer/A.scala +++ /dev/null @@ -1,16 +0,0 @@ -class Foo(flag: Boolean) { - val classpath = - if (flag) - new AClasspath - else - new BClasspath -} - -class AClasspath extends MergedClasspath[A] - -class BClasspath extends MergedClasspath[B] - -abstract class MergedClasspath[T] - -class A -class B diff --git a/test/files/buildmanager/infer/infer.check b/test/files/buildmanager/infer/infer.check deleted file mode 100644 index 1f736977ff..0000000000 --- a/test/files/buildmanager/infer/infer.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > A.scala -compiling Set(A.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(), class AClasspath -> List(), class B -> List(), class BClasspath -> List(), class Foo -> List(), class MergedClasspath -> List()) diff --git a/test/files/buildmanager/infer/infer.test b/test/files/buildmanager/infer/infer.test deleted file mode 100644 index 392e0d365f..0000000000 --- a/test/files/buildmanager/infer/infer.test +++ /dev/null @@ -1,2 +0,0 @@ ->>compile A.scala ->>compile A.scala diff --git a/test/files/buildmanager/namesdefaults/defparam-use.scala b/test/files/buildmanager/namesdefaults/defparam-use.scala deleted file mode 100644 index 5b5bbb3f4e..0000000000 --- a/test/files/buildmanager/namesdefaults/defparam-use.scala +++ /dev/null @@ -1,5 +0,0 @@ - -object Test extends App { - val outer = new Outer - new outer.Inner -} diff --git a/test/files/buildmanager/namesdefaults/defparam.scala b/test/files/buildmanager/namesdefaults/defparam.scala deleted file mode 100644 index d817c719ab..0000000000 --- a/test/files/buildmanager/namesdefaults/defparam.scala +++ /dev/null @@ -1,7 +0,0 @@ -class Outer { - - class Inner(val x: List[Int] = Nil) - -// lazy val Inner = "abc" -} - diff --git a/test/files/buildmanager/namesdefaults/namesdefaults.check b/test/files/buildmanager/namesdefaults/namesdefaults.check deleted file mode 100644 index 4a94d1fb55..0000000000 --- a/test/files/buildmanager/namesdefaults/namesdefaults.check +++ /dev/null @@ -1,9 +0,0 @@ -builder > defparam.scala defparam-use.scala -compiling Set(defparam-use.scala, defparam.scala) -Changes: Map() -builder > defparam-use.scala -compiling Set(defparam-use.scala) -Changes: Map(class Test$delayedInit$body -> List(), object Test -> List()) -builder > defparam-use.scala -compiling Set(defparam-use.scala) -Changes: Map(class Test$delayedInit$body -> List(), object Test -> List()) diff --git a/test/files/buildmanager/namesdefaults/namesdefaults.test b/test/files/buildmanager/namesdefaults/namesdefaults.test deleted file mode 100644 index 84ccc36bc3..0000000000 --- a/test/files/buildmanager/namesdefaults/namesdefaults.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile defparam.scala defparam-use.scala ->>compile defparam-use.scala ->>compile defparam-use.scala diff --git a/test/files/buildmanager/simpletest/A.scala b/test/files/buildmanager/simpletest/A.scala deleted file mode 100644 index ef704706bb..0000000000 --- a/test/files/buildmanager/simpletest/A.scala +++ /dev/null @@ -1,3 +0,0 @@ -class A { - def foo = 2 -} diff --git a/test/files/buildmanager/simpletest/B.scala b/test/files/buildmanager/simpletest/B.scala deleted file mode 100644 index 364dc6e4cb..0000000000 --- a/test/files/buildmanager/simpletest/B.scala +++ /dev/null @@ -1,3 +0,0 @@ -class B extends A { - override def foo = 2 -} diff --git a/test/files/buildmanager/simpletest/simpletest.changes/A1.scala b/test/files/buildmanager/simpletest/simpletest.changes/A1.scala deleted file mode 100644 index 83d15dc739..0000000000 --- a/test/files/buildmanager/simpletest/simpletest.changes/A1.scala +++ /dev/null @@ -1 +0,0 @@ -class A diff --git a/test/files/buildmanager/simpletest/simpletest.check b/test/files/buildmanager/simpletest/simpletest.check deleted file mode 100644 index 95ea2c4c0d..0000000000 --- a/test/files/buildmanager/simpletest/simpletest.check +++ /dev/null @@ -1,11 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(Removed(Definition(A.foo)))) -invalidate B.scala because inherited method removed [Removed(Definition(A.foo))] -compiling Set(B.scala) -B.scala:2: error: method foo overrides nothing - override def foo = 2 - ^ diff --git a/test/files/buildmanager/simpletest/simpletest.test b/test/files/buildmanager/simpletest/simpletest.test deleted file mode 100644 index 2c0be1502f..0000000000 --- a/test/files/buildmanager/simpletest/simpletest.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A1.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2280/A.scala b/test/files/buildmanager/t2280/A.scala deleted file mode 100644 index 5febadeb06..0000000000 --- a/test/files/buildmanager/t2280/A.scala +++ /dev/null @@ -1 +0,0 @@ -class A extends B diff --git a/test/files/buildmanager/t2280/B.java b/test/files/buildmanager/t2280/B.java deleted file mode 100644 index aef8e106e9..0000000000 --- a/test/files/buildmanager/t2280/B.java +++ /dev/null @@ -1,2 +0,0 @@ -public class B {} - diff --git a/test/files/buildmanager/t2280/t2280.check b/test/files/buildmanager/t2280/t2280.check deleted file mode 100644 index 7ea7511c63..0000000000 --- a/test/files/buildmanager/t2280/t2280.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > A.scala B.java -compiling Set(A.scala, B.java) -Changes: Map() -builder > B.java -compiling Set(B.java) -Changes: Map(class B -> List()) diff --git a/test/files/buildmanager/t2280/t2280.test b/test/files/buildmanager/t2280/t2280.test deleted file mode 100644 index 2eda777853..0000000000 --- a/test/files/buildmanager/t2280/t2280.test +++ /dev/null @@ -1,2 +0,0 @@ ->>compile A.scala B.java ->>compile B.java diff --git a/test/files/buildmanager/t2556_1/A.scala b/test/files/buildmanager/t2556_1/A.scala deleted file mode 100644 index c6e200b217..0000000000 --- a/test/files/buildmanager/t2556_1/A.scala +++ /dev/null @@ -1,3 +0,0 @@ -class A { - def x(i: Int) = i+"3" -} diff --git a/test/files/buildmanager/t2556_1/B.scala b/test/files/buildmanager/t2556_1/B.scala deleted file mode 100644 index 8529587b56..0000000000 --- a/test/files/buildmanager/t2556_1/B.scala +++ /dev/null @@ -1,3 +0,0 @@ -class B extends A { - def x(s: String) = s+"5" -} diff --git a/test/files/buildmanager/t2556_1/t2556_1.changes/A2.scala b/test/files/buildmanager/t2556_1/t2556_1.changes/A2.scala deleted file mode 100644 index 4ac1045e13..0000000000 --- a/test/files/buildmanager/t2556_1/t2556_1.changes/A2.scala +++ /dev/null @@ -1,4 +0,0 @@ -class A { - def x(i: String) = i+"3" -} - diff --git a/test/files/buildmanager/t2556_1/t2556_1.check b/test/files/buildmanager/t2556_1/t2556_1.check deleted file mode 100644 index 2e501c8f6f..0000000000 --- a/test/files/buildmanager/t2556_1/t2556_1.check +++ /dev/null @@ -1,12 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(Changed(Definition(A.x))[method x changed from (i: Int)String to (i: String)String flags: <method>])) -invalidate B.scala because inherited method changed [Changed(Definition(A.x))[method x changed from (i: Int)String to (i: String)String flags: <method>]] -compiling Set(B.scala) -B.scala:2: error: overriding method x in class A of type (i: String)String; - method x needs `override' modifier - def x(s: String) = s+"5" - ^ diff --git a/test/files/buildmanager/t2556_1/t2556_1.test b/test/files/buildmanager/t2556_1/t2556_1.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2556_1/t2556_1.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2556_2/A.scala b/test/files/buildmanager/t2556_2/A.scala deleted file mode 100644 index b8da5c8fb1..0000000000 --- a/test/files/buildmanager/t2556_2/A.scala +++ /dev/null @@ -1,4 +0,0 @@ -class A { - def x(i: Int) = i+"3" -} - diff --git a/test/files/buildmanager/t2556_2/B.scala b/test/files/buildmanager/t2556_2/B.scala deleted file mode 100644 index 80ff25d0ca..0000000000 --- a/test/files/buildmanager/t2556_2/B.scala +++ /dev/null @@ -1,2 +0,0 @@ -class B extends A - diff --git a/test/files/buildmanager/t2556_2/C.scala b/test/files/buildmanager/t2556_2/C.scala deleted file mode 100644 index 0ab13e3757..0000000000 --- a/test/files/buildmanager/t2556_2/C.scala +++ /dev/null @@ -1,4 +0,0 @@ -class C extends B { - def x(s: String) = s+"5" -} - diff --git a/test/files/buildmanager/t2556_2/t2556_2.changes/A2.scala b/test/files/buildmanager/t2556_2/t2556_2.changes/A2.scala deleted file mode 100644 index 4ac1045e13..0000000000 --- a/test/files/buildmanager/t2556_2/t2556_2.changes/A2.scala +++ /dev/null @@ -1,4 +0,0 @@ -class A { - def x(i: String) = i+"3" -} - diff --git a/test/files/buildmanager/t2556_2/t2556_2.check b/test/files/buildmanager/t2556_2/t2556_2.check deleted file mode 100644 index cae4f72212..0000000000 --- a/test/files/buildmanager/t2556_2/t2556_2.check +++ /dev/null @@ -1,13 +0,0 @@ -builder > A.scala B.scala C.scala -compiling Set(A.scala, B.scala, C.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(Changed(Definition(A.x))[method x changed from (i: Int)String to (i: String)String flags: <method>])) -invalidate B.scala because inherited method changed [Changed(Definition(A.x))[method x changed from (i: Int)String to (i: String)String flags: <method>]] -invalidate C.scala because inherited method changed [Changed(Definition(A.x))[method x changed from (i: Int)String to (i: String)String flags: <method>]] -compiling Set(B.scala, C.scala) -C.scala:2: error: overriding method x in class A of type (i: String)String; - method x needs `override' modifier - def x(s: String) = s+"5" - ^ diff --git a/test/files/buildmanager/t2556_2/t2556_2.test b/test/files/buildmanager/t2556_2/t2556_2.test deleted file mode 100644 index 9f31bb6409..0000000000 --- a/test/files/buildmanager/t2556_2/t2556_2.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala C.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2556_3/A.scala b/test/files/buildmanager/t2556_3/A.scala deleted file mode 100644 index 089a05f493..0000000000 --- a/test/files/buildmanager/t2556_3/A.scala +++ /dev/null @@ -1,5 +0,0 @@ -class A { - def x = 3 -} -class B extends A - diff --git a/test/files/buildmanager/t2556_3/B.scala b/test/files/buildmanager/t2556_3/B.scala deleted file mode 100644 index 0ec5ae4b55..0000000000 --- a/test/files/buildmanager/t2556_3/B.scala +++ /dev/null @@ -1,5 +0,0 @@ -object E { - def main(args: Array[String]) = - println( (new C).x ) -} - diff --git a/test/files/buildmanager/t2556_3/C.scala b/test/files/buildmanager/t2556_3/C.scala deleted file mode 100644 index 403df8455e..0000000000 --- a/test/files/buildmanager/t2556_3/C.scala +++ /dev/null @@ -1,2 +0,0 @@ -class C extends B - diff --git a/test/files/buildmanager/t2556_3/t2556_3.changes/A2.scala b/test/files/buildmanager/t2556_3/t2556_3.changes/A2.scala deleted file mode 100644 index 21cb2779f9..0000000000 --- a/test/files/buildmanager/t2556_3/t2556_3.changes/A2.scala +++ /dev/null @@ -1,5 +0,0 @@ -class A { - def x = 3 -} -class B - diff --git a/test/files/buildmanager/t2556_3/t2556_3.check b/test/files/buildmanager/t2556_3/t2556_3.check deleted file mode 100644 index 34f90f7f9b..0000000000 --- a/test/files/buildmanager/t2556_3/t2556_3.check +++ /dev/null @@ -1,18 +0,0 @@ -builder > A.scala B.scala C.scala -compiling Set(A.scala, B.scala, C.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(), class B -> List(Changed(Class(B))[List((A,Object))])) -invalidate C.scala because parents have changed [Changed(Class(B))[List((A,Object))]] -invalidate B.scala because it references invalid (no longer inherited) definition [ParentChanged(Class(C))] -compiling Set(B.scala, C.scala) -B.scala:3: error: type mismatch; - found : C - required: ?{def x: ?} -Note that implicit conversions are not applicable because they are ambiguous: - both method any2Ensuring in object Predef of type [A](x: A)Ensuring[A] - and method any2ArrowAssoc in object Predef of type [A](x: A)ArrowAssoc[A] - are possible conversion functions from C to ?{def x: ?} - println( (new C).x ) - ^ diff --git a/test/files/buildmanager/t2556_3/t2556_3.test b/test/files/buildmanager/t2556_3/t2556_3.test deleted file mode 100644 index 9f31bb6409..0000000000 --- a/test/files/buildmanager/t2556_3/t2556_3.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala C.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2557/A.scala b/test/files/buildmanager/t2557/A.scala deleted file mode 100644 index 3be55f19a6..0000000000 --- a/test/files/buildmanager/t2557/A.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait A { - def x = 3 -} - diff --git a/test/files/buildmanager/t2557/B.scala b/test/files/buildmanager/t2557/B.scala deleted file mode 100644 index ea86a90079..0000000000 --- a/test/files/buildmanager/t2557/B.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait B extends A { - override def x = super.x * 2 -} - diff --git a/test/files/buildmanager/t2557/C.scala b/test/files/buildmanager/t2557/C.scala deleted file mode 100644 index dd575ac38d..0000000000 --- a/test/files/buildmanager/t2557/C.scala +++ /dev/null @@ -1,3 +0,0 @@ -trait C extends A { - override def x = super.x + 5 -} diff --git a/test/files/buildmanager/t2557/D.scala b/test/files/buildmanager/t2557/D.scala deleted file mode 100644 index 4e662a80ce..0000000000 --- a/test/files/buildmanager/t2557/D.scala +++ /dev/null @@ -1 +0,0 @@ -trait D extends C with B diff --git a/test/files/buildmanager/t2557/E.scala b/test/files/buildmanager/t2557/E.scala deleted file mode 100644 index 2aee552675..0000000000 --- a/test/files/buildmanager/t2557/E.scala +++ /dev/null @@ -1 +0,0 @@ -trait E extends D diff --git a/test/files/buildmanager/t2557/F.scala b/test/files/buildmanager/t2557/F.scala deleted file mode 100644 index e1996704e7..0000000000 --- a/test/files/buildmanager/t2557/F.scala +++ /dev/null @@ -1,4 +0,0 @@ -object F extends E { - def main(args: Array[String]) = - println(x) -} diff --git a/test/files/buildmanager/t2557/t2557.changes/D2.scala b/test/files/buildmanager/t2557/t2557.changes/D2.scala deleted file mode 100644 index 67295f8e6d..0000000000 --- a/test/files/buildmanager/t2557/t2557.changes/D2.scala +++ /dev/null @@ -1,2 +0,0 @@ -trait D extends B with C - diff --git a/test/files/buildmanager/t2557/t2557.check b/test/files/buildmanager/t2557/t2557.check deleted file mode 100644 index 736ef3645e..0000000000 --- a/test/files/buildmanager/t2557/t2557.check +++ /dev/null @@ -1,10 +0,0 @@ -builder > A.scala B.scala C.scala D.scala E.scala F.scala -compiling Set(A.scala, B.scala, C.scala, D.scala, E.scala, F.scala) -Changes: Map() -builder > D.scala -compiling Set(D.scala) -Changes: Map(trait D -> List(Changed(Class(D))[List((Object,Object), (C,B), (B,C))])) -invalidate E.scala because parents have changed [Changed(Class(D))[List((Object,Object), (C,B), (B,C))]] -invalidate F.scala because parents have changed [Changed(Class(D))[List((Object,Object), (C,B), (B,C))]] -compiling Set(E.scala, F.scala) -Changes: Map(object F -> List(), trait E -> List()) diff --git a/test/files/buildmanager/t2557/t2557.test b/test/files/buildmanager/t2557/t2557.test deleted file mode 100644 index 6b0103092f..0000000000 --- a/test/files/buildmanager/t2557/t2557.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala C.scala D.scala E.scala F.scala ->>update D.scala=>D2.scala ->>compile D.scala diff --git a/test/files/buildmanager/t2559/A.scala b/test/files/buildmanager/t2559/A.scala deleted file mode 100644 index fb4f6e3545..0000000000 --- a/test/files/buildmanager/t2559/A.scala +++ /dev/null @@ -1,5 +0,0 @@ -sealed trait A -class B extends A -class C extends A -//class E extends A - diff --git a/test/files/buildmanager/t2559/D.scala b/test/files/buildmanager/t2559/D.scala deleted file mode 100644 index 62dc5427f9..0000000000 --- a/test/files/buildmanager/t2559/D.scala +++ /dev/null @@ -1,4 +0,0 @@ -object D { - def x(a: A) = if (a.isInstanceOf[B] || a.isInstanceOf[C]) () -} - diff --git a/test/files/buildmanager/t2559/t2559.changes/A2.scala b/test/files/buildmanager/t2559/t2559.changes/A2.scala deleted file mode 100644 index 8e90594e2c..0000000000 --- a/test/files/buildmanager/t2559/t2559.changes/A2.scala +++ /dev/null @@ -1,5 +0,0 @@ -sealed trait A -class B extends A -class C extends A -class E extends A - diff --git a/test/files/buildmanager/t2559/t2559.check b/test/files/buildmanager/t2559/t2559.check deleted file mode 100644 index 4d43838cf5..0000000000 --- a/test/files/buildmanager/t2559/t2559.check +++ /dev/null @@ -1,9 +0,0 @@ -builder > A.scala D.scala -compiling Set(A.scala, D.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class B -> List(), class C -> List(), class E -> List(Changed(Class(A))[class E extends a sealed trait A]), trait A -> List()) -invalidate D.scala because it references changed class [Changed(Class(A))[class E extends a sealed trait A]] -compiling Set(D.scala) -Changes: Map(object D -> List()) diff --git a/test/files/buildmanager/t2559/t2559.test b/test/files/buildmanager/t2559/t2559.test deleted file mode 100644 index b787c5b39f..0000000000 --- a/test/files/buildmanager/t2559/t2559.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala D.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2562/A.scala b/test/files/buildmanager/t2562/A.scala deleted file mode 100644 index 740cd1e868..0000000000 --- a/test/files/buildmanager/t2562/A.scala +++ /dev/null @@ -1,7 +0,0 @@ -object A -{ - def x0 = B.x0 - def x1 = B.x1 - def x2 = B.x2 - def x3 = 3 -} diff --git a/test/files/buildmanager/t2562/B.scala b/test/files/buildmanager/t2562/B.scala deleted file mode 100644 index a524e5cc84..0000000000 --- a/test/files/buildmanager/t2562/B.scala +++ /dev/null @@ -1,8 +0,0 @@ -object B -{ - def x0 = A.x1 - def x1 = A.x2 - def x2 = A.x3 -} - - diff --git a/test/files/buildmanager/t2562/t2562.changes/A2.scala b/test/files/buildmanager/t2562/t2562.changes/A2.scala deleted file mode 100644 index c560e1e816..0000000000 --- a/test/files/buildmanager/t2562/t2562.changes/A2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object A -{ - def x0 = B.x0 - def x1 = B.x1 - def x2 = B.x2 - def x3 = "3" -} - diff --git a/test/files/buildmanager/t2562/t2562.check b/test/files/buildmanager/t2562/t2562.check deleted file mode 100644 index 74575f28ea..0000000000 --- a/test/files/buildmanager/t2562/t2562.check +++ /dev/null @@ -1,12 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(object A -> List(Changed(Definition(A.x3))[method x3 changed from ()Int to ()String flags: <method> <triedcooking>])) -invalidate B.scala because it references changed definition [Changed(Definition(A.x3))[method x3 changed from ()Int to ()String flags: <method> <triedcooking>]] -compiling Set(B.scala) -Changes: Map(object B -> List(Changed(Definition(B.x2))[method x2 changed from ()Int to ()String flags: <method> <triedcooking>])) -invalidate A.scala because it references changed definition [Changed(Definition(B.x2))[method x2 changed from ()Int to ()String flags: <method> <triedcooking>]] -compiling Set(A.scala, B.scala) -Changes: Map(object A -> List(Changed(Definition(A.x0))[method x0 changed from ()Int to ()String flags: <method>], Changed(Definition(A.x1))[method x1 changed from ()Int to ()String flags: <method> <triedcooking>], Changed(Definition(A.x2))[method x2 changed from ()Int to ()String flags: <method> <triedcooking>]), object B -> List(Changed(Definition(B.x0))[method x0 changed from ()Int to ()String flags: <method>], Changed(Definition(B.x1))[method x1 changed from ()Int to ()String flags: <method>])) diff --git a/test/files/buildmanager/t2562/t2562.test b/test/files/buildmanager/t2562/t2562.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2562/t2562.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2649/A.scala b/test/files/buildmanager/t2649/A.scala deleted file mode 100644 index 86cc3f2c15..0000000000 --- a/test/files/buildmanager/t2649/A.scala +++ /dev/null @@ -1,3 +0,0 @@ -object A { - def x(zz: Int, yy: Int) = yy - zz -} diff --git a/test/files/buildmanager/t2649/B.scala b/test/files/buildmanager/t2649/B.scala deleted file mode 100644 index 26c89518cb..0000000000 --- a/test/files/buildmanager/t2649/B.scala +++ /dev/null @@ -1,4 +0,0 @@ -object B { - def main(args: Array[String]): Unit = - println( A.x(zz = 3, yy = 4) ) -} diff --git a/test/files/buildmanager/t2649/t2649.changes/A2.scala b/test/files/buildmanager/t2649/t2649.changes/A2.scala deleted file mode 100644 index 9a6309fca3..0000000000 --- a/test/files/buildmanager/t2649/t2649.changes/A2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object A { - def x(yy: Int, zz: Int) = yy - zz -} - diff --git a/test/files/buildmanager/t2649/t2649.check b/test/files/buildmanager/t2649/t2649.check deleted file mode 100644 index d0f41f32ec..0000000000 --- a/test/files/buildmanager/t2649/t2649.check +++ /dev/null @@ -1,9 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(object A -> List(Changed(Definition(A.x))[method x changed from (zz: Int, yy: Int)Int to (yy: Int, zz: Int)Int flags: <method> <triedcooking>])) -invalidate B.scala because it references changed definition [Changed(Definition(A.x))[method x changed from (zz: Int, yy: Int)Int to (yy: Int, zz: Int)Int flags: <method> <triedcooking>]] -compiling Set(B.scala) -Changes: Map(object B -> List()) diff --git a/test/files/buildmanager/t2649/t2649.test b/test/files/buildmanager/t2649/t2649.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2649/t2649.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2650_1/A.scala b/test/files/buildmanager/t2650_1/A.scala deleted file mode 100644 index 74714a3c47..0000000000 --- a/test/files/buildmanager/t2650_1/A.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait A { - type S[_] -} - diff --git a/test/files/buildmanager/t2650_1/B.scala b/test/files/buildmanager/t2650_1/B.scala deleted file mode 100644 index 80f0e30259..0000000000 --- a/test/files/buildmanager/t2650_1/B.scala +++ /dev/null @@ -1,3 +0,0 @@ -trait B extends A { - type F = S[Int] -} diff --git a/test/files/buildmanager/t2650_1/t2650_1.changes/A2.scala b/test/files/buildmanager/t2650_1/t2650_1.changes/A2.scala deleted file mode 100644 index 2b8ead4ff1..0000000000 --- a/test/files/buildmanager/t2650_1/t2650_1.changes/A2.scala +++ /dev/null @@ -1,3 +0,0 @@ -trait A { - type S -} diff --git a/test/files/buildmanager/t2650_1/t2650_1.check b/test/files/buildmanager/t2650_1/t2650_1.check deleted file mode 100644 index 2f9dd124af..0000000000 --- a/test/files/buildmanager/t2650_1/t2650_1.check +++ /dev/null @@ -1,12 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -warning: there were 1 feature warning(s); re-run with -feature for details -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(trait A -> List(Changed(Definition(A.S))[type S changed from A.this.S[_] to A.this.S flags: <deferred>])) -invalidate B.scala because inherited method changed [Changed(Definition(A.S))[type S changed from A.this.S[_] to A.this.S flags: <deferred>]] -compiling Set(B.scala) -B.scala:2: error: B.this.S does not take type parameters - type F = S[Int] - ^ diff --git a/test/files/buildmanager/t2650_1/t2650_1.test b/test/files/buildmanager/t2650_1/t2650_1.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2650_1/t2650_1.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2650_2/A.scala b/test/files/buildmanager/t2650_2/A.scala deleted file mode 100644 index bcea634485..0000000000 --- a/test/files/buildmanager/t2650_2/A.scala +++ /dev/null @@ -1,3 +0,0 @@ -trait A { - type S = Int -} diff --git a/test/files/buildmanager/t2650_2/B.scala b/test/files/buildmanager/t2650_2/B.scala deleted file mode 100644 index 22a3a9a48e..0000000000 --- a/test/files/buildmanager/t2650_2/B.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait B extends A { - def x: S - def y: Int = x -} diff --git a/test/files/buildmanager/t2650_2/t2650_2.changes/A2.scala b/test/files/buildmanager/t2650_2/t2650_2.changes/A2.scala deleted file mode 100644 index 8274c1b62d..0000000000 --- a/test/files/buildmanager/t2650_2/t2650_2.changes/A2.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait A { - type S = Long -} - diff --git a/test/files/buildmanager/t2650_2/t2650_2.check b/test/files/buildmanager/t2650_2/t2650_2.check deleted file mode 100644 index 53a0287dfc..0000000000 --- a/test/files/buildmanager/t2650_2/t2650_2.check +++ /dev/null @@ -1,14 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(trait A -> List(Changed(Definition(A.S))[type S changed from A.this.S to A.this.S flags: ])) -invalidate B.scala because inherited method changed [Changed(Definition(A.S))[type S changed from A.this.S to A.this.S flags: ]] -compiling Set(B.scala) -B.scala:3: error: type mismatch; - found : B.this.S - (which expands to) Long - required: Int - def y: Int = x - ^ diff --git a/test/files/buildmanager/t2650_2/t2650_2.test b/test/files/buildmanager/t2650_2/t2650_2.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2650_2/t2650_2.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2650_3/A.scala b/test/files/buildmanager/t2650_3/A.scala deleted file mode 100644 index cd13843eb9..0000000000 --- a/test/files/buildmanager/t2650_3/A.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait A { - type T = Int - def x: T -} diff --git a/test/files/buildmanager/t2650_3/B.scala b/test/files/buildmanager/t2650_3/B.scala deleted file mode 100644 index 46a8cf270a..0000000000 --- a/test/files/buildmanager/t2650_3/B.scala +++ /dev/null @@ -1,3 +0,0 @@ -object B { - def x(a: A): Int = a.x -} diff --git a/test/files/buildmanager/t2650_3/t2650_3.changes/A2.scala b/test/files/buildmanager/t2650_3/t2650_3.changes/A2.scala deleted file mode 100644 index e5667b2539..0000000000 --- a/test/files/buildmanager/t2650_3/t2650_3.changes/A2.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait A { - type T = Long - def x: T -} diff --git a/test/files/buildmanager/t2650_3/t2650_3.check b/test/files/buildmanager/t2650_3/t2650_3.check deleted file mode 100644 index 5c6326d59f..0000000000 --- a/test/files/buildmanager/t2650_3/t2650_3.check +++ /dev/null @@ -1,14 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(trait A -> List(Changed(Definition(A.T))[type T changed from A.this.T to A.this.T flags: ])) -invalidate B.scala because it references changed definition [Changed(Definition(A.T))[type T changed from A.this.T to A.this.T flags: ]] -compiling Set(B.scala) -B.scala:2: error: type mismatch; - found : a.T - (which expands to) Long - required: Int - def x(a: A): Int = a.x - ^ diff --git a/test/files/buildmanager/t2650_3/t2650_3.test b/test/files/buildmanager/t2650_3/t2650_3.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2650_3/t2650_3.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2650_4/A.scala b/test/files/buildmanager/t2650_4/A.scala deleted file mode 100644 index b9a519eb48..0000000000 --- a/test/files/buildmanager/t2650_4/A.scala +++ /dev/null @@ -1,5 +0,0 @@ -trait A { - type T = Int - type T2 = T - def x: T2 -} diff --git a/test/files/buildmanager/t2650_4/B.scala b/test/files/buildmanager/t2650_4/B.scala deleted file mode 100644 index 46a8cf270a..0000000000 --- a/test/files/buildmanager/t2650_4/B.scala +++ /dev/null @@ -1,3 +0,0 @@ -object B { - def x(a: A): Int = a.x -} diff --git a/test/files/buildmanager/t2650_4/t2650_4.changes/A2.scala b/test/files/buildmanager/t2650_4/t2650_4.changes/A2.scala deleted file mode 100644 index 0220e7b7bc..0000000000 --- a/test/files/buildmanager/t2650_4/t2650_4.changes/A2.scala +++ /dev/null @@ -1,5 +0,0 @@ -trait A { - type T = Long - type T2 = T - def x: T2 -} diff --git a/test/files/buildmanager/t2650_4/t2650_4.check b/test/files/buildmanager/t2650_4/t2650_4.check deleted file mode 100644 index a4aeaddfbb..0000000000 --- a/test/files/buildmanager/t2650_4/t2650_4.check +++ /dev/null @@ -1,14 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(trait A -> List(Changed(Definition(A.T))[type T changed from A.this.T to A.this.T flags: ])) -invalidate B.scala because it references changed definition [Changed(Definition(A.T))[type T changed from A.this.T to A.this.T flags: ]] -compiling Set(B.scala) -B.scala:2: error: type mismatch; - found : a.T2 - (which expands to) Long - required: Int - def x(a: A): Int = a.x - ^ diff --git a/test/files/buildmanager/t2650_4/t2650_4.test b/test/files/buildmanager/t2650_4/t2650_4.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2650_4/t2650_4.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2651_2/A.scala b/test/files/buildmanager/t2651_2/A.scala deleted file mode 100644 index d712f6febe..0000000000 --- a/test/files/buildmanager/t2651_2/A.scala +++ /dev/null @@ -1 +0,0 @@ -trait A[T] diff --git a/test/files/buildmanager/t2651_2/t2651_2.changes/A2.scala b/test/files/buildmanager/t2651_2/t2651_2.changes/A2.scala deleted file mode 100644 index 7fb573e077..0000000000 --- a/test/files/buildmanager/t2651_2/t2651_2.changes/A2.scala +++ /dev/null @@ -1 +0,0 @@ -trait A[S] diff --git a/test/files/buildmanager/t2651_2/t2651_2.check b/test/files/buildmanager/t2651_2/t2651_2.check deleted file mode 100644 index dd789b7565..0000000000 --- a/test/files/buildmanager/t2651_2/t2651_2.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > A.scala -compiling Set(A.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(trait A -> List()) diff --git a/test/files/buildmanager/t2651_2/t2651_2.test b/test/files/buildmanager/t2651_2/t2651_2.test deleted file mode 100644 index d0614473ce..0000000000 --- a/test/files/buildmanager/t2651_2/t2651_2.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2651_3/A.scala b/test/files/buildmanager/t2651_3/A.scala deleted file mode 100644 index 14f9e4662f..0000000000 --- a/test/files/buildmanager/t2651_3/A.scala +++ /dev/null @@ -1,3 +0,0 @@ -trait A[T, S] { - def x: T -} diff --git a/test/files/buildmanager/t2651_3/t2651_3.changes/A2.scala b/test/files/buildmanager/t2651_3/t2651_3.changes/A2.scala deleted file mode 100644 index 51bf27d1fa..0000000000 --- a/test/files/buildmanager/t2651_3/t2651_3.changes/A2.scala +++ /dev/null @@ -1,3 +0,0 @@ -trait A[T, S] { - def x: S -} diff --git a/test/files/buildmanager/t2651_3/t2651_3.check b/test/files/buildmanager/t2651_3/t2651_3.check deleted file mode 100644 index 2a60e3d806..0000000000 --- a/test/files/buildmanager/t2651_3/t2651_3.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > A.scala -compiling Set(A.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(trait A -> List(Changed(Definition(A.x))[method x changed from ()T to ()S flags: <method> <deferred>])) diff --git a/test/files/buildmanager/t2651_3/t2651_3.test b/test/files/buildmanager/t2651_3/t2651_3.test deleted file mode 100644 index d0614473ce..0000000000 --- a/test/files/buildmanager/t2651_3/t2651_3.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2651_4/A.scala b/test/files/buildmanager/t2651_4/A.scala deleted file mode 100644 index 63f2a1643e..0000000000 --- a/test/files/buildmanager/t2651_4/A.scala +++ /dev/null @@ -1,5 +0,0 @@ -trait A[T, S] { - def x: T - def y(a: T) - def z[B <: T] -} diff --git a/test/files/buildmanager/t2651_4/B.scala b/test/files/buildmanager/t2651_4/B.scala deleted file mode 100644 index b33dbde676..0000000000 --- a/test/files/buildmanager/t2651_4/B.scala +++ /dev/null @@ -1,3 +0,0 @@ -trait B extends A[Int, String] { - def x = 3 -} diff --git a/test/files/buildmanager/t2651_4/t2651_4.changes/A2.scala b/test/files/buildmanager/t2651_4/t2651_4.changes/A2.scala deleted file mode 100644 index f155129d13..0000000000 --- a/test/files/buildmanager/t2651_4/t2651_4.changes/A2.scala +++ /dev/null @@ -1,5 +0,0 @@ -trait A[S, T] { - def x: T - def y(a: T) - def z[B <: T] -} diff --git a/test/files/buildmanager/t2651_4/t2651_4.check b/test/files/buildmanager/t2651_4/t2651_4.check deleted file mode 100644 index 74e5d8f99b..0000000000 --- a/test/files/buildmanager/t2651_4/t2651_4.check +++ /dev/null @@ -1,13 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(trait A -> List(Changed(Definition(A.x))[method x changed from ()T to ()T flags: <method> <deferred> <triedcooking>], Changed(Definition(A.y))[method y changed from (a: T)Unit to (a: T)Unit flags: <method> <deferred>], Changed(Definition(A.z))[method z changed from [B <: T]()Unit to [B <: T]()Unit flags: <method> <deferred>])) -invalidate B.scala because inherited method changed [Changed(Definition(A.x))[method x changed from ()T to ()T flags: <method> <deferred> <triedcooking>]] -compiling Set(B.scala) -B.scala:2: error: type mismatch; - found : Int(3) - required: String - def x = 3 - ^ diff --git a/test/files/buildmanager/t2651_4/t2651_4.test b/test/files/buildmanager/t2651_4/t2651_4.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2651_4/t2651_4.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2653/A.scala b/test/files/buildmanager/t2653/A.scala deleted file mode 100644 index fb17a158c7..0000000000 --- a/test/files/buildmanager/t2653/A.scala +++ /dev/null @@ -1,2 +0,0 @@ -class A[+T] - diff --git a/test/files/buildmanager/t2653/B.scala b/test/files/buildmanager/t2653/B.scala deleted file mode 100644 index 8f55a88e05..0000000000 --- a/test/files/buildmanager/t2653/B.scala +++ /dev/null @@ -1,3 +0,0 @@ -object B { - val a: A[Any] = new A[Int] -} diff --git a/test/files/buildmanager/t2653/t2653.changes/A2.scala b/test/files/buildmanager/t2653/t2653.changes/A2.scala deleted file mode 100644 index 51d13cce6e..0000000000 --- a/test/files/buildmanager/t2653/t2653.changes/A2.scala +++ /dev/null @@ -1,2 +0,0 @@ -class A[T] - diff --git a/test/files/buildmanager/t2653/t2653.check b/test/files/buildmanager/t2653/t2653.check deleted file mode 100644 index 36781522af..0000000000 --- a/test/files/buildmanager/t2653/t2653.check +++ /dev/null @@ -1,15 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(Changed(Class(A))[ tparams: List((type T,type T))], Changed(Definition(A.<init>))[constructor A changed from ()A[T] to ()A[T] flags: <method> <triedcooking>])) -invalidate B.scala because it references changed class [Changed(Class(A))[ tparams: List((type T,type T))]] -compiling Set(B.scala) -B.scala:2: error: type mismatch; - found : A[Int] - required: A[Any] -Note: Int <: Any, but class A is invariant in type T. -You may wish to define T as +T instead. (SLS 4.5) - val a: A[Any] = new A[Int] - ^ diff --git a/test/files/buildmanager/t2653/t2653.test b/test/files/buildmanager/t2653/t2653.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2653/t2653.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2654/A.scala b/test/files/buildmanager/t2654/A.scala deleted file mode 100644 index 75f396d039..0000000000 --- a/test/files/buildmanager/t2654/A.scala +++ /dev/null @@ -1,2 +0,0 @@ -class A - diff --git a/test/files/buildmanager/t2654/B.scala b/test/files/buildmanager/t2654/B.scala deleted file mode 100644 index a18aec3dbe..0000000000 --- a/test/files/buildmanager/t2654/B.scala +++ /dev/null @@ -1 +0,0 @@ -class B extends A diff --git a/test/files/buildmanager/t2654/t2654.changes/A2.scala b/test/files/buildmanager/t2654/t2654.changes/A2.scala deleted file mode 100644 index c302edbd85..0000000000 --- a/test/files/buildmanager/t2654/t2654.changes/A2.scala +++ /dev/null @@ -1,4 +0,0 @@ -class A { - private def x = 5 -} - diff --git a/test/files/buildmanager/t2654/t2654.check b/test/files/buildmanager/t2654/t2654.check deleted file mode 100644 index 68f6e8efc0..0000000000 --- a/test/files/buildmanager/t2654/t2654.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List()) diff --git a/test/files/buildmanager/t2654/t2654.test b/test/files/buildmanager/t2654/t2654.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2654/t2654.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2655/A.scala b/test/files/buildmanager/t2655/A.scala deleted file mode 100644 index b2c54ac47d..0000000000 --- a/test/files/buildmanager/t2655/A.scala +++ /dev/null @@ -1,4 +0,0 @@ -object A { - def x(i: => String) = () -} - diff --git a/test/files/buildmanager/t2655/B.scala b/test/files/buildmanager/t2655/B.scala deleted file mode 100644 index 6c1918c0fb..0000000000 --- a/test/files/buildmanager/t2655/B.scala +++ /dev/null @@ -1,3 +0,0 @@ -object B { - val x = A.x("3") -} diff --git a/test/files/buildmanager/t2655/t2655.changes/A2.scala b/test/files/buildmanager/t2655/t2655.changes/A2.scala deleted file mode 100644 index 0d6a7c69bb..0000000000 --- a/test/files/buildmanager/t2655/t2655.changes/A2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object A { - def x(i: Function0[String]) = () -} - diff --git a/test/files/buildmanager/t2655/t2655.check b/test/files/buildmanager/t2655/t2655.check deleted file mode 100644 index 41ce65a2f5..0000000000 --- a/test/files/buildmanager/t2655/t2655.check +++ /dev/null @@ -1,13 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(object A -> List(Changed(Definition(A.x))[method x changed from (i: Function0)Unit to (i: Function0)Unit flags: <method> <triedcooking>])) -invalidate B.scala because it references changed definition [Changed(Definition(A.x))[method x changed from (i: Function0)Unit to (i: Function0)Unit flags: <method> <triedcooking>]] -compiling Set(B.scala) -B.scala:2: error: type mismatch; - found : String("3") - required: () => String - val x = A.x("3") - ^ diff --git a/test/files/buildmanager/t2655/t2655.test b/test/files/buildmanager/t2655/t2655.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2655/t2655.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2657/A.scala b/test/files/buildmanager/t2657/A.scala deleted file mode 100644 index 2a6c62d29c..0000000000 --- a/test/files/buildmanager/t2657/A.scala +++ /dev/null @@ -1,3 +0,0 @@ -class A { - implicit def y(i: Int): String = i.toString -} diff --git a/test/files/buildmanager/t2657/B.scala b/test/files/buildmanager/t2657/B.scala deleted file mode 100644 index 77869890db..0000000000 --- a/test/files/buildmanager/t2657/B.scala +++ /dev/null @@ -1,4 +0,0 @@ -object B extends A { - val x: String = 3 -} - diff --git a/test/files/buildmanager/t2657/t2657.changes/A2.scala b/test/files/buildmanager/t2657/t2657.changes/A2.scala deleted file mode 100644 index 7dc99d425e..0000000000 --- a/test/files/buildmanager/t2657/t2657.changes/A2.scala +++ /dev/null @@ -1,3 +0,0 @@ -class A { - def y(i: Int): String = i.toString -} diff --git a/test/files/buildmanager/t2657/t2657.check b/test/files/buildmanager/t2657/t2657.check deleted file mode 100644 index 7bff078f56..0000000000 --- a/test/files/buildmanager/t2657/t2657.check +++ /dev/null @@ -1,14 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -warning: there were 1 feature warning(s); re-run with -feature for details -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(Changed(Definition(A.y))[method y changed from (i: Int)String to (i: Int)String flags: <method> implicit <triedcooking>])) -invalidate B.scala because inherited method changed [Changed(Definition(A.y))[method y changed from (i: Int)String to (i: Int)String flags: <method> implicit <triedcooking>]] -compiling Set(B.scala) -B.scala:2: error: type mismatch; - found : Int(3) - required: String - val x: String = 3 - ^ diff --git a/test/files/buildmanager/t2657/t2657.test b/test/files/buildmanager/t2657/t2657.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2657/t2657.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2789/A.scala b/test/files/buildmanager/t2789/A.scala deleted file mode 100644 index 08d5bc840c..0000000000 --- a/test/files/buildmanager/t2789/A.scala +++ /dev/null @@ -1,5 +0,0 @@ -class A { - implicit def e: E = new E - def x(i: Int)(implicit y: E): String = "" -} -class E diff --git a/test/files/buildmanager/t2789/B.scala b/test/files/buildmanager/t2789/B.scala deleted file mode 100644 index dcefbeec1b..0000000000 --- a/test/files/buildmanager/t2789/B.scala +++ /dev/null @@ -1,3 +0,0 @@ -object B extends A { - val y = x(3) -} diff --git a/test/files/buildmanager/t2789/t2789.changes/A2.scala b/test/files/buildmanager/t2789/t2789.changes/A2.scala deleted file mode 100644 index 4ba3814e71..0000000000 --- a/test/files/buildmanager/t2789/t2789.changes/A2.scala +++ /dev/null @@ -1,5 +0,0 @@ -class A { - def e: E = new E - def x(i: Int)(implicit y: E): String = "" -} -class E diff --git a/test/files/buildmanager/t2789/t2789.check b/test/files/buildmanager/t2789/t2789.check deleted file mode 100644 index 066561ac44..0000000000 --- a/test/files/buildmanager/t2789/t2789.check +++ /dev/null @@ -1,11 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(Changed(Definition(A.e))[method e changed from ()E to ()E flags: <method> implicit <triedcooking>]), class E -> List()) -invalidate B.scala because inherited method changed [Changed(Definition(A.e))[method e changed from ()E to ()E flags: <method> implicit <triedcooking>]] -compiling Set(B.scala) -B.scala:2: error: could not find implicit value for parameter y: E - val y = x(3) - ^ diff --git a/test/files/buildmanager/t2789/t2789.test b/test/files/buildmanager/t2789/t2789.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2789/t2789.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2790/A.scala b/test/files/buildmanager/t2790/A.scala deleted file mode 100644 index 6e9c1a90db..0000000000 --- a/test/files/buildmanager/t2790/A.scala +++ /dev/null @@ -1,5 +0,0 @@ -object A { - def x(f: String, g: Int): Int = g - def x(f: Int, g: Int = 3): Int = g -} - diff --git a/test/files/buildmanager/t2790/B.scala b/test/files/buildmanager/t2790/B.scala deleted file mode 100644 index 441055ca12..0000000000 --- a/test/files/buildmanager/t2790/B.scala +++ /dev/null @@ -1,4 +0,0 @@ -object B { - val y = A.x(5) -} - diff --git a/test/files/buildmanager/t2790/t2790.changes/A2.scala b/test/files/buildmanager/t2790/t2790.changes/A2.scala deleted file mode 100644 index 704ef4e96e..0000000000 --- a/test/files/buildmanager/t2790/t2790.changes/A2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object A { - def x(f: String, g: Int = 3): Int = g - def x(f: Int, g: Int): Int = g -} diff --git a/test/files/buildmanager/t2790/t2790.check b/test/files/buildmanager/t2790/t2790.check deleted file mode 100644 index 13d61dac42..0000000000 --- a/test/files/buildmanager/t2790/t2790.check +++ /dev/null @@ -1,13 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(object A -> List(Added(Definition(A.x)), Changed(Definition(A.x))[value x changed from (f: String, g: Int)Int to (f: String, g: Int)Int <and> (f: Int, g: Int)Int flags: <method>])) -invalidate B.scala because it references changed definition [Changed(Definition(A.x))[value x changed from (f: String, g: Int)Int to (f: String, g: Int)Int <and> (f: Int, g: Int)Int flags: <method>]] -compiling Set(B.scala) -B.scala:2: error: type mismatch; - found : Int(5) - required: String - val y = A.x(5) - ^ diff --git a/test/files/buildmanager/t2790/t2790.test b/test/files/buildmanager/t2790/t2790.test deleted file mode 100644 index 6f3bd03361..0000000000 --- a/test/files/buildmanager/t2790/t2790.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A.scala B.scala ->>update A.scala=>A2.scala ->>compile A.scala diff --git a/test/files/buildmanager/t2792/A1.scala b/test/files/buildmanager/t2792/A1.scala deleted file mode 100644 index 96dc0ef933..0000000000 --- a/test/files/buildmanager/t2792/A1.scala +++ /dev/null @@ -1,3 +0,0 @@ -object A { - val x = new C -} diff --git a/test/files/buildmanager/t2792/A2.scala b/test/files/buildmanager/t2792/A2.scala deleted file mode 100644 index e55e681c76..0000000000 --- a/test/files/buildmanager/t2792/A2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object B { - import A.x.y - val z = y -} diff --git a/test/files/buildmanager/t2792/A3.scala b/test/files/buildmanager/t2792/A3.scala deleted file mode 100644 index cd083cdb34..0000000000 --- a/test/files/buildmanager/t2792/A3.scala +++ /dev/null @@ -1,3 +0,0 @@ -class C { - val y = 4 -} diff --git a/test/files/buildmanager/t2792/t2792.changes/A1_1.scala b/test/files/buildmanager/t2792/t2792.changes/A1_1.scala deleted file mode 100644 index 00ee05f273..0000000000 --- a/test/files/buildmanager/t2792/t2792.changes/A1_1.scala +++ /dev/null @@ -1,3 +0,0 @@ -object A { - var x = new C -} diff --git a/test/files/buildmanager/t2792/t2792.check b/test/files/buildmanager/t2792/t2792.check deleted file mode 100644 index 00a2b83469..0000000000 --- a/test/files/buildmanager/t2792/t2792.check +++ /dev/null @@ -1,14 +0,0 @@ -builder > A1.scala A2.scala A3.scala -compiling Set(A1.scala, A2.scala, A3.scala) -Changes: Map() -builder > A1.scala -compiling Set(A1.scala) -Changes: Map(object A -> List(Added(Definition(A.x_$eq)), Changed(Definition(A.x))[value x changed to variable x])) -invalidate A2.scala because it references changed definition [Changed(Definition(A.x))[value x changed to variable x]] -compiling Set(A2.scala) -A2.scala:2: error: stable identifier required, but A.x found. - import A.x.y - ^ -A2.scala:3: error: not found: value y - val z = y - ^ diff --git a/test/files/buildmanager/t2792/t2792.test b/test/files/buildmanager/t2792/t2792.test deleted file mode 100644 index f199950bba..0000000000 --- a/test/files/buildmanager/t2792/t2792.test +++ /dev/null @@ -1,3 +0,0 @@ ->>compile A1.scala A2.scala A3.scala ->>update A1.scala=>A1_1.scala ->>compile A1.scala diff --git a/test/files/buildmanager/t3045/A.java b/test/files/buildmanager/t3045/A.java deleted file mode 100644 index d1acb00cd6..0000000000 --- a/test/files/buildmanager/t3045/A.java +++ /dev/null @@ -1,7 +0,0 @@ -public interface A { - public class C implements A {} -} - -class B { - static class C {} -} diff --git a/test/files/buildmanager/t3045/t3045.check b/test/files/buildmanager/t3045/t3045.check deleted file mode 100644 index 5e4e71e045..0000000000 --- a/test/files/buildmanager/t3045/t3045.check +++ /dev/null @@ -1,3 +0,0 @@ -builder > A.java -compiling Set(A.java) -Changes: Map() diff --git a/test/files/buildmanager/t3045/t3045.test b/test/files/buildmanager/t3045/t3045.test deleted file mode 100644 index 6cf7e35543..0000000000 --- a/test/files/buildmanager/t3045/t3045.test +++ /dev/null @@ -1 +0,0 @@ ->>compile A.java diff --git a/test/files/buildmanager/t3054/bar/Bar.java b/test/files/buildmanager/t3054/bar/Bar.java deleted file mode 100644 index e1b056d4e5..0000000000 --- a/test/files/buildmanager/t3054/bar/Bar.java +++ /dev/null @@ -1,7 +0,0 @@ -package bar; -import foo.Foo$; - - -public class Bar { - void bar() { Foo$.MODULE$.foo(); } -} diff --git a/test/files/buildmanager/t3054/foo/Foo.scala b/test/files/buildmanager/t3054/foo/Foo.scala deleted file mode 100644 index c0fcd97390..0000000000 --- a/test/files/buildmanager/t3054/foo/Foo.scala +++ /dev/null @@ -1,5 +0,0 @@ -package foo - -class Foo { - def foo() = println("foo") -} diff --git a/test/files/buildmanager/t3054/t3054.check b/test/files/buildmanager/t3054/t3054.check deleted file mode 100644 index 97cca8862e..0000000000 --- a/test/files/buildmanager/t3054/t3054.check +++ /dev/null @@ -1,3 +0,0 @@ -builder > bar/Bar.java foo/Foo.scala -compiling Set(bar/Bar.java, foo/Foo.scala) -Changes: Map() diff --git a/test/files/buildmanager/t3054/t3054.test b/test/files/buildmanager/t3054/t3054.test deleted file mode 100644 index 903df24b13..0000000000 --- a/test/files/buildmanager/t3054/t3054.test +++ /dev/null @@ -1 +0,0 @@ ->>compile bar/Bar.java foo/Foo.scala diff --git a/test/files/buildmanager/t3059/A.scala b/test/files/buildmanager/t3059/A.scala deleted file mode 100644 index 0dd25f6647..0000000000 --- a/test/files/buildmanager/t3059/A.scala +++ /dev/null @@ -1,4 +0,0 @@ -class A extends B { - private def getBar = List(1,2,3) - lazy val bar: List[Int] = getBar -} diff --git a/test/files/buildmanager/t3059/B.scala b/test/files/buildmanager/t3059/B.scala deleted file mode 100644 index 46596870ac..0000000000 --- a/test/files/buildmanager/t3059/B.scala +++ /dev/null @@ -1,4 +0,0 @@ -abstract class B { - private def getFoo = 12 - lazy val foo: Int = getFoo -} diff --git a/test/files/buildmanager/t3059/t3059.check b/test/files/buildmanager/t3059/t3059.check deleted file mode 100644 index 4a8076aae1..0000000000 --- a/test/files/buildmanager/t3059/t3059.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > A.scala B.scala -compiling Set(A.scala, B.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List())
\ No newline at end of file diff --git a/test/files/buildmanager/t3059/t3059.test b/test/files/buildmanager/t3059/t3059.test deleted file mode 100644 index 6f3749dc4b..0000000000 --- a/test/files/buildmanager/t3059/t3059.test +++ /dev/null @@ -1,2 +0,0 @@ ->>compile A.scala B.scala ->>compile A.scala
\ No newline at end of file diff --git a/test/files/buildmanager/t3133/A.java b/test/files/buildmanager/t3133/A.java deleted file mode 100644 index c4e7f3af0e..0000000000 --- a/test/files/buildmanager/t3133/A.java +++ /dev/null @@ -1,7 +0,0 @@ -public class A { - class Foo {} - - public A(Foo a) {} - - private void bar(Foo z) {} -} diff --git a/test/files/buildmanager/t3133/t3133.check b/test/files/buildmanager/t3133/t3133.check deleted file mode 100644 index 5e4e71e045..0000000000 --- a/test/files/buildmanager/t3133/t3133.check +++ /dev/null @@ -1,3 +0,0 @@ -builder > A.java -compiling Set(A.java) -Changes: Map() diff --git a/test/files/buildmanager/t3133/t3133.test b/test/files/buildmanager/t3133/t3133.test deleted file mode 100644 index 6cf7e35543..0000000000 --- a/test/files/buildmanager/t3133/t3133.test +++ /dev/null @@ -1 +0,0 @@ ->>compile A.java diff --git a/test/files/buildmanager/t3140/A.scala b/test/files/buildmanager/t3140/A.scala deleted file mode 100644 index f7768044d1..0000000000 --- a/test/files/buildmanager/t3140/A.scala +++ /dev/null @@ -1,8 +0,0 @@ -class As { - trait A { - def foo(parents: String): A = { - (() => parents) - null - } - } -} diff --git a/test/files/buildmanager/t3140/t3140.check b/test/files/buildmanager/t3140/t3140.check deleted file mode 100644 index 008d5a9618..0000000000 --- a/test/files/buildmanager/t3140/t3140.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > A.scala -compiling Set(A.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class As -> List(), object As$A$class -> List(), trait As$A -> List()) diff --git a/test/files/buildmanager/t3140/t3140.test b/test/files/buildmanager/t3140/t3140.test deleted file mode 100644 index 392e0d365f..0000000000 --- a/test/files/buildmanager/t3140/t3140.test +++ /dev/null @@ -1,2 +0,0 @@ ->>compile A.scala ->>compile A.scala diff --git a/test/files/buildmanager/t4215/A.scala b/test/files/buildmanager/t4215/A.scala deleted file mode 100644 index 9db40b0fee..0000000000 --- a/test/files/buildmanager/t4215/A.scala +++ /dev/null @@ -1,5 +0,0 @@ -class A { - def B() { - object C - } -} diff --git a/test/files/buildmanager/t4215/t4215.check b/test/files/buildmanager/t4215/t4215.check deleted file mode 100644 index d9ec9a743a..0000000000 --- a/test/files/buildmanager/t4215/t4215.check +++ /dev/null @@ -1,6 +0,0 @@ -builder > A.scala -compiling Set(A.scala) -Changes: Map() -builder > A.scala -compiling Set(A.scala) -Changes: Map(class A -> List(), object A$C$2 -> List()) diff --git a/test/files/buildmanager/t4215/t4215.test b/test/files/buildmanager/t4215/t4215.test deleted file mode 100644 index 392e0d365f..0000000000 --- a/test/files/buildmanager/t4215/t4215.test +++ /dev/null @@ -1,2 +0,0 @@ ->>compile A.scala ->>compile A.scala diff --git a/test/files/continuations-neg/function0.scala b/test/files/continuations-neg/function0.scala index 6ef0d98b90..4112ee3835 100644 --- a/test/files/continuations-neg/function0.scala +++ b/test/files/continuations-neg/function0.scala @@ -4,13 +4,13 @@ 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.scala b/test/files/continuations-neg/function2.scala index 402c6dcad8..ae0fda509d 100644 --- a/test/files/continuations-neg/function2.scala +++ b/test/files/continuations-neg/function2.scala @@ -4,13 +4,13 @@ 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.scala b/test/files/continuations-neg/function3.scala index c4acc4c2e9..0c3f1667e5 100644 --- a/test/files/continuations-neg/function3.scala +++ b/test/files/continuations-neg/function3.scala @@ -4,12 +4,12 @@ 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 index 59eb670bc3..d92bc9c572 100644 --- a/test/files/continuations-neg/infer2.check +++ b/test/files/continuations-neg/infer2.check @@ -1,4 +1,4 @@ infer2.scala:14: error: illegal answer type modification: scala.util.continuations.cpsParam[String,Int] andThen scala.util.continuations.cpsParam[String,Int] - test { sym(); sym() } + test { sym(); sym() } ^ one error found diff --git a/test/files/continuations-neg/infer2.scala b/test/files/continuations-neg/infer2.scala index eaffbc17fc..a890ac1fc4 100644 --- a/test/files/continuations-neg/infer2.scala +++ b/test/files/continuations-neg/infer2.scala @@ -4,16 +4,16 @@ 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() } + test { sym(); sym() } } - + } diff --git a/test/files/continuations-neg/lazy.scala b/test/files/continuations-neg/lazy.scala index a2fad83be8..3c8169dd46 100644 --- a/test/files/continuations-neg/lazy.scala +++ b/test/files/continuations-neg/lazy.scala @@ -1,16 +1,16 @@ -import scala.util.continuations._ - -object Test { +import scala.util.continuations._ + +object Test { def foo() = { lazy val x = shift((k:Unit=>Unit)=>k()) println(x) } - - def main(args: Array[String]) { + + def main(args: Array[String]) { reset { foo() } - } - + } + }
\ No newline at end of file diff --git a/test/files/continuations-neg/t2285.scala b/test/files/continuations-neg/t2285.scala index b906dc455a..f3c7f4c89c 100644 --- a/test/files/continuations-neg/t2285.scala +++ b/test/files/continuations-neg/t2285.scala @@ -5,7 +5,7 @@ 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.scala b/test/files/continuations-neg/t2949.scala index 2d426a4d89..ce27c7c0e8 100644 --- a/test/files/continuations-neg/t2949.scala +++ b/test/files/continuations-neg/t2949.scala @@ -8,7 +8,7 @@ object Test { 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 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.scala b/test/files/continuations-neg/t3628.scala index 3fdd32a034..c56e7752c4 100644 --- a/test/files/continuations-neg/t3628.scala +++ b/test/files/continuations-neg/t3628.scala @@ -3,7 +3,7 @@ import scala.actors.Actor._ object Test { val impl: Actor = actor { loop { - react { + react { case 1 => impl ! 2 } } diff --git a/test/files/continuations-neg/trycatch2.scala b/test/files/continuations-neg/trycatch2.scala index d329a3b530..ee0a180ed6 100644 --- a/test/files/continuations-neg/trycatch2.scala +++ b/test/files/continuations-neg/trycatch2.scala @@ -7,7 +7,7 @@ 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 diff --git a/test/files/continuations-run/basics.scala b/test/files/continuations-run/basics.scala index b63710bc64..07b3de5194 100755 --- a/test/files/continuations-run/basics.scala +++ b/test/files/continuations-run/basics.scala @@ -13,11 +13,11 @@ object Test { 2 * shift((k:Int => Int) => k(k(7))) } - def main(args: Array[String]) = { - + def main(args: Array[String]) { + println(reset(m0())) println(reset(m1())) - + } - + } diff --git a/test/files/continuations-run/function1.scala b/test/files/continuations-run/function1.scala index fbd413ed9d..82dfe46c08 100644 --- a/test/files/continuations-run/function1.scala +++ b/test/files/continuations-run/function1.scala @@ -4,13 +4,13 @@ import scala.util.continuations._ object Test { - - def main(args: Array[String]): Any = { - + + def main(args: Array[String]): Unit = { + val f = () => shift { k: (Int=>Int) => k(7) } val g: () => Int @cps[Int] = f - + println(reset(g())) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/function4.scala b/test/files/continuations-run/function4.scala index 2ccd0b4ff2..ccb432fe93 100644 --- a/test/files/continuations-run/function4.scala +++ b/test/files/continuations-run/function4.scala @@ -4,12 +4,12 @@ import scala.util.continuations._ object Test { - - def main(args: Array[String]): Any = { - + + def main(args: Array[String]): Unit = { + val g: () => Int @cps[Int] = () => shift { k: (Int=>Int) => k(7) } - + println(reset(g())) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/function5.scala b/test/files/continuations-run/function5.scala index fe528e14e7..a83eb80d08 100644 --- a/test/files/continuations-run/function5.scala +++ b/test/files/continuations-run/function5.scala @@ -4,12 +4,12 @@ import scala.util.continuations._ object Test { - - def main(args: Array[String]): Any = { - + + def main(args: Array[String]): Unit = { + val g: () => Int @cps[Int] = () => 7 - + println(reset(g())) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/function6.scala b/test/files/continuations-run/function6.scala index 54a6ffcc93..13ef88bd9f 100644 --- a/test/files/continuations-run/function6.scala +++ b/test/files/continuations-run/function6.scala @@ -4,13 +4,13 @@ import scala.util.continuations._ object Test { - - def main(args: Array[String]): Any = { - + + def main(args: Array[String]): Unit = { + val g: PartialFunction[Int, Int @cps[Int]] = { case x => 7 } - + println(reset(g(2))) - + } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/ifelse0.scala b/test/files/continuations-run/ifelse0.scala index 2facab4b98..cbff72c77c 100644 --- a/test/files/continuations-run/ifelse0.scala +++ b/test/files/continuations-run/ifelse0.scala @@ -4,15 +4,15 @@ 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]): Any = { + + def main(args: Array[String]): Unit = { println(reset(1 + test(7))) println(reset(1 + test(8))) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/ifelse1.scala b/test/files/continuations-run/ifelse1.scala index c624b84b75..f8e3cf2ca3 100644 --- a/test/files/continuations-run/ifelse1.scala +++ b/test/files/continuations-run/ifelse1.scala @@ -4,22 +4,22 @@ 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]): Any = { + 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))) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/ifelse2.scala b/test/files/continuations-run/ifelse2.scala index 506acc4d00..f5ec864a06 100644 --- a/test/files/continuations-run/ifelse2.scala +++ b/test/files/continuations-run/ifelse2.scala @@ -4,13 +4,13 @@ import scala.util.continuations._ object Test { - + def test(x:Int) = if (x <= 7) shift { k: (Unit=>Unit) => println("abort") } - - def main(args: Array[String]): Any = { + + def main(args: Array[String]): Unit = { println(reset{ test(7); println("alive") }) println(reset{ test(8); println("alive") }) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/ifelse3.scala b/test/files/continuations-run/ifelse3.scala index 54566a421c..2c5b5765db 100644 --- a/test/files/continuations-run/ifelse3.scala +++ b/test/files/continuations-run/ifelse3.scala @@ -4,18 +4,18 @@ 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]): Any = { + + + def main(args: Array[String]): Unit = { println(reset(test(7))) println(reset(test(8))) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/ifelse4.scala b/test/files/continuations-run/ifelse4.scala index 8360375283..46ec15365e 100644 --- a/test/files/continuations-run/ifelse4.scala +++ b/test/files/continuations-run/ifelse4.scala @@ -2,7 +2,7 @@ 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) @@ -11,7 +11,7 @@ object Test { 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 @@ -22,10 +22,10 @@ object Test { if (sh(x1)==45) x1 else sh(x1) } - def main(args: Array[String]): Any = { + 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))) } -}
\ No newline at end of file +} diff --git a/test/files/continuations-run/implicit-infer-annotations.check b/test/files/continuations-run/implicit-infer-annotations.check new file mode 100644 index 0000000000..e8206c4319 --- /dev/null +++ b/test/files/continuations-run/implicit-infer-annotations.check @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000000..3f0e959f60 --- /dev/null +++ b/test/files/continuations-run/implicit-infer-annotations.scala @@ -0,0 +1,59 @@ +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 index 10822508e7..76f746da57 100644 --- a/test/files/continuations-run/infer1.scala +++ b/test/files/continuations-run/infer1.scala @@ -4,9 +4,9 @@ import scala.util.continuations._ object Test { - + def test(x: => Int @cpsParam[String,Int]) = 7 - + def test2() = { val x = shift { k: (Int => String) => 9 } x @@ -14,10 +14,10 @@ object Test { def test3(x: => Int @cpsParam[Int,Int]) = 7 - + def util() = shift { k: (String => String) => "7" } - - def main(args: Array[String]): Any = { + + 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 @@ -29,5 +29,5 @@ object Test { test3 { { test3(0); 2 } } } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/match0.scala b/test/files/continuations-run/match0.scala index b65d343c07..8769ed9fcb 100644 --- a/test/files/continuations-run/match0.scala +++ b/test/files/continuations-run/match0.scala @@ -4,15 +4,15 @@ 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]): Any = { + + def main(args: Array[String]): Unit = { println(reset(1 + test(7))) println(reset(1 + test(8))) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/match1.scala b/test/files/continuations-run/match1.scala index 20671f26ba..b89fb706b0 100644 --- a/test/files/continuations-run/match1.scala +++ b/test/files/continuations-run/match1.scala @@ -4,15 +4,15 @@ 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]): Any = { + + def main(args: Array[String]): Unit = { println(reset(1 + test(7))) println(reset(1 + test(8))) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/match2.scala b/test/files/continuations-run/match2.scala index 5092ce3abe..002d9b52dd 100644 --- a/test/files/continuations-run/match2.scala +++ b/test/files/continuations-run/match2.scala @@ -4,23 +4,23 @@ 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.scala b/test/files/continuations-run/patvirt.scala index 5b4d312f20..cfbdda538d 100644 --- a/test/files/continuations-run/patvirt.scala +++ b/test/files/continuations-run/patvirt.scala @@ -2,11 +2,11 @@ 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 = + val o3 = if (7 == x1) Some(x1) else None @@ -25,7 +25,7 @@ object Test { o7.get } - def main(args: Array[String]): Any = { + def main(args: Array[String]): Unit = { println(reset(1 + test(7))) println(reset(1 + test(8))) } diff --git a/test/files/continuations-run/t1820.scala b/test/files/continuations-run/t1820.scala index 893ddab6d1..7de6ccabef 100644 --- a/test/files/continuations-run/t1820.scala +++ b/test/files/continuations-run/t1820.scala @@ -10,5 +10,5 @@ object Test { if (b) shifted } } - def main(args: Array[String]) = test1(true) -}
\ No newline at end of file + def main(args: Array[String]): Unit = test1(true) +} diff --git a/test/files/continuations-run/t1821.scala b/test/files/continuations-run/t1821.scala index 0d5fb553be..55bf7b6f12 100644 --- a/test/files/continuations-run/t1821.scala +++ b/test/files/continuations-run/t1821.scala @@ -11,10 +11,10 @@ object Test { 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]) = { + def main(args: Array[String]) { println(reset(test1())) println(reset(test2(List(())))) println(reset(test3())) println(reset(test4(List(())))) } -}
\ No newline at end of file +} diff --git a/test/files/continuations-run/t3199.scala b/test/files/continuations-run/t3199.scala index 7b54793e05..2cb73c005a 100644 --- a/test/files/continuations-run/t3199.scala +++ b/test/files/continuations-run/t3199.scala @@ -1,20 +1,20 @@ -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) - } - } +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/t3199b.scala b/test/files/continuations-run/t3199b.scala index 2122c963ac..5010f2b085 100644 --- a/test/files/continuations-run/t3199b.scala +++ b/test/files/continuations-run/t3199b.scala @@ -1,11 +1,11 @@ object Test { - + def test() = { java.util.Arrays.asList(Array(1,2,3):_*) } - - def main(args: Array[String]) = { + + def main(args: Array[String]) { println(test()) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/t3223.scala b/test/files/continuations-run/t3223.scala index efed1ff581..75613fe5c7 100644 --- a/test/files/continuations-run/t3223.scala +++ b/test/files/continuations-run/t3223.scala @@ -2,18 +2,18 @@ import scala.util.continuations._ object Test { def foo(x:Int) = { - try { + try { throw new Exception shiftUnit0[Int,Int](7) } catch { - case ex => + case ex: Throwable => val g = (a:Int)=>a 9 } } - + def main(args: Array[String]) { println(reset(foo(0))) } -}
\ No newline at end of file +} diff --git a/test/files/continuations-run/t3225.scala b/test/files/continuations-run/t3225.scala index 5b6259c43f..a0c9c91985 100644 --- a/test/files/continuations-run/t3225.scala +++ b/test/files/continuations-run/t3225.scala @@ -31,10 +31,10 @@ object Test { } 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)) @@ -48,9 +48,9 @@ object Test { // TODO: check whether this also applies to a::shift { k => ... } - def main(args: Array[String]) = { + def main(args: Array[String]) { testMono() testPoly() } - + } diff --git a/test/files/continuations-run/t5314-2.scala b/test/files/continuations-run/t5314-2.scala index 8a896dec2c..e7e5d46f03 100644 --- a/test/files/continuations-run/t5314-2.scala +++ b/test/files/continuations-run/t5314-2.scala @@ -1,15 +1,15 @@ import scala.util.continuations._ -class ReturnRepro { - def s1: Int @cps[Any] = shift { k => k(5) } +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 p(i: Int): Int @cps[Any] = { + val v= s1 + 3 + return v + } def p2(i: Int): Int @cps[Any] = { val v = s1 + 3 diff --git a/test/files/continuations-run/t5314-3.scala b/test/files/continuations-run/t5314-3.scala index 62c547f5a2..c2fe8f6f87 100644 --- a/test/files/continuations-run/t5314-3.scala +++ b/test/files/continuations-run/t5314-3.scala @@ -1,14 +1,14 @@ import scala.util.continuations._ -class ReturnRepro { - def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) } +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 + 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 diff --git a/test/files/continuations-run/t5314.check b/test/files/continuations-run/t5314.check index 4b35d8e6d0..61f5b25dc7 100644 --- a/test/files/continuations-run/t5314.check +++ b/test/files/continuations-run/t5314.check @@ -1,3 +1,9 @@ +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 diff --git a/test/files/continuations-run/t5314.scala b/test/files/continuations-run/t5314.scala index d611016ce4..e448d8558d 100644 --- a/test/files/continuations-run/t5314.scala +++ b/test/files/continuations-run/t5314.scala @@ -1,14 +1,14 @@ import scala.util.continuations._ -class ReturnRepro { - def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) } +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 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 @@ -38,7 +38,7 @@ object Test extends App { println(reset { bar3(10) }) println(reset { bar4(10) }) println(reset { bar5(10) }) - + /* original test case */ val repro = new ReturnRepro repro.caller diff --git a/test/files/continuations-run/t5472.check b/test/files/continuations-run/t5472.check index d42e80c18e..3192c746eb 100644 --- a/test/files/continuations-run/t5472.check +++ b/test/files/continuations-run/t5472.check @@ -1 +1,15 @@ +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 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 index 3e3c76b32a..060d267544 100644 --- a/test/files/continuations-run/t5472.scala +++ b/test/files/continuations-run/t5472.scala @@ -2,6 +2,7 @@ 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) @@ -15,7 +16,6 @@ object Test { println(mapped.toList) } } -} final class ContinuationizedParallelIterable[+A](protected val underline: Iterable[A]) { def toList = underline.toList.sortBy(_.toString) @@ -76,7 +76,7 @@ final class ContinuationizedParallelIterable[+A](protected val underline: Iterab 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) { + for ((element, i) <- underline.view.zipWithIndex) { reset { val result = f(element) results(i) = result @@ -88,3 +88,4 @@ final class ContinuationizedParallelIterable[+A](protected val underline: Iterab } }) } +} diff --git a/test/files/continuations-run/t5506.scala b/test/files/continuations-run/t5506.scala index 2b5c1118f7..08f64c9db1 100644 --- a/test/files/continuations-run/t5506.scala +++ b/test/files/continuations-run/t5506.scala @@ -4,11 +4,11 @@ object Test { def g: List[Int] @suspendable = List(1,2,3) -def fp10: List[Int] @suspendable = { +def fp10: List[Int] @suspendable = { g.map(x => x) } -def fp11: List[Int] @suspendable = { +def fp11: List[Int] @suspendable = { val z = g.map(x => x) z } @@ -42,12 +42,12 @@ z } -def main(args: Array[String]) = { +def main(args: Array[String]) { reset { println(fp10) println(fp11) println(fp12) - + println(fp20) println(fp21) println(fp22) diff --git a/test/files/continuations-run/t5538.check b/test/files/continuations-run/t5538.check index 457721d5e0..d9d873663d 100644 --- a/test/files/continuations-run/t5538.check +++ b/test/files/continuations-run/t5538.check @@ -1 +1,2 @@ +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 index 42f8163caf..9f01624da1 100644 --- a/test/files/continuations-run/t5538.scala +++ b/test/files/continuations-run/t5538.scala @@ -1,6 +1,8 @@ import scala.util.continuations._ import scala.collection.generic.CanBuildFrom +import scala.language.{ implicitConversions } + object Test { class ExecutionContext @@ -14,13 +16,13 @@ object Test { 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)) } @@ -38,13 +40,13 @@ object Test { 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]) = { + def main(args: Array[String]) { val p = new PromiseStream[Int] println(Future.flow(p << (Future(1), Future(2), Future(3), Future(4), Future(5)))) } -}
\ No newline at end of file +} diff --git a/test/files/continuations-run/trycatch0.scala b/test/files/continuations-run/trycatch0.scala index ec39863f3f..d0b4a52a30 100644 --- a/test/files/continuations-run/trycatch0.scala +++ b/test/files/continuations-run/trycatch0.scala @@ -3,23 +3,23 @@ import scala.util.continuations._ object Test { - + def foo = try { shift((k: Int=>Int) => k(7)) } catch { - case ex => + case ex: Throwable => 9 } def bar = try { 7 } catch { - case ex => + case ex: Throwable => shiftUnit0[Int,Int](9) } - + def main(args: Array[String]): Unit = { println(reset { foo + 3 }) println(reset { bar + 3 }) } -}
\ No newline at end of file +} diff --git a/test/files/continuations-run/trycatch1.check b/test/files/continuations-run/trycatch1.check index a028d2b1e1..061ecdcd54 100644 --- a/test/files/continuations-run/trycatch1.check +++ b/test/files/continuations-run/trycatch1.check @@ -1,4 +1,10 @@ +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 -12
\ No newline at end of file diff --git a/test/files/continuations-run/trycatch1.scala b/test/files/continuations-run/trycatch1.scala index 10dfd30bb2..2a8db72a8b 100644 --- a/test/files/continuations-run/trycatch1.scala +++ b/test/files/continuations-run/trycatch1.scala @@ -5,12 +5,12 @@ 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 => + case ex: Throwable => 9 } @@ -18,7 +18,7 @@ object Test { shift((k: Int=>Int) => k(7)) fatal } catch { - case ex => + case ex: Throwable => 9 } @@ -26,7 +26,7 @@ object Test { fatal 7 } catch { - case ex => + case ex: Throwable => shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner } @@ -34,7 +34,7 @@ object Test { 7 fatal } catch { - case ex => + case ex: Throwable => shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner } @@ -45,4 +45,4 @@ object Test { println(reset { bar2 + 3 }) } -}
\ No newline at end of file +} diff --git a/test/files/continuations-run/while0.scala b/test/files/continuations-run/while0.scala index 46005a4a77..e21745374e 100644 --- a/test/files/continuations-run/while0.scala +++ b/test/files/continuations-run/while0.scala @@ -4,9 +4,9 @@ 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 @@ -15,8 +15,8 @@ object Test { println(x) } - def main(args: Array[String]): Any = { + def main(args: Array[String]): Unit = { reset(test()) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/while1.scala b/test/files/continuations-run/while1.scala index fd41ab36ee..7ba9f94881 100644 --- a/test/files/continuations-run/while1.scala +++ b/test/files/continuations-run/while1.scala @@ -4,9 +4,9 @@ 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) { @@ -15,8 +15,8 @@ object Test { println(x) } - def main(args: Array[String]): Any = { + def main(args: Array[String]): Unit = { reset(test()) } - -}
\ No newline at end of file + +} diff --git a/test/files/continuations-run/while2.scala b/test/files/continuations-run/while2.scala index 63f9cb99fe..3dbf2ad2fe 100644 --- a/test/files/continuations-run/while2.scala +++ b/test/files/continuations-run/while2.scala @@ -4,10 +4,10 @@ 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 @@ -16,8 +16,8 @@ object Test { println(x) } - def main(args: Array[String]): Any = { + def main(args: Array[String]): Unit = { reset(test()) } - -}
\ No newline at end of file + +} diff --git a/test/files/detach-neg/det_bar.check b/test/files/detach-neg/det_bar.check deleted file mode 100644 index 70b47581a5..0000000000 --- a/test/files/detach-neg/det_bar.check +++ /dev/null @@ -1,4 +0,0 @@ -det_bar.scala:7: error: detach inapplicable for method bar - detach(bar) - ^ -one error found diff --git a/test/files/detach-neg/det_bar.scala b/test/files/detach-neg/det_bar.scala deleted file mode 100644 index 862afb1d6e..0000000000 --- a/test/files/detach-neg/det_bar.scala +++ /dev/null @@ -1,13 +0,0 @@ -import scala.remoting._ -class A(y: Int) { - var z = 2 - var bar = (x: Int) => x + y + z - def foo(x: Int): Int = x + y + z - bar = (x: Int) => x * y - detach(bar) -} - -object test extends App { - val a = new A(1) - println(a.bar(2)) -} diff --git a/test/files/detach-run/actor-run.check b/test/files/detach-run/actor-run.check deleted file mode 100644 index 9448ddd5fe..0000000000 --- a/test/files/detach-run/actor-run.check +++ /dev/null @@ -1,5 +0,0 @@ -Server.main 8889 -Client.main 127.0.0.1 8889 -yInstVal = 10 -zLocVal = 1000 -result received: 11111 diff --git a/test/files/detach-run/actor/Client.scala b/test/files/detach-run/actor/Client.scala deleted file mode 100644 index 12573e24d3..0000000000 --- a/test/files/detach-run/actor/Client.scala +++ /dev/null @@ -1,54 +0,0 @@ -/* - * @author Stephane Micheloud - */ - -import scala.actors.Actor._, ClientHelper._ -import scala.actors.remote._, RemoteActor._ -import scala.remoting._, Debug._ - -object Foo { - def trace(msg: String) { info("[Foo.trace] "+msg)} -} -object Client { - val yInstVal: Int = 10 - var yInstVar: Int = 99 - object Bar { - def trace(msg: String) { info("[Bar.trace] "+msg) } - } - def main(args: Array[String]) { - init(args) - actor { - val server = select(Node(host, port), 'Server) - val zLocVal: Int = 1000 - var zLocVar: Int = 9998 - server ! detach( - (x: Int) => { - println("yInstVal = "+yInstVal) - this.trace("yInstVar = "+yInstVar) - Bar.trace("zLocVal = "+zLocVal) - Foo.trace("zLocVar = "+zLocVar) - zLocVar += 2 - System.out.println("zLocVal = "+zLocVal) - Debug.info("zLocVar = "+zLocVar) - x + yInstVal + yInstVar + zLocVal + zLocVar - }) - react { - case result: Int => - println("result received: " + result) - Predef.exit(0) - } - } - } - private def trace(msg: String) { info("[Client.trace] "+msg) } -} - -object ClientHelper { - private var _host = "127.0.0.1" - private var _port = 8888 - def host = _host - def port = _port - def init(args: Array[String]) { - try { _host = args(0) } catch { case _ => } - try { _port = args(1).toInt } catch { case _ => } - } -} diff --git a/test/files/detach-run/actor/Server.scala b/test/files/detach-run/actor/Server.scala deleted file mode 100644 index b56d22f744..0000000000 --- a/test/files/detach-run/actor/Server.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* - * @author Stephane Micheloud - */ - -import scala.actors.Actor._ -import scala.actors.remote.RemoteActor._ - -object Server extends ServerConsole { - private def computation(f: Int => Int): Int = { - //some time-consuming task - f(2) - } - def main(args: Array[String]) { - actor { - classLoader = serverClassLoader - alive(args(0).toInt) - register('Server, self) - loopWhile(isRunning) { - react { - case f: (Int => Int) => - val result = computation(f) - sender ! result - } - } - } - } -} diff --git a/test/files/detach-run/actor/ServerConsole.scala b/test/files/detach-run/actor/ServerConsole.scala deleted file mode 100644 index 8ebd9d4c2e..0000000000 --- a/test/files/detach-run/actor/ServerConsole.scala +++ /dev/null @@ -1,75 +0,0 @@ -/* - * @author Stephane Micheloud - */ - -import java.io.{BufferedReader, InputStreamReader} - -import scala.compat.Platform.currentTime -import scala.remoting.Debug, Debug._ - -trait ServerConsole extends Thread { - private val startTime = currentTime - actors.Debug.level = // e.g. 3 // info+warning+error - try { System.getProperty("scala.actors.logLevel", "0").toInt } - catch { case e => 0 } - - start() - - val serverClassLoader = { - import java.rmi.server.RMIClassLoader - val codebase = System.getProperty("java.rmi.server.codebase") - info("[ServerConsole] codebase="+codebase) - RMIClassLoader getClassLoader codebase - } - - private var isTerminated = false - - def terminate() { isTerminated = false } - - def isRunning = !isTerminated - - override def run() { - val in = new BufferedReader(new InputStreamReader(System.in)) - var quit = false - while (!quit) { - val args = getArgs(in) - if (args contains "quit") - quit = true - if (args contains "cls") { - println(ERASE_SCREEN) - println(CURSOR_HOME) - } - if (args contains "warning") - Debug.level = Level.WARNING - if (args contains "info") - Debug.level = Level.INFO - if (args contains "silent") - Debug.level = Level.SILENT - } - terminate() - println("Server exited ("+mkTimeString(currentTime - startTime)+")") - sys.exit(0) - } - - protected def trace(msg: String) { - Debug.info("[ServerConsole.trace] "+msg) - } - - private def getArgs(in: BufferedReader): List[String] = { - val input = try { in.readLine() } catch { case _ => null } - if (input != null) (input.trim split "\\s+").toList else Nil - } - - private def mkTimeString(time: Long): String = { - def twoDigits(i: Long) = (if (i < 10) "0" else "")+i - val sec = time / 1000 - val min = sec / 60 - val h = min / 60 - twoDigits(h) +":"+ - twoDigits(min - h * 60)+":"+ - twoDigits(sec - min * 60) - } - - private val ERASE_SCREEN = "\033[2J" - private val CURSOR_HOME = "\033[H" -} diff --git a/test/files/detach-run/actor/actor.flags b/test/files/detach-run/actor/actor.flags deleted file mode 100644 index 55eed8bbcd..0000000000 --- a/test/files/detach-run/actor/actor.flags +++ /dev/null @@ -1 +0,0 @@ --Xpluginsdir ../../../../build/pack/misc/scala-devel/plugins -Xplugin-require:detach -P:detach:enable diff --git a/test/files/detach-run/actor/actor.scala b/test/files/detach-run/actor/actor.scala deleted file mode 100644 index 23a10d6982..0000000000 --- a/test/files/detach-run/actor/actor.scala +++ /dev/null @@ -1,157 +0,0 @@ -/* - * @author Stephane Micheloud - */ - -object Test { - - val name = "actor" - val host = "127.0.0.1" - val port = 8889 - - def main(args: Array[String]) { - setenv() - println("Server.main "+port) - Server.main(Array(port.toString)) - println("Client.main "+host+" "+port) - Client.main(Array(host, port.toString)) - Server.terminate() - } - - private def setenv() { - import Env._ - - // Java properties for server & client - System.setProperty("scala.actors.logLevel", actors_logLevel) - System.setProperty("scala.remoting.logLevel", logLevel) - System.setProperty("java.security.manager", "") - System.setProperty("java.security.policy", policyFile) - // Java properties for server only - System.setProperty("java.rmi.server.codebase", deployUrl) - System.setProperty("java.rmi.server.hostname", host) - System.setProperty("java.rmi.server.useCodebaseOnly", "true") - - // application-specific classes to be deployed and accessed via URL - // (i.e. detached closure, proxy interfaces and proxy stubs) - val classNames = List( - "$anonfun$main$1$proxy", - "$anonfun$main$1$proxyImpl_Stub", - "Bar$proxy", - "Bar$proxyImpl_Stub", - "Client$$anonfun$main$1$$anonfun$apply$1$detach", - "Client$proxy", - "Client$proxyImpl_Stub", - "Foo$proxy", - "Foo$proxyImpl_Stub") - - val proxyImplNames = - for (n <- classNames; i = n lastIndexOf "_Stub"; if i > 0) - yield n.substring(0, i) - - generatePolicyFile() - generateRmiStubs(proxyImplNames) - generateJarFile(classNames) - } -} - -object Env { - import java.io._, java.util.jar._ - - val actors_logLevel = "0" - // = "3" // info+warning+error - val logLevel = "silent" - // = "info" // debug user code only - // = "info,lib" // debug user & library code - - // we assume an Apache server is running locally for deployment - private val sep = File.separator - val docPath = System.getProperty("user.home")+sep+"public_html" - val docRoot = "http://127.0.0.1/~"+System.getProperty("user.name") - - private val policyTmpl = - System.getProperty("partest.cwd")+sep+Test.name+sep+"java.policy" - val outPath = System.getProperty("partest.output") - val libPath = System.getProperty("partest.lib") - val policyFile = outPath+sep+"java.policy" - val codebaseDir = outPath+sep+"-" - - assert((new File(docPath)).isDirectory, - "Root directory \""+docPath+"\" not found") - val deployJar = docPath+sep+Test.name+"_deploy.jar" - val deployUrl = docRoot+"/"+Test.name+"_deploy.jar" - - def generatePolicyFile() { - val in = new BufferedReader(new FileReader(policyTmpl)) - val out = new PrintWriter(new BufferedWriter(new FileWriter(policyFile))) - var line = in.readLine() - while (line != null) { - val line1 = line.replaceAll("@PROJECT_LIB_BASE@", codebaseDir) - out.println(line1) - line = in.readLine() - } - in.close() - out.close() - } - - def generateRmiStubs(classNames: List[String]) { - val options = List( - "-v1.2", - "-classpath "+libPath+File.pathSeparator+outPath, - "-d "+outPath) - rmic(options, classNames) - //ls(outPath) - } - - def generateJarFile(classNames: List[String]) { - val out = new JarOutputStream(new FileOutputStream(deployJar)) - classNames foreach (name => try { - val classFile = name+".class" - val in = new FileInputStream(outPath+sep+classFile) - out putNextEntry new JarEntry(classFile) - val buf = new Array[Byte](512) - var len = in read buf - while (len != -1) { - out.write(buf, 0, len) - len = in read buf - } - in.close() - } catch { - case e: FileNotFoundException => println(e) - }) - out.close() - } - - private def ls(path: String) { exec("ls -al "+path) } - - private def rmic(options: List[String], classNames: List[String]) { - val javaHome = scala.util.Properties.javaHome - val jdkHome = - if (javaHome endsWith "jre") javaHome.substring(0, javaHome.length-4) - else javaHome - val rmicExt = if (scala.util.Properties.isWin) ".exe" else "" - val rmicCmd = jdkHome+sep+"bin"+sep+"rmic"+rmicExt - val cmdLine = rmicCmd+options.mkString(" ", " ", "")+ - classNames.mkString(" "," ","") - // println(cmdLine) - exec(cmdLine) - } - - private def exec(command: String) { - val proc = Runtime.getRuntime exec command - proc.waitFor() - val out = new BufferedReader(new InputStreamReader(proc.getInputStream)) - var line = out.readLine() - while (line != null) { - println(line) - line = out.readLine() - } - out.close() - val err = new BufferedReader(new InputStreamReader(proc.getErrorStream)) - line = err.readLine() - while (line != null) { - println(line) - line = err.readLine() - } - err.close() - } -} - diff --git a/test/files/detach-run/actor/java.policy b/test/files/detach-run/actor/java.policy deleted file mode 100644 index 4beb2ca26b..0000000000 --- a/test/files/detach-run/actor/java.policy +++ /dev/null @@ -1,25 +0,0 @@ -// See http://java.sun.com/javase/6/docs/technotes/guides/security/permissions.html -// See http://mindprod.com/jgloss/policyfile.html -// The policy expands ${/} to the correct path or folder delimiter on your host platform. - -// Actions available with SocketPermission: accept, connect, listen, resolve -// 1) The "resolve" action is implied when any of the other actions are present. -// 2) The "listen" action is only meaningful when used with "localhost". - -grant { - permission java.net.SocketPermission "*:80", "connect,accept,listen"; - permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; - permission java.util.PropertyPermission "scala.remoting.logLevel", "read"; - permission java.util.PropertyPermission "scala.remoting.port", "read"; -}; - -grant codeBase "@PROJECT_LIB_BASE@" { - permission java.lang.RuntimePermission "getClassLoader"; - permission java.util.PropertyPermission "java.rmi.server.codebase", "read"; - permission java.util.PropertyPermission "java.rmi.server.hostname", "read"; - permission java.util.PropertyPermission "sun.rmi.dgc.server.gcInterval", "read,write"; -}; -
-//grant { -// permission java.security.AllPermission; -//}; diff --git a/test/files/detach-run/basic-run.check b/test/files/detach-run/basic-run.check deleted file mode 100644 index 6463d97497..0000000000 --- a/test/files/detach-run/basic-run.check +++ /dev/null @@ -1,5 +0,0 @@ -Server.main 8889 -> Client.main 127.0.0.1 8889 -yInstVal = 10 -zLocVal = 1000 -result received: 11111 diff --git a/test/files/detach-run/basic/Client.scala b/test/files/detach-run/basic/Client.scala deleted file mode 100644 index f8eddb041d..0000000000 --- a/test/files/detach-run/basic/Client.scala +++ /dev/null @@ -1,48 +0,0 @@ -/* - * @author Stephane Micheloud - */ - -import java.net._, Thread._, ClientHelper._ -import scala.remoting._, Debug._ - -object Foo { - def trace(s: String) { info("[Foo.trace] "+s)} -} -object Client { - val yInstVal: Int = 10 - var yInstVar: Int = 99 - object Bar { - def trace(s: String) { info("[Bar.trace] "+s) } - } - def main(args: Array[String]) { - init(args) - val server = new Channel(host, port) - val zLocVal: Int = 1000 - var zLocVar: Int = 9998 - server ! detach( - (x: Int) => { - println("yInstVal = "+yInstVal) - this.trace("yInstVar = "+yInstVar) - Bar.trace("zLocVal = "+zLocVal) - Foo.trace("zLocVar = "+zLocVar) - zLocVar += 2 - System.out.println("zLocVal = "+zLocVal) - Debug.info("zLocVar = "+zLocVar) - x + yInstVal + yInstVar + zLocVal + zLocVar - }) - val result = server.receiveInt - println("result received: " + result) - } - private def trace(s: String) { info("[Client.trace] "+s) } -} - -object ClientHelper { - private var _host = "127.0.0.1" - private var _port = 8888 - def host = _host - def port = _port - def init(args: Array[String]) { - try { _host = args(0) } catch { case _ => } - try { _port = args(1).toInt } catch { case _ => } - } -} diff --git a/test/files/detach-run/basic/Server.scala b/test/files/detach-run/basic/Server.scala deleted file mode 100644 index f8aa02a4ba..0000000000 --- a/test/files/detach-run/basic/Server.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* - * @author Stephane Micheloud - */ - -import scala.remoting.ServerChannel - -object Server extends ServerConsole { - private def computation(f: Int => Int): Int = { - //some time-consuming task - f(2) - } - def main(args: Array[String]) { - val server = new ServerChannel(args(0).toInt) - loop { - val client = server.accept - val f = client.receive[Int => Int] - val result = computation(f) - client ! result - } - server.close() - } -} diff --git a/test/files/detach-run/basic/ServerConsole.scala b/test/files/detach-run/basic/ServerConsole.scala deleted file mode 100644 index 65b81c0ca1..0000000000 --- a/test/files/detach-run/basic/ServerConsole.scala +++ /dev/null @@ -1,83 +0,0 @@ -/* - * @author Stephane Micheloud - */ - -import java.io._ - -import scala.compat.Platform.currentTime -import scala.remoting.Debug, Debug._ - -trait ServerConsole extends Thread { - private val startTime = currentTime - - start() - - private var isTerminated = false - - def terminate() { isTerminated = true } - - protected def loop(block: => Unit) { - while (!isTerminated) { - try { - block - } - catch { - case e: ObjectStreamException => - trace("Object stream error ("+e.getMessage+")") - case e: EOFException => - trace("Connection lost") - case e: ClassNotFoundException => - trace("Class not found") - case e => - trace("Server error: "+e) - } - } - } - - override def run() { - val in = new BufferedReader(new InputStreamReader(System.in)) - var quit = false - while (!quit) { - val args = getArgs(in) - if (args contains "quit") - quit = true - if (args contains "cls") { - println(ERASE_SCREEN) - println(CURSOR_HOME) - } - if (args contains "warning") - Debug.level = Level.WARNING - if (args contains "info") - Debug.level = Level.INFO - if (args contains "silent") - Debug.level = Level.SILENT - } - terminate() - println("Server exited ("+mkTimeString(currentTime - startTime)+")") - exit(0) - - } - - protected def trace(msg: String) { - Debug.info("[ServerConsole.trace] "+msg) - } - - private def getArgs(in: BufferedReader): List[String] = { - print("> ") - val input = try { in.readLine() } catch { case _ => null } - if (input != null) (input.trim split "\\s+").toList else Nil - } - - private def mkTimeString(time: Long): String = { - def twoDigits(i: Long) = (if (i < 10) "0" else "")+i - val sec = time / 1000 - val min = sec / 60 - val h = min / 60 - twoDigits(h) +":"+ - twoDigits(min - h * 60)+":"+ - twoDigits(sec - min * 60) - } - - private val ERASE_SCREEN = "\033[2J" - private val CURSOR_HOME = "\033[H" -} diff --git a/test/files/detach-run/basic/basic.flags b/test/files/detach-run/basic/basic.flags deleted file mode 100644 index 55eed8bbcd..0000000000 --- a/test/files/detach-run/basic/basic.flags +++ /dev/null @@ -1 +0,0 @@ --Xpluginsdir ../../../../build/pack/misc/scala-devel/plugins -Xplugin-require:detach -P:detach:enable diff --git a/test/files/detach-run/basic/basic.scala b/test/files/detach-run/basic/basic.scala deleted file mode 100644 index 4d0fc2d933..0000000000 --- a/test/files/detach-run/basic/basic.scala +++ /dev/null @@ -1,169 +0,0 @@ -/* - * @author Stephane Micheloud - */ - -object Test { - - val name = "basic" - val host = "127.0.0.1" - val port = 8889 - - def main(args: Array[String]) { - setenv() - println("Server.main "+port) - server.start() - println("Client.main "+host+" "+port) - client.start() - server.terminate() - } - - private var server = new ServerThread(port) - private var client = new ClientThread(host, port) - - private class ServerThread(port: Int) extends Runnable { - private var th = new Thread(this) - def start() { th.start(); Thread.sleep(1000) } - def run() { Server.main(Array(port.toString)) } - def terminate() { Server.terminate(); sys.exit(0) } - } - - private class ClientThread(host: String, port: Int) extends Runnable { - private var th = new Thread(this) - def start() { th.start(); th.join() } - def run() { Client.main(Array(host, port.toString)) } - } - - private def setenv() { - import Env._ - - // Java properties for server & client - System.setProperty("scala.remoting.logLevel", logLevel) - System.setProperty("java.security.manager", "") - System.setProperty("java.security.policy", policyFile) - // Java properties for server only - System.setProperty("java.rmi.server.codebase", deployUrl) - System.setProperty("java.rmi.server.hostname", host) - System.setProperty("java.rmi.server.useCodebaseOnly", "true") - - // application-secific classes to be deployed and accessed via URL - // (i.e. detached closure, proxy interfaces and proxy stubs) - val classNames = List( - "Bar$proxy", - "Bar$proxyImpl_Stub", - "Client$$anonfun$main$1$detach", - "Client$proxy", - "Client$proxyImpl_Stub", - "Foo$proxy", - "Foo$proxyImpl_Stub") - - val proxyImplNames = - for (n <- classNames; i = n lastIndexOf "_Stub"; if i > 0) - yield n.substring(0, i) - - generatePolicyFile() - generateRmiStubs(proxyImplNames) - generateJarFile(classNames) - } -} - -object Env { - import java.io._, java.util.jar._ - - val actors_logLevel = "0" - // = "3" // info+warning+error - val logLevel = "silent" - // = "info" // debug user code only - // = "info,lib" // debug user & library code - - // we assume an Apache server is running locally for deployment - private val sep = File.separator - val docPath = System.getProperty("user.home")+sep+"public_html" - val docRoot = "http://127.0.0.1/~"+System.getProperty("user.name") - - private val policyTmpl = - System.getProperty("partest.cwd")+sep+Test.name+sep+"java.policy" - val outPath = System.getProperty("partest.output") - val libPath = System.getProperty("partest.lib") - val policyFile = outPath+sep+"java.policy" - val codebaseDir = outPath+sep+"-" - - assert((new File(docPath)).isDirectory, - "Root directory \""+docPath+"\" not found") - val deployJar = docPath+sep+Test.name+"_deploy.jar" - val deployUrl = docRoot+"/"+Test.name+"_deploy.jar" - - def generatePolicyFile() { - val in = new BufferedReader(new FileReader(policyTmpl)) - val out = new PrintWriter(new BufferedWriter(new FileWriter(policyFile))) - var line = in.readLine() - while (line != null) { - val line1 = line.replaceAll("@PROJECT_LIB_BASE@", codebaseDir) - out.println(line1) - line = in.readLine() - } - in.close() - out.close() - } - - def generateRmiStubs(classNames: List[String]) { - val options = List( - "-v1.2", - "-classpath "+libPath+File.pathSeparator+outPath, - "-d "+outPath) - rmic(options, classNames) - //ls(outPath) - } - - def generateJarFile(classNames: List[String]) { - val out = new JarOutputStream(new FileOutputStream(deployJar)) - classNames foreach (name => try { - val classFile = name+".class" - val in = new FileInputStream(outPath+sep+classFile) - out putNextEntry new JarEntry(classFile) - val buf = new Array[Byte](512) - var len = in read buf - while (len != -1) { - out.write(buf, 0, len) - len = in read buf - } - in.close() - } catch { - case e: FileNotFoundException => println(e) - }) - out.close() - } - - private def ls(path: String) { exec("ls -al "+path) } - - private def rmic(options: List[String], classNames: List[String]) { - val javaHome = scala.util.Properties.javaHome - val jdkHome = - if (javaHome endsWith "jre") javaHome.substring(0, javaHome.length-4) - else javaHome - val rmicExt = if (scala.util.Properties.isWin) ".exe" else "" - val rmicCmd = jdkHome+sep+"bin"+sep+"rmic"+rmicExt - val cmdLine = rmicCmd+options.mkString(" ", " ", "")+ - classNames.mkString(" "," ","") - // println(cmdLine) - exec(cmdLine) - } - - private def exec(command: String) { - val proc = Runtime.getRuntime exec command - proc.waitFor() - val out = new BufferedReader(new InputStreamReader(proc.getInputStream)) - var line = out.readLine() - while (line != null) { - println(line) - line = out.readLine() - } - out.close() - val err = new BufferedReader(new InputStreamReader(proc.getErrorStream)) - line = err.readLine() - while (line != null) { - println(line) - line = err.readLine() - } - err.close() - } -} diff --git a/test/files/detach-run/basic/java.policy b/test/files/detach-run/basic/java.policy deleted file mode 100644 index 92c1045c3d..0000000000 --- a/test/files/detach-run/basic/java.policy +++ /dev/null @@ -1,26 +0,0 @@ -// See http://java.sun.com/javase/6/docs/technotes/guides/security/permissions.html -// See http://mindprod.com/jgloss/policyfile.html -// The policy expands ${/} to the correct path or folder delimiter on your host platform. - -// Actions available with SocketPermission: accept, connect, listen, resolve -// 1) The "resolve" action is implied when any of the other actions are present. -// 2) The "listen" action is only meaningful when used with "localhost". - -grant { - permission java.net.SocketPermission "*:80", "connect,accept,listen"; - permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; - permission java.util.PropertyPermission "scala.remoting.logLevel", "read"; - permission java.util.PropertyPermission "scala.remoting.port", "read"; -}; - -grant codeBase "@PROJECT_LIB_BASE@" { - permission java.lang.RuntimePermission "getClassLoader"; - permission java.lang.RuntimePermission "createClassLoader"; - permission java.util.PropertyPermission "java.rmi.server.codebase", "read"; - permission java.util.PropertyPermission "java.rmi.server.hostname", "read"; - permission java.util.PropertyPermission "sun.rmi.dgc.server.gcInterval", "read,write"; -}; - -//grant { -// permission java.security.AllPermission; -//}; diff --git a/test/files/disabled/run/t4602.scala b/test/files/disabled/run/t4602.scala index 73ba231ccf..655c350497 100644 --- a/test/files/disabled/run/t4602.scala +++ b/test/files/disabled/run/t4602.scala @@ -4,7 +4,7 @@ import java.util.concurrent.{CountDownLatch, TimeUnit} object Test extends App { val startupLatch = new CountDownLatch(1) - // we have to explicitly launch our server because when the client launches a server it uses + // we have to explicitly launch our server because when the client launches a server it uses // the "scala" shell command meaning whatever version of scala (and whatever version of libraries) // happens to be in the path gets used val t = new Thread(new Runnable { @@ -18,10 +18,10 @@ object Test extends App { sys error "Timeout waiting for server to start" val baos = new ByteArrayOutputStream() - val ps = new PrintStream(baos) + val ps = new PrintStream(baos) val outdir = scala.reflect.io.Directory(sys.props("partest.output")) - + val dirNameAndPath = (1 to 2).toList map {number => val name = s"Hello${number}" val dir = outdir / number.toString @@ -32,9 +32,9 @@ object Test extends App { dir.createDirectory() val file = path.jfile val out = new FileWriter(file) - try + try out.write(s"object ${name}\n") - finally + finally out.close } @@ -50,7 +50,7 @@ object Test extends App { val msg = baos.toString() assert(success, s"got a failure. Full results were: \n${msg}") - dirNameAndPath foreach {case (_, _, path) => + dirNameAndPath foreach {case (_, _, path) => val expected = s"Input files after normalizing paths: ${path}" assert(msg contains expected, s"could not find '${expected}' in output. Full results were: \n${msg}") } diff --git a/test/files/filters b/test/files/filters new file mode 100644 index 0000000000..9a9b439784 --- /dev/null +++ b/test/files/filters @@ -0,0 +1,3 @@ +# +#Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 28). +Java HotSpot\(TM\) .* warning: diff --git a/test/files/instrumented/InstrumentationTest.check b/test/files/instrumented/InstrumentationTest.check index f0f447560a..0c570fa12c 100644 --- a/test/files/instrumented/InstrumentationTest.check +++ b/test/files/instrumented/InstrumentationTest.check @@ -4,5 +4,7 @@ Method call statistics: 1 Foo1.someMethod()I 1 instrumented/Foo2.<init>()V 1 instrumented/Foo2.someMethod()I + 1 scala/DeprecatedConsole.<init>()V 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; diff --git a/test/files/jvm/actor-exceptions.scala b/test/files/jvm/actor-exceptions.scala index 3ee4db9ed2..bdd983a0e8 100644 --- a/test/files/jvm/actor-exceptions.scala +++ b/test/files/jvm/actor-exceptions.scala @@ -1,4 +1,7 @@ + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.{Actor, Exit} import Actor._ @@ -58,7 +61,6 @@ object Slave extends Actor { case object A -object Test { def main(args: Array[String]) { Master.start() } diff --git a/test/files/jvm/actor-executor.scala b/test/files/jvm/actor-executor.scala index b1f9caebdd..0fc28b4d85 100644 --- a/test/files/jvm/actor-executor.scala +++ b/test/files/jvm/actor-executor.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import java.util.concurrent.Executors import scala.actors.{Actor, SchedulerAdapter} import Actor._ @@ -50,7 +54,6 @@ object Two extends AdaptedActor { } } -object Test { val executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) diff --git a/test/files/jvm/actor-executor2.scala b/test/files/jvm/actor-executor2.scala index f8fcaef69f..5badf2ae7e 100644 --- a/test/files/jvm/actor-executor2.scala +++ b/test/files/jvm/actor-executor2.scala @@ -1,3 +1,8 @@ + + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.{Actor, SchedulerAdapter, Exit} import Actor._ import java.util.concurrent.{Executors, RejectedExecutionException} @@ -48,7 +53,6 @@ trait AdaptedActor extends Actor { Test.scheduler } -object Test { val NUM_MSG = 100000 val executor = diff --git a/test/files/jvm/actor-executor3.scala b/test/files/jvm/actor-executor3.scala index 4fde2c6c5f..f8b57d84b3 100644 --- a/test/files/jvm/actor-executor3.scala +++ b/test/files/jvm/actor-executor3.scala @@ -1,3 +1,8 @@ + + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.Actor import scala.actors.scheduler.ExecutorScheduler import java.util.concurrent.Executors @@ -48,7 +53,6 @@ trait AdaptedActor extends Actor { Test.scheduler } -object Test { val NUM_MSG = 100000 val executor = diff --git a/test/files/jvm/actor-getstate.scala b/test/files/jvm/actor-getstate.scala index a6e15a8721..425efbe5e6 100644 --- a/test/files/jvm/actor-getstate.scala +++ b/test/files/jvm/actor-getstate.scala @@ -1,7 +1,9 @@ -import scala.actors.{Reactor, Actor, TIMEOUT} -import Actor._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.{Reactor, Actor, TIMEOUT} + import Actor._ def assert(cond: => Boolean, hint: String) { if (!cond) diff --git a/test/files/jvm/actor-link-getstate.scala b/test/files/jvm/actor-link-getstate.scala index c24daf2eff..d8b8ada1e6 100644 --- a/test/files/jvm/actor-link-getstate.scala +++ b/test/files/jvm/actor-link-getstate.scala @@ -1,5 +1,9 @@ -import scala.actors.{Actor, Exit} -import scala.actors.Actor._ + + +@deprecated("Suppress warnings", since="2.11") +object Test { + import scala.actors.{Actor, Exit} + import scala.actors.Actor._ case class MyException(text: String) extends Exception(text) { override def fillInStackTrace() = this @@ -39,7 +43,6 @@ object Master extends Actor { } } -object Test { def main(args: Array[String]) { actor { diff --git a/test/files/jvm/actor-looping.scala b/test/files/jvm/actor-looping.scala index 475d4754ce..7bc6f1e5c5 100644 --- a/test/files/jvm/actor-looping.scala +++ b/test/files/jvm/actor-looping.scala @@ -1,7 +1,8 @@ -import scala.actors.Actor._ +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.Actor._ case object A def main(args: Array[String]) { diff --git a/test/files/jvm/actor-normal-exit.scala b/test/files/jvm/actor-normal-exit.scala index 20863d5bb0..90495866e2 100644 --- a/test/files/jvm/actor-normal-exit.scala +++ b/test/files/jvm/actor-normal-exit.scala @@ -1,7 +1,9 @@ -import scala.actors.{Actor, Exit} + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.{Actor, Exit} object Master extends Actor { trapExit = true def act() { diff --git a/test/files/jvm/actor-receivewithin.scala b/test/files/jvm/actor-receivewithin.scala index a5c87c2722..5982462502 100644 --- a/test/files/jvm/actor-receivewithin.scala +++ b/test/files/jvm/actor-receivewithin.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.{Actor, TIMEOUT} object A extends Actor { @@ -62,7 +66,6 @@ object B extends Actor { } } -object Test { def main(args:Array[String]) { B.start() } diff --git a/test/files/jvm/actor-sync-send-timeout.scala b/test/files/jvm/actor-sync-send-timeout.scala index 21e624bd0a..66a0b0a6ff 100644 --- a/test/files/jvm/actor-sync-send-timeout.scala +++ b/test/files/jvm/actor-sync-send-timeout.scala @@ -1,10 +1,11 @@ +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.Actor /* This test is a regression test for SI-4759. */ -object Test { val Runs = 5 - + def main(args: Array[String]) = { var i = 0 while (i < Runs) { @@ -14,7 +15,6 @@ object Test { } //println("done sending to A1") } -} object A2 extends Actor { this.start() @@ -45,3 +45,4 @@ object A1 extends Actor { } } } +} diff --git a/test/files/jvm/actor-termination.scala b/test/files/jvm/actor-termination.scala index d8e44a2797..4a6bf92d48 100644 --- a/test/files/jvm/actor-termination.scala +++ b/test/files/jvm/actor-termination.scala @@ -1,8 +1,9 @@ -import scala.actors.Actor /* Test that an actor that hasn't finished prevents termination */ +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.Actor def main(args: Array[String]) { Actor.actor { try { diff --git a/test/files/jvm/actor-uncaught-exception.scala b/test/files/jvm/actor-uncaught-exception.scala index 5ae66de640..c28ad2fa3c 100644 --- a/test/files/jvm/actor-uncaught-exception.scala +++ b/test/files/jvm/actor-uncaught-exception.scala @@ -1,63 +1,64 @@ +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.{Actor, Exit} class MyException(msg: String) extends Exception(msg) { override def fillInStackTrace() = this } -object Test { - case object StartError extends Actor { - def act() { + case object StartError extends Actor { + def act() { try { - throw new MyException("I don't want to run!") + throw new MyException("I don't want to run!") } catch { case e: Throwable if (!e.isInstanceOf[scala.util.control.ControlThrowable] && !e.isInstanceOf[MyException]) => e.printStackTrace() } - } - } + } + } - case object MessageError extends Actor { - def act() { + case object MessageError extends Actor { + def act() { try { - react { - case _ => throw new MyException("No message for me!") - } + react { + case _ => throw new MyException("No message for me!") + } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } - } + } + } - case object Supervisor extends Actor { - def act() { + case object Supervisor extends Actor { + def act() { try { - trapExit = true + trapExit = true link(StartError) link(MessageError) - StartError.start() + StartError.start() MessageError.start() - Actor.loop { - react { + Actor.loop { + react { case Exit(actor, reason) => println("OK") if (actor == StartError) MessageError ! 'ping else exit() - } - } + } + } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } - } + } + } - def main(args: Array[String]) { - Supervisor.start() - } -} + def main(args: Array[String]) { + Supervisor.start() + } +} diff --git a/test/files/jvm/actor-uncaught-exception2.check b/test/files/jvm/actor-uncaught-exception2.check index 870a5d32f9..a54f374aed 100644 --- a/test/files/jvm/actor-uncaught-exception2.check +++ b/test/files/jvm/actor-uncaught-exception2.check @@ -1,2 +1,2 @@ -UncaughtException(StartError,None,None,MyException: I don't want to run!) -UncaughtException(MessageError,Some('ping),Some(Supervisor),MyException: No message for me!) +UncaughtException(StartError,None,None,Test$MyException: I don't want to run!) +UncaughtException(MessageError,Some('ping),Some(Supervisor),Test$MyException: No message for me!) diff --git a/test/files/jvm/actor-uncaught-exception2.scala b/test/files/jvm/actor-uncaught-exception2.scala index 0364cbeb03..8327b4e19d 100644 --- a/test/files/jvm/actor-uncaught-exception2.scala +++ b/test/files/jvm/actor-uncaught-exception2.scala @@ -1,63 +1,63 @@ +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.{Actor, Exit, Debug} class MyException(msg: String) extends Exception(msg) { override def fillInStackTrace() = this } -object Test { - - case object StartError extends Actor { - def act() { + case object StartError extends Actor { + def act() { try { - throw new MyException("I don't want to run!") + throw new MyException("I don't want to run!") } catch { case e: Throwable if (!e.isInstanceOf[scala.util.control.ControlThrowable] && !e.isInstanceOf[MyException]) => e.printStackTrace() } - } - } + } + } - case object MessageError extends Actor { - def act() { + case object MessageError extends Actor { + def act() { try { - react { - case _ => throw new MyException("No message for me!") - } + react { + case _ => throw new MyException("No message for me!") + } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } - } + } + } - case object Supervisor extends Actor { - def act() { + case object Supervisor extends Actor { + def act() { try { - trapExit = true + trapExit = true link(StartError) link(MessageError) - StartError.start() + StartError.start() MessageError.start() - Actor.loop { - react { + Actor.loop { + react { case Exit(actor, reason) => println(reason) if (actor == StartError) MessageError ! 'ping else exit() - } - } + } + } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } - } + } + } - def main(args: Array[String]) { - Supervisor.start() - } -} + def main(args: Array[String]) { + Supervisor.start() + } +} diff --git a/test/files/jvm/annotations.scala b/test/files/jvm/annotations.scala index 77a45fae89..c42eceef4c 100644 --- a/test/files/jvm/annotations.scala +++ b/test/files/jvm/annotations.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds, reflectiveCalls } + object Test1 { class Foo { @remote diff --git a/test/files/jvm/backendBugUnapply.scala b/test/files/jvm/backendBugUnapply.scala deleted file mode 100644 index 45ee6f7d4f..0000000000 --- a/test/files/jvm/backendBugUnapply.scala +++ /dev/null @@ -1,17 +0,0 @@ -object Test { - import scala.xml.{Node,UnprefixedAttribute} - - def domatch(x:Node) = - x match { - case Node("foo", UnprefixedAttribute("bar", z, _), _*) => z - case _ => null - } - - def main(args: Array[String]): Unit = { - println(domatch(<foo bar="baz"><hi/></foo>)) - println(domatch(<foo bingo="donkey"><hi/></foo>)) - // - // assert(domatch(<foo bar="baz"><hi/></foo>).toString == "baz") - // assert(domatch(<foo bar="baz2"><hi/></foo>) == null)//, domatch(<foo bar="baz2"><hi/></foo>)) - } -} diff --git a/test/files/jvm/bytecode-test-example/Foo_1.flags b/test/files/jvm/bytecode-test-example/Foo_1.flags new file mode 100644 index 0000000000..49f2d2c4c8 --- /dev/null +++ b/test/files/jvm/bytecode-test-example/Foo_1.flags @@ -0,0 +1 @@ +-Ybackend:GenASM diff --git a/test/files/jvm/console.scala b/test/files/jvm/console.scala index 75449416aa..0ac43f2d26 100644 --- a/test/files/jvm/console.scala +++ b/test/files/jvm/console.scala @@ -9,6 +9,6 @@ object Test extends App { flush println("..") println(1) - printf("Argument nr. %d has value %1.2f\n", + printf("Argument nr. %d has value %1.2f\n", 1, 10.0/3) } diff --git a/test/files/jvm/constant-optimization/Foo_1.flags b/test/files/jvm/constant-optimization/Foo_1.flags new file mode 100644 index 0000000000..86f52af447 --- /dev/null +++ b/test/files/jvm/constant-optimization/Foo_1.flags @@ -0,0 +1 @@ +-Ynooptimise -Yconst-opt
\ No newline at end of file diff --git a/test/files/jvm/constant-optimization/Foo_1.scala b/test/files/jvm/constant-optimization/Foo_1.scala new file mode 100644 index 0000000000..cb67ad4e90 --- /dev/null +++ b/test/files/jvm/constant-optimization/Foo_1.scala @@ -0,0 +1,9 @@ +class Foo_1 { + def foo() { + // constant optimization should eliminate all branches + val i = 1 + val x = if (i != 1) null else "good" + val y = if (x == null) "good" else x + "" + println(y) + } +}
\ No newline at end of file diff --git a/test/files/jvm/constant-optimization/Test.scala b/test/files/jvm/constant-optimization/Test.scala new file mode 100644 index 0000000000..dc0f8f6103 --- /dev/null +++ b/test/files/jvm/constant-optimization/Test.scala @@ -0,0 +1,27 @@ + +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import asm.tree.InsnList +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + val comparisons = Set(asm.Opcodes.IF_ACMPEQ, asm.Opcodes.IF_ACMPNE, asm.Opcodes.IF_ICMPEQ, asm.Opcodes.IF_ICMPGE, asm.Opcodes.IF_ICMPGT, asm.Opcodes.IF_ICMPLE, + asm.Opcodes.IF_ICMPLT, asm.Opcodes.IF_ICMPNE, asm.Opcodes.IFEQ, asm.Opcodes.IFGE, asm.Opcodes.IFGT, asm.Opcodes.IFLE, asm.Opcodes.IFLT, + asm.Opcodes.IFNE, asm.Opcodes.IFNONNULL, asm.Opcodes.IFNULL) + + def show: Unit = { + val classNode = loadClassNode("Foo_1") + val methodNode = getMethod(classNode, "foo") + // after optimization there should be no comparisons left + val expected = 0 + + val got = countComparisons(methodNode.instructions) + assert(got == expected, s"expected $expected but got $got comparisons") + } + + def countComparisons(insnList: InsnList): Int = { + def isComparison(node: asm.tree.AbstractInsnNode): Boolean = + (comparisons contains node.getOpcode) + insnList.iterator.asScala count isComparison + } +}
\ No newline at end of file diff --git a/test/files/jvm/daemon-actor-termination.scala b/test/files/jvm/daemon-actor-termination.scala index 6ddfc3139d..40acd8583e 100644 --- a/test/files/jvm/daemon-actor-termination.scala +++ b/test/files/jvm/daemon-actor-termination.scala @@ -1,8 +1,10 @@ -import scala.actors.{Actor, DaemonActor} /* Test that a daemon Actor that hasn't finished does not prevent termination */ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.{Actor, DaemonActor} class MyDaemon extends DaemonActor { def act() { try { diff --git a/test/files/jvm/deprecation.check b/test/files/jvm/deprecation.check new file mode 100644 index 0000000000..e263e4909d --- /dev/null +++ b/test/files/jvm/deprecation.check @@ -0,0 +1,3 @@ +warning: there were 5 deprecation warning(s); re-run with -deprecation for details +Note: deprecation/Use_2.java uses or overrides a deprecated API. +Note: Recompile with -Xlint:deprecation for details. diff --git a/test/files/jvm/deprecation/Test_1.scala b/test/files/jvm/deprecation/Test_1.scala index b68a40c94b..0a5b607037 100644 --- a/test/files/jvm/deprecation/Test_1.scala +++ b/test/files/jvm/deprecation/Test_1.scala @@ -7,7 +7,7 @@ class Test { val i = new d.Inner val w = i.buz() } - + @deprecated("no longer!", "") class Inner { @deprecated("uncool", "") def f: Int = 1 @deprecated("this one as well!", "") var g = -1 diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala index b2573448c7..3bc8a2c100 100644 --- a/test/files/jvm/duration-tck.scala +++ b/test/files/jvm/duration-tck.scala @@ -6,6 +6,8 @@ import scala.concurrent.duration._ import scala.reflect._ import scala.tools.partest.TestUtil.intercept +import scala.language.{ postfixOps } + object Test extends App { implicit class Assert(val left: Any) extends AnyVal { diff --git a/test/files/jvm/future-alarm.scala b/test/files/jvm/future-alarm.scala index 8ee902b5ea..3e71fa681c 100644 --- a/test/files/jvm/future-alarm.scala +++ b/test/files/jvm/future-alarm.scala @@ -1,6 +1,8 @@ -import scala.actors.Futures + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.Futures def main(args: Array[String]) { try { for (i <- 1 to 100000) { diff --git a/test/files/jvm/future-awaitall-zero.scala b/test/files/jvm/future-awaitall-zero.scala index cd6ba172cc..56f4bab16f 100644 --- a/test/files/jvm/future-awaitall-zero.scala +++ b/test/files/jvm/future-awaitall-zero.scala @@ -1,7 +1,9 @@ -import scala.actors.Futures._ -import scala.actors.Actor._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.Futures._ + import scala.actors.Actor._ def main(args: Array[String]) { try { val ft1 = future { reactWithin(10000) { diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala index ddd819c109..5d213691df 100644 --- a/test/files/jvm/future-spec/FutureTests.scala +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -13,15 +13,15 @@ import scala.util.{Try,Success,Failure} object FutureTests extends MinimalScalaTest { /* some utils */ - + def testAsync(s: String)(implicit ec: ExecutionContext): Future[String] = s match { case "Hello" => future { "World" } case "Failure" => Future.failed(new RuntimeException("Expected exception; to test fault-tolerance")) case "NoReply" => Promise[String]().future } - + val defaultTimeout = 5 seconds - + /* future specification */ "A future with custom ExecutionContext" should { @@ -31,41 +31,41 @@ object FutureTests extends MinimalScalaTest { t => ms += t }) - + class ThrowableTest(m: String) extends Throwable(m) - + val f1 = future[Any] { throw new ThrowableTest("test") } - + intercept[ThrowableTest] { Await.result(f1, defaultTimeout) } - + val latch = new TestLatch val f2 = future { Await.ready(latch, 5 seconds) "success" } val f3 = f2 map { s => s.toUpperCase } - + f2 foreach { _ => throw new ThrowableTest("dispatcher foreach") } f2 onSuccess { case _ => throw new ThrowableTest("dispatcher receive") } - + latch.open() - + Await.result(f2, defaultTimeout) mustBe ("success") - + f2 foreach { _ => throw new ThrowableTest("current thread foreach") } f2 onSuccess { case _ => throw new ThrowableTest("current thread receive") } - + Await.result(f3, defaultTimeout) mustBe ("SUCCESS") - + val waiting = future { Thread.sleep(1000) } Await.ready(waiting, 2000 millis) - + ms.size mustBe (4) //FIXME should check } @@ -96,7 +96,7 @@ object FutureTests extends MinimalScalaTest { val logThrowable: Throwable => Unit = p.trySuccess(_) val ec: ExecutionContext = ExecutionContext.fromExecutor(null, logThrowable) - val t = new NotImplementedError("foo") + val t = new InterruptedException() val f = Future(throw t)(ec) Await.result(p.future, 2.seconds) mustBe t } @@ -110,24 +110,24 @@ object FutureTests extends MinimalScalaTest { val future0 = future[Any] { "five!".length } - + val future1 = for { a <- future0.mapTo[Int] // returns 5 b <- async(a) // returns "10" c <- async(7) // returns "14" } yield b + "-" + c - + val future2 = for { a <- future0.mapTo[Int] b <- (future { (a * 2).toString }).mapTo[Int] - c <- future { (7 * 2).toString } + c <- future { (7 * 2).toString } } yield b + "-" + c - + Await.result(future1, defaultTimeout) mustBe ("10-14") assert(checkType(future1, manifest[String])) intercept[ClassCastException] { Await.result(future2, defaultTimeout) } } - + "support pattern matching within a for-comprehension" in { case class Req[T](req: T) case class Res[T](res: T) @@ -135,44 +135,44 @@ object FutureTests extends MinimalScalaTest { case Req(s: String) => future { Res(s.length) } case Req(i: Int) => future { Res((i * 2).toString) } } - + val future1 = for { Res(a: Int) <- async(Req("Hello")) Res(b: String) <- async(Req(a)) Res(c: String) <- async(Req(7)) } yield b + "-" + c - + val future2 = for { Res(a: Int) <- async(Req("Hello")) Res(b: Int) <- async(Req(a)) Res(c: Int) <- async(Req(7)) } yield b + "-" + c - + Await.result(future1, defaultTimeout) mustBe ("10-14") intercept[NoSuchElementException] { Await.result(future2, defaultTimeout) } } - + "recover from exceptions" in { val future1 = Future(5) val future2 = future1 map (_ / 0) val future3 = future2 map (_.toString) - + val future4 = future1 recover { case e: ArithmeticException => 0 } map (_.toString) - + val future5 = future2 recover { case e: ArithmeticException => 0 } map (_.toString) - + val future6 = future2 recover { case e: MatchError => 0 } map (_.toString) - + val future7 = future3 recover { case e: ArithmeticException => "You got ERROR" } - + val future8 = testAsync("Failure") val future9 = testAsync("Failure") recover { case e: RuntimeException => "FAIL!" @@ -183,7 +183,7 @@ object FutureTests extends MinimalScalaTest { val future11 = testAsync("Failure") recover { case _ => "Oops!" } - + Await.result(future1, defaultTimeout) mustBe (5) intercept[ArithmeticException] { Await.result(future2, defaultTimeout) } intercept[ArithmeticException] { Await.result(future3, defaultTimeout) } @@ -196,23 +196,23 @@ object FutureTests extends MinimalScalaTest { Await.result(future10, defaultTimeout) mustBe ("World") Await.result(future11, defaultTimeout) mustBe ("Oops!") } - + "recoverWith from exceptions" in { val o = new IllegalStateException("original") val r = new IllegalStateException("recovered") - + intercept[IllegalStateException] { val failed = Future.failed[String](o) recoverWith { case _ if false == true => Future.successful("yay!") } Await.result(failed, defaultTimeout) } mustBe (o) - + val recovered = Future.failed[String](o) recoverWith { case _ => Future.successful("yay!") } Await.result(recovered, defaultTimeout) mustBe ("yay!") - + intercept[IllegalStateException] { val refailed = Future.failed[String](o) recoverWith { case _ => Future.failed[String](r) @@ -220,7 +220,7 @@ object FutureTests extends MinimalScalaTest { Await.result(refailed, defaultTimeout) } mustBe (r) } - + "andThen like a boss" in { val q = new java.util.concurrent.LinkedBlockingQueue[Int] for (i <- 1 to 1000) { @@ -240,28 +240,28 @@ object FutureTests extends MinimalScalaTest { q.clear() } } - + "firstCompletedOf" in { def futures = Vector.fill[Future[Int]](10) { Promise[Int]().future } :+ Future.successful[Int](5) - + Await.result(Future.firstCompletedOf(futures), defaultTimeout) mustBe (5) Await.result(Future.firstCompletedOf(futures.iterator), defaultTimeout) mustBe (5) } - + "find" in { val futures = for (i <- 1 to 10) yield future { i } - + val result = Future.find[Int](futures)(_ == 3) Await.result(result, defaultTimeout) mustBe (Some(3)) val notFound = Future.find[Int](futures.iterator)(_ == 11) Await.result(notFound, defaultTimeout) mustBe (None) } - + "zip" in { val timeout = 10000 millis val f = new IllegalStateException("test") @@ -269,48 +269,48 @@ object FutureTests extends MinimalScalaTest { val failed = Future.failed[String](f) zip Future.successful("foo") Await.result(failed, timeout) } mustBe (f) - + intercept[IllegalStateException] { val failed = Future.successful("foo") zip Future.failed[String](f) Await.result(failed, timeout) } mustBe (f) - + intercept[IllegalStateException] { val failed = Future.failed[String](f) zip Future.failed[String](f) Await.result(failed, timeout) } mustBe (f) - + val successful = Future.successful("foo") zip Future.successful("foo") Await.result(successful, timeout) mustBe (("foo", "foo")) } - + "fold" in { val timeout = 10000 millis def async(add: Int, wait: Int) = future { Thread.sleep(wait) add } - + val futures = (0 to 9) map { idx => async(idx, idx * 20) } val folded = Future.fold(futures)(0)(_ + _) Await.result(folded, timeout) mustBe (45) - + val futuresit = (0 to 9) map { idx => async(idx, idx * 20) } val foldedit = Future.fold(futures)(0)(_ + _) Await.result(foldedit, timeout) mustBe (45) } - + "fold by composing" in { val timeout = 10000 millis def async(add: Int, wait: Int) = future { Thread.sleep(wait) add } - def futures = (0 to 9) map { + def futures = (0 to 9) map { idx => async(idx, idx * 20) } val folded = futures.foldLeft(Future(0)) { @@ -318,7 +318,7 @@ object FutureTests extends MinimalScalaTest { } Await.result(folded, timeout) mustBe (45) } - + "fold with an exception" in { val timeout = 10000 millis def async(add: Int, wait: Int) = future { @@ -334,7 +334,7 @@ object FutureTests extends MinimalScalaTest { Await.result(folded, timeout) }.getMessage mustBe ("shouldFoldResultsWithException: expected") } - + "fold mutable zeroes safely" in { import scala.collection.mutable.ArrayBuffer def test(testNumber: Int) { @@ -344,34 +344,34 @@ object FutureTests extends MinimalScalaTest { case (l, _) => l } val result = Await.result(f.mapTo[ArrayBuffer[Int]], 10000 millis).sum - + assert(result == 250500) } (1 to 100) foreach test //Make sure it tries to provoke the problem } - + "return zero value if folding empty list" in { val zero = Future.fold(List[Future[Int]]())(0)(_ + _) Await.result(zero, defaultTimeout) mustBe (0) } - + "shouldReduceResults" in { def async(idx: Int) = future { Thread.sleep(idx * 20) idx } val timeout = 10000 millis - + val futures = (0 to 9) map { async } val reduced = Future.reduce(futures)(_ + _) Await.result(reduced, timeout) mustBe (45) - + val futuresit = (0 to 9) map { async } val reducedit = Future.reduce(futuresit)(_ + _) Await.result(reducedit, timeout) mustBe (45) } - + "shouldReduceResultsWithException" in { def async(add: Int, wait: Int) = future { Thread.sleep(wait) @@ -387,14 +387,14 @@ object FutureTests extends MinimalScalaTest { Await.result(failed, timeout) }.getMessage mustBe ("shouldFoldResultsWithException: expected") } - + "shouldReduceThrowNSEEOnEmptyInput" in { intercept[java.util.NoSuchElementException] { val emptyreduced = Future.reduce(List[Future[Int]]())(_ + _) Await.result(emptyreduced, defaultTimeout) } } - + "shouldTraverseFutures" in { object counter { var count = -1 @@ -403,23 +403,23 @@ object FutureTests extends MinimalScalaTest { count } } - + val oddFutures = List.fill(100)(future { counter.incAndGet() }).iterator val traversed = Future.sequence(oddFutures) Await.result(traversed, defaultTimeout).sum mustBe (10000) - + val list = (1 to 100).toList val traversedList = Future.traverse(list)(x => Future(x * 2 - 1)) Await.result(traversedList, defaultTimeout).sum mustBe (10000) - + val iterator = (1 to 100).toList.iterator val traversedIterator = Future.traverse(iterator)(x => Future(x * 2 - 1)) Await.result(traversedIterator, defaultTimeout).sum mustBe (10000) } - + "shouldBlockUntilResult" in { val latch = new TestLatch - + val f = future { Await.ready(latch, 5 seconds) 5 @@ -428,28 +428,28 @@ object FutureTests extends MinimalScalaTest { val res = Await.result(f, Inf) res + 9 } - + intercept[TimeoutException] { Await.ready(f2, 100 millis) } - + latch.open() - + Await.result(f2, defaultTimeout) mustBe (14) - + val f3 = future { Thread.sleep(100) 5 } - + intercept[TimeoutException] { Await.ready(f3, 0 millis) } } - + "run callbacks async" in { val latch = Vector.fill(10)(new TestLatch) - + val f1 = future { latch(0).open() Await.ready(latch(1), TestLatch.DefaultTimeout) @@ -462,18 +462,18 @@ object FutureTests extends MinimalScalaTest { s.length } for (_ <- f2) latch(4).open() - + Await.ready(latch(0), TestLatch.DefaultTimeout) - + f1.isCompleted mustBe (false) f2.isCompleted mustBe (false) - + latch(1).open() Await.ready(latch(2), TestLatch.DefaultTimeout) - + f1.isCompleted mustBe (true) f2.isCompleted mustBe (false) - + val f3 = f1 map { s => latch(5).open() @@ -481,17 +481,17 @@ object FutureTests extends MinimalScalaTest { s.length * 2 } for (_ <- f3) latch(3).open() - + Await.ready(latch(5), TestLatch.DefaultTimeout) - + f3.isCompleted mustBe (false) - + latch(6).open() Await.ready(latch(4), TestLatch.DefaultTimeout) - + f2.isCompleted mustBe (true) f3.isCompleted mustBe (true) - + val p1 = Promise[String]() val f4 = p1.future map { s => @@ -500,23 +500,23 @@ object FutureTests extends MinimalScalaTest { s.length } for (_ <- f4) latch(9).open() - + p1.future.isCompleted mustBe (false) f4.isCompleted mustBe (false) - + p1 complete Success("Hello") - + Await.ready(latch(7), TestLatch.DefaultTimeout) - + p1.future.isCompleted mustBe (true) f4.isCompleted mustBe (false) - + latch(8).open() Await.ready(latch(9), TestLatch.DefaultTimeout) - + Await.ready(f4, defaultTimeout).isCompleted mustBe (true) } - + "should not deadlock with nested await (ticket 1313)" in { val simple = Future() map { _ => @@ -525,7 +525,7 @@ object FutureTests extends MinimalScalaTest { Await.result(umap, Inf) } Await.ready(simple, Inf).isCompleted mustBe (true) - + val l1, l2 = new TestLatch val complex = Future() map { _ => @@ -545,9 +545,9 @@ object FutureTests extends MinimalScalaTest { val f = future(5).map(_ / 0) Await.ready(f, defaultTimeout).value.get.toString mustBe expected.toString } - + } - + } diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala index 8e07393900..6e613bf3ec 100644 --- a/test/files/jvm/future-spec/PromiseTests.scala +++ b/test/files/jvm/future-spec/PromiseTests.scala @@ -13,29 +13,29 @@ object PromiseTests extends MinimalScalaTest { import ExecutionContext.Implicits._ val defaultTimeout = Inf - + /* promise specification */ - + "An empty Promise" should { - + "not be completed" in { val p = Promise() p.future.isCompleted mustBe (false) p.isCompleted mustBe (false) } - + "have no value" in { val p = Promise() p.future.value mustBe (None) p.isCompleted mustBe (false) } - + "return supplied value on timeout" in { val failure = Promise.failed[String](new RuntimeException("br0ken")).future val otherFailure = Promise.failed[String](new RuntimeException("last")).future val empty = Promise[String]().future val timedOut = Promise.successful[String]("Timedout").future - + Await.result(failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") Await.result(timedOut fallbackTo empty, defaultTimeout) mustBe ("Timedout") Await.result(failure fallbackTo failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") @@ -43,47 +43,47 @@ object PromiseTests extends MinimalScalaTest { Await.result(failure fallbackTo otherFailure, defaultTimeout) }.getMessage mustBe ("last") } - + } - + "A successful Promise" should { val result = "test value" val promise = Promise[String]().complete(Success(result)) promise.isCompleted mustBe (true) futureWithResult(_(promise.future, result)) } - + "A failed Promise" should { val message = "Expected Exception" val promise = Promise[String]().complete(Failure(new RuntimeException(message))) promise.isCompleted mustBe (true) futureWithException[RuntimeException](_(promise.future, message)) } - + "An interrupted Promise" should { val message = "Boxed InterruptedException" val future = Promise[String]().complete(Failure(new InterruptedException(message))).future futureWithException[ExecutionException](_(future, message)) } - + "A NonLocalReturnControl failed Promise" should { val result = "test value" val future = Promise[String]().complete(Failure(new NonLocalReturnControl[String]("test", result))).future futureWithResult(_(future, result)) } - + def futureWithResult(f: ((Future[Any], Any) => Unit) => Unit) { - + "be completed" in { f((future, _) => future.isCompleted mustBe (true)) } - + "contain a value" in { f((future, result) => future.value mustBe (Some(Success(result)))) } - + "return when ready with 'Await.ready'" in { f((future, result) => Await.ready(future, defaultTimeout).isCompleted mustBe (true)) } - + "return result with 'Await.result'" in { f((future, result) => Await.result(future, defaultTimeout) mustBe (result)) } - + "not timeout" in { f((future, _) => Await.ready(future, 0 millis)) } - + "filter result" in { f { (future, result) => @@ -93,16 +93,16 @@ object PromiseTests extends MinimalScalaTest { } } } - + "transform result with map" in { f((future, result) => Await.result((future map (_.toString.length)), defaultTimeout) mustBe (result.toString.length)) } - + "compose result with flatMap" in { f { (future, result) => val r = for (r <- future; p <- Promise.successful("foo").future) yield r.toString + p Await.result(r, defaultTimeout) mustBe (result.toString + "foo") } } - + "perform action with foreach" in { f { (future, result) => @@ -111,7 +111,7 @@ object PromiseTests extends MinimalScalaTest { Await.result(p.future, defaultTimeout) mustBe (result) } } - + "zip properly" in { f { (future, result) => @@ -121,9 +121,9 @@ object PromiseTests extends MinimalScalaTest { }.getMessage mustBe ("ohnoes") } } - + "not recover from exception" in { f((future, result) => Await.result(future.recover({ case _ => "pigdog" }), defaultTimeout) mustBe (result)) } - + "perform action on result" in { f { (future, result) => @@ -132,7 +132,7 @@ object PromiseTests extends MinimalScalaTest { Await.result(p.future, defaultTimeout) mustBe (result) } } - + "not project a failure" in { f { (future, result) => @@ -141,34 +141,34 @@ object PromiseTests extends MinimalScalaTest { }.getMessage mustBe ("Future.failed not completed with a throwable.") } } - + "cast using mapTo" in { f { (future, result) => Await.result(future.mapTo[Boolean].recover({ case _: ClassCastException ⇒ false }), defaultTimeout) mustBe (false) } } - + } def futureWithException[E <: Throwable: Manifest](f: ((Future[Any], String) => Unit) => Unit) { - + "be completed" in { f((future, _) => future.isCompleted mustBe (true)) } - + "contain a value" in { f((future, message) => { future.value.get.failed.get.getMessage mustBe (message) }) } - + "throw not throw exception with 'Await.ready'" in { f { (future, message) => Await.ready(future, defaultTimeout).isCompleted mustBe (true) } } - + "throw exception with 'Await.result'" in { f { (future, message) => @@ -177,7 +177,7 @@ object PromiseTests extends MinimalScalaTest { }.getMessage mustBe (message) } } - + "retain exception with filter" in { f { (future, message) => @@ -185,21 +185,21 @@ object PromiseTests extends MinimalScalaTest { intercept[E] { Await.result(future filter (_ => false), defaultTimeout) }.getMessage mustBe (message) } } - + "retain exception with map" in { f { (future, message) => intercept[E] { Await.result(future map (_.toString.length), defaultTimeout) }.getMessage mustBe (message) } } - + "retain exception with flatMap" in { f { (future, message) => intercept[E] { Await.result(future flatMap (_ => Promise.successful("foo").future), defaultTimeout) }.getMessage mustBe (message) } } - + "zip properly" in { f { (future, message) => @@ -208,18 +208,18 @@ object PromiseTests extends MinimalScalaTest { }.getMessage mustBe (message) } } - + "recover from exception" in { f { (future, message) => Await.result(future.recover({ case e if e.getMessage == message ⇒ "pigdog" }), defaultTimeout) mustBe ("pigdog") } } - + "project a failure" in { f((future, message) => Await.result(future.failed, defaultTimeout).getMessage mustBe (message)) } - + "perform action on exception" in { f { (future, message) => @@ -228,7 +228,7 @@ object PromiseTests extends MinimalScalaTest { Await.result(p.future, defaultTimeout) mustBe (message) } } - + "always cast successfully using mapTo" in { f { (future, message) => diff --git a/test/files/jvm/future-spec/main.scala b/test/files/jvm/future-spec/main.scala index 90048ccda0..132263e2e8 100644 --- a/test/files/jvm/future-spec/main.scala +++ b/test/files/jvm/future-spec/main.scala @@ -8,40 +8,46 @@ import java.util.concurrent.{ TimeoutException, CountDownLatch, TimeUnit } object Test { - + def main(args: Array[String]) { FutureTests.check() PromiseTests.check() TryTests.check() } - + +} + +trait Features { + implicit def implicitously = scala.language.implicitConversions + implicit def reflectively = scala.language.reflectiveCalls + implicit def postulously = scala.language.postfixOps } trait Output { val buffer = new StringBuilder - + def bufferPrintln(a: Any) = buffer.synchronized { buffer.append(a.toString + "\n") } } -trait MinimalScalaTest extends Output { - +trait MinimalScalaTest extends Output with Features { + val throwables = mutable.ArrayBuffer[Throwable]() - + def check() { if (throwables.nonEmpty) println(buffer.toString) } - + implicit def stringops(s: String) = new { - + def should[U](snippets: =>U) = { bufferPrintln(s + " should:") snippets } - + def in[U](snippet: =>U) = { try { bufferPrintln("- " + s) @@ -54,27 +60,27 @@ trait MinimalScalaTest extends Output { throwables += e } } - + } - + implicit def objectops(obj: Any) = new { - + def mustBe(other: Any) = assert(obj == other, obj + " is not " + other) def mustEqual(other: Any) = mustBe(other) - + } - + def intercept[T <: Throwable: Manifest](body: =>Any): T = { try { body throw new Exception("Exception of type %s was not thrown".format(manifest[T])) } catch { case t: Throwable => - if (manifest[T].erasure != t.getClass) throw t + if (manifest[T].runtimeClass != t.getClass) throw t else t.asInstanceOf[T] } } - + def checkType[T: Manifest, S](in: Future[T], refmanifest: Manifest[S]): Boolean = manifest[T] == refmanifest } @@ -88,23 +94,23 @@ object TestLatch { class TestLatch(count: Int = 1) extends Awaitable[Unit] { private var latch = new CountDownLatch(count) - + def countDown() = latch.countDown() def isOpen: Boolean = latch.getCount == 0 def open() = while (!isOpen) countDown() def reset() = latch = new CountDownLatch(count) - + @throws(classOf[TimeoutException]) def ready(atMost: Duration)(implicit permit: CanAwait) = { val opened = latch.await(atMost.toNanos, TimeUnit.NANOSECONDS) if (!opened) throw new TimeoutException("Timeout of %s." format (atMost.toString)) this } - + @throws(classOf[Exception]) def result(atMost: Duration)(implicit permit: CanAwait): Unit = { ready(atMost) } - + } diff --git a/test/files/jvm/future-termination.scala b/test/files/jvm/future-termination.scala index f51642cb7a..90ea336ce8 100644 --- a/test/files/jvm/future-termination.scala +++ b/test/files/jvm/future-termination.scala @@ -1,19 +1,21 @@ -import scala.actors.Futures - -/* Test that unevaluated futures do not prevent program termination */ - -object Test { - def main(args: Array[String]) { + +/* Test that unevaluated futures do not prevent program termination */ + + +@deprecated("Suppress warnings", since="2.11") +object Test { + import scala.actors.Futures + def main(args: Array[String]) { try { - val meaningOfLife = Futures.future { - Thread.sleep(5000) // pretend this is a harder problem than it is - println("I have the answer!") - 42 - } - println("I can't wait that long, bye.") + val meaningOfLife = Futures.future { + Thread.sleep(5000) // pretend this is a harder problem than it is + println("I have the answer!") + 42 + } + println("I can't wait that long, bye.") } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => e.printStackTrace() } - } + } } diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala index 009d52e5bc..c05e803449 100644 --- a/test/files/jvm/inner.scala +++ b/test/files/jvm/inner.scala @@ -14,7 +14,7 @@ class A { trait Itf { def method1(x: Int): Int - + trait Itf2 extends Itf { def method2: Unit } diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index 96b57c7742..6e5fada381 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> // basics scala> 3+4 @@ -301,7 +299,7 @@ scala> <a> c="c" d="dd" /></a> -res8: scala.xml.Elem = +res8: scala.xml.Elem = <a> <b c="c" d="dd"/></a> @@ -324,7 +322,7 @@ scala> """ hello there """ -res12: String = +res12: String = " hello there @@ -357,17 +355,13 @@ defined class Term scala> def f(e: Exp) = e match { // non-exhaustive warning here case _:Fact => 3 } -<console>:18: warning: match is not exhaustive! -missing combination Exp -missing combination Term - +<console>:18: warning: match may not be exhaustive. +It would fail on the following inputs: Exp(), Term() def f(e: Exp) = e match { // non-exhaustive warning here ^ f: (e: Exp)Int scala> - -scala> plusOne: (x: Int)Int res0: Int = 6 res0: String = after reset diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala index f45eb034a9..bd1851053f 100644 --- a/test/files/jvm/interpreter.scala +++ b/test/files/jvm/interpreter.scala @@ -2,7 +2,7 @@ import scala.tools.nsc._ import scala.tools.partest.ReplTest object Test extends ReplTest { - override def extraSettings = "-deprecation -Xoldpatmat" + override def extraSettings = "-deprecation" def code = <code> // basics 3+4 diff --git a/test/files/jvm/manifests-new.check b/test/files/jvm/manifests-new.check index a1ff9491cf..7b229ba679 100644 --- a/test/files/jvm/manifests-new.check +++ b/test/files/jvm/manifests-new.check @@ -31,8 +31,8 @@ x=Foo, t=TypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo x=Foo, t=TypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo x=Foo, t=TypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo -x=Test1$$anon$1, t=TypeTag[Bar[String]], k=RefinedType, s=<local Test1> -x=Test1$$anon$2, t=TypeTag[Bar[String]], k=RefinedType, s=<local Test1> +x=Test1$$anon$1, t=TypeTag[Bar[String]], k=RefinedType, s=<refinement of Bar[String]> +x=Test1$$anon$2, t=TypeTag[Bar[String]], k=RefinedType, s=<refinement of Bar[String]> ()=() true=true diff --git a/test/files/jvm/manifests-new.scala b/test/files/jvm/manifests-new.scala index f730be67bb..3937fdec69 100644 --- a/test/files/jvm/manifests-new.scala +++ b/test/files/jvm/manifests-new.scala @@ -56,7 +56,7 @@ object Test1 extends TestUtil { } object Test2 { - import scala.util.Marshal._ + import Marshal._ println("()="+load[Unit](dump(()))) println("true="+load[Boolean](dump(true))) println("a="+load[Char](dump('a'))) @@ -88,6 +88,38 @@ object Test2 { println() } +object Marshal { + import java.io._ + import scala.reflect.ClassTag + + def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = { + val ba = new ByteArrayOutputStream(512) + val out = new ObjectOutputStream(ba) + out.writeObject(t) + out.writeObject(o) + out.close() + ba.toByteArray() + } + + @throws(classOf[IOException]) + @throws(classOf[ClassCastException]) + @throws(classOf[ClassNotFoundException]) + def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = { + val in = new ObjectInputStream(new ByteArrayInputStream(buffer)) + val found = in.readObject.asInstanceOf[ClassTag[_]] + try { + found.runtimeClass.asSubclass(expected.runtimeClass) + in.readObject.asInstanceOf[A] + } catch { + case _: ClassCastException => + in.close() + throw new ClassCastException("type mismatch;"+ + "\n found : "+found+ + "\n required: "+expected) + } + } +} + trait TestUtil { import java.io._ def write[A](o: A): Array[Byte] = { diff --git a/test/files/jvm/manifests-old.scala b/test/files/jvm/manifests-old.scala index 241966fd9d..bb1928f094 100644 --- a/test/files/jvm/manifests-old.scala +++ b/test/files/jvm/manifests-old.scala @@ -55,7 +55,7 @@ object Test1 extends TestUtil { } object Test2 { - import scala.util.Marshal._ + import Marshal._ println("()="+load[Unit](dump(()))) println("true="+load[Boolean](dump(true))) println("a="+load[Char](dump('a'))) @@ -87,6 +87,38 @@ object Test2 { println() } +object Marshal { + import java.io._ + import scala.reflect.ClassTag + + def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = { + val ba = new ByteArrayOutputStream(512) + val out = new ObjectOutputStream(ba) + out.writeObject(t) + out.writeObject(o) + out.close() + ba.toByteArray() + } + + @throws(classOf[IOException]) + @throws(classOf[ClassCastException]) + @throws(classOf[ClassNotFoundException]) + def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = { + val in = new ObjectInputStream(new ByteArrayInputStream(buffer)) + val found = in.readObject.asInstanceOf[ClassTag[_]] + try { + found.runtimeClass.asSubclass(expected.runtimeClass) + in.readObject.asInstanceOf[A] + } catch { + case _: ClassCastException => + in.close() + throw new ClassCastException("type mismatch;"+ + "\n found : "+found+ + "\n required: "+expected) + } + } +} + trait TestUtil { import java.io._ def write[A](o: A): Array[Byte] = { diff --git a/test/files/jvm/methvsfield.java b/test/files/jvm/methvsfield.java index c1b2b87b48..dadc98669a 100644 --- a/test/files/jvm/methvsfield.java +++ b/test/files/jvm/methvsfield.java @@ -1,11 +1,11 @@ // This should be compiled with javac and saved // in ../lib/methvsfield.jar . -class MethVsField +class MethVsField { int three = 3; - int three() - { + int three() + { return 3; } } diff --git a/test/files/jvm/named-args-in-order.check b/test/files/jvm/named-args-in-order.check new file mode 100644 index 0000000000..29a3ba55d3 --- /dev/null +++ b/test/files/jvm/named-args-in-order.check @@ -0,0 +1,3 @@ +bytecode identical +bytecode identical +bytecode identical diff --git a/test/files/jvm/named-args-in-order/SameBytecode.scala b/test/files/jvm/named-args-in-order/SameBytecode.scala new file mode 100644 index 0000000000..c00641777e --- /dev/null +++ b/test/files/jvm/named-args-in-order/SameBytecode.scala @@ -0,0 +1,9 @@ +class SameBytecode { + def foo(a: Int, b: String) = 0 + def foo(a: Int, b: Any) = 0 + + def a = foo(0, "") + def b = foo(a = 0, "") + def c = foo(0, b = "") + def d = foo(a = 0, b = "") +}
\ No newline at end of file diff --git a/test/files/jvm/named-args-in-order/Test.scala b/test/files/jvm/named-args-in-order/Test.scala new file mode 100644 index 0000000000..36b9cbc1d1 --- /dev/null +++ b/test/files/jvm/named-args-in-order/Test.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.BytecodeTest + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("SameBytecode") + def sameAsA(meth: String) = + sameBytecode(getMethod(classNode, "a"), getMethod(classNode, meth)) + Seq("b", "c", "d").foreach(sameAsA) + } +} diff --git a/test/files/jvm/natives.scala b/test/files/jvm/natives.scala index ba868dc85e..14ee4e1c1b 100644 --- a/test/files/jvm/natives.scala +++ b/test/files/jvm/natives.scala @@ -1,16 +1,16 @@ object Test { //println("java.library.path=" + System.getProperty("java.library.path")) - + val sysWordSize = System.getProperty("sun.arch.data.model", "32") val sysType = System.getProperty("os.name") - + val libName = if (sysType == "Mac OS X") "natives" else "natives-" + sysWordSize - + System.loadLibrary(libName) @native diff --git a/test/files/jvm/non-fatal-tests.scala b/test/files/jvm/non-fatal-tests.scala index 471a9d227a..791b1d3100 100644 --- a/test/files/jvm/non-fatal-tests.scala +++ b/test/files/jvm/non-fatal-tests.scala @@ -7,16 +7,16 @@ trait NonFatalTests { Seq(new StackOverflowError, new RuntimeException, new Exception, - new Throwable) - + new Throwable, + new NotImplementedError) + //Fatals val fatals: Seq[Throwable] = Seq(new InterruptedException, new OutOfMemoryError, new LinkageError, new VirtualMachineError {}, - new Throwable with scala.util.control.ControlThrowable, - new NotImplementedError) + new Throwable with scala.util.control.ControlThrowable) def testFatalsUsingApply(): Unit = { fatals foreach { t => assert(NonFatal(t) == false) } diff --git a/test/files/jvm/nooptimise/Foo_1.flags b/test/files/jvm/nooptimise/Foo_1.flags new file mode 100644 index 0000000000..f493cf9f3f --- /dev/null +++ b/test/files/jvm/nooptimise/Foo_1.flags @@ -0,0 +1 @@ +-Ybackend:GenASM -optimise -Ynooptimise
\ No newline at end of file diff --git a/test/files/jvm/nooptimise/Foo_1.scala b/test/files/jvm/nooptimise/Foo_1.scala new file mode 100644 index 0000000000..896d5695de --- /dev/null +++ b/test/files/jvm/nooptimise/Foo_1.scala @@ -0,0 +1,8 @@ +class Foo_1 { + def foo() { + // optimization will remove this magic 3 from appearing in the source + // so -Ynooptimize should prevent that + val x = 3 + + } +} diff --git a/test/files/jvm/nooptimise/Test.scala b/test/files/jvm/nooptimise/Test.scala new file mode 100644 index 0000000000..7b7ecd6dbd --- /dev/null +++ b/test/files/jvm/nooptimise/Test.scala @@ -0,0 +1,23 @@ +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import asm.tree.InsnList +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("Foo_1") + val methodNode = getMethod(classNode, "foo") + // if optimization didn't run then + // there should be some useless instructions + // with the magic constant 3 + val expected = 1 + val got = countMagicThrees(methodNode.instructions) + assert(got == expected, s"expected $expected but got $got magic threes") + } + + def countMagicThrees(insnList: InsnList): Int = { + def isMagicThree(node: asm.tree.AbstractInsnNode): Boolean = + (node.getOpcode == asm.Opcodes.ICONST_3) + insnList.iterator.asScala.count(isMagicThree) + } +} diff --git a/test/files/jvm/opt_value_class.check b/test/files/jvm/opt_value_class.check new file mode 100644 index 0000000000..a0c18c5ca0 --- /dev/null +++ b/test/files/jvm/opt_value_class.check @@ -0,0 +1,2 @@ +[ok] <init> ()V public +[ok] unapply (Ljava/lang/Object;)Ljava/lang/String; public (Ljava/lang/Object;)Ljava/lang/String; diff --git a/test/files/jvm/opt_value_class/Value_1.scala b/test/files/jvm/opt_value_class/Value_1.scala new file mode 100644 index 0000000000..2440609b9e --- /dev/null +++ b/test/files/jvm/opt_value_class/Value_1.scala @@ -0,0 +1,28 @@ +final class Opt[+A >: Null](val value: A) extends AnyVal { + def get: A = value + def isEmpty = value == null +} +object Opt { + final val None = new Opt[Null](null) + def unapply[A >: Null](x: A): Opt[A] = if (x == null) None else Opt(x) + def empty[A >: Null] = None + def apply[A >: Null](value: A): Opt[A] = if (value == null) None else new Opt[A](value) +} + +class ValueExtract { + def unapply(x: Any): Opt[String] = x match { + case _: String => Opt("String") + case _: List[_] => Opt("List") + case _: Int => Opt("Int") + case _ => Opt.None + } +} + +class Direct { + def unapply(x: Any): String = x match { + case _: String => "String" + case _: List[_] => "List" + case _: Int => "Int" + case _ => null + } +} diff --git a/test/files/jvm/opt_value_class/test.scala b/test/files/jvm/opt_value_class/test.scala new file mode 100644 index 0000000000..7aea7deb99 --- /dev/null +++ b/test/files/jvm/opt_value_class/test.scala @@ -0,0 +1,16 @@ +import scala.tools.partest.BytecodeTest + +// import scala.tools.nsc.util.JavaClassPath +// import java.io.InputStream +// import scala.tools.asm +// import asm.ClassReader +// import asm.tree.{ClassNode, InsnList} +// import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode1 = loadClassNode("ValueExtract") + val classNode2 = loadClassNode("Direct") + sameMethodAndFieldDescriptors(classNode1, classNode2) + } +} diff --git a/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala b/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala index fa3639380d..b0506018f6 100644 --- a/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala +++ b/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala @@ -6,7 +6,7 @@ class SameBytecode { case class Foo(x: Any, y: String) - def a = + def a = Foo(1, "a") match { case Foo(_: String, y) => y } diff --git a/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala b/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala index 3a594c401e..1e4d564cdf 100644 --- a/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala +++ b/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala @@ -3,7 +3,7 @@ case class Foo(x: Any) class SameBytecode { - def a = + def a = (Foo(1): Any) match { case Foo(_: String) => } diff --git a/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala b/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala index e5db6c4dd0..c961082fa7 100644 --- a/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala +++ b/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala @@ -3,7 +3,7 @@ class SameBytecode { case class Foo(x: Int, y: String) - def a = + def a = Foo(1, "a") match { case Foo(_: Int, y) => y } diff --git a/test/files/jvm/protectedacc.scala b/test/files/jvm/protectedacc.scala index f213e0da19..89e70b90d8 100644 --- a/test/files/jvm/protectedacc.scala +++ b/test/files/jvm/protectedacc.scala @@ -16,7 +16,7 @@ object Test { val ji = new p.b.JavaInteraction(Array('a', 'b', 'c')); (new ji.Inner).m; - + (new p.b.OuterObj.Inner).m } } @@ -36,13 +36,13 @@ package p { def getA: this.type = this; } - + /** Test type members */ trait HighlighterXXX { type Node; protected def highlight(node : Node) : Unit; } - + /** Test type parameters */ abstract class PolyA[a] { protected def m(x: a): Unit; @@ -119,22 +119,22 @@ package p { val inc = meth2(1)_; Console.println("100 = " + inc("10")); - + getA.x; } } } - + trait ScalaAutoEditXXX extends HighlighterXXX { - trait NodeImpl { + trait NodeImpl { def self : Node; highlight(self); } } - + abstract class X[T] extends PolyA[T] { - trait Inner extends B { + trait Inner extends B { def self: T; def self2: Node; def getB: Inner; diff --git a/test/files/jvm/reactor-exceptionOnSend.scala b/test/files/jvm/reactor-exceptionOnSend.scala index 3d9a042131..6d79fc9d13 100644 --- a/test/files/jvm/reactor-exceptionOnSend.scala +++ b/test/files/jvm/reactor-exceptionOnSend.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.Reactor import scala.actors.Actor._ @@ -48,7 +52,6 @@ object B extends Reactor[Any] { } } -object Test { def main(args: Array[String]) { B.start() } diff --git a/test/files/jvm/reactor-producer-consumer.scala b/test/files/jvm/reactor-producer-consumer.scala index 8a6b17c3ad..ec34febe01 100644 --- a/test/files/jvm/reactor-producer-consumer.scala +++ b/test/files/jvm/reactor-producer-consumer.scala @@ -1,6 +1,8 @@ -import scala.actors.Reactor + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.Reactor case class Stop() case class Get(from: Reactor[Any]) case class Put(x: Int) diff --git a/test/files/jvm/reactor.scala b/test/files/jvm/reactor.scala index dbc9a6bdda..91ded27f07 100644 --- a/test/files/jvm/reactor.scala +++ b/test/files/jvm/reactor.scala @@ -1,3 +1,11 @@ +/** + * Ping pong example for Reactor. + * + * @author Philipp Haller + */ + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.Reactor @@ -5,19 +13,12 @@ case class Ping(from: Reactor[Any]) case object Pong case object Stop -/** - * Ping pong example for Reactor. - * - * @author Philipp Haller - */ -object Test { def main(args: Array[String]) { val pong = new PongActor val ping = new PingActor(100000, pong) ping.start pong.start } -} class PingActor(count: Int, pong: Reactor[Any]) extends Reactor[Any] { def act() { @@ -68,3 +69,4 @@ class PongActor extends Reactor[Any] { } } } +} diff --git a/test/files/jvm/replyablereactor.scala b/test/files/jvm/replyablereactor.scala index e1fabc98da..4c4e13d9ab 100644 --- a/test/files/jvm/replyablereactor.scala +++ b/test/files/jvm/replyablereactor.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.ReplyReactor class MyActor extends ReplyReactor { @@ -18,7 +22,6 @@ class MyActor extends ReplyReactor { } } -object Test { def main(args: Array[String]) { val a = new MyActor a.start() diff --git a/test/files/jvm/replyablereactor2.scala b/test/files/jvm/replyablereactor2.scala index da9e0e269e..21f33cce56 100644 --- a/test/files/jvm/replyablereactor2.scala +++ b/test/files/jvm/replyablereactor2.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors._ import scala.actors.Actor._ @@ -19,7 +23,6 @@ class MyActor extends ReplyReactor { } } -object Test { def main(args: Array[String]) { val a = new MyActor a.start() diff --git a/test/files/jvm/replyablereactor3.scala b/test/files/jvm/replyablereactor3.scala index 2c26b8a176..5810ed053f 100644 --- a/test/files/jvm/replyablereactor3.scala +++ b/test/files/jvm/replyablereactor3.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors._ import scala.actors.Actor._ @@ -19,7 +23,6 @@ class MyActor extends ReplyReactor { } } -object Test { def main(args: Array[String]) { val a = new MyActor a.start() diff --git a/test/files/jvm/replyablereactor4.scala b/test/files/jvm/replyablereactor4.scala index 8776cf63f0..95d63684dd 100644 --- a/test/files/jvm/replyablereactor4.scala +++ b/test/files/jvm/replyablereactor4.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors._ import scala.actors.Actor._ @@ -19,7 +23,6 @@ class MyActor extends ReplyReactor { } } -object Test { def main(args: Array[String]) { val a = new MyActor a.start() diff --git a/test/files/jvm/replyreactor-react-sender.scala b/test/files/jvm/replyreactor-react-sender.scala index c9884295f6..fdcea09035 100644 --- a/test/files/jvm/replyreactor-react-sender.scala +++ b/test/files/jvm/replyreactor-react-sender.scala @@ -1,7 +1,9 @@ -import scala.actors.ReplyReactor -import scala.actors.Actor._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.ReplyReactor + import scala.actors.Actor._ val NUM = 2000 diff --git a/test/files/jvm/replyreactor.scala b/test/files/jvm/replyreactor.scala index 0cecf29ec7..7512fb0eb2 100644 --- a/test/files/jvm/replyreactor.scala +++ b/test/files/jvm/replyreactor.scala @@ -1,6 +1,8 @@ -import scala.actors.ReplyReactor + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.ReplyReactor def main(args: Array[String]) { val a = new ReplyReactor { def act() { diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index 6e2b8ca033..5006793084 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -38,12 +38,12 @@ trait FutureCallbacks extends TestBase { val f = future { x = 1 } f onSuccess { case _ => done(x == 1) } } - + def testOnSuccessWhenCompleted(): Unit = once { done => var x = 0 val f = future { x = 1 } - f onSuccess { + f onSuccess { case _ if x == 1 => x = 2 f onSuccess { case _ => done(x == 2) } @@ -56,7 +56,7 @@ trait FutureCallbacks extends TestBase { f onSuccess { case _ => done(false) } f onFailure { case _ => done(true) } } - + def testOnFailure(): Unit = once { done => val f = future[Unit] { throw new Exception } @@ -73,7 +73,7 @@ trait FutureCallbacks extends TestBase { case _ => done(false) } } - + def testOnFailureWhenTimeoutException(): Unit = once { done => val f = future[Unit] { throw new TimeoutException() } @@ -89,7 +89,7 @@ trait FutureCallbacks extends TestBase { (0 to 10000).map(Future(_)).foldLeft(promise.future)((f1, f2) => f2.flatMap(i => f1)) promise.success(-1) } - + testOnSuccess() testOnSuccessWhenCompleted() testOnSuccessWhenFailed() @@ -236,7 +236,7 @@ def testTransformFailure(): Unit = once { val f = future[Int] { 5 } f foreach { x => p.success(x * 2) } val g = p.future - + g.onSuccess { case res: Int => done(res == 10) } g.onFailure { case _ => done(false) } } @@ -248,7 +248,7 @@ def testTransformFailure(): Unit = once { f foreach { x => p.success(x * 2) } f onFailure { case _ => p.failure(new Exception) } val g = p.future - + g.onSuccess { case _ => done(false) } g.onFailure { case _ => done(true) } } @@ -276,7 +276,7 @@ def testTransformFailure(): Unit = once { f onSuccess { case _ => done(false) } f onFailure { case any => done(any == cause) } } - + def testRecoverWithSuccess(): Unit = once { done => val cause = new RuntimeException @@ -302,7 +302,7 @@ def testTransformFailure(): Unit = once { f onSuccess { case x => done(false) } f onFailure { case any => done(any == cause) } } - + def testZipSuccess(): Unit = once { done => val f = future { 5 } @@ -388,14 +388,14 @@ trait FutureProjections extends TestBase { case Failure(t) => done(false) } } - + def testFailedFailureOnSuccess(): Unit = once { done => val cause = new RuntimeException val f = future { throw cause } f.failed onSuccess { case t => done(t == cause) } } - + def testFailedSuccessOnComplete(): Unit = once { done => val f = future { 0 } @@ -404,7 +404,7 @@ trait FutureProjections extends TestBase { case _ => done(false) } } - + def testFailedSuccessOnFailure(): Unit = once { done => val f = future { 0 } @@ -414,14 +414,14 @@ trait FutureProjections extends TestBase { } f.failed onSuccess { case _ => done(false) } } - + def testFailedFailureAwait(): Unit = once { done => val cause = new RuntimeException val f = future { throw cause } done(Await.result(f.failed, Duration(500, "ms")) == cause) } - + def testFailedSuccessAwait(): Unit = once { done => val f = future { 0 } @@ -456,7 +456,7 @@ trait FutureProjections extends TestBase { done(true) } onFailure { case x => done(throw x) } } - + testFailedFailureOnComplete() testFailedFailureOnSuccess() testFailedSuccessOnComplete() @@ -476,7 +476,7 @@ trait Blocking extends TestBase { val f = future { 0 } done(Await.result(f, Duration(500, "ms")) == 0) } - + def testAwaitFailure(): Unit = once { done => val cause = new RuntimeException @@ -488,13 +488,13 @@ trait Blocking extends TestBase { case t: Throwable => done(t == cause) } } - + def testFQCNForAwaitAPI(): Unit = once { done => - done(classOf[CanAwait].getName == "scala.concurrent.CanAwait" && + done(classOf[CanAwait].getName == "scala.concurrent.CanAwait" && Await.getClass.getName == "scala.concurrent.Await") } - + testAwaitSuccess() testAwaitFailure() testFQCNForAwaitAPI() @@ -564,10 +564,10 @@ trait Promises extends TestBase { done => val p = promise[Int]() val f = p.future - + f onSuccess { case x => done(x == 5) } f onFailure { case any => done(false) } - + p.success(5) } @@ -576,10 +576,10 @@ trait Promises extends TestBase { val e = new Exception("expected") val p = promise[Int]() val f = p.future - + f onSuccess { case x => done(false) } f onFailure { case any => done(any eq e) } - + p.failure(e) } @@ -715,13 +715,13 @@ trait ExecutionContextPrepare extends TestBase { val theLocal = new ThreadLocal[String] { override protected def initialValue(): String = "" } - + class PreparingExecutionContext extends ExecutionContext { def delegate = ExecutionContext.global - + override def execute(runnable: Runnable): Unit = delegate.execute(runnable) - + override def prepare(): ExecutionContext = { // save object stored in ThreadLocal storage val localData = theLocal.get @@ -739,27 +739,27 @@ trait ExecutionContextPrepare extends TestBase { } } } - + override def reportFailure(t: Throwable): Unit = delegate.reportFailure(t) } - + implicit val ec = new PreparingExecutionContext - + def testOnComplete(): Unit = once { done => theLocal.set("secret") val fut = future { 42 } fut onComplete { case _ => done(theLocal.get == "secret") } } - + def testMap(): Unit = once { done => theLocal.set("secret2") val fut = future { 42 } fut map { x => done(theLocal.get == "secret2") } } - + testOnComplete() testMap() } diff --git a/test/files/jvm/scheduler-adapter.scala b/test/files/jvm/scheduler-adapter.scala index d6a8a446a0..1c9cfe7019 100644 --- a/test/files/jvm/scheduler-adapter.scala +++ b/test/files/jvm/scheduler-adapter.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.{Actor, SchedulerAdapter} trait AdaptedActor extends Actor { @@ -36,7 +40,6 @@ object Two extends AdaptedActor { } } -object Test { val adapted = new SchedulerAdapter { def execute(block: => Unit) { diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check index f886cfe29c..e2d2e4aee6 100644 --- a/test/files/jvm/serialization-new.check +++ b/test/files/jvm/serialization-new.check @@ -220,60 +220,6 @@ x = TrieMap(1 -> one, 2 -> two, 3 -> three) y = TrieMap(1 -> one, 2 -> two, 3 -> three) x equals y: true, y equals x: true -x = xml:src="hello" -y = xml:src="hello" -x equals y: true, y equals x: true - -x = <title></title> -y = <title></title> -x equals y: true, y equals x: true - -x = <html><title>title</title><body></body></html> -y = <html><title>title</title><body></body></html> -x equals y: true, y equals x: true - -x = <html> - <body> - <table cellpadding="2" cellspacing="0"> - <tr> - <th>Last Name</th> - <th>First Name</th> - </tr> - <tr> - <td> Tom </td> - <td> 20 </td> - </tr><tr> - <td> Bob </td> - <td> 22 </td> - </tr><tr> - <td> James </td> - <td> 19 </td> - </tr> - </table> - </body> - </html> -y = <html> - <body> - <table cellpadding="2" cellspacing="0"> - <tr> - <th>Last Name</th> - <th>First Name</th> - </tr> - <tr> - <td> Tom </td> - <td> 20 </td> - </tr><tr> - <td> Bob </td> - <td> 22 </td> - </tr><tr> - <td> James </td> - <td> 19 </td> - </tr> - </table> - </body> - </html> -x equals y: true, y equals x: true - x = Tim y = Tim x equals y: true, y equals x: true diff --git a/test/files/jvm/serialization-new.scala b/test/files/jvm/serialization-new.scala index 1522fc8e27..1b5e856645 100644 --- a/test/files/jvm/serialization-new.scala +++ b/test/files/jvm/serialization-new.scala @@ -419,70 +419,6 @@ object Test3_mutable { } } - -//############################################################################ -// Test classes in package "scala.xml" - -object Test4_xml { - import scala.xml.{Attribute, Document, Elem, Null, PrefixedAttribute, Text} - - case class Person(name: String, age: Int) - - try { - // Attribute - val a1 = new PrefixedAttribute("xml", "src", Text("hello"), Null) - val _a1: Attribute = read(write(a1)) - check(a1, _a1) - - // Document - val d1 = new Document - d1.docElem = <title></title> - d1.encoding = Some("UTF-8") - val _d1: Document = read(write(d1)) - check(d1, _d1) - - // Elem - val e1 = <html><title>title</title><body></body></html>; - val _e1: Elem = read(write(e1)) - check(e1, _e1) - - class AddressBook(a: Person*) { - private val people: List[Person] = a.toList - def toXHTML = - <table cellpadding="2" cellspacing="0"> - <tr> - <th>Last Name</th> - <th>First Name</th> - </tr> - { for (p <- people) yield - <tr> - <td> { p.name } </td> - <td> { p.age.toString() } </td> - </tr> } - </table>; - } - - val people = new AddressBook( - Person("Tom", 20), - Person("Bob", 22), - Person("James", 19)) - - val e2 = - <html> - <body> - { people.toXHTML } - </body> - </html>; - val _e2: Elem = read(write(e2)) - check(e2, _e2) - } - catch { - case e: Exception => - println("Error in Test4_xml: " + e) - throw e - } -} - //############################################################################ // Test user-defined classes WITHOUT nesting @@ -594,11 +530,10 @@ object Test8 { // Test code object Test { - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { Test1_scala Test2_immutable Test3_mutable - Test4_xml Test5 Test6 Test7 diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index f886cfe29c..e2d2e4aee6 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -220,60 +220,6 @@ x = TrieMap(1 -> one, 2 -> two, 3 -> three) y = TrieMap(1 -> one, 2 -> two, 3 -> three) x equals y: true, y equals x: true -x = xml:src="hello" -y = xml:src="hello" -x equals y: true, y equals x: true - -x = <title></title> -y = <title></title> -x equals y: true, y equals x: true - -x = <html><title>title</title><body></body></html> -y = <html><title>title</title><body></body></html> -x equals y: true, y equals x: true - -x = <html> - <body> - <table cellpadding="2" cellspacing="0"> - <tr> - <th>Last Name</th> - <th>First Name</th> - </tr> - <tr> - <td> Tom </td> - <td> 20 </td> - </tr><tr> - <td> Bob </td> - <td> 22 </td> - </tr><tr> - <td> James </td> - <td> 19 </td> - </tr> - </table> - </body> - </html> -y = <html> - <body> - <table cellpadding="2" cellspacing="0"> - <tr> - <th>Last Name</th> - <th>First Name</th> - </tr> - <tr> - <td> Tom </td> - <td> 20 </td> - </tr><tr> - <td> Bob </td> - <td> 22 </td> - </tr><tr> - <td> James </td> - <td> 19 </td> - </tr> - </table> - </body> - </html> -x equals y: true, y equals x: true - x = Tim y = Tim x equals y: true, y equals x: true diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala index 34b64938b4..bc61235267 100644 --- a/test/files/jvm/serialization.scala +++ b/test/files/jvm/serialization.scala @@ -281,6 +281,7 @@ object Test2_immutable { //############################################################################ // Test classes in package "scala.collection.mutable" +@deprecated("Suppress warnings", since="2.11") object Test3_mutable { import scala.reflect.ClassManifest import scala.collection.mutable.{ @@ -296,7 +297,7 @@ object Test3_mutable { ab1 ++= List("one", "two") val _ab1: ArrayBuffer[String] = read(write(ab1)) check(ab1, _ab1) - + // ArrayBuilder val abu1 = ArrayBuilder.make[Long] val _abu1: ArrayBuilder[ClassManifest[Long]] = read(write(abu1)) @@ -305,12 +306,12 @@ object Test3_mutable { val abu2 = ArrayBuilder.make[Float] val _abu2: ArrayBuilder[ClassManifest[Float]] = read(write(abu2)) check(abu2, _abu2) - + // ArraySeq val aq1 = ArraySeq(1, 2, 3) val _aq1: ArraySeq[Int] = read(write(aq1)) check(aq1, _aq1) - + // ArrayStack val as1 = new ArrayStack[Int] as1 ++= List(20, 2, 3).iterator @@ -401,12 +402,12 @@ object Test3_mutable { val wa1 = WrappedArray.make(Array(1, 2, 3)) val _wa1: WrappedArray[Int] = read(write(wa1)) check(wa1, _wa1) - + // TreeSet val ts1 = TreeSet[Int]() ++= Array(1, 2, 3) val _ts1: TreeSet[Int] = read(write(ts1)) check(ts1, _ts1) - + // concurrent.TrieMap val ct1 = TrieMap[Int, String]() ++= Array(1 -> "one", 2 -> "two", 3 -> "three") val _ct1: TrieMap[Int, String] = read(write(ct1)) @@ -419,70 +420,6 @@ object Test3_mutable { } } - -//############################################################################ -// Test classes in package "scala.xml" - -object Test4_xml { - import scala.xml.{Attribute, Document, Elem, Null, PrefixedAttribute, Text} - - case class Person(name: String, age: Int) - - try { - // Attribute - val a1 = new PrefixedAttribute("xml", "src", Text("hello"), Null) - val _a1: Attribute = read(write(a1)) - check(a1, _a1) - - // Document - val d1 = new Document - d1.docElem = <title></title> - d1.encoding = Some("UTF-8") - val _d1: Document = read(write(d1)) - check(d1, _d1) - - // Elem - val e1 = <html><title>title</title><body></body></html>; - val _e1: Elem = read(write(e1)) - check(e1, _e1) - - class AddressBook(a: Person*) { - private val people: List[Person] = a.toList - def toXHTML = - <table cellpadding="2" cellspacing="0"> - <tr> - <th>Last Name</th> - <th>First Name</th> - </tr> - { for (p <- people) yield - <tr> - <td> { p.name } </td> - <td> { p.age.toString() } </td> - </tr> } - </table>; - } - - val people = new AddressBook( - Person("Tom", 20), - Person("Bob", 22), - Person("James", 19)) - - val e2 = - <html> - <body> - { people.toXHTML } - </body> - </html>; - val _e2: Elem = read(write(e2)) - check(e2, _e2) - } - catch { - case e: Exception => - println("Error in Test4_xml: " + e) - throw e - } -} - //############################################################################ // Test user-defined classes WITHOUT nesting @@ -568,7 +505,7 @@ class WithTransient extends Serializable { @transient private lazy val a2 = 2 @transient object B extends Serializable @transient private object C extends Serializable - + def test = { println(a1) println(a2) @@ -593,17 +530,18 @@ object Test8 { //############################################################################ // Test code +@deprecated("Suppress warnings", since="2.11") object Test { def main(args: Array[String]) { Test1_scala Test2_immutable Test3_mutable - Test4_xml Test5 Test6 Test7 Test8 Test9_parallel + Test10_util } } @@ -614,58 +552,72 @@ object Test { // Test classes in package "scala.collection.parallel" and subpackages object Test9_parallel { import scala.collection.parallel._ - + try { println() - + // UnrolledBuffer val ub = new collection.mutable.UnrolledBuffer[String] ub ++= List("one", "two") val _ub: collection.mutable.UnrolledBuffer[String] = read(write(ub)) check(ub, _ub) - + // mutable.ParArray val pa = mutable.ParArray("abc", "def", "etc") val _pa: mutable.ParArray[String] = read(write(pa)) check(pa, _pa) - + // mutable.ParHashMap val mpm = mutable.ParHashMap(1 -> 2, 2 -> 4) val _mpm: mutable.ParHashMap[Int, Int] = read(write(mpm)) check(mpm, _mpm) - + // mutable.ParTrieMap val mpc = mutable.ParTrieMap(1 -> 2, 2 -> 4) val _mpc: mutable.ParTrieMap[Int, Int] = read(write(mpc)) check(mpc, _mpc) - + // mutable.ParHashSet val mps = mutable.ParHashSet(1, 2, 3) val _mps: mutable.ParHashSet[Int] = read(write(mps)) check(mps, _mps) - + // immutable.ParRange val pr1 = immutable.ParRange(0, 4, 1, true) val _pr1: immutable.ParRange = read(write(pr1)) check(pr1, _pr1) - + val pr2 = immutable.ParRange(0, 4, 1, false) val _pr2: immutable.ParRange = read(write(pr2)) check(pr2, _pr2) - + // immutable.ParHashMap val ipm = immutable.ParHashMap(5 -> 1, 10 -> 2) val _ipm: immutable.ParHashMap[Int, Int] = read(write(ipm)) check(ipm, _ipm) - + // immutable.ParHashSet val ips = immutable.ParHashSet("one", "two") val _ips: immutable.ParHashSet[String] = read(write(ips)) check(ips, _ips) - + } catch { case e: Exception => println("Error in Test5_parallel: " + e) throw e } } + +//############################################################################ +// Test classes in package scala.util + +object Test10_util { + import scala.util.Random + def rep[A](n: Int)(f: => A) { if (n > 0) { f; rep(n-1)(f) } } + + { + val random = new Random(345) + val random2: Random = read(write(random)) + rep(5) { assert(random.nextInt == random2.nextInt) } + } +} diff --git a/test/files/jvm/si5471.scala b/test/files/jvm/si5471.scala index 2c8c4205c5..2efd869b61 100644 --- a/test/files/jvm/si5471.scala +++ b/test/files/jvm/si5471.scala @@ -4,12 +4,12 @@ object Test { def main(args: Array[String]) { import scala.math.Numeric import scala.math.Numeric.Implicits._ - + val b = BigInt(Long.MaxValue) + 1 def dbl[N :Numeric](n: N) = n.toDouble def flt[N :Numeric](n: N) = n.toFloat - + println(dbl(b) == b.toDouble) println(flt(b) == b.toFloat) } diff --git a/test/files/jvm/stringbuilder.scala b/test/files/jvm/stringbuilder.scala index 54951d657b..1fbf61aeab 100644 --- a/test/files/jvm/stringbuilder.scala +++ b/test/files/jvm/stringbuilder.scala @@ -2,6 +2,7 @@ * * @author Stephane Micheloud */ +import scala.language.{ postfixOps } object Test { def main(args: Array[String]) { Test1.run() //ctor, reverse diff --git a/test/files/jvm/t0632.check b/test/files/jvm/t0632.check deleted file mode 100755 index 681bc9da92..0000000000 --- a/test/files/jvm/t0632.check +++ /dev/null @@ -1,12 +0,0 @@ -<foo x="&"/> -<foo x="&"/> -<foo x="&"/> -<foo x="&"/> -<foo x="&amp;"/> -<foo x="&amp;"/> -<foo x="&amp;"/> -<foo x="&amp;"/> -<foo x="&&"/> -<foo x="&&"/> -<foo x="&&"/> -<foo x="&&"/> diff --git a/test/files/jvm/t0632.scala b/test/files/jvm/t0632.scala deleted file mode 100644 index a2bb5aa7f4..0000000000 --- a/test/files/jvm/t0632.scala +++ /dev/null @@ -1,22 +0,0 @@ -object Test { -import scala.io.Source.fromString -import scala.xml.parsing.ConstructingParser.fromSource -import scala.xml.TopScope - def parse(s:String) = fromSource(fromString(s), false).element(TopScope) - def main(argv : Array[String]) : Unit = { - - println(parse("<foo x='&'/>")) - println(xml.XML.loadString("<foo x='&'/>")) - println(<foo x="&"/>) - println(<foo x={ "&" }/>) - - println(xml.XML.loadString("<foo x='&amp;'/>")) - println(parse("<foo x='&amp;'/>")) - println(<foo x="&amp;"/>) - println(<foo x={ "&" }/>) - println(xml.XML.loadString("<foo x='&&'/>")) - println(parse("<foo x='&&'/>")) - println(<foo x="&&"/>) - println(<foo x={ "&&" }/>) - } -} diff --git a/test/files/jvm/t1118.check b/test/files/jvm/t1118.check deleted file mode 100755 index d676b413c9..0000000000 --- a/test/files/jvm/t1118.check +++ /dev/null @@ -1,11 +0,0 @@ - -<hi/> <!-- literal short --> -<there></there> <!-- literal long --> -<guys who="you all"></guys> <!-- literal long with attribute--> -<hows it="going"/> <!-- literal short with attribute --> -<this>is pretty cool</this> <!-- literal not empty --> - -<emptiness></emptiness> <!--programmatic long--> -<vide/> <!--programmatic short--> -<elem attr="value"/> <!--programmatic short with attribute--> -<elem2 attr2="value2"></elem2> <!--programmatic long with attribute--> diff --git a/test/files/jvm/t1118.scala b/test/files/jvm/t1118.scala deleted file mode 100755 index 3c86547241..0000000000 --- a/test/files/jvm/t1118.scala +++ /dev/null @@ -1,21 +0,0 @@ -import scala.xml._ - -object Test { - def main(args: Array[String]) { - println(<xml:group> -<hi/> <!-- literal short --> -<there></there> <!-- literal long --> -<guys who="you all"></guys> <!-- literal long with attribute--> -<hows it="going"/> <!-- literal short with attribute --> -<this>is pretty cool</this> <!-- literal not empty --> -</xml:group>) - - println(Elem(null, "emptiness", Null, TopScope, false) ++ Text(" ") ++ Comment("programmatic long")) - - println(Elem(null, "vide", Null, TopScope, true) ++ Text(" ") ++ Comment("programmatic short")) - - println(Elem(null, "elem", Attribute("attr", Text("value"), Null), TopScope, true) ++ Text(" ") ++ Comment ("programmatic short with attribute")) - - println(Elem(null, "elem2", Attribute("attr2", Text("value2"), Null), TopScope, false) ++ Text(" ") ++ Comment ("programmatic long with attribute")) - } -}
\ No newline at end of file diff --git a/test/files/jvm/t1143-2/t1143-2.scala b/test/files/jvm/t1143-2/t1143-2.scala index 44b1febd8b..13ab13b48c 100644 --- a/test/files/jvm/t1143-2/t1143-2.scala +++ b/test/files/jvm/t1143-2/t1143-2.scala @@ -16,43 +16,39 @@ object Serialize { } } -@serializable @SerialVersionUID(1L) -class VarModel[T]( getter: => T, setter: T => Unit ) -{ +class VarModel[T](getter: => T, setter: T => Unit) extends Serializable { Serialize.write(getter) Serialize.write(setter) - def this( getter: => T ) = this( getter, null ) + def this(getter: => T) = this(getter, null) def getObject: AnyRef = getter.asInstanceOf[AnyRef] - def setObject( v: AnyRef ) = { - if( setter==null ) - throw new RuntimeException( "Tried to set readonly model!") - setter( v.asInstanceOf[T] ) + def setObject(v: AnyRef) = { + if(setter==null) + throw new RuntimeException("Tried to set readonly model!") + setter(v.asInstanceOf[T]) } def detach = () } -@serializable @SerialVersionUID(1L) -class Printer( p: VarModel[String] ) { - def print = println( p.getObject ); +class Printer(p: VarModel[String]) extends Serializable { + def print = println(p.getObject) } class Component extends Marker { } class Form extends Component { } -@serializable @SerialVersionUID(1L) -class Main { +class Main extends Serializable { var pass = "pass" - def main(args : Array[String]) : Unit = { + def main(args: Array[String]): Unit = { val f = new Form { - val p = new Printer( new VarModel( pass, s => pass = s ) ); + val p = new Printer(new VarModel(pass, s => pass = s)) p.print } () diff --git a/test/files/jvm/t1143.scala b/test/files/jvm/t1143.scala index 7dd374f432..eb03c7224e 100644 --- a/test/files/jvm/t1143.scala +++ b/test/files/jvm/t1143.scala @@ -16,9 +16,8 @@ object Serialize { } } -@serializable @SerialVersionUID(1L) -class VarModel[T](getter: => T, setter: T => Unit) { +class VarModel[T](getter: => T, setter: T => Unit) extends Serializable { Serialize.write(getter) Serialize.write(setter) @@ -35,23 +34,20 @@ class VarModel[T](getter: => T, setter: T => Unit) { def detach = () } -@serializable @SerialVersionUID(1L) -class Printer(p: VarModel[String]) { +class Printer(p: VarModel[String]) extends Serializable { def print = println(p.getObject) } -@serializable @SerialVersionUID(1L) -class Component { +class Component extends Serializable { } class Form extends Component { } -@serializable @SerialVersionUID(1L) -class Main { +class Main extends Serializable { var pass = "pass" def main(args: Array[String]) { val f = new Form { diff --git a/test/files/jvm/t1342/SI.scala b/test/files/jvm/t1342/SI.scala index 8e3b753210..7c37d4bcd7 100644 --- a/test/files/jvm/t1342/SI.scala +++ b/test/files/jvm/t1342/SI.scala @@ -4,7 +4,7 @@ class SI extends JI { } } -object Test extends Application { +object Test extends App { val x: JI = new SI x.varArgsMethod("one", "two") } diff --git a/test/files/jvm/t1449.scala b/test/files/jvm/t1449.scala index 3822cf7dd5..7917d6f6d5 100644 --- a/test/files/jvm/t1449.scala +++ b/test/files/jvm/t1449.scala @@ -1,7 +1,10 @@ -import scala.actors.Actor._ -import scala.actors.Future -import scala.actors.Futures._ + + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.Actor._ + import scala.actors.Future + import scala.actors.Futures._ def main(args: Array[String]) { val a = actor { try { diff --git a/test/files/jvm/t1461.scala b/test/files/jvm/t1461.scala index a963ec6a12..f0e3cea6cd 100644 --- a/test/files/jvm/t1461.scala +++ b/test/files/jvm/t1461.scala @@ -3,7 +3,7 @@ object Test { def main(args: Array[String]) { val jl = classOf[Foo].getMethod("jl", classOf[Baz[_]]) jl.getGenericParameterTypes // works fine - + val l = classOf[Foo].getMethod("l", classOf[Baz[_]]) // By debugger inspection l.signature is (Ltest/Baz<J>;)V l.getGenericParameterTypes // throws GenericSignatureFormatError diff --git a/test/files/jvm/t1464/MyTrait.scala b/test/files/jvm/t1464/MyTrait.scala index 014ddf86c3..0b8ccc412b 100644 --- a/test/files/jvm/t1464/MyTrait.scala +++ b/test/files/jvm/t1464/MyTrait.scala @@ -1,5 +1,5 @@ trait MyTrait { type K def findChildByClass[T <: K with MyTrait]: Unit - + } diff --git a/test/files/jvm/t1600.scala b/test/files/jvm/t1600.scala index 7e23687425..5a1b2900c5 100644 --- a/test/files/jvm/t1600.scala +++ b/test/files/jvm/t1600.scala @@ -4,23 +4,23 @@ * changes on deserialization. */ object Test { - + import collection._ def main(args: Array[String]) { for (i <- Seq(0, 1, 2, 10, 100)) { def entries = (0 until i).map(i => (new Foo, i)).toList def elements = entries.map(_._1) - + val maps = Seq[Map[Foo, Int]](new mutable.HashMap, new mutable.LinkedHashMap, immutable.HashMap.empty).map(_ ++ entries) test[Map[Foo, Int]](maps, entries.size, assertMap _) - + val sets = Seq[Set[Foo]](new mutable.HashSet, new mutable.LinkedHashSet, immutable.HashSet.empty).map(_ ++ elements) test[Set[Foo]](sets, entries.size, assertSet _) } } - + private def test[A <: AnyRef](collections: Seq[A], expectedSize: Int, assertFunction: (A, Int) => Unit) { for (collection <- collections) { assertFunction(collection, expectedSize) @@ -28,19 +28,19 @@ object Test { val bytes = toBytes(collection) Foo.hashCodeModifier = 1 val deserializedCollection = toObject[A](bytes) - + assertFunction(deserializedCollection, expectedSize) assert(deserializedCollection.getClass == collection.getClass, "collection class should remain the same after deserialization ("+deserializedCollection.getClass+" != "+collection.getClass+")") Foo.hashCodeModifier = 0 } } - + private def toObject[A](bytes: Array[Byte]): A = { val in = new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(bytes)) in.readObject.asInstanceOf[A] } - + private def toBytes(o: AnyRef): Array[Byte] = { val bos = new java.io.ByteArrayOutputStream val out = new java.io.ObjectOutputStream(bos) @@ -48,7 +48,7 @@ object Test { out.close bos.toByteArray } - + private def assertMap[A, B](map: Map[A, B], expectedSize: Int) { assert(expectedSize == map.size, "expected map size: " + expectedSize + ", actual size: " + map.size) map.foreach { case (k, v) => @@ -56,21 +56,20 @@ object Test { assert(map(k) == v) } } - + private def assertSet[A](set: Set[A], expectedSize: Int) { assert(expectedSize == set.size, "expected set size: " + expectedSize + ", actual size: " + set.size) set.foreach { e => assert(set.contains(e), "contains should return true for element in the set, element: " + e) } } - + object Foo { - /* Used to simulate a hashCode change caused by deserializing an instance with an + /* Used to simulate a hashCode change caused by deserializing an instance with an * identity-based hashCode in another JVM. */ var hashCodeModifier = 0 } - - @serializable - class Foo { + + class Foo extends Serializable { override def hashCode = System.identityHashCode(this) + Foo.hashCodeModifier } } diff --git a/test/files/jvm/t1948.scala b/test/files/jvm/t1948.scala index 084c956398..95777b8037 100644 --- a/test/files/jvm/t1948.scala +++ b/test/files/jvm/t1948.scala @@ -1,7 +1,9 @@ -import scala.actors._ -import scala.actors.Actor._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors._ + import scala.actors.Actor._ def main (args: Array[String]) { val actors = (1 to 1000).toList map { x => actor { diff --git a/test/files/jvm/ticket2163/ticket2163.java b/test/files/jvm/t2163/t2163.java index b6511d241c..83bd37d212 100644 --- a/test/files/jvm/ticket2163/ticket2163.java +++ b/test/files/jvm/t2163/t2163.java @@ -1,9 +1,9 @@ import java.util.*; -public class ticket2163 { +public class t2163 { public void test() { List<Integer> array = new ArrayList<Integer>(); - Ticket2163Scala<List> foo = new Ticket2163Scala<List>(array); + T2163Scala<List> foo = new T2163Scala<List>(array); foo.bar(array); } } diff --git a/test/files/jvm/t2163/t2163.scala b/test/files/jvm/t2163/t2163.scala new file mode 100644 index 0000000000..fdf19c4e25 --- /dev/null +++ b/test/files/jvm/t2163/t2163.scala @@ -0,0 +1,10 @@ + +import scala.language.{ higherKinds } + +class T2163Scala[CC[X]](x: CC[Int]) { + def bar[DD[X]](meh: DD[Int]): CC[Int] = x +} + +object Test extends App { + new t2163().test() +} diff --git a/test/files/jvm/t2359.scala b/test/files/jvm/t2359.scala index 69c69d7b3b..76b78d44f7 100644 --- a/test/files/jvm/t2359.scala +++ b/test/files/jvm/t2359.scala @@ -1,6 +1,8 @@ -import scala.actors.Futures._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.Futures._ def main(args: Array[String]) { val x = future { try { diff --git a/test/files/jvm/t2470.cmds b/test/files/jvm/t2470.cmds deleted file mode 100644 index b4ef0f4aeb..0000000000 --- a/test/files/jvm/t2470.cmds +++ /dev/null @@ -1,3 +0,0 @@ -javac Action.java Task.java -scalac Test_1.scala -scalac Read_Classfile_2.scala diff --git a/test/files/jvm/t2530.scala b/test/files/jvm/t2530.scala index c2925a92d1..b41661e623 100644 --- a/test/files/jvm/t2530.scala +++ b/test/files/jvm/t2530.scala @@ -1,6 +1,8 @@ -import scala.actors.{Future, Futures} + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.{Future, Futures} def main(args:Array[String]) : Unit = { //scala.actors.Debug.level = 3 @@ -29,7 +31,6 @@ object Test { } println("Test done with no deadlock. Try again, it will not occur...") } -} case class Matrix(numRows: Int, numCols: Int, values: Array[Double]) { @@ -94,3 +95,4 @@ case class Matrix(numRows: Int, numCols: Int, values: Array[Double]) { } } +} diff --git a/test/files/jvm/t2570/Test.scala b/test/files/jvm/t2570/Test.scala index 7944aedae6..ad4d29dd7f 100644 --- a/test/files/jvm/t2570/Test.scala +++ b/test/files/jvm/t2570/Test.scala @@ -1,3 +1,3 @@ class Test2 extends Test1[Test3[Test4]] class Test4 -object Test extends Application {}
\ No newline at end of file +object Test extends App {}
\ No newline at end of file diff --git a/test/files/jvm/t3003.cmds b/test/files/jvm/t3003.cmds deleted file mode 100644 index c00396627c..0000000000 --- a/test/files/jvm/t3003.cmds +++ /dev/null @@ -1,2 +0,0 @@ -javac Annot.java -scalac Test_1.scala diff --git a/test/files/jvm/t3003/Test_1.scala b/test/files/jvm/t3003/Test_1.scala index 38af66a25a..8ec08bebc6 100644 --- a/test/files/jvm/t3003/Test_1.scala +++ b/test/files/jvm/t3003/Test_1.scala @@ -9,7 +9,7 @@ object Test { . map(f => f.getAnnotations.toList) . filterNot (_.isEmpty) // there are extra fields under -Xcheckinit ) - + println(xs) } } diff --git a/test/files/jvm/t3102.scala b/test/files/jvm/t3102.scala index fbcf2e60e6..d0e0704859 100644 --- a/test/files/jvm/t3102.scala +++ b/test/files/jvm/t3102.scala @@ -1,7 +1,10 @@ -import scala.actors.{Actor, TIMEOUT} -import Actor._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.{Actor, TIMEOUT} + import Actor._ + def main(args: Array[String]) { val a = actor { try { diff --git a/test/files/jvm/t3356.scala b/test/files/jvm/t3356.scala index a9e83fe503..53bfd737cd 100644 --- a/test/files/jvm/t3356.scala +++ b/test/files/jvm/t3356.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.{Actor, Exit, !, UncaughtException} import Actor._ @@ -10,7 +14,6 @@ case class ImageInfo(text: String) { case class ImageData(text: String) case class Download(info: ImageInfo) -object Test { def scanForImageInfo(url: String): List[ImageInfo] = List(ImageInfo("A"), ImageInfo("B")) diff --git a/test/files/jvm/t3365.scala b/test/files/jvm/t3365.scala index b94e804e63..8321428093 100644 --- a/test/files/jvm/t3365.scala +++ b/test/files/jvm/t3365.scala @@ -1,3 +1,7 @@ + + +@deprecated("Suppress warnings", since="2.11") +object Test { import scala.actors.{ReplyReactor, Channel, Actor, Future} case class ChannelMsg(chan: Channel[Any]) @@ -27,7 +31,6 @@ class MyActor extends Actor { } } -object Test { def main(args: Array[String]) { val a = new MyActor a.start() diff --git a/test/files/jvm/t3407.scala b/test/files/jvm/t3407.scala index 6c2ce85c71..757fa3a438 100644 --- a/test/files/jvm/t3407.scala +++ b/test/files/jvm/t3407.scala @@ -1,6 +1,8 @@ -import scala.actors._, scala.actors.Actor._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors._, scala.actors.Actor._ def main(args: Array[String]) { for (i <- 1 to 10) { diff --git a/test/files/jvm/t3412-channel.scala b/test/files/jvm/t3412-channel.scala index fcc439b488..af319d2303 100644 --- a/test/files/jvm/t3412-channel.scala +++ b/test/files/jvm/t3412-channel.scala @@ -1,6 +1,8 @@ -import scala.actors._, scala.actors.Actor._, scala.actors.Futures._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors._, scala.actors.Actor._, scala.actors.Futures._ def main(args: Array[String]) { diff --git a/test/files/jvm/t3412.scala b/test/files/jvm/t3412.scala index ced15ab5dc..fde6c04cb7 100644 --- a/test/files/jvm/t3412.scala +++ b/test/files/jvm/t3412.scala @@ -1,6 +1,8 @@ -import scala.actors._, scala.actors.Actor._, scala.actors.Futures._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors._, scala.actors.Actor._, scala.actors.Futures._ def main(args: Array[String]) { diff --git a/test/files/jvm/t3415/HelloWorld.scala b/test/files/jvm/t3415/HelloWorld.scala index 53bf55e444..5ef012390e 100644 --- a/test/files/jvm/t3415/HelloWorld.scala +++ b/test/files/jvm/t3415/HelloWorld.scala @@ -1,4 +1,4 @@ -object Test extends Application { +object Test extends App { @Hello def foo() { } } diff --git a/test/files/jvm/t3470.scala b/test/files/jvm/t3470.scala index 5e4242cdd7..bcb1d4f8de 100644 --- a/test/files/jvm/t3470.scala +++ b/test/files/jvm/t3470.scala @@ -1,6 +1,8 @@ -import scala.actors._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors._ def expectActorState(a: Reactor[T] forSome { type T }, s: Actor.State.Value) { var done = false diff --git a/test/files/jvm/t3838.scala b/test/files/jvm/t3838.scala index ba8f15fc31..a1a71d1049 100644 --- a/test/files/jvm/t3838.scala +++ b/test/files/jvm/t3838.scala @@ -1,6 +1,8 @@ -import scala.actors.Actor._ + +@deprecated("Suppress warnings", since="2.11") object Test { + import scala.actors.Actor._ def main(args: Array[String]) { actor { try { diff --git a/test/files/jvm/ticket4283/AbstractFoo.java b/test/files/jvm/t4283/AbstractFoo.java index 74f3827fe3..74f3827fe3 100644 --- a/test/files/jvm/ticket4283/AbstractFoo.java +++ b/test/files/jvm/t4283/AbstractFoo.java diff --git a/test/files/jvm/ticket4283/ScalaBipp.scala b/test/files/jvm/t4283/ScalaBipp.scala index 36dea9f4de..36dea9f4de 100644 --- a/test/files/jvm/ticket4283/ScalaBipp.scala +++ b/test/files/jvm/t4283/ScalaBipp.scala diff --git a/test/files/jvm/ticket4283/Test.scala b/test/files/jvm/t4283/Test.scala index 9bbfaab928..9bbfaab928 100644 --- a/test/files/jvm/ticket4283/Test.scala +++ b/test/files/jvm/t4283/Test.scala diff --git a/test/files/jvm/t560bis.check b/test/files/jvm/t560bis.check deleted file mode 100644 index 91eb4c19a2..0000000000 --- a/test/files/jvm/t560bis.check +++ /dev/null @@ -1,2 +0,0 @@ -cool! -cool! diff --git a/test/files/jvm/t560bis.scala b/test/files/jvm/t560bis.scala deleted file mode 100644 index b04303c8a0..0000000000 --- a/test/files/jvm/t560bis.scala +++ /dev/null @@ -1,21 +0,0 @@ -object Test { -import scala.xml._; - - def bar(args: Seq[String]) = args match { - case Seq(a,b,c,d @ _*) => Console.println("cool!") - case _ => Console.println("bah") - } - def foo(args: List[String]) = - Elem(null,"bla",Null, TopScope, (args map {x => Text(x)}):_*) match { - case Elem(_,_,_,_,Text("1"),_*) => - Console.println("cool!") - case _ => - Console.println("bah") - } - - def main(args: Array[String]) = { - val li = List("1","2","3","4") - bar(li) - foo(li) - } -} diff --git a/test/files/jvm/t6941/Analyzed_1.flags b/test/files/jvm/t6941/Analyzed_1.flags new file mode 100644 index 0000000000..ad51758c39 --- /dev/null +++ b/test/files/jvm/t6941/Analyzed_1.flags @@ -0,0 +1 @@ +-nowarn diff --git a/test/files/jvm/t7006.check b/test/files/jvm/t7006.check new file mode 100644 index 0000000000..7c99eba30c --- /dev/null +++ b/test/files/jvm/t7006.check @@ -0,0 +1,28 @@ +[running phase parser on Foo_1.scala] +[running phase namer on Foo_1.scala] +[running phase packageobjects on Foo_1.scala] +[running phase typer on Foo_1.scala] +[running phase patmat on Foo_1.scala] +[running phase superaccessors on Foo_1.scala] +[running phase extmethods on Foo_1.scala] +[running phase pickler on Foo_1.scala] +[running phase refchecks on Foo_1.scala] +[running phase uncurry on Foo_1.scala] +[running phase tailcalls on Foo_1.scala] +[running phase specialize on Foo_1.scala] +[running phase explicitouter on Foo_1.scala] +[running phase erasure on Foo_1.scala] +[running phase posterasure on Foo_1.scala] +[running phase lazyvals on Foo_1.scala] +[running phase lambdalift on Foo_1.scala] +[running phase constructors on Foo_1.scala] +[running phase flatten on Foo_1.scala] +[running phase mixin on Foo_1.scala] +[running phase cleanup on Foo_1.scala] +[running phase icode on Foo_1.scala] +[running phase inliner on Foo_1.scala] +[running phase inlinehandlers on Foo_1.scala] +[running phase closelim on Foo_1.scala] +[running phase constopt on Foo_1.scala] +[running phase dce on Foo_1.scala] +[running phase jvm on icode] diff --git a/test/files/jvm/t7006/Foo_1.flags b/test/files/jvm/t7006/Foo_1.flags new file mode 100644 index 0000000000..37b2116413 --- /dev/null +++ b/test/files/jvm/t7006/Foo_1.flags @@ -0,0 +1 @@ +-optimise -Ydebug -Xfatal-warnings diff --git a/test/files/jvm/t7006/Foo_1.scala b/test/files/jvm/t7006/Foo_1.scala new file mode 100644 index 0000000000..995619ce6b --- /dev/null +++ b/test/files/jvm/t7006/Foo_1.scala @@ -0,0 +1,10 @@ +class Foo_1 { + def foo { + try { + val x = 3 // this will be optimized away, leaving a useless jump only block + } finally { + print("hello") + } + while(true){} // ensure infinite loop doesn't break the algoirthm + } +} diff --git a/test/files/jvm/t7006/Test.scala b/test/files/jvm/t7006/Test.scala new file mode 100644 index 0000000000..065a23510e --- /dev/null +++ b/test/files/jvm/t7006/Test.scala @@ -0,0 +1,19 @@ +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import asm.tree.InsnList +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("Foo_1") + val methodNode = getMethod(classNode, "foo") + assert(count(methodNode.instructions, asm.Opcodes.NOP) == 0) + assert(count(methodNode.instructions, asm.Opcodes.GOTO) == 1) + } + + def count(insnList: InsnList, opcode: Int): Int = { + def isNop(node: asm.tree.AbstractInsnNode): Boolean = + (node.getOpcode == opcode) + insnList.iterator.asScala.count(isNop) + } +} diff --git a/test/files/jvm/t7146.scala b/test/files/jvm/t7146.scala index 2bd03d6d02..aaa3dc7ca4 100644 --- a/test/files/jvm/t7146.scala +++ b/test/files/jvm/t7146.scala @@ -1,3 +1,5 @@ + +import scala.language.{ reflectiveCalls } import java.util.concurrent.Executor import scala.concurrent._ import scala.util.control.NoStackTrace diff --git a/test/files/jvm/t7181/Foo_1.scala b/test/files/jvm/t7181/Foo_1.scala new file mode 100644 index 0000000000..f9dfdd4442 --- /dev/null +++ b/test/files/jvm/t7181/Foo_1.scala @@ -0,0 +1,26 @@ +class Exception1 extends RuntimeException +class Exception2 extends RuntimeException + +class Foo_1 { + def foo(baz: Baz) { + try { + baz.bar + } catch { + case _: Exception1 => println("exception 1") + case _: Exception2 => println("exception 2") + } finally { + // this should be the only copy of the magic constant 3 + // making it easy to detect copies of this finally block + println(s"finally ${3}") + } + println(s"normal flow") + } +} + +trait Baz { + // does it throw? who knows? This way + // I can ensure that no optimization that honors + // separate compilation could ever + // change the exception handling structure + def bar: Unit +} diff --git a/test/files/jvm/t7181/Test.scala b/test/files/jvm/t7181/Test.scala new file mode 100644 index 0000000000..35dba436c1 --- /dev/null +++ b/test/files/jvm/t7181/Test.scala @@ -0,0 +1,24 @@ +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import asm.tree.InsnList +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("Foo_1") + val methodNode = getMethod(classNode, "foo") + // there should be 2 copies of the finally block, each with the magic constant 3 + // one for the "normal" exit + // one for the uncaught exception exit + // prior to this PR there would have been 4 since each exception handler would also get a copy + val expected = 2 + val got = countMagicThrees(methodNode.instructions) + assert(got == expected, s"expected $expected but got $got magic threes") + } + + def countMagicThrees(insnList: InsnList): Int = { + def isMagicThree(node: asm.tree.AbstractInsnNode): Boolean = + (node.getOpcode == asm.Opcodes.ICONST_3) + insnList.iterator.asScala.count(isMagicThree) + } +} diff --git a/test/files/jvm/throws-annot.scala b/test/files/jvm/throws-annot.scala index b679b6c121..90b58b9976 100644 --- a/test/files/jvm/throws-annot.scala +++ b/test/files/jvm/throws-annot.scala @@ -43,24 +43,24 @@ object TestThrows { /** Test the top-level mirror that is has the annotations. */ object TL { - + @throws(classOf[IOException]) def read(): Int = 0 - + @throws(classOf[ClassCastException]) @throws(classOf[IOException]) def readWith2(): Int = 0 - + @throws(classOf[IOException]) @Deprecated @throws(classOf[NullPointerException]) def readMixed(): Int = 0 - + @Deprecated @throws(classOf[IOException]) @throws(classOf[NullPointerException]) def readMixed2(): Int = 0 - + @Deprecated def readNoEx(): Int = 0 } diff --git a/test/files/jvm/ticket2163/ticket2163.scala b/test/files/jvm/ticket2163/ticket2163.scala deleted file mode 100644 index d30bfe251b..0000000000 --- a/test/files/jvm/ticket2163/ticket2163.scala +++ /dev/null @@ -1,5 +0,0 @@ -class Ticket2163Scala[CC[X]](x: CC[Int]) { - def bar[DD[X]](meh: DD[Int]): CC[Int] = x -} - -object Test extends Application {} diff --git a/test/files/jvm/try-type-tests.scala b/test/files/jvm/try-type-tests.scala index 17811f64c5..e5e53ee737 100644 --- a/test/files/jvm/try-type-tests.scala +++ b/test/files/jvm/try-type-tests.scala @@ -49,6 +49,7 @@ trait TryStandard { n match { case Success(v) => assert(false) case Failure(e: NoSuchElementException) => assert(true) + case _ => assert(false) } } @@ -141,4 +142,4 @@ object Test extends App with TryStandard { System.exit(0) -}
\ No newline at end of file +} diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala index 3befc7ff3f..1d6f0b7907 100644 --- a/test/files/jvm/typerep.scala +++ b/test/files/jvm/typerep.scala @@ -109,7 +109,7 @@ object testFuncs { def f5(f: Int => Int, x: Int) = f(x) println(getType(f5 _)) println(getType(f5(f1, 1))) - println + println } class Foo { @@ -280,100 +280,74 @@ object TypeRep { override def toString = "Nothing" } - @serializable case class ClassRep[A](elemRep: TypeRep[A]) extends TypeRep[Class[A]] { override def toString = "Class[" + elemRep + "]" } - @serializable case class SomeRep[A](elemRep: TypeRep[A]) extends TypeRep[Some[A]] { override def toString = "Some[" + elemRep + "]" } - @serializable case class NoneRep[A](elemRep: TypeRep[A]) extends TypeRep[Option[A]] { override def toString = "None[" + elemRep + "]" } - - @serializable case class ListRep[A](elemRep: TypeRep[A]) extends TypeRep[List[A]] { override def toString = "List[" + elemRep + "]" } - - @serializable case class ArrayRep[A](elemRep: TypeRep[A]) extends TypeRep[Array[A]] { override def toString = "Array[" + elemRep + "]" } - - @serializable case class Tuple2Rep[A1, A2](_1: TypeRep[A1], _2: TypeRep[A2]) extends TypeRep[(A1, A2)] { override def toString = "Tuple2[" + _1 + ", " + _2 + "]" } - @serializable case class Tuple3Rep[A1, A2, A3](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3]) extends TypeRep[Tuple3[A1, A2, A3]] { override def toString = "Tuple3[" + _1 + ", " + _2 + ", " + _3 + "]" } - @serializable case class Tuple4Rep[A1, A2, A3, A4](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4]) extends TypeRep[Tuple4[A1, A2, A3, A4]] { override def toString = "Tuple4[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + "]" } - @serializable case class Tuple5Rep[A1, A2, A3, A4, A5](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5]) extends TypeRep[Tuple5[A1, A2, A3, A4, A5]] { override def toString = "Tuple5[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + "]" } - @serializable case class Tuple6Rep[A1, A2, A3, A4, A5, A6](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6]) extends TypeRep[Tuple6[A1, A2, A3, A4, A5, A6]] { override def toString = "Tuple6[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + "]" } - @serializable case class Tuple7Rep[A1, A2, A3, A4, A5, A6, A7](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7]) extends TypeRep[Tuple7[A1, A2, A3, A4, A5, A6, A7]] { override def toString = "Tuple7[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + "]" } - @serializable case class Tuple8Rep[A1, A2, A3, A4, A5, A6, A7, A8](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8]) extends TypeRep[Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] { override def toString = "Tuple8[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + "]" } - @serializable case class Tuple9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8], val _9: TypeRep[A9]) extends TypeRep[Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] { override def toString = "Tuple9[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + ", " + _9 + "]" } - @serializable case class Function1Rep[A1, B](a1: TypeRep[A1], b: TypeRep[B]) extends TypeRep[Function1[A1, B]] { override def toString = "Function1[" + a1 + ", " + b + "]" } - @serializable case class Function2Rep[A1, A2, B](a1: TypeRep[A1], a2: TypeRep[A2], b: TypeRep[B]) extends TypeRep[Function2[A1, A2, B]] { override def toString = "Function2[" + a1 + ", " + a2 + ", " + b + "]" } - @serializable case class Function3Rep[A1, A2, A3, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], b: TypeRep[B]) extends TypeRep[Function3[A1, A2, A3, B]] { override def toString = "Function3[" + a1 + ", " + a2 + ", " + a3 + ", " + b + "]" } - @serializable case class Function4Rep[A1, A2, A3, A4, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], b: TypeRep[B]) extends TypeRep[Function4[A1, A2, A3, A4, B]] { override def toString = "Function4[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + b + "]" } - @serializable case class Function5Rep[A1, A2, A3, A4, A5, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], b: TypeRep[B]) extends TypeRep[Function5[A1, A2, A3, A4, A5, B]] { override def toString = "Function5[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + b + "]" } - @serializable case class Function6Rep[A1, A2, A3, A4, A5, A6, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], b: TypeRep[B]) extends TypeRep[Function6[A1, A2, A3, A4, A5, A6, B]] { override def toString = "Function6[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + b + "]" } - @serializable case class Function7Rep[A1, A2, A3, A4, A5, A6, A7, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], b: TypeRep[B]) extends TypeRep[Function7[A1, A2, A3, A4, A5, A6, A7, B]] { override def toString = "Function7[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + b + "]" } - @serializable case class Function8Rep[A1, A2, A3, A4, A5, A6, A7, A8, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], b: TypeRep[B]) extends TypeRep[Function8[A1, A2, A3, A4, A5, A6, A7, A8, B]] { override def toString = "Function8[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + b + "]" } - @serializable case class Function9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], a9: TypeRep[A9], b: TypeRep[B]) extends TypeRep[Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, B]] { override def toString = "Function9[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + ", " + b + "]" } /* - @serializable case class ObjectRep[A](c: Class) extends TypeRep[A] { override def toString = c.getName } diff --git a/test/files/jvm/unittest_io_Jvm.check b/test/files/jvm/unittest_io_Jvm.check index d6e855f939..bcfce8cbdb 100644 --- a/test/files/jvm/unittest_io_Jvm.check +++ b/test/files/jvm/unittest_io_Jvm.check @@ -1,5 +1,5 @@ lines.size = 5 - + This is a file it is split on several lines. diff --git a/test/files/jvm/unittest_io_Jvm.scala b/test/files/jvm/unittest_io_Jvm.scala index 1484774fb3..7c8ef131bc 100644 --- a/test/files/jvm/unittest_io_Jvm.scala +++ b/test/files/jvm/unittest_io_Jvm.scala @@ -3,7 +3,7 @@ import scala.io.Source object Test { def main(args: Array[String]) { val lines = Source.fromString( - """| + """| |This is a file |it is split on several lines. | diff --git a/test/files/jvm/unittest_xml.scala b/test/files/jvm/unittest_xml.scala deleted file mode 100644 index 106334e625..0000000000 --- a/test/files/jvm/unittest_xml.scala +++ /dev/null @@ -1,101 +0,0 @@ -import scala.xml.{ MetaData, Null, Utility, PrefixedAttribute, UnprefixedAttribute } - -object Test { - - def main(args:Array[String]) = { - MetaDataTest.run() - UtilityTest.run() - } - - object MetaDataTest { - - import scala.xml.{ TopScope, NamespaceBinding, Node, Atom, Text } - - def domatch(x:Node): Node = { - x match { - case Node("foo", md @ UnprefixedAttribute(_, value, _), _*) if !value.isEmpty => - md("bar")(0) - case _ => new Atom(3) - } - } - - def run() { - - var x: MetaData = Null - var s: NamespaceBinding = TopScope - - // testing method def apply(uri:String, scp:NamespaceBinding, k:String): Seq[Node] - // def apply(k:String): Seq[Node] - - assert(null == x("za://foo.com", s, "bar" ), "absent element (prefixed) 1") - assert(null == x("bar"), "absent element (unprefix) 1") - - assert(None == x.get("za://foo.com", s, "bar" ), "absent element (prefixed) 2") - assert(None == x.get("bar"), "absent element (unprefix) 2") - - x = new PrefixedAttribute("zo","bar", new Atom(42), x) - s = new NamespaceBinding("zo","za://foo.com",s) - - assert(new Atom(42) == x("za://foo.com", s, "bar" ), "present element (prefixed) 3") - assert(null == x("bar"), "present element (unprefix) 3") - - assert(Some(new Atom(42)) == x.get("za://foo.com", s, "bar" ), "present element (prefixed) 4") - assert(None == x.get("bar"), "present element (unprefix) 4") - - x = new UnprefixedAttribute("bar","meaning", x) - - assert(null == x(null, s, "bar"), "present element (prefixed) 5") - assert(Text("meaning") == x("bar"), "present element (unprefix) 5") - - assert(None == x.get(null, s, "bar" ), "present element (prefixed) 6") - assert(Some(Text("meaning")) == x.get("bar"), "present element (unprefix) 6") - - val z = <foo bar="gar"/> - val z2 = <foo/> - - assert(Text("gar") == domatch(z), "attribute extractor 1") - assert(new Atom(3) == domatch(z2), "attribute extractor 2") - - } - } - - object UtilityTest { - def run() { - assert(Utility.isNameStart('b')) - assert(!Utility.isNameStart(':')) - - val x = <foo> - <toomuchws/> - </foo> - - val y = xml.Utility.trim(x) - - assert(1 == (y match { case <foo><toomuchws/></foo> => 1 }), "trim 1") - - val x2 = <foo> - <toomuchws> a b b a </toomuchws> - </foo> - - val y2 = xml.Utility.trim(x2) - - assert(2 == (y2 match { case <foo><toomuchws>a b b a</toomuchws></foo> => 2 }), "trim 2") - - val z = <bar>''</bar> - val z1 = z.toString - - assert("<bar>''</bar>" == z1, "apos unescaped") - - val q = xml.Utility.sort(<a g='3' j='2' oo='2' a='2'/>) - assert(" a=\"2\" g=\"3\" j=\"2\" oo=\"2\"" == xml.Utility.sort(q.attributes).toString) - - val pp = new xml.PrettyPrinter(80,5) - assert("<a a=\"2\" g=\"3\" j=\"2\" oo=\"2\"/>" == pp.format(q)) - - <hi> - <there/> - <guys/> - </hi>.hashCode // Bug #777 - } - } - -} diff --git a/test/files/jvm/unreachable/Foo_1.flags b/test/files/jvm/unreachable/Foo_1.flags new file mode 100644 index 0000000000..ce6e93b3da --- /dev/null +++ b/test/files/jvm/unreachable/Foo_1.flags @@ -0,0 +1 @@ +-Ynooptimise
\ No newline at end of file diff --git a/test/files/jvm/unreachable/Foo_1.scala b/test/files/jvm/unreachable/Foo_1.scala new file mode 100644 index 0000000000..600b96bb18 --- /dev/null +++ b/test/files/jvm/unreachable/Foo_1.scala @@ -0,0 +1,112 @@ +import scala.sys.error + +class Foo_1 { + def unreachableNormalExit: Int = { + return 42 + 0 + } + + def unreachableIf: Int = { + return 42 + if (util.Random.nextInt % 2 == 0) + 0 + else + 1 + } + + def unreachableIfBranches: Int = { + if (util.Random.nextInt % 2 == 0) + return 42 + else + return 42 + + return 0 + } + + def unreachableOneLegIf: Int = { + if (util.Random.nextInt % 2 == 0) + return 42 + + return 42 + } + + def unreachableLeftBranch: Int = { + val result = if (util.Random.nextInt % 2 == 0) + return 42 + else + 42 + + return result + } + + def unreachableRightBranch: Int = { + val result = if (util.Random.nextInt % 2 == 0) + 42 + else + return 42 + + return result + } + + def unreachableTryCatchFinally: Int = { + return 42 + try { + return 0 + } catch { + case x: Throwable => return 1 + } finally { + return 2 + } + return 3 + } + + def unreachableAfterTry: Int = { + try { + return 42 + } catch { + case x: Throwable => return 2 + } + return 3 + } + + def unreachableAfterCatch: Int = { + try { + error("haha") + } catch { + case x: Throwable => return 42 + } + return 3 + } + + def unreachableAfterFinally: Int = { + try { + return 1 + } catch { + case x: Throwable => return 2 + } finally { + return 42 + } + return 3 + } + + def unreachableSwitch: Int = { + return 42 + val x = util.Random.nextInt % 2 + x match { + case 0 => return 0 + case 1 => return 1 + case _ => error("wtf") + } + 2 + } + + def unreachableAfterSwitch: Int = { + val x = util.Random.nextInt % 2 + x match { + case 0 => return 42 + case 1 => return 41 + x + case _ => error("wtf") + } + 2 + } +} diff --git a/test/files/jvm/unreachable/Test.scala b/test/files/jvm/unreachable/Test.scala new file mode 100644 index 0000000000..3f520eb106 --- /dev/null +++ b/test/files/jvm/unreachable/Test.scala @@ -0,0 +1,23 @@ +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import asm.tree.InsnList +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("Foo_1") + // Foo_1 is full of unreachable code which if not elimintated + // will result in NOPs as can be confirmed by adding -Ydisable-unreachable-prevention + // to Foo_1.flags + for (methodNode <- classNode.methods.asScala) { + val got = count(methodNode.instructions, asm.Opcodes.NOP) + if (got != 0) println(s"Found $got NOP(s) in ${methodNode.name}") + } + } + + def count(insnList: InsnList, opcode: Int): Int = { + def isNop(node: asm.tree.AbstractInsnNode): Boolean = + (node.getOpcode == opcode) + insnList.iterator.asScala.count(isNop) + } +}
\ No newline at end of file diff --git a/test/files/jvm/value-class-boxing.check b/test/files/jvm/value-class-boxing.check new file mode 100644 index 0000000000..20a9fe2ba8 --- /dev/null +++ b/test/files/jvm/value-class-boxing.check @@ -0,0 +1,7 @@ +a2 and a1: bytecode identical +a3 and a1: bytecode identical +a4 and a1: bytecode identical +b2 and b1: bytecode identical +b3 and b1: bytecode identical +b4 and b1: bytecode identical +b5 and b1: bytecode identical diff --git a/test/files/jvm/value-class-boxing/Analyzed_1.scala b/test/files/jvm/value-class-boxing/Analyzed_1.scala new file mode 100644 index 0000000000..dec8565351 --- /dev/null +++ b/test/files/jvm/value-class-boxing/Analyzed_1.scala @@ -0,0 +1,17 @@ +class Wrap(val x: Int) extends AnyVal { + def ***(other: Bip): Wrap = new Wrap(x * other.x) +} +class Bip(val x: Int) extends AnyVal + +class SameBytecode { + def a1(x: Int, y: Int): Int = x + y + def a2(x: Wrap, y: Wrap): Wrap = new Wrap(x.x + y.x) + def a3(x: Int, y: Wrap): Wrap = new Wrap(x + y.x) + def a4(x: Int, y: Wrap): Int = x + y.x + + def b1(x: Wrap, y: Int): Int = (x *** new Bip(y)).x + def b2(x: Wrap, y: Bip): Wrap = x *** y + def b3(x: Wrap, y: Int): Wrap = x *** new Bip(y) + def b4(x: Wrap, y: Bip): Bip = new Bip((x *** y).x) + def b5(x: Wrap, y: Int): Bip = new Bip((x *** new Bip(y)).x) +} diff --git a/test/files/jvm/value-class-boxing/test.scala b/test/files/jvm/value-class-boxing/test.scala new file mode 100644 index 0000000000..cf331832de --- /dev/null +++ b/test/files/jvm/value-class-boxing/test.scala @@ -0,0 +1,15 @@ +import scala.tools.partest.BytecodeTest + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("SameBytecode") + List("a2", "a3", "a4") foreach { m => + print(m + " and a1: ") + sameBytecode(getMethod(classNode, "a1"), getMethod(classNode, m)) + } + List("b2", "b3", "b4", "b5") foreach { m => + print(m + " and b1: ") + sameBytecode(getMethod(classNode, "b1"), getMethod(classNode, m)) + } + } +} diff --git a/test/files/jvm/varargs/JavaClass.java b/test/files/jvm/varargs/JavaClass.java index 536e9a38fb..9851e1b78b 100644 --- a/test/files/jvm/varargs/JavaClass.java +++ b/test/files/jvm/varargs/JavaClass.java @@ -4,7 +4,7 @@ public class JavaClass { public static <T> void varargz(int i, T... v) { } - + public static void callSomeAnnotations() { VaClass va = new VaClass(); va.vs(4, "", "", ""); diff --git a/test/files/jvm/varargs/VaClass.scala b/test/files/jvm/varargs/VaClass.scala index 8e9cbdbb3f..6343f9c6f6 100644 --- a/test/files/jvm/varargs/VaClass.scala +++ b/test/files/jvm/varargs/VaClass.scala @@ -5,9 +5,9 @@ import annotation.varargs class VaClass { - + @varargs def vs(a: Int, b: String*) = println(a + b.length) @varargs def vi(a: Int, b: Int*) = println(a + b.sum) @varargs def vt[T](a: Int, b: T*) = println(a + b.length) - + } diff --git a/test/files/jvm/xml01.check b/test/files/jvm/xml01.check deleted file mode 100755 index d78e6df410..0000000000 --- a/test/files/jvm/xml01.check +++ /dev/null @@ -1,8 +0,0 @@ -equality -xpath \ -xpath \\ DESCENDANTS -<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book> --- group nodes -<f><a/><b/><c/></f> -<a/><f><a/><b/><c/></f><a/><b/><c/> -attribute value normalization diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala deleted file mode 100644 index 2fab650637..0000000000 --- a/test/files/jvm/xml01.scala +++ /dev/null @@ -1,181 +0,0 @@ -import java.io.StringReader -import org.xml.sax.InputSource - -import scala.util.logging._ -import scala.xml._ - -object Test extends App { - val e: scala.xml.MetaData = Null //Node.NoAttributes - val sc: scala.xml.NamespaceBinding = TopScope - - val xmlFile1 = "<hello><world/></hello>"; - val isrc1 = new InputSource(new StringReader(xmlFile1)) - val parsedxml1 = XML.load(isrc1) - val isrc11 = new InputSource(new StringReader(xmlFile1)) - val parsedxml11 = XML.load(isrc11) - - val c = new Node { - def label = "hello" - override def hashCode() = - Utility.hashCode(prefix, label, attributes.hashCode(), scope.hashCode(), child); - def child = Elem(null, "world", e, sc); - //def attributes = e; - override def text = "" - } - - println("equality") - assert(c == parsedxml11) - assert(parsedxml1 == parsedxml11) - assert(List(parsedxml1) sameElements List(parsedxml11)) - assert(Array(parsedxml1).toList sameElements List(parsedxml11)) - - val x2 = "<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book>"; - - val i = new InputSource(new StringReader(x2)) - val x2p = XML.load(i) - - assert(x2p == Elem(null, "book" , e, sc, - Elem(null, "author", e, sc,Text("Peter Buneman")), - Elem(null, "author", e, sc,Text("Dan Suciu")), - Elem(null, "title" , e, sc,Text("Data on ze web")))) - - val xmlFile2 = "<bib><book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book><book><author>John Mitchell</author><title>Foundations of Programming Languages</title></book></bib>"; - val isrc2 = new InputSource(new StringReader(xmlFile2)) - val parsedxml2 = XML.load(isrc2) - - println("xpath \\") - - assert(parsedxml1 \ "_" sameElements List(Elem(null,"world", e, sc))) - - assert(parsedxml1 \ "world" sameElements List(Elem(null,"world", e, sc))) - - assert( - (parsedxml2 \ "_") sameElements List( - Elem(null,"book", e, sc, - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"title" , e, sc, Text("Data on ze web"))), - Elem(null,"book",e,sc, - Elem(null,"author",e,sc,Text("John Mitchell")), - Elem(null,"title",e,sc,Text("Foundations of Programming Languages")))) - ) - assert((parsedxml2 \ "author").isEmpty) - - assert( - (parsedxml2 \ "book") sameElements List( - Elem(null,"book",e,sc, - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"title" , e, sc, Text("Data on ze web"))), - Elem(null,"book",e,sc, - Elem(null,"author", e, sc, Text("John Mitchell")), - Elem(null,"title" , e, sc, Text("Foundations of Programming Languages"))) - ) - ) - - assert( - (parsedxml2 \ "_" \ "_") sameElements List( - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"title" , e, sc, Text("Data on ze web")), - Elem(null,"author", e, sc, Text("John Mitchell")), - Elem(null,"title" , e, sc, Text("Foundations of Programming Languages")) - ) - ) - - assert( - (parsedxml2 \ "_" \ "author") sameElements List( - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"author", e, sc, Text("John Mitchell")) - ) - ) - - assert((parsedxml2 \ "_" \ "_" \ "author").isEmpty) - - Console.println("xpath \\\\ DESCENDANTS"); - - assert( - (parsedxml2 \\ "author") sameElements List( - Elem(null,"author", e, sc, Text("Peter Buneman")), - Elem(null,"author", e, sc, Text("Dan Suciu")), - Elem(null,"author", e, sc, Text("John Mitchell")) - ) - ) - - assert( - (parsedxml2 \\ "title") sameElements List( - Elem(null,"title", e, sc, Text("Data on ze web")), - Elem(null,"title", e, sc, Text("Foundations of Programming Languages"))) - ) - - - println( - (parsedxml2 \\ "book" ){ n:Node => (n \ "title") xml_== "Data on ze web" } - ) - - assert( - ((new NodeSeq { val theSeq = List( parsedxml2 ) }) \\ "_") sameElements List( - Elem(null,"bib",e,sc, - Elem(null,"book",e,sc, - Elem(null, "author", e, sc, Text("Peter Buneman")), - Elem(null, "author", e, sc, Text("Dan Suciu")), - Elem(null, "title" , e, sc, Text("Data on ze web"))), - Elem(null,"book",e,sc, - Elem(null,"author",e,sc,Text("John Mitchell")), - Elem(null,"title",e,sc,Text("Foundations of Programming Languages")))), - Elem(null,"book",e,sc, - Elem(null,"author",e,sc,Text("Peter Buneman")), - Elem(null,"author",e,sc,Text("Dan Suciu")), - Elem(null,"title",e,sc,Text("Data on ze web"))), - Elem(null,"author",e,sc,Text("Peter Buneman")), - Elem(null,"author",e,sc,Text("Dan Suciu")), - Elem(null,"title",e,sc,Text("Data on ze web")), - Elem(null,"book",e,sc, - Elem(null,"author",e,sc,Text("John Mitchell")), - Elem(null,"title",e,sc,Text("Foundations of Programming Languages"))), - Elem(null,"author",e,sc,Text("John Mitchell")), - Elem(null,"title",e,sc,Text("Foundations of Programming Languages")) - ) - ) - - // test group node - Console println "-- group nodes" - val zx1: Node = Group { <a/><b/><c/> } - val zy1 = <f>{zx1}</f> - Console println zy1.toString() - - val zx2: Node = Group { List(<a/>,zy1,zx1) } - Console println zx2.toString() - - val zz1 = <xml:group><a/><b/><c/></xml:group> - - assert(zx1 xml_== zz1) - assert(zz1.length == 3) - - // unparsed - - println("attribute value normalization") - val xmlAttrValueNorm = "<personne id='p0003' nom='Şahingöz' />"; - { - val isrcA = new InputSource( new StringReader(xmlAttrValueNorm) ); - val parsedxmlA = XML.load(isrcA); - val c = (parsedxmlA \ "@nom").text.charAt(0); - assert(c == '\u015e'); - } - // buraq: if the following test fails with 'character x not allowed', it is - // related to the mutable variable in a closures in MarkupParser.parsecharref - { - val isr = scala.io.Source.fromString(xmlAttrValueNorm); - val pxmlB = scala.xml.parsing.ConstructingParser.fromSource(isr,false); - val parsedxmlB = pxmlB.element(TopScope); - val c = (parsedxmlB \ "@nom").text.charAt(0); - assert(c == '\u015e'); - } - - // #60 test by round trip - - val p = scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<foo bar:attr='&'/>"),true) - val n = p.element(new scala.xml.NamespaceBinding("bar","BAR",scala.xml.TopScope))(0) - assert( n.attributes.get("BAR", n, "attr").nonEmpty) -} diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala deleted file mode 100644 index b830a0e694..0000000000 --- a/test/files/jvm/xml02.scala +++ /dev/null @@ -1,78 +0,0 @@ -object Test { - - def main(args: Array[String]) { - XmlEx.run() - XmlEy.run() - XmlPat.run() - DodgyNamespace.run() - } - - import scala.xml.{NodeSeq, Utility} - import NodeSeq.seqToNodeSeq - - val ax = <hello foo="bar" x:foo="baz" xmlns:x="the namespace from outer space"> - <world/> - </hello> - - val cx = <z:hello foo="bar" xmlns:z="z" x:foo="baz" xmlns:x="the namespace from outer space"> - crazy text world - </z:hello> - - val bx = <hello foo="bar&x"></hello> - - object XmlEx { - - def run() { - assert((ax \ "@foo") xml_== "bar") // uses NodeSeq.view! - assert((ax \ "@foo") xml_== xml.Text("bar")) // dto. - assert((bx \ "@foo") xml_== "bar&x") // dto. - assert((bx \ "@foo") xml_sameElements List(xml.Text("bar&x"))) - assert("<hello foo=\"bar&x\"></hello>" == bx.toString) - } - } - - object XmlEy { - def run() { - val z = ax \ "@{the namespace from outer space}foo" - assert((ax \ "@{the namespace from outer space}foo") xml_== "baz") - assert((cx \ "@{the namespace from outer space}foo") xml_== "baz") - - try { - ax \ "@" - assert(false) - } catch { - case _: IllegalArgumentException => - } - try { - ax \ "@{" - assert(false) - } catch { - case _: IllegalArgumentException => - } - try { - ax \ "@{}" - assert(false) - } catch { - case _: IllegalArgumentException => - } - - } - } - - object XmlPat { - def run() { - assert(<hello/> match { case <hello/> => true; case _ => false; }) - assert(<x:ga xmlns:x="z"/> match { case <x:ga/> => true; case _ => false; }); - assert(Utility.trim(cx) match { case n @ <hello>crazy text world</hello> if (n \ "@foo") xml_== "bar" => true; }) - assert(Utility.trim(cx) match { case n @ <z:hello>crazy text world</z:hello> if (n \ "@foo") xml_== "bar" => true; }) - } - } - - object DodgyNamespace { - def run() { - val x = <flog xmlns:ee="http://ee.com"><foo xmlns:dog="http://dog.com"><dog:cat/></foo></flog> - assert(x.toString.matches(".*xmlns:dog=\"http://dog.com\".*")); - } - } - -} diff --git a/test/files/jvm/xml03syntax.check b/test/files/jvm/xml03syntax.check deleted file mode 100755 index edcdbdd2ba..0000000000 --- a/test/files/jvm/xml03syntax.check +++ /dev/null @@ -1,26 +0,0 @@ -true -true -true -<hello>world</hello> -true -<hello>1.5</hello> -true -<hello>5</hello> -true -<hello>true</hello> -true -<hello>5</hello> -true -<hello>27</hello> -true -<hello>1 2 3 4</hello> -1 -2 -3 -4 -<hello>2 4</hello> -2 -4 - -node=<elem key="<b>hello</b>"/>, key=Some(<b>hello</b>) -node=<elem/>, key=None diff --git a/test/files/jvm/xml03syntax.scala b/test/files/jvm/xml03syntax.scala deleted file mode 100644 index 2c93f7c176..0000000000 --- a/test/files/jvm/xml03syntax.scala +++ /dev/null @@ -1,97 +0,0 @@ -import scala.xml._ - -object Test { - - private def handle[A](x: Node): A = { - println(x) - x.child(0).asInstanceOf[Atom[A]].data - } - - def main(args: Array[String]) { - test1() - test2() - test3() - } - - private def test1() { - val xNull = <hello>{null}</hello> // these used to be Atom(unit), changed to empty children - - println(xNull.child sameElements Nil) - - val x0 = <hello>{}</hello> // these used to be Atom(unit), changed to empty children - val x00 = <hello>{ }</hello> // dto. - - val xa = <hello>{ "world" }</hello> - - - println(x0.child sameElements Nil) - println(x00.child sameElements Nil) - println(handle[String](xa) == "world") - - val xb = <hello>{ 1.5 }</hello> - - println(handle[Double](xb) == 1.5) - - val xc = <hello>{ 5 }</hello> - - println(handle[Int](xc) == 5) - - val xd = <hello>{ true }</hello> - - println(handle[Boolean](xd) == true) - - val xe = <hello>{ 5:Short }</hello> - - println(handle[Short](xe) == (5:Short)) - - val xf = <hello>{ val x = 27; x }</hello> - - println(handle[Int](xf) == 27) - - val xg = <hello>{ List(1,2,3,4) }</hello> - - println(xg) - for (z <- xg.child) { - println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""}) - } - - val xh = <hello>{ for(x <- List(1,2,3,4) if x % 2 == 0) yield x }</hello> - - println(xh) - for (z <- xh.child) { - println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""}) - } - println - } - - /** see SVN r13821 (emir): support for <elem key={x:Option[Seq[Node]]} />, - * so that Options can be used for optional attributes. - */ - private def test2() { - val x1: Option[Seq[Node]] = Some(<b>hello</b>) - val n1 = <elem key={x1} />; - println("node="+n1+", key="+n1.attribute("key")) - - val x2: Option[Seq[Node]] = None - val n2 = <elem key={x2} />; - println("node="+n2+", key="+n2.attribute("key")) - } - - private def test3() { - // this demonstrates how to handle entities - val s = io.Source.fromString("<a> </a>") - object parser extends xml.parsing.ConstructingParser(s, false /*ignore ws*/) { - override def replacementText(entityName: String): io.Source = { - entityName match { - case "nbsp" => io.Source.fromString("\u0160"); - case _ => super.replacementText(entityName); - } - } - nextch; // !!important, to initialize the parser - } - val parsed = parser.element(TopScope) // parse the source as element - // alternatively, we could call document() - parsed - } - -} diff --git a/test/files/jvm/xml04embed.check b/test/files/jvm/xml04embed.check deleted file mode 100644 index e71e645149..0000000000 --- a/test/files/jvm/xml04embed.check +++ /dev/null @@ -1,3 +0,0 @@ -{ -} -{}{}{} diff --git a/test/files/jvm/xml04embed.scala b/test/files/jvm/xml04embed.scala deleted file mode 100644 index fa453e4295..0000000000 --- a/test/files/jvm/xml04embed.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test { - def main(args: Array[String]) { - val ya = <x>{{</x> - println(ya.text) - val ua = <x>}}</x> - println(ua.text) - val za = <x>{{}}{{}}{{}}</x> - println(za.text) - } -} diff --git a/test/files/jvm/xml05.check b/test/files/jvm/xml05.check index 8d3e803bc8..92ea995350 100644 --- a/test/files/jvm/xml05.check +++ b/test/files/jvm/xml05.check @@ -1,11 +1,7 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> <city name="San José"/> res0: scala.xml.Elem = <city name="San José"/> scala> - -scala> diff --git a/test/files/jvm/xmlattr.check b/test/files/jvm/xmlattr.check deleted file mode 100644 index a87420d86c..0000000000 --- a/test/files/jvm/xmlattr.check +++ /dev/null @@ -1,18 +0,0 @@ -true -true -true -true -true -true -removal of duplicates for unprefixed attributes in append = 1 -true -true -true -true -true -true -true -true -true -<b x="&"/> -<b x="&"/> diff --git a/test/files/jvm/xmlattr.scala b/test/files/jvm/xmlattr.scala deleted file mode 100644 index d214642eb6..0000000000 --- a/test/files/jvm/xmlattr.scala +++ /dev/null @@ -1,63 +0,0 @@ -import xml.{ NodeSeq, Null, Text, UnprefixedAttribute } - -object Test { - - def main(args: Array[String]) { - UnprefixedAttributeTest() - AttributeWithOptionTest() - AttributeOutputTest() - } - - object UnprefixedAttributeTest { - def apply() { - val x = new UnprefixedAttribute("foo","bar", Null) - println(Some(Text("bar")) == x.get("foo")) - println(Text("bar") == x("foo")) - println(None == x.get("no_foo")) - println(null == x("no_foo")) - - val y = x.remove("foo") - println(Null == y) - - val z = new UnprefixedAttribute("foo", null:NodeSeq, x) - println(None == z.get("foo")) - - var appended = x append x append x append x - var len = 0; while (appended ne Null) { - appended = appended.next - len = len + 1 - } - println("removal of duplicates for unprefixed attributes in append = " + len) - } - } - - object AttributeWithOptionTest { - def apply() { - val x = new UnprefixedAttribute("foo", Some(Text("bar")), Null) - - println(Some(Text("bar")) == x.get("foo")) - println(Text("bar") == x("foo")) - println(None == x.get("no_foo")) - println(null == x("no_foo")) - - val attr1 = Some(Text("foo value")) - val attr2 = None - val y = <b foo={attr1} bar={attr2} /> - println(Some(Text("foo value")) == y.attributes.get("foo")); - println(Text("foo value") == y.attributes("foo")) - println(None == y.attributes.get("bar")) - println(null == y.attributes("bar")) - - val z = new UnprefixedAttribute("foo", None, x) - println(None == z.get("foo")) - } - } - - object AttributeOutputTest { - def apply() { - println(<b x="&"/>) - println(<b x={"&"}/>) - } - } - -} diff --git a/test/files/jvm/xmlmore.check b/test/files/jvm/xmlmore.check deleted file mode 100644 index 29f144c89f..0000000000 --- a/test/files/jvm/xmlmore.check +++ /dev/null @@ -1,10 +0,0 @@ -<!-- thissa comment --> -<?this is a pi foo bar = && {{ ?> - - "Come, come again, whoever you are, come! -Heathen, fire worshipper or idolatrous, come! -Come even if you broke your penitence a hundred times, -Ours is the portal of hope, come as you are." - Mevlana Celaleddin Rumi -<foo><br /></foo> -End Test diff --git a/test/files/jvm/xmlmore.scala b/test/files/jvm/xmlmore.scala deleted file mode 100644 index 04d0a6c759..0000000000 --- a/test/files/jvm/xmlmore.scala +++ /dev/null @@ -1,29 +0,0 @@ -object myBreak extends scala.xml.Unparsed("<br />") - -object Test extends App { - val com = <!-- thissa comment --> - val pi = <?this is a pi foo bar = && {{ ?> - val crz = <![CDATA[ - "Come, come again, whoever you are, come! -Heathen, fire worshipper or idolatrous, come! -Come even if you broke your penitence a hundred times, -Ours is the portal of hope, come as you are." - Mevlana Celaleddin Rumi]]> - - val nazim = <foo>{myBreak}</foo> // shows use of unparsed - - Console println com - Console println pi - Console println crz // this guy will escaped, and rightly so - Console println nazim - Console println "End Test" - - <x:foo xmlns:x="gaga"/> match { - case scala.xml.QNode("gaga","foo",md,child@_*) => - } - - <x:foo xmlns:x="gaga"/> match { - case scala.xml.Node("foo",md,child@_*) => - } - -} diff --git a/test/files/jvm/xmlpull.scala b/test/files/jvm/xmlpull.scala deleted file mode 100644 index 9ba7d4cf02..0000000000 --- a/test/files/jvm/xmlpull.scala +++ /dev/null @@ -1,31 +0,0 @@ -import scala.xml._ -import scala.xml.pull._ -import scala.io.Source - -object Test { - - val src = Source.fromString("<hello><world/>!</hello>") - - def main(args: Array[String]) { - var er = new XMLEventReader(src) - er.next match { - case EvElemStart(_, "hello", _, _) => //println("1") - } - er.next match { - case EvElemStart(_, "world", _, _) => //println("2") - } - er.next match { - case EvElemEnd(_, "world") => //println("3") - } - er.next match { - case EvText("!") => //println("4") - } - er.next match { - case EvElemEnd(_, "hello") => //println("5") - } - // you get the picture... - er.stop // allow thread to be garbage-collected - //println("6") - } -} - diff --git a/test/files/jvm/xmlstuff.check b/test/files/jvm/xmlstuff.check deleted file mode 100644 index e1222479f7..0000000000 --- a/test/files/jvm/xmlstuff.check +++ /dev/null @@ -1,22 +0,0 @@ -NodeSeq -<result> - <title>Blabla</title> - <remarks> Hallo Welt. </remarks> -</result><result> - <title>Blubabla</title> - <remarks> Hello Blu </remarks> -</result><result> - <title>Blubabla</title> - <remarks> rem 2 </remarks> -</result> -List(<book><title>Blabla</title></book>) -<result> - <name>John</name> - <street> Elm Street</street> - <city>Dolphin City</city> - <phone where="work"> +41 21 693 68 67</phone> - <phone where="mobile">+41 79 602 23 23</phone> -</result> -namespaces -validation - elements -validation - attributes diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala deleted file mode 100644 index 45234c7139..0000000000 --- a/test/files/jvm/xmlstuff.scala +++ /dev/null @@ -1,181 +0,0 @@ -import java.io.StringReader -import org.xml.sax.InputSource -import scala.xml.{Node, NodeSeq, Elem, Text, XML} - -object Test { - - /** returns true if exception was thrown */ - def catcher(att: Function1[Unit, scala.xml.MetaData]): Boolean = { - var ex = false - try { - att.apply({}) - } catch { - case scala.xml.MalformedAttributeException(msg) => - println(msg) - ex = true - } - ex - } - - def main(args: Array[String]) { - - println("NodeSeq") - - val p = <foo> - <bar gt='ga' value="3"/> - <baz bazValue="8"/> - <bar value="5" gi='go'/> - </foo>; - - val pelems_1 = for (x <- p \ "bar"; y <- p \ "baz" ) yield { - Text(x.attributes("value").toString + y.attributes("bazValue").toString+ "!") - }; - val pelems_2 = new NodeSeq { val theSeq = List(Text("38!"),Text("58!")) }; - assert(pelems_1 sameElements pelems_2) - - assert(Text("8") sameElements (p \\ "@bazValue")) - - val books = - <bks> - <book><title>Blabla</title></book> - <book><title>Blubabla</title></book> - <book><title>Baaaaaaalabla</title></book> - </bks>; - - val reviews = - <reviews> - <entry><title>Blabla</title> - <remarks> - Hallo Welt. - </remarks> - </entry> - <entry><title>Blubabla</title> - <remarks> - Hello Blu - </remarks> - </entry> - <entry><title>Blubabla</title> - <remarks> - rem 2 - </remarks> - </entry> - </reviews>; - - println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( - for (t <- books \\ "title"; - r <- reviews \\ "entry" - if (r \ "title") xml_== t) yield - <result> - { t } - { r \ "remarks" } - </result> - )); - - // example - println( - for (t @ <book><title>Blabla</title></book> <- new NodeSeq { val theSeq = books.child }.toList) - yield t - ); - val phoneBook = - <phonebook> - <descr> - This is the <b>phonebook</b> of the - <a href="http://acme.org">ACME</a> corporation. - </descr> - <entry> - <name>John</name> - <phone where="work"> +41 21 693 68 67</phone> - <phone where="mobile">+41 79 602 23 23</phone> - </entry> - </phonebook>; - - - val addrBook = - <addrbook> - <descr> - This is the <b>addressbook</b> of the - <a href="http://acme.org">ACME</a> corporation. - </descr> - <entry> - <name>John</name> - <street> Elm Street</street> - <city>Dolphin City</city> - </entry> - </addrbook>; - - println( new scala.xml.PrettyPrinter(80, 5).formatNodes ( - for (t <- addrBook \\ "entry"; - r <- phoneBook \\ "entry" - if (t \ "name") xml_== (r \ "name")) yield - <result> - { t.child } - { r \ "phone" } - </result> - )); - - - /* namespaces */ - // begin tmp - println("namespaces") - val cuckoo = <cuckoo xmlns="http://cuckoo.com"> - <foo/> - <bar/> - </cuckoo>; - assert(cuckoo.namespace == "http://cuckoo.com") - for (n <- cuckoo \ "_" ) { - //println("n = "+n); - //println("n.prefix = "+n.prefix); - //.println("n.scope = "+n.scope); - assert( n.namespace == "http://cuckoo.com") - } - - println("validation - elements") - val vtor = new scala.xml.dtd.ElementValidator(); - { - import scala.xml.dtd.ELEMENTS - import scala.xml.dtd.ContentModel._ - vtor.setContentModel( - ELEMENTS( - Sequ( - Letter(ElemName("bar")), - Star(Letter(ElemName("baz"))) ))); - - } - assert(vtor( <foo><bar/><baz/><baz/></foo> )) - - { - import scala.xml.dtd.MIXED - import scala.xml.dtd.ContentModel._ - - vtor.setContentModel( - MIXED( - Alt(Letter(ElemName("bar")), - Letter(ElemName("baz")), - Letter(ElemName("bal"))))); - } - - assert(vtor(<foo><bar/><baz/><baz/></foo> )) - assert(vtor(<foo>ab<bar/>cd<baz/>ed<baz/>gh</foo> )) - assert(!vtor(<foo> <ugha/> <bugha/> </foo> )) - - println("validation - attributes") - vtor.setContentModel(null) - vtor.setMetaData(List()) - assert(!vtor( <foo bar="hello"/> )) - - { - import scala.xml.dtd._ - vtor setMetaData List(AttrDecl("bar", "CDATA", IMPLIED)) - } - assert(!vtor(<foo href="http://foo.com" bar="hello"/>)) - assert(vtor(<foo bar="hello"/>)) - - { - import scala.xml.dtd._ - vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED))) - } - assert(!vtor( <foo href="http://foo.com" /> )) - assert( vtor( <foo bar="http://foo.com" /> )) - - } -} diff --git a/test/files/lib/jsoup-1.3.1.jar.desired.sha1 b/test/files/lib/jsoup-1.3.1.jar.desired.sha1 new file mode 100644 index 0000000000..46fa3dae9d --- /dev/null +++ b/test/files/lib/jsoup-1.3.1.jar.desired.sha1 @@ -0,0 +1 @@ +346d3dff4088839d6b4d163efa2892124039d216 ?jsoup-1.3.1.jar diff --git a/test/files/lib/scalacheck.jar.desired.sha1 b/test/files/lib/scalacheck.jar.desired.sha1 deleted file mode 100644 index 2f15402d18..0000000000 --- a/test/files/lib/scalacheck.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -b6f4dbb29f0c2ec1eba682414f60d52fea84f703 *scalacheck.jar diff --git a/test/files/neg/abstract-class-2.scala b/test/files/neg/abstract-class-2.scala index be45a09343..19f74f3da6 100644 --- a/test/files/neg/abstract-class-2.scala +++ b/test/files/neg/abstract-class-2.scala @@ -1,7 +1,7 @@ class P { trait S1 val p = new P - + trait S2 { def f(x: p.S1): Int } @@ -10,5 +10,5 @@ class P { class P2 extends P { object O2 extends S2 { def f(x: S1) = 5 - } + } } diff --git a/test/files/neg/abstract-explaintypes.check b/test/files/neg/abstract-explaintypes.check new file mode 100644 index 0000000000..e303b45a32 --- /dev/null +++ b/test/files/neg/abstract-explaintypes.check @@ -0,0 +1,15 @@ +abstract-explaintypes.scala:6: error: type mismatch; + found : A + required: A.this.T + def foo2: T = bar().baz(); + ^ +A <: A.this.T? +false +abstract-explaintypes.scala:9: error: type mismatch; + found : A + required: A.this.T + def foo5: T = baz().baz(); + ^ +A <: A.this.T? +false +two errors found diff --git a/test/files/neg/abstract-explaintypes.flags b/test/files/neg/abstract-explaintypes.flags new file mode 100644 index 0000000000..b36707c7cf --- /dev/null +++ b/test/files/neg/abstract-explaintypes.flags @@ -0,0 +1 @@ +-explaintypes diff --git a/test/files/neg/abstract-explaintypes.scala b/test/files/neg/abstract-explaintypes.scala new file mode 100644 index 0000000000..f8ecae16fa --- /dev/null +++ b/test/files/neg/abstract-explaintypes.scala @@ -0,0 +1,11 @@ +trait A { + type T <: A; + def baz(): A; + def bar(): T; + def foo1: A = bar().bar(); + def foo2: T = bar().baz(); + def foo3 = bar().baz(); + def foo4: A = baz().bar(); + def foo5: T = baz().baz(); + def foo6 = baz().baz(); +} diff --git a/test/files/neg/abstract-inaccessible.check b/test/files/neg/abstract-inaccessible.check index 42b98ac026..d56f5691be 100644 --- a/test/files/neg/abstract-inaccessible.check +++ b/test/files/neg/abstract-inaccessible.check @@ -1,13 +1,15 @@ -abstract-inaccessible.scala:5: error: method implementMe in trait YourTrait references private[foo] trait Bippy. +abstract-inaccessible.scala:5: warning: method implementMe in trait YourTrait references private[foo] trait Bippy. Classes which cannot access Bippy may be unable to provide a concrete implementation of implementMe. def implementMe(f: Int => (String, Bippy)): Unit ^ -abstract-inaccessible.scala:6: error: method overrideMe in trait YourTrait references private[foo] trait Bippy. +abstract-inaccessible.scala:6: warning: method overrideMe in trait YourTrait references private[foo] trait Bippy. Classes which cannot access Bippy may be unable to override overrideMe. def overrideMe[T <: Bippy](x: T): T = x ^ -abstract-inaccessible.scala:7: error: method overrideMeAlso in trait YourTrait references private[foo] trait Bippy. +abstract-inaccessible.scala:7: warning: method overrideMeAlso in trait YourTrait references private[foo] trait Bippy. Classes which cannot access Bippy may be unable to override overrideMeAlso. def overrideMeAlso(x: Map[Int, Set[Bippy]]) = 5 ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/abstract-inaccessible.scala b/test/files/neg/abstract-inaccessible.scala index 7eaaf2d620..3c80f30522 100644 --- a/test/files/neg/abstract-inaccessible.scala +++ b/test/files/neg/abstract-inaccessible.scala @@ -1,6 +1,6 @@ package foo { private[foo] trait Bippy { } - + trait YourTrait { def implementMe(f: Int => (String, Bippy)): Unit def overrideMe[T <: Bippy](x: T): T = x diff --git a/test/files/neg/abstract-report.check b/test/files/neg/abstract-report.check index bd550f39f4..1ffeac060b 100644 --- a/test/files/neg/abstract-report.check +++ b/test/files/neg/abstract-report.check @@ -7,7 +7,7 @@ it has 12 unimplemented members. def isTraversableAgain: Boolean = ??? def toIterator: Iterator[String] = ??? def toStream: Stream[String] = ??? - + // Members declared in scala.collection.TraversableOnce def copyToArray[B >: String](xs: Array[B],start: Int,len: Int): Unit = ??? def exists(p: String => Boolean): Boolean = ??? diff --git a/test/files/neg/abstract-report2.check b/test/files/neg/abstract-report2.check index 35a99bdd25..6ea949353a 100644 --- a/test/files/neg/abstract-report2.check +++ b/test/files/neg/abstract-report2.check @@ -78,15 +78,15 @@ it has 24 unimplemented members. def retainAll(x$1: java.util.Collection[_]): Boolean = ??? def toArray[T](x$1: Array[T with Object]): Array[T with Object] = ??? def toArray(): Array[Object] = ??? - + // Members declared in scala.collection.GenTraversableOnce def isTraversableAgain: Boolean = ??? def toIterator: Iterator[(Set[Int], String)] = ??? def toStream: Stream[(Set[Int], String)] = ??? - + // Members declared in scala.math.Ordering def compare(x: List[Int],y: List[Int]): Int = ??? - + // Members declared in scala.collection.TraversableOnce def copyToArray[B >: (Set[Int], String)](xs: Array[B],start: Int,len: Int): Unit = ??? def exists(p: ((Set[Int], String)) => Boolean): Boolean = ??? diff --git a/test/files/neg/accesses.scala b/test/files/neg/accesses.scala index 290291586c..b1df6c0e6c 100644 --- a/test/files/neg/accesses.scala +++ b/test/files/neg/accesses.scala @@ -6,7 +6,7 @@ abstract class A { private[p1] def f4(): Unit protected[p1] def f5(): Unit } - + abstract class OK1 extends A { private[p1] def f2(): Unit protected[p2] def f3(): Unit diff --git a/test/files/neg/ambiguous-float-dots.check b/test/files/neg/ambiguous-float-dots.check deleted file mode 100644 index 6c21056d7a..0000000000 --- a/test/files/neg/ambiguous-float-dots.check +++ /dev/null @@ -1,16 +0,0 @@ -ambiguous-float-dots.scala:2: error: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - val x0 = 5. - ^ -ambiguous-float-dots.scala:6: error: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - val x1 = 5.f - ^ -ambiguous-float-dots.scala:7: error: Treating numbers with a leading zero as octal is deprecated. - val y0 = 055 - ^ -ambiguous-float-dots.scala:11: error: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - 1.+(2) - ^ -ambiguous-float-dots.scala:12: error: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - 1. + 2 - ^ -5 errors found diff --git a/test/files/neg/ambiguous-float-dots.flags b/test/files/neg/ambiguous-float-dots.flags deleted file mode 100644 index 65faf53579..0000000000 --- a/test/files/neg/ambiguous-float-dots.flags +++ /dev/null @@ -1 +0,0 @@ --Xfatal-warnings -deprecation
\ No newline at end of file diff --git a/test/files/neg/ambiguous-float-dots.scala b/test/files/neg/ambiguous-float-dots.scala deleted file mode 100644 index 87e948db35..0000000000 --- a/test/files/neg/ambiguous-float-dots.scala +++ /dev/null @@ -1,14 +0,0 @@ -class A { - val x0 = 5. -} - -class B { - val x1 = 5.f - val y0 = 055 -} - -class D { - 1.+(2) - 1. + 2 - 1 + 2 -} diff --git a/test/files/neg/ambiguous-float-dots2.check b/test/files/neg/ambiguous-float-dots2.check index 8919d2c6a8..40c9b4186d 100644 --- a/test/files/neg/ambiguous-float-dots2.check +++ b/test/files/neg/ambiguous-float-dots2.check @@ -1,10 +1,7 @@ -ambiguous-float-dots2.scala:7: error: Non-zero numbers may not have a leading zero. - val y0 = 055 - ^ ambiguous-float-dots2.scala:3: error: identifier expected but '}' found. } ^ -ambiguous-float-dots2.scala:12: error: ';' expected but integer literal found. +ambiguous-float-dots2.scala:11: error: ';' expected but integer literal found. 1. + 2 ^ -three errors found +two errors found diff --git a/test/files/neg/ambiguous-float-dots2.flags b/test/files/neg/ambiguous-float-dots2.flags deleted file mode 100644 index 112fc720a0..0000000000 --- a/test/files/neg/ambiguous-float-dots2.flags +++ /dev/null @@ -1 +0,0 @@ --Xfuture
\ No newline at end of file diff --git a/test/files/neg/ambiguous-float-dots2.scala b/test/files/neg/ambiguous-float-dots2.scala index 87e948db35..b1615c9273 100644 --- a/test/files/neg/ambiguous-float-dots2.scala +++ b/test/files/neg/ambiguous-float-dots2.scala @@ -4,7 +4,6 @@ class A { class B { val x1 = 5.f - val y0 = 055 } class D { diff --git a/test/files/neg/annot-nonconst.check b/test/files/neg/annot-nonconst.check index b43e58a0ca..5b3da7a13c 100644 --- a/test/files/neg/annot-nonconst.check +++ b/test/files/neg/annot-nonconst.check @@ -8,7 +8,7 @@ make your annotation visible at runtime. If that is what you want, you must write the annotation class in Java. class Ann2(value: String) extends annotation.ClassfileAnnotation ^ -annot-nonconst.scala:6: error: annotation argument needs to be a constant; found: n +annot-nonconst.scala:6: error: annotation argument needs to be a constant; found: Test.this.n @Length(n) def foo = "foo" ^ annot-nonconst.scala:7: error: annotation argument cannot be null diff --git a/test/files/neg/anytrait.scala b/test/files/neg/anytrait.scala index 1501486105..e76164f63d 100644 --- a/test/files/neg/anytrait.scala +++ b/test/files/neg/anytrait.scala @@ -1,7 +1,7 @@ trait T extends Any { var x = 1 - + { x += 1 } type T = Int diff --git a/test/files/neg/anyval-anyref-parent.check b/test/files/neg/anyval-anyref-parent.check index fe20e5de81..8c2aa36583 100644 --- a/test/files/neg/anyval-anyref-parent.check +++ b/test/files/neg/anyval-anyref-parent.check @@ -3,7 +3,7 @@ trait Foo2 extends AnyVal // fail ^ anyval-anyref-parent.scala:5: error: Any does not have a constructor class Bar1 extends Any // fail - ^ + ^ anyval-anyref-parent.scala:6: error: value class needs to have exactly one public val parameter class Bar2(x: Int) extends AnyVal // fail ^ diff --git a/test/files/neg/array-not-seq.check b/test/files/neg/array-not-seq.check deleted file mode 100644 index a3a639e772..0000000000 --- a/test/files/neg/array-not-seq.check +++ /dev/null @@ -1,13 +0,0 @@ -array-not-seq.scala:2: error: An Array will no longer match as Seq[_]. - def f1(x: Any) = x.isInstanceOf[Seq[_]] - ^ -array-not-seq.scala:4: error: An Array will no longer match as Seq[_]. - case _: Seq[_] => true - ^ -array-not-seq.scala:16: error: An Array will no longer match as Seq[_]. - case (Some(_: Seq[_]), Nil, _) => 1 - ^ -array-not-seq.scala:17: error: An Array will no longer match as Seq[_]. - case (None, List(_: List[_], _), _) => 2 - ^ -four errors found diff --git a/test/files/neg/array-not-seq.flags b/test/files/neg/array-not-seq.flags deleted file mode 100644 index 4e9f7e4a56..0000000000 --- a/test/files/neg/array-not-seq.flags +++ /dev/null @@ -1 +0,0 @@ --Xmigration -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/array-not-seq.scala b/test/files/neg/array-not-seq.scala deleted file mode 100644 index 5f367bdd85..0000000000 --- a/test/files/neg/array-not-seq.scala +++ /dev/null @@ -1,26 +0,0 @@ -object Test { - def f1(x: Any) = x.isInstanceOf[Seq[_]] - def f2(x: Any) = x match { - case _: Seq[_] => true - case _ => false - } - - def f3(x: Any) = x match { - case _: Array[_] => true - case _ => false - } - - def f4(x: Any) = x.isInstanceOf[Traversable[_]] - - def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match { - case (Some(_: Seq[_]), Nil, _) => 1 - case (None, List(_: List[_], _), _) => 2 - case _ => 3 - } - - def main(args: Array[String]): Unit = { - // println(f1(Array(1))) - // println(f2(Array(1))) - // println(f3(Array(1)) - } -} diff --git a/test/files/neg/bad-advice.check b/test/files/neg/bad-advice.check new file mode 100644 index 0000000000..03b3e4f616 --- /dev/null +++ b/test/files/neg/bad-advice.check @@ -0,0 +1,6 @@ +bad-advice.scala:4: error: pattern type is incompatible with expected type; + found : Bip.type + required: Int + case Bip => true + ^ +one error found diff --git a/test/pending/pos/t4649.flags b/test/files/neg/bad-advice.flags index e8fb65d50c..e8fb65d50c 100644 --- a/test/pending/pos/t4649.flags +++ b/test/files/neg/bad-advice.flags diff --git a/test/files/neg/bad-advice.scala b/test/files/neg/bad-advice.scala new file mode 100644 index 0000000000..b1955330d7 --- /dev/null +++ b/test/files/neg/bad-advice.scala @@ -0,0 +1,6 @@ +object Bip +object Test { + def f(x: Int) = x match { + case Bip => true + } +} diff --git a/test/files/neg/case-collision.check b/test/files/neg/case-collision.check index 4edc6f1205..22cf105a4f 100644 --- a/test/files/neg/case-collision.check +++ b/test/files/neg/case-collision.check @@ -1,10 +1,12 @@ -case-collision.scala:5: error: Class foo.BIPPY differs only in case from foo.Bippy. Such classes will overwrite one another on case-insensitive filesystems. +case-collision.scala:5: warning: Class foo.BIPPY differs only in case from foo.Bippy. Such classes will overwrite one another on case-insensitive filesystems. class BIPPY ^ -case-collision.scala:11: error: Class foo.HyRaX$ differs only in case from foo.Hyrax$. Such classes will overwrite one another on case-insensitive filesystems. +case-collision.scala:11: warning: Class foo.HyRaX$ differs only in case from foo.Hyrax$. Such classes will overwrite one another on case-insensitive filesystems. object HyRaX ^ -case-collision.scala:8: error: Class foo.DINGO$ differs only in case from foo.Dingo$. Such classes will overwrite one another on case-insensitive filesystems. +case-collision.scala:8: warning: Class foo.DINGO$ differs only in case from foo.Dingo$. Such classes will overwrite one another on case-insensitive filesystems. object DINGO ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/case-collision.flags b/test/files/neg/case-collision.flags index 85d8eb2ba2..14c1069dee 100644 --- a/test/files/neg/case-collision.flags +++ b/test/files/neg/case-collision.flags @@ -1 +1 @@ --Xfatal-warnings +-Ybackend:GenASM -Xfatal-warnings diff --git a/test/files/neg/case-collision2.check b/test/files/neg/case-collision2.check new file mode 100644 index 0000000000..b8481f46bb --- /dev/null +++ b/test/files/neg/case-collision2.check @@ -0,0 +1,12 @@ +case-collision2.scala:5: warning: Class foo.BIPPY differs only in case from foo.Bippy. Such classes will overwrite one another on case-insensitive filesystems. +class BIPPY + ^ +case-collision2.scala:8: warning: Class foo.DINGO$ differs only in case from foo.Dingo$. Such classes will overwrite one another on case-insensitive filesystems. +object DINGO + ^ +case-collision2.scala:11: warning: Class foo.HyRaX$ differs only in case from foo.Hyrax$. Such classes will overwrite one another on case-insensitive filesystems. +object HyRaX + ^ +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/case-collision2.flags b/test/files/neg/case-collision2.flags new file mode 100644 index 0000000000..5bfa9da5c5 --- /dev/null +++ b/test/files/neg/case-collision2.flags @@ -0,0 +1 @@ +-Ynooptimize -Ybackend:GenBCode -Xfatal-warnings diff --git a/test/files/neg/case-collision2.scala b/test/files/neg/case-collision2.scala new file mode 100644 index 0000000000..924e33005a --- /dev/null +++ b/test/files/neg/case-collision2.scala @@ -0,0 +1,12 @@ +package foo + +class Bippy + +class BIPPY + +object Dingo +object DINGO + +case class Hyrax() +object HyRaX + diff --git a/test/files/neg/catch-all.check b/test/files/neg/catch-all.check index 62f895cc7e..aaf51480c3 100644 --- a/test/files/neg/catch-all.check +++ b/test/files/neg/catch-all.check @@ -1,10 +1,12 @@ -catch-all.scala:2: error: This catches all Throwables. If this is really intended, use `case _ : Throwable` to clear this warning. +catch-all.scala:2: warning: This catches all Throwables. If this is really intended, use `case _ : Throwable` to clear this warning. try { "warn" } catch { case _ => } ^ -catch-all.scala:4: error: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. +catch-all.scala:4: warning: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. try { "warn" } catch { case x => } ^ -catch-all.scala:6: error: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. +catch-all.scala:6: warning: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. try { "warn" } catch { case _: RuntimeException => ; case x => } ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/check-dead.check b/test/files/neg/check-dead.check index 29601c1d4a..2150a942bf 100644 --- a/test/files/neg/check-dead.check +++ b/test/files/neg/check-dead.check @@ -1,13 +1,15 @@ -check-dead.scala:7: error: dead code following this construct +check-dead.scala:7: warning: dead code following this construct def z1 = y1(throw new Exception) // should warn ^ -check-dead.scala:10: error: dead code following this construct +check-dead.scala:10: warning: dead code following this construct def z2 = y2(throw new Exception) // should warn ^ -check-dead.scala:29: error: dead code following this construct +check-dead.scala:29: warning: dead code following this construct throw new Exception // should warn ^ -check-dead.scala:33: error: dead code following this construct +check-dead.scala:33: warning: dead code following this construct throw new Exception // should warn ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/check-dead.scala b/test/files/neg/check-dead.scala index aadd788814..2d5bccb21d 100644 --- a/test/files/neg/check-dead.scala +++ b/test/files/neg/check-dead.scala @@ -5,11 +5,11 @@ object Other { class NoDeads { def y1(arg: Any) = println("foo") def z1 = y1(throw new Exception) // should warn - + def y2[T](arg: T) = println("foo") def z2 = y2(throw new Exception) // should warn - - def y3[T](arg: => T) = println("foo") + + def y3[T](arg: => T) = println("foo") def z3 = y3(throw new Exception) // should not warn: by name arg def nowarn1 = synchronized { throw new Exception } // should not warn: synchronized should be by name @@ -22,9 +22,9 @@ class NoDeads { val i = 10 + 2 i } - + def nowarn4: String = Other.oops("don't warn about me") // should not warn - + def yeswarn1 = synchronized { throw new Exception // should warn 5 * 5 @@ -32,6 +32,6 @@ class NoDeads { def yeswarn2: Int = synchronized { throw new Exception // should warn return 5 - } + } } diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check index d785179a56..e5f1a38d96 100644 --- a/test/files/neg/checksensible.check +++ b/test/files/neg/checksensible.check @@ -1,100 +1,102 @@ -checksensible.scala:13: error: comparing a fresh object using `eq' will always yield false +checksensible.scala:13: warning: comparing a fresh object using `eq' will always yield false (new AnyRef) eq (new AnyRef) ^ -checksensible.scala:14: error: comparing a fresh object using `ne' will always yield true +checksensible.scala:14: warning: comparing a fresh object using `ne' will always yield true (new AnyRef) ne (new AnyRef) ^ -checksensible.scala:15: error: comparing a fresh object using `eq' will always yield false +checksensible.scala:15: warning: comparing a fresh object using `eq' will always yield false Shmoopie eq (new AnyRef) ^ -checksensible.scala:16: error: comparing a fresh object using `eq' will always yield false +checksensible.scala:16: warning: comparing a fresh object using `eq' will always yield false (Shmoopie: AnyRef) eq (new AnyRef) ^ -checksensible.scala:17: error: comparing a fresh object using `eq' will always yield false +checksensible.scala:17: warning: comparing a fresh object using `eq' will always yield false (new AnyRef) eq Shmoopie ^ -checksensible.scala:18: error: comparing a fresh object using `eq' will always yield false +checksensible.scala:18: warning: comparing a fresh object using `eq' will always yield false (new AnyRef) eq null ^ -checksensible.scala:19: error: comparing a fresh object using `eq' will always yield false +checksensible.scala:19: warning: comparing a fresh object using `eq' will always yield false null eq new AnyRef ^ -checksensible.scala:26: error: comparing values of types Unit and Int using `==' will always yield false +checksensible.scala:26: warning: comparing values of types Unit and Int using `==' will always yield false (c = 1) == 0 ^ -checksensible.scala:27: error: comparing values of types Int and Unit using `==' will always yield false +checksensible.scala:27: warning: comparing values of types Int and Unit using `==' will always yield false 0 == (c = 1) ^ -checksensible.scala:29: error: comparing values of types Int and String using `==' will always yield false +checksensible.scala:29: warning: comparing values of types Int and String using `==' will always yield false 1 == "abc" ^ -checksensible.scala:33: error: comparing values of types Some[Int] and Int using `==' will always yield false +checksensible.scala:33: warning: comparing values of types Some[Int] and Int using `==' will always yield false Some(1) == 1 // as above ^ -checksensible.scala:38: error: comparing a fresh object using `==' will always yield false +checksensible.scala:38: warning: comparing a fresh object using `==' will always yield false new AnyRef == 1 ^ -checksensible.scala:41: error: comparing values of types Int and Boolean using `==' will always yield false +checksensible.scala:41: warning: comparing values of types Int and Boolean using `==' will always yield false 1 == (new java.lang.Boolean(true)) ^ -checksensible.scala:43: error: comparing values of types Int and Boolean using `!=' will always yield true +checksensible.scala:43: warning: comparing values of types Int and Boolean using `!=' will always yield true 1 != true ^ -checksensible.scala:44: error: comparing values of types Unit and Boolean using `==' will always yield false +checksensible.scala:44: warning: comparing values of types Unit and Boolean using `==' will always yield false () == true ^ -checksensible.scala:45: error: comparing values of types Unit and Unit using `==' will always yield true +checksensible.scala:45: warning: comparing values of types Unit and Unit using `==' will always yield true () == () ^ -checksensible.scala:46: error: comparing values of types Unit and Unit using `==' will always yield true +checksensible.scala:46: warning: comparing values of types Unit and Unit using `==' will always yield true () == println ^ -checksensible.scala:47: error: comparing values of types Unit and scala.runtime.BoxedUnit using `==' will always yield true +checksensible.scala:47: warning: comparing values of types Unit and scala.runtime.BoxedUnit using `==' will always yield true () == scala.runtime.BoxedUnit.UNIT // these should warn for always being true/false ^ -checksensible.scala:48: error: comparing values of types scala.runtime.BoxedUnit and Unit using `!=' will always yield false +checksensible.scala:48: warning: comparing values of types scala.runtime.BoxedUnit and Unit using `!=' will always yield false scala.runtime.BoxedUnit.UNIT != () ^ -checksensible.scala:51: error: comparing values of types Int and Unit using `!=' will always yield true +checksensible.scala:51: warning: comparing values of types Int and Unit using `!=' will always yield true (1 != println) ^ -checksensible.scala:52: error: comparing values of types Int and Symbol using `!=' will always yield true +checksensible.scala:52: warning: comparing values of types Int and Symbol using `!=' will always yield true (1 != 'sym) ^ -checksensible.scala:58: error: comparing a fresh object using `==' will always yield false +checksensible.scala:58: warning: comparing a fresh object using `==' will always yield false ((x: Int) => x + 1) == null ^ -checksensible.scala:59: error: comparing a fresh object using `==' will always yield false +checksensible.scala:59: warning: comparing a fresh object using `==' will always yield false Bep == ((_: Int) + 1) ^ -checksensible.scala:61: error: comparing a fresh object using `==' will always yield false +checksensible.scala:61: warning: comparing a fresh object using `==' will always yield false new Object == new Object ^ -checksensible.scala:62: error: comparing a fresh object using `==' will always yield false +checksensible.scala:62: warning: comparing a fresh object using `==' will always yield false new Object == "abc" ^ -checksensible.scala:63: error: comparing a fresh object using `!=' will always yield true +checksensible.scala:63: warning: comparing a fresh object using `!=' will always yield true new Exception() != new Exception() ^ -checksensible.scala:66: error: comparing values of types Int and Null using `==' will always yield false +checksensible.scala:66: warning: comparing values of types Int and Null using `==' will always yield false if (foo.length == null) "plante" else "plante pas" ^ -checksensible.scala:71: error: comparing values of types Bip and Bop using `==' will always yield false +checksensible.scala:71: warning: comparing values of types Bip and Bop using `==' will always yield false (x1 == x2) ^ -checksensible.scala:81: error: comparing values of types EqEqRefTest.this.C3 and EqEqRefTest.this.Z1 using `==' will always yield false +checksensible.scala:81: warning: comparing values of types EqEqRefTest.this.C3 and EqEqRefTest.this.Z1 using `==' will always yield false c3 == z1 ^ -checksensible.scala:82: error: comparing values of types EqEqRefTest.this.Z1 and EqEqRefTest.this.C3 using `==' will always yield false +checksensible.scala:82: warning: comparing values of types EqEqRefTest.this.Z1 and EqEqRefTest.this.C3 using `==' will always yield false z1 == c3 ^ -checksensible.scala:83: error: comparing values of types EqEqRefTest.this.Z1 and EqEqRefTest.this.C3 using `!=' will always yield true +checksensible.scala:83: warning: comparing values of types EqEqRefTest.this.Z1 and EqEqRefTest.this.C3 using `!=' will always yield true z1 != c3 ^ -checksensible.scala:84: error: comparing values of types EqEqRefTest.this.C3 and String using `!=' will always yield true +checksensible.scala:84: warning: comparing values of types EqEqRefTest.this.C3 and String using `!=' will always yield true c3 != "abc" ^ -checksensible.scala:95: error: comparing values of types Unit and Int using `!=' will always yield true +checksensible.scala:95: warning: comparing values of types Unit and Int using `!=' will always yield true while ((c = in.read) != -1) ^ -33 errors found +error: No warnings can be incurred under -Xfatal-warnings. +33 warnings found +one error found diff --git a/test/files/neg/checksensible.scala b/test/files/neg/checksensible.scala index 27ee908153..b6083f75e4 100644 --- a/test/files/neg/checksensible.scala +++ b/test/files/neg/checksensible.scala @@ -9,7 +9,7 @@ final class Zing { // 7 warnings class RefEqTest { object Shmoopie - + (new AnyRef) eq (new AnyRef) (new AnyRef) ne (new AnyRef) Shmoopie eq (new AnyRef) @@ -22,10 +22,10 @@ class RefEqTest { // 13 warnings class EqEqValTest { var c = 0 - + (c = 1) == 0 0 == (c = 1) - + 1 == "abc" 1 == ("abc": Any) // doesn't warn because an Any may be a boxed Int 1 == (1: Any) // as above @@ -34,12 +34,12 @@ class EqEqValTest { true == new java.lang.Boolean(true) // none of these should warn new java.lang.Boolean(true) == true - + new AnyRef == 1 1 == new AnyRef // doesn't warn because it could be... 1 == (new java.lang.Integer(1)) // ...something like this 1 == (new java.lang.Boolean(true)) - + 1 != true () == true () == () @@ -47,13 +47,13 @@ class EqEqValTest { () == scala.runtime.BoxedUnit.UNIT // these should warn for always being true/false scala.runtime.BoxedUnit.UNIT != () (scala.runtime.BoxedUnit.UNIT: java.io.Serializable) != () // shouldn't warn - + (1 != println) (1 != 'sym) } // 12 warnings -class EqEqRefTest { +class EqEqRefTest { val ref = new Bop ((x: Int) => x + 1) == null Bep == ((_: Int) + 1) @@ -67,9 +67,9 @@ class EqEqRefTest { // final classes with default equals val x1 = new Bip - val x2 = new Bop + val x2 = new Bop (x1 == x2) - + class C1 { } class C2 extends C1 { } final class Z1 extends C2 { } @@ -84,14 +84,14 @@ class EqEqRefTest { c3 != "abc" // this should warn when feeling chatty c3 != z1 - + // non-warners (null: AnyRef) == (null: AnyRef) (x1 <= x2) - + def main(args: Array[String]) = { val in = new java.io.FileInputStream(args(0)) - var c = 0 + var c = 0 while ((c = in.read) != -1) print(c.toChar) diff --git a/test/files/neg/choices.check b/test/files/neg/choices.check index 3e63f9999d..b114394e96 100644 --- a/test/files/neg/choices.check +++ b/test/files/neg/choices.check @@ -1,2 +1,2 @@ -partest error: bad flags: -Ylinearizer +error: bad options: -Yresolve-term-conflict one error found diff --git a/test/files/neg/choices.flags b/test/files/neg/choices.flags index 5464a18c5d..9718467d4c 100644 --- a/test/files/neg/choices.flags +++ b/test/files/neg/choices.flags @@ -1 +1 @@ --Ylinearizer
\ No newline at end of file +-Yresolve-term-conflict diff --git a/test/files/neg/choices.scala b/test/files/neg/choices.scala index fe9236f10f..8827494874 100644 --- a/test/files/neg/choices.scala +++ b/test/files/neg/choices.scala @@ -1,5 +1,5 @@ object Test { def main(args: Array[String]): Unit = { - + } } diff --git a/test/files/neg/classmanifests_new_deprecations.check b/test/files/neg/classmanifests_new_deprecations.check index 12428c7626..fd1e2728c3 100644 --- a/test/files/neg/classmanifests_new_deprecations.check +++ b/test/files/neg/classmanifests_new_deprecations.check @@ -1,31 +1,27 @@ -classmanifests_new_deprecations.scala:2: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:2: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead def cm1[T: ClassManifest] = ??? ^ -classmanifests_new_deprecations.scala:3: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:3: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead def cm2[T](implicit evidence$1: ClassManifest[T]) = ??? ^ -classmanifests_new_deprecations.scala:4: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:4: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead val cm3: ClassManifest[Int] = null ^ -classmanifests_new_deprecations.scala:4: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead - val cm3: ClassManifest[Int] = null - ^ -classmanifests_new_deprecations.scala:6: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:6: warning: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead def rcm1[T: scala.reflect.ClassManifest] = ??? ^ -classmanifests_new_deprecations.scala:7: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:7: warning: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead def rcm2[T](implicit evidence$1: scala.reflect.ClassManifest[T]) = ??? ^ -classmanifests_new_deprecations.scala:8: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:8: warning: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead val rcm3: scala.reflect.ClassManifest[Int] = null ^ -classmanifests_new_deprecations.scala:8: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead - val rcm3: scala.reflect.ClassManifest[Int] = null - ^ -classmanifests_new_deprecations.scala:10: error: type ClassManifest in object Predef is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:10: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead type CM[T] = ClassManifest[T] ^ -classmanifests_new_deprecations.scala:15: error: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead +classmanifests_new_deprecations.scala:15: warning: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead type RCM[T] = scala.reflect.ClassManifest[T] ^ -10 errors found +error: No warnings can be incurred under -Xfatal-warnings. +8 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 new file mode 100644 index 0000000000..1c4c72171f --- /dev/null +++ b/test/files/neg/compile-time-only-a.check @@ -0,0 +1,49 @@ +compile-time-only-a.scala:9: error: C3 +@compileTimeOnly("C3") case class C3(x: Int) + ^ +compile-time-only-a.scala:11: error: C4 +@compileTimeOnly("C4") case class C4(x: Int) + ^ +compile-time-only-a.scala:16: error: C5 + implicit class C5(val x: Int) { + ^ +compile-time-only-a.scala:28: error: C1 + new C1() + ^ +compile-time-only-a.scala:32: error: C2 + C2 + ^ +compile-time-only-a.scala:34: error: C3 + new C3(2) + ^ +compile-time-only-a.scala:37: error: C4 + new C4(2) + ^ +compile-time-only-a.scala:41: error: C5 + 2.ext + ^ +compile-time-only-a.scala:42: error: C5 + C5(2) + ^ +compile-time-only-a.scala:45: error: C6.x + val _ = c6.x + ^ +compile-time-only-a.scala:46: error: C6.foo + c6.foo + ^ +compile-time-only-a.scala:48: error: C6.y + c6.y = c6.y + ^ +compile-time-only-a.scala:48: error: C6.y + c6.y = c6.y + ^ +compile-time-only-a.scala:54: error: placebo +@placebo + ^ +compile-time-only-a.scala:56: error: placebo + @placebo def x = (2: @placebo) + ^ +compile-time-only-a.scala:56: error: placebo + @placebo def x = (2: @placebo) + ^ +16 errors found diff --git a/test/files/neg/compile-time-only-a.scala b/test/files/neg/compile-time-only-a.scala new file mode 100644 index 0000000000..43d36dfab1 --- /dev/null +++ b/test/files/neg/compile-time-only-a.scala @@ -0,0 +1,57 @@ +import scala.annotation.compileTimeOnly + +@compileTimeOnly("C1") class C1 +object C1 + +class C2 +@compileTimeOnly("C2") object C2 + +@compileTimeOnly("C3") case class C3(x: Int) + +@compileTimeOnly("C4") case class C4(x: Int) +object C4 + +object pkg { + @compileTimeOnly("C5") + implicit class C5(val x: Int) { + def ext = ??? + } +} + +class C6(@compileTimeOnly("C6.x") val x: Int) { + @compileTimeOnly("C6.foo") def foo = 2 + @compileTimeOnly("C6.Foo") type Foo = Int + @compileTimeOnly("C6.y") var y = 3 +} + +object Test extends App { + new C1() + C1 + + new C2() + C2 + + new C3(2) + C3(2) + + new C4(2) + C4(2) + + import pkg._ + 2.ext + C5(2) + + val c6 = new C6(2) + val _ = c6.x + c6.foo + type Foo = c6.Foo + c6.y = c6.y +} + +@compileTimeOnly("placebo") +class placebo extends scala.annotation.StaticAnnotation + +@placebo +class Test { + @placebo def x = (2: @placebo) +}
\ No newline at end of file diff --git a/test/files/neg/compile-time-only-b.check b/test/files/neg/compile-time-only-b.check new file mode 100644 index 0000000000..8292a0ddeb --- /dev/null +++ b/test/files/neg/compile-time-only-b.check @@ -0,0 +1,7 @@ +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 diff --git a/test/files/neg/compile-time-only-b.scala b/test/files/neg/compile-time-only-b.scala new file mode 100644 index 0000000000..d5568dbe67 --- /dev/null +++ b/test/files/neg/compile-time-only-b.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + // HAHA!!! + // no compileTimeOnly errors here, because scalac does constant folding + // the type of reify(42) is Expr[42.type] + // therefore the type of expr.splice is 42.type, which is then constfolded + val expr = reify(42) + val ignored1 = expr.splice + val ignored2 = expr.value + + val fortyTwo = 42 + val ignored3 = reify(fortyTwo).splice + val ignored4 = reify(fortyTwo).value +}
\ No newline at end of file diff --git a/test/files/neg/constructor-init-order.check b/test/files/neg/constructor-init-order.check new file mode 100644 index 0000000000..9ab6ac5923 --- /dev/null +++ b/test/files/neg/constructor-init-order.check @@ -0,0 +1,9 @@ +constructor-init-order.scala:7: warning: Reference to uninitialized value baz + val bar1 = baz // warn + ^ +constructor-init-order.scala:17: warning: Reference to uninitialized variable baz + var bar1 = baz // warn + ^ +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/constructor-init-order.flags b/test/files/neg/constructor-init-order.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/constructor-init-order.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/constructor-init-order.scala b/test/files/neg/constructor-init-order.scala new file mode 100644 index 0000000000..fe8fec87ad --- /dev/null +++ b/test/files/neg/constructor-init-order.scala @@ -0,0 +1,23 @@ +trait Foo0 { + val quux1: String + val quux2 = quux1 // warning here is "future work" +} + +class Foo1 extends Foo0 { + val bar1 = baz // warn + val bar2 = lazybaz // no warn + val bar3 = defbaz // no warn + val baz = "oops" + lazy val lazybaz = "ok" + def defbaz = "ok" + val quux1 = "oops" +} + +class Foo2 { + var bar1 = baz // warn + var bar2 = lazybaz // no warn + var bar3 = defbaz // no warn + var baz = "oops" + lazy val lazybaz = "ok" + def defbaz = "ok" +} diff --git a/test/files/neg/cycle-bounds.check b/test/files/neg/cycle-bounds.check new file mode 100644 index 0000000000..d924838aec --- /dev/null +++ b/test/files/neg/cycle-bounds.check @@ -0,0 +1,4 @@ +cycle-bounds.scala:5: error: illegal cyclic reference involving type T +class NotOk[T <: Comparable[_ <: T]] + ^ +one error found diff --git a/test/files/neg/cycle-bounds.flags b/test/files/neg/cycle-bounds.flags new file mode 100644 index 0000000000..ca20f55172 --- /dev/null +++ b/test/files/neg/cycle-bounds.flags @@ -0,0 +1 @@ +-Ybreak-cycles diff --git a/test/files/neg/cycle-bounds.scala b/test/files/neg/cycle-bounds.scala new file mode 100644 index 0000000000..0b43bc703e --- /dev/null +++ b/test/files/neg/cycle-bounds.scala @@ -0,0 +1,5 @@ +// This should be allowed +class Ok[T <: Comparable[_ >: T]] + +// This is (il)legitimately a cyclic reference +class NotOk[T <: Comparable[_ <: T]] diff --git a/test/files/neg/cyclics-import.check b/test/files/neg/cyclics-import.check index ef355fab0a..be09fca374 100644 --- a/test/files/neg/cyclics-import.check +++ b/test/files/neg/cyclics-import.check @@ -3,13 +3,4 @@ Note: this is often due in part to a class depending on a definition nested with If applicable, you may wish to try moving some members into another object. import User.UserStatus._ ^ -cyclics-import.scala:12: error: not found: type Value - type UserStatus = Value - ^ -cyclics-import.scala:14: error: not found: value Value - val Active = Value("1") - ^ -cyclics-import.scala:15: error: not found: value Value - val Disabled = Value("2") - ^ -four errors found +one error found diff --git a/test/files/neg/dbldef.check b/test/files/neg/dbldef.check index 3ee63475e4..b896c4cdcf 100644 --- a/test/files/neg/dbldef.check +++ b/test/files/neg/dbldef.check @@ -6,9 +6,7 @@ dbldef.scala:1: error: type mismatch; required: Int case class test0(x: Int, x: Float) ^ -dbldef.scala:1: error: type mismatch; - found : Float - required: Int +dbldef.scala:1: error: in class test0, multiple overloaded alternatives of x define default arguments case class test0(x: Int, x: Float) ^ three errors found diff --git a/test/files/neg/delayed-init-ref.check b/test/files/neg/delayed-init-ref.check index 42ccabed1b..ce5b205832 100644 --- a/test/files/neg/delayed-init-ref.check +++ b/test/files/neg/delayed-init-ref.check @@ -1,10 +1,12 @@ -delayed-init-ref.scala:17: error: Selecting value vall from object O, which extends scala.DelayedInit, is likely to yield an uninitialized value +delayed-init-ref.scala:17: warning: Selecting value vall from object O, which extends scala.DelayedInit, is likely to yield an uninitialized value println(O.vall) // warn ^ -delayed-init-ref.scala:19: error: Selecting value vall from object O, which extends scala.DelayedInit, is likely to yield an uninitialized value +delayed-init-ref.scala:19: warning: Selecting value vall from object O, which extends scala.DelayedInit, is likely to yield an uninitialized value println(vall) // warn ^ -delayed-init-ref.scala:40: error: Selecting value foo from trait UserContext, which extends scala.DelayedInit, is likely to yield an uninitialized value +delayed-init-ref.scala:40: warning: Selecting value foo from trait UserContext, which extends scala.DelayedInit, is likely to yield an uninitialized value println({locally(()); this}.foo) // warn (spurious, but we can't discriminate) ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/eta-expand-star-deprecation.check b/test/files/neg/eta-expand-star-deprecation.check new file mode 100644 index 0000000000..a79f0df76c --- /dev/null +++ b/test/files/neg/eta-expand-star-deprecation.check @@ -0,0 +1,4 @@ +warning: -Yeta-expand-keeps-star is deprecated: This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug. +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/eta-expand-star-deprecation.flags b/test/files/neg/eta-expand-star-deprecation.flags new file mode 100644 index 0000000000..5ac8b638e4 --- /dev/null +++ b/test/files/neg/eta-expand-star-deprecation.flags @@ -0,0 +1 @@ +-Yeta-expand-keeps-star -deprecation -Xfatal-warnings diff --git a/test/files/neg/eta-expand-star-deprecation.scala b/test/files/neg/eta-expand-star-deprecation.scala new file mode 100644 index 0000000000..5749692522 --- /dev/null +++ b/test/files/neg/eta-expand-star-deprecation.scala @@ -0,0 +1,8 @@ +object Test { + def f[T](xs: T*): Unit = () + def g[T] = f[T] _ + + def main(args: Array[String]): Unit = { + g(1, 2) + } +} diff --git a/test/files/neg/exhausting.check b/test/files/neg/exhausting.check index 0f0d13cb33..619849693c 100644 --- a/test/files/neg/exhausting.check +++ b/test/files/neg/exhausting.check @@ -1,25 +1,27 @@ -exhausting.scala:21: error: match may not be exhaustive. -It would fail on the following input: List(_, _, _) +exhausting.scala:21: warning: match may not be exhaustive. +It would fail on the following inputs: List(_), List(_, _, _) def fail1[T](xs: List[T]) = xs match { ^ -exhausting.scala:27: error: match may not be exhaustive. +exhausting.scala:27: warning: match may not be exhaustive. It would fail on the following input: Nil def fail2[T](xs: List[T]) = xs match { ^ -exhausting.scala:32: error: match may not be exhaustive. +exhausting.scala:32: warning: match may not be exhaustive. It would fail on the following input: List((x: Int forSome x not in (1, 2))) def fail3a(xs: List[Int]) = xs match { ^ -exhausting.scala:39: error: match may not be exhaustive. +exhausting.scala:39: warning: match may not be exhaustive. It would fail on the following input: Bar3 def fail3[T](x: Foo[T]) = x match { ^ -exhausting.scala:47: error: match may not be exhaustive. +exhausting.scala:47: warning: match may not be exhaustive. It would fail on the following inputs: (Bar1, Bar2), (Bar1, Bar3), (Bar2, Bar1), (Bar2, Bar2) def fail4[T <: AnyRef](xx: (Foo[T], Foo[T])) = xx match { ^ -exhausting.scala:56: error: match may not be exhaustive. +exhausting.scala:56: warning: match may not be exhaustive. It would fail on the following inputs: (Bar1, Bar2), (Bar1, Bar3), (Bar2, Bar1), (Bar2, Bar2) def fail5[T](xx: (Foo[T], Foo[T])) = xx match { ^ -6 errors found +error: No warnings can be incurred under -Xfatal-warnings. +6 warnings found +one error found diff --git a/test/files/neg/exhausting.scala b/test/files/neg/exhausting.scala index 5554ee2671..c00569c91d 100644 --- a/test/files/neg/exhausting.scala +++ b/test/files/neg/exhausting.scala @@ -3,7 +3,7 @@ object Test { case object Bar1 extends Foo[Int] case object Bar2 extends Foo[String] case object Bar3 extends Foo[Any] - + def ex1[T](xs: List[T]) = xs match { case ys: List[_] => "ok" } @@ -17,7 +17,7 @@ object Test { case (_: Foo[_], _: Foo[_]) => () } - // fails for: ::(_, ::(_, ::(_, _))) + // fails for: ::(_, Nil), ::(_, ::(_, ::(_, _))), ... def fail1[T](xs: List[T]) = xs match { case Nil => "ok" case x :: y :: Nil => "ok" diff --git a/test/files/neg/forgot-interpolator.check b/test/files/neg/forgot-interpolator.check new file mode 100644 index 0000000000..a96431841f --- /dev/null +++ b/test/files/neg/forgot-interpolator.check @@ -0,0 +1,24 @@ +forgot-interpolator.scala:4: warning: `$bippy` looks like an interpolated identifier! Did you forget the interpolator? + def f = "Put the $bippy in the $bippy!" // warn + ^ +forgot-interpolator.scala:14: warning: That looks like an interpolated expression! Did you forget the interpolator? + def f = """Put the ${println("bippy")} in the bippy!""" // warn + ^ +forgot-interpolator.scala:30: warning: `$beppo` looks like an interpolated identifier! Did you forget the interpolator? + def f = "$beppo was a marx bros who saw dollars." // warn + ^ +forgot-interpolator.scala:34: warning: `$aleppo` looks like an interpolated identifier! Did you forget the interpolator? + def f = "$aleppo is a pepper and a city." // warn + ^ +forgot-interpolator.scala:40: warning: `$bar` looks like an interpolated identifier! Did you forget the interpolator? + def f = "$bar is private, shall we warn just in case?" // warn + ^ +forgot-interpolator.scala:45: warning: `$hippo` looks like an interpolated identifier! Did you forget the interpolator? + def h = "$hippo takes an implicit" // warn + ^ +forgot-interpolator.scala:37: warning: private method in class Bar is never used + private def bar = 8 + ^ +error: No warnings can be incurred under -Xfatal-warnings. +7 warnings found +one error found diff --git a/test/files/neg/forgot-interpolator.flags b/test/files/neg/forgot-interpolator.flags new file mode 100644 index 0000000000..7949c2afa2 --- /dev/null +++ b/test/files/neg/forgot-interpolator.flags @@ -0,0 +1 @@ +-Xlint -Xfatal-warnings diff --git a/test/files/neg/forgot-interpolator.scala b/test/files/neg/forgot-interpolator.scala new file mode 100644 index 0000000000..5067f1dce9 --- /dev/null +++ b/test/files/neg/forgot-interpolator.scala @@ -0,0 +1,47 @@ +class A { + val bippy = 123 + + def f = "Put the $bippy in the $bippy!" // warn +} + +class B { + val dingus = 123 + + def f = "Put the $bippy in the $bippy!" // no warn +} + +class C { + def f = """Put the ${println("bippy")} in the bippy!""" // warn +} + +package object test { + def aleppo = 9 + def greppo(n: Int) = ??? + def zappos(n: Int)(implicit ord: math.Ordering[Int]) = ??? + def hippo(implicit n: Int) = ??? +} + +package test { + // not sure if overloading is kosher in pkg obj yet + class Doo { + def beppo(i: Int) = 8 * i + def beppo = 8 + class Dah extends Doo { + def f = "$beppo was a marx bros who saw dollars." // warn + } + } + class E { + def f = "$aleppo is a pepper and a city." // warn + } + class Bar { + private def bar = 8 + } + class Baz extends Bar { + def f = "$bar is private, shall we warn just in case?" // warn + } + class G { + def g = "$greppo takes an arg" // no warn + def z = "$zappos takes an arg too" // no warn + def h = "$hippo takes an implicit" // warn + } +} diff --git a/test/files/neg/forward.scala b/test/files/neg/forward.scala index 3774fa838f..d5c0851f09 100644 --- a/test/files/neg/forward.scala +++ b/test/files/neg/forward.scala @@ -5,20 +5,20 @@ object Test { { def f: Int = x; val x: Int = f; - } + } { def f: Int = g; val x: Int = f; def g: Int = x; - } + } { def f: Int = g; var x: Int = f; def g: Int = x; - } + } { def f: Int = g; Console.println("foo"); def g: Int = f; - } + } } diff --git a/test/files/neg/found-req-variance.scala b/test/files/neg/found-req-variance.scala index fd3b11160e..024b24c367 100644 --- a/test/files/neg/found-req-variance.scala +++ b/test/files/neg/found-req-variance.scala @@ -27,7 +27,7 @@ object Test { def f7 = Set[Inv[C]]() + new Inv[A] def f8 = Set[Inv[C]]() + new Inv[B] def f9 = Set[Inv[C]]() + new Inv[C] - + def g1 = Set[Multi[A, B, C]]() + new MultiCov[A] def g2 = Set[Multi[A, B, C]]() + new MultiCov[B] def g3 = Set[Multi[A, B, C]]() + new MultiCov[C] @@ -43,12 +43,12 @@ object Functions { object Set1 { def f[T, R](x: FF1[T, R]) = () def h[T, R] : FF1[T, R] = sys.error("") - + def ff1 = f[B, B](h[A, A]) // fail def ff2 = f[B, B](h[B, A]) // fail def ff3 = f[B, B](h[C, A]) // fail def ff4 = f[B, B](h[A, B]) // suggest - def ff5 = f[B, B](h[B, B]) // ok + def ff5 = f[B, B](h[B, B]) // ok def ff6 = f[B, B](h[C, B]) // suggest def ff7 = f[B, B](h[A, C]) // suggest def ff8 = f[B, B](h[B, C]) // ok @@ -57,7 +57,7 @@ object Functions { object Set2 { def f[T, R](x: FF2[T, R]) = () def h[T, R] : FF2[T, R] = sys.error("") - + def ff1 = f[B, B](h[A, A]) // suggest def ff2 = f[B, B](h[B, A]) // suggest def ff3 = f[B, B](h[C, A]) // fail @@ -74,7 +74,7 @@ object Functions { // object TypeAlias { // type LL[T] = List[T] // val LL = List -// +// // def f1 = Set[LL[B]]() + LL[A](new A) // def f2 = Set[LL[B]]() + LL[C](new C) // } @@ -82,12 +82,12 @@ object Functions { object Javas { def f[T](x: java.util.List[T]) = () def g[T](x: java.util.Comparator[T]) = () - + def g1 = f[AnyRef](new java.util.ArrayList[String] { }) def g2 = g[String](Ordering.fromLessThan[AnyRef](_.toString < _.toString)) } -object Misc { +object Misc { // original motivation class Data[A <: AnyVal] class MyData extends Data[Int] { } diff --git a/test/files/neg/gadts1.check b/test/files/neg/gadts1.check index a5e3e0de10..9b7ea5556a 100644 --- a/test/files/neg/gadts1.check +++ b/test/files/neg/gadts1.check @@ -1,8 +1,3 @@ -gadts1.scala:15: error: type mismatch; - found : Test.Double - required: a - case NumTerm(n) => c.x = Double(1.0) - ^ gadts1.scala:20: error: Test.Cell[a] does not take parameters case Cell[a](x: Int) => c.x = 5 ^ @@ -11,4 +6,4 @@ gadts1.scala:20: error: type mismatch; required: a case Cell[a](x: Int) => c.x = 5 ^ -three errors found +two errors found diff --git a/test/files/neg/gadts1.scala b/test/files/neg/gadts1.scala index 1fb6e57e2d..08403e6eec 100644 --- a/test/files/neg/gadts1.scala +++ b/test/files/neg/gadts1.scala @@ -11,8 +11,8 @@ class IntTerm(n: Int) extends NumTerm(n) with Term[Int] def f[a](t:Term[a], c:Cell[a]): Unit = { - t match { - case NumTerm(n) => c.x = Double(1.0) + t match { + case NumTerm(n) => c.x = Double(1.0) } t match { // presently testing that this gets past the parser: eventually diff --git a/test/files/neg/implicits.scala b/test/files/neg/implicits.scala index 878d3a7c99..22633a1f35 100644 --- a/test/files/neg/implicits.scala +++ b/test/files/neg/implicits.scala @@ -4,14 +4,14 @@ class Super object Super { implicit def pos2int(p: Pos): Int = 0 -} +} object Sub extends Super { class Plus(x: Any) { def +(y: String): String = x.toString + y } implicit def any2plus(x: Any): Plus = new Plus(x) -} +} object Test { import Super._ @@ -33,7 +33,7 @@ object test2 { val set = HEmpty + 3 + "3" implicit def select[T](t: HSome[T,_]) = t.head implicit def selectTail[L](t: HSome[_,L]) = t.tail - + def foo(x: Int) = 3 foo(set) } @@ -55,7 +55,7 @@ class Mxml { } -} +} // SI-5316 class Test3 { diff --git a/test/files/neg/import-precedence.check b/test/files/neg/import-precedence.check new file mode 100644 index 0000000000..5f99611052 --- /dev/null +++ b/test/files/neg/import-precedence.check @@ -0,0 +1,19 @@ +import-precedence.scala:18: error: reference to X is ambiguous; +it is imported twice in the same scope by +import uniq1.uniq2._ +and import uniq1.X + object Y { def f = X } + ^ +import-precedence.scala:61: error: reference to X is ambiguous; +it is imported twice in the same scope by +import uniq1.uniq2._ +and import uniq1._ + object Y { def f = X } + ^ +import-precedence.scala:67: error: reference to X is ambiguous; +it is imported twice in the same scope by +import uniq1.uniq2.X +and import uniq1.X + object Y { def f = X } + ^ +three errors found diff --git a/test/files/neg/import-precedence.scala b/test/files/neg/import-precedence.scala new file mode 100644 index 0000000000..0401635e32 --- /dev/null +++ b/test/files/neg/import-precedence.scala @@ -0,0 +1,68 @@ +package uniq1 { + object X + package uniq2 { + object X + package uniq3 { + object X + package uniq4 { + object X + } + } + } +} + +package p1 { + import uniq1.X + package p2 { + import uniq1.uniq2._ + object Y { def f = X } + } +} + +package p2 { + import uniq1.uniq2._ + package p2 { + import uniq1.X + object Y { def f = X } + } +} + +package p3 { + import uniq1.X + import uniq1.uniq2._ + object Y { def f = X } +} + +package p4 { + import uniq1.uniq2._ + import uniq1.X + object Y { def f = X } +} + +package p5 { + import uniq1.X + package p6 { + import uniq1.uniq2.X + object Y { def f = X } + } +} + +package p6 { + import uniq1._ + package p5 { + import uniq1.uniq2._ + object Y { def f = X } + } +} + +package p7 { + import uniq1._ + import uniq1.uniq2._ + object Y { def f = X } +} + +package p8 { + import uniq1.X + import uniq1.uniq2.X + object Y { def f = X } +} diff --git a/test/files/neg/java-access-neg/J.java b/test/files/neg/java-access-neg/J.java index 4f2024673c..b6bc3363a1 100644 --- a/test/files/neg/java-access-neg/J.java +++ b/test/files/neg/java-access-neg/J.java @@ -4,11 +4,11 @@ public abstract class J { public J() { } J(int x1) { } protected J(int x1, int x2) { } - + abstract void packageAbstract(); protected abstract void protectedAbstract(); public abstract void publicAbstract(); - + void packageConcrete() { return; } protected void protectedConcrete() { return; } public void publicConcrete() { return; } diff --git a/test/files/neg/java-access-neg/S2.scala b/test/files/neg/java-access-neg/S2.scala index dd0af8d39d..b082bb7174 100644 --- a/test/files/neg/java-access-neg/S2.scala +++ b/test/files/neg/java-access-neg/S2.scala @@ -12,7 +12,7 @@ class S1 extends J { override private[b] def packageAbstract() = () // fail override protected[b] def protectedAbstract() = () override def publicAbstract() = () - + override private[b] def packageConcrete() = () // fail override protected[b] def protectedConcrete() = () override def publicConcrete() = () @@ -32,7 +32,7 @@ class S3 extends J { protected[b] def packageAbstract() = () // fail protected[b] def protectedAbstract() = () def publicAbstract() = () - + override protected[b] def packageConcrete() = () // fail override protected[b] def protectedConcrete() = () override def publicConcrete() = () @@ -43,7 +43,7 @@ class S4 extends J { private[a] def packageAbstract() = () // fail protected[a] def protectedAbstract() = () def publicAbstract() = () - + override private[a] def packageConcrete() = () // fail override protected[a] def protectedConcrete() = () override def publicConcrete() = () @@ -54,7 +54,7 @@ class S5 extends J { def packageAbstract() = () // fail def protectedAbstract() = () def publicAbstract() = () - + override def packageConcrete() = () // fail override def protectedConcrete() = () override def publicConcrete() = () diff --git a/test/files/neg/javaConversions-2.10-ambiguity.check b/test/files/neg/javaConversions-2.10-ambiguity.check deleted file mode 100644 index c064a22964..0000000000 --- a/test/files/neg/javaConversions-2.10-ambiguity.check +++ /dev/null @@ -1,6 +0,0 @@ -javaConversions-2.10-ambiguity.scala:8: error: type mismatch; - found : scala.collection.concurrent.Map[String,String] - required: scala.collection.mutable.ConcurrentMap[String,String] - assertType[mutable.ConcurrentMap[String, String]](a) - ^ -one error found diff --git a/test/files/neg/lazy-override.scala b/test/files/neg/lazy-override.scala index a0f6e3bd73..f41d7f038b 100644 --- a/test/files/neg/lazy-override.scala +++ b/test/files/neg/lazy-override.scala @@ -5,7 +5,7 @@ lazy val y: Int = { print("/*A.y*/"); 2 } } - + class B extends A { // lazy overrides strict val override lazy val x: Int = { print("/*B.x*/"); 3 } diff --git a/test/files/neg/lazyvals.scala b/test/files/neg/lazyvals.scala index bbc4fe114a..f92534f506 100644 --- a/test/files/neg/lazyvals.scala +++ b/test/files/neg/lazyvals.scala @@ -1,7 +1,7 @@ /** Test which should fail compilation */ class Lazy { - + // no abstract lazy values lazy val t: Int @@ -31,7 +31,7 @@ object T2 { lazy val y: Int = { print("/*A.y*/"); 2 } } - + class B extends A { // lazy overrides strict val override lazy val x: Int = { print("/*B.x*/"); 3 } diff --git a/test/files/neg/logImplicits.check b/test/files/neg/logImplicits.check index 54afc6f86d..0522bd8354 100644 --- a/test/files/neg/logImplicits.check +++ b/test/files/neg/logImplicits.check @@ -7,10 +7,10 @@ logImplicits.scala:7: applied implicit conversion from String("abc") to ?{def ma logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String("abc"))Int math.max(122, x: Int) ^ -logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] +logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def ArrowAssoc[A](__leftOfArrow: A): ArrowAssoc[A] def f = (1 -> 2) + "c" ^ -logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{def +: ?} = implicit def any2stringadd(x: Any): scala.runtime.StringAdd +logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{def +: ?} = implicit def StringAdd[A](__thingToAdd: A): StringAdd[A] def f = (1 -> 2) + "c" ^ logImplicits.scala:22: error: class Un needs to be abstract, since method unimplemented is not defined diff --git a/test/files/neg/logImplicits.scala b/test/files/neg/logImplicits.scala index fb5dd8a025..caf827163c 100644 --- a/test/files/neg/logImplicits.scala +++ b/test/files/neg/logImplicits.scala @@ -9,9 +9,9 @@ class B { object C { final val x = "abc" - + implicit def convert(p: x.type): Int = 123 - + math.max(122, x: Int) } diff --git a/test/files/neg/lubs.check b/test/files/neg/lubs.check index 77ab20102c..affbd4983c 100644 --- a/test/files/neg/lubs.check +++ b/test/files/neg/lubs.check @@ -1,5 +1,10 @@ +lubs.scala:10: error: type mismatch; + found : test1.A[test1.A[Object]] + required: test1.A[test1.A[test1.A[Any]]] + val x3: A[A[A[Any]]] = f + ^ lubs.scala:11: error: type mismatch; - found : test1.A[test1.A[test1.A[Any]]] + found : test1.A[test1.A[Object]] required: test1.A[test1.A[test1.A[test1.A[Any]]]] val x4: A[A[A[A[Any]]]] = f ^ @@ -13,4 +18,4 @@ lubs.scala:25: error: type mismatch; required: test2.A{type T >: Null <: test2.A{type T >: Null <: test2.A{type T >: Null <: test2.A}}} val x4: A { type T >: Null <: A { type T >: Null <: A { type T >: Null <: A } } } = f ^ -three errors found +four errors found diff --git a/test/files/neg/lubs.scala b/test/files/neg/lubs.scala index 639117f7bf..3524fa4d87 100644 --- a/test/files/neg/lubs.scala +++ b/test/files/neg/lubs.scala @@ -18,7 +18,7 @@ object test2 { class D extends A { type T = D } def f = if (1 == 2) new C else new D - + val x1: A { type T } = f val x2: A { type T >: Null <: A } = f val x3: A { type T >: Null <: A { type T >: Null <: A } } = f diff --git a/test/files/neg/macro-basic-mamdmi.check b/test/files/neg/macro-basic-mamdmi.check index c7b58d70d2..621d318ceb 100644 --- a/test/files/neg/macro-basic-mamdmi.check +++ b/test/files/neg/macro-basic-mamdmi.check @@ -1,4 +1,5 @@ -Impls_Macros_Test_1.scala:36: error: macro implementation not found: foo (the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them) +Impls_Macros_Test_1.scala:36: error: macro implementation not found: foo +(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them) println(foo(2) + Macros.bar(2) * new Macros().quux(4)) ^ one error found diff --git a/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala b/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala index 908438cf65..f9e0ca5077 100644 --- a/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala +++ b/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala @@ -3,19 +3,19 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } } diff --git a/test/files/neg/macro-deprecate-idents.check b/test/files/neg/macro-deprecate-idents.check index 22b667c390..c653eabaef 100644 --- a/test/files/neg/macro-deprecate-idents.check +++ b/test/files/neg/macro-deprecate-idents.check @@ -1,52 +1,54 @@ -macro-deprecate-idents.scala:2: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:2: warning: macro is now a reserved word; usage as an identifier is deprecated val macro = ??? ^ -macro-deprecate-idents.scala:6: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:6: warning: macro is now a reserved word; usage as an identifier is deprecated var macro = ??? ^ -macro-deprecate-idents.scala:10: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:10: warning: macro is now a reserved word; usage as an identifier is deprecated type macro = Int ^ -macro-deprecate-idents.scala:14: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:14: warning: macro is now a reserved word; usage as an identifier is deprecated class macro ^ -macro-deprecate-idents.scala:18: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:18: warning: macro is now a reserved word; usage as an identifier is deprecated class macro ^ -macro-deprecate-idents.scala:22: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:22: warning: macro is now a reserved word; usage as an identifier is deprecated object macro ^ -macro-deprecate-idents.scala:26: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:26: warning: macro is now a reserved word; usage as an identifier is deprecated object macro ^ -macro-deprecate-idents.scala:30: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:30: warning: macro is now a reserved word; usage as an identifier is deprecated trait macro ^ -macro-deprecate-idents.scala:34: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:34: warning: macro is now a reserved word; usage as an identifier is deprecated trait macro ^ -macro-deprecate-idents.scala:37: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:37: warning: macro is now a reserved word; usage as an identifier is deprecated package macro { ^ -macro-deprecate-idents.scala:38: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:38: warning: macro is now a reserved word; usage as an identifier is deprecated package macro.bar { ^ -macro-deprecate-idents.scala:43: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:43: warning: macro is now a reserved word; usage as an identifier is deprecated package macro.foo { ^ -macro-deprecate-idents.scala:48: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:48: warning: macro is now a reserved word; usage as an identifier is deprecated val Some(macro) = Some(42) ^ -macro-deprecate-idents.scala:49: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:49: warning: macro is now a reserved word; usage as an identifier is deprecated macro match { ^ -macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:50: warning: macro is now a reserved word; usage as an identifier is deprecated case macro => println(macro) ^ -macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:50: warning: macro is now a reserved word; usage as an identifier is deprecated case macro => println(macro) ^ -macro-deprecate-idents.scala:55: error: macro is now a reserved word; usage as an identifier is deprecated +macro-deprecate-idents.scala:55: warning: macro is now a reserved word; usage as an identifier is deprecated def macro = 2 ^ -17 errors found +error: No warnings can be incurred under -Xfatal-warnings. +17 warnings found +one error found diff --git a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala index cdea3104a1..59acaede65 100644 --- a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala +++ b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala @@ -11,7 +11,7 @@ object Complex { val tpe = weakTypeOf[T] for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { val trecur = appliedType(typeOf[Complex[_]], List(f.typeSignature)) - if (c.openImplicits.tail.exists(ic => ic._1 =:= trecur)) c.abort(c.enclosingPosition, "diverging implicit expansion. reported by a macro!") + if (c.openImplicits.tail.exists(ic => ic.pt =:= trecur)) c.abort(c.enclosingPosition, "diverging implicit expansion. reported by a macro!") val recur = c.inferImplicitValue(trecur, silent = true) if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") } diff --git a/test/files/neg/macro-exception.check b/test/files/neg/macro-exception.check index cee8b32ebd..dca97aebce 100644 --- a/test/files/neg/macro-exception.check +++ b/test/files/neg/macro-exception.check @@ -1,4 +1,4 @@ -Test_2.scala:2: error: exception during macro expansion: +Test_2.scala:2: error: exception during macro expansion: java.lang.Exception at Macros$.impl(Macros_1.scala:6) diff --git a/test/files/neg/macro-invalidimpl-a.check b/test/files/neg/macro-invalidimpl-a.check deleted file mode 100644 index 7f11f3b865..0000000000 --- a/test/files/neg/macro-invalidimpl-a.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:3: error: macro implementation must be in statically accessible object - def foo(x: Any) = macro impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidimpl-a/Impls_1.scala b/test/files/neg/macro-invalidimpl-a/Impls_1.scala deleted file mode 100644 index cfa1218038..0000000000 --- a/test/files/neg/macro-invalidimpl-a/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -class Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? -} diff --git a/test/files/neg/macro-invalidimpl-a/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl-a/Macros_Test_2.scala deleted file mode 100644 index 2220ddae0c..0000000000 --- a/test/files/neg/macro-invalidimpl-a/Macros_Test_2.scala +++ /dev/null @@ -1,9 +0,0 @@ -object Macros { - val impls = new Impls - def foo(x: Any) = macro impls.foo -} - -object Test extends App { - import Macros._ - foo(42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-b.check b/test/files/neg/macro-invalidimpl-b.check deleted file mode 100644 index 7f11f3b865..0000000000 --- a/test/files/neg/macro-invalidimpl-b.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:3: error: macro implementation must be in statically accessible object - def foo(x: Any) = macro impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidimpl-b/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl-b/Macros_Test_2.scala deleted file mode 100644 index 81e40837d2..0000000000 --- a/test/files/neg/macro-invalidimpl-b/Macros_Test_2.scala +++ /dev/null @@ -1,9 +0,0 @@ -object Macros { - val impls = Impls - def foo(x: Any) = macro impls.foo -} - -object Test extends App { - import Macros._ - foo(42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-c.check b/test/files/neg/macro-invalidimpl-c.check deleted file mode 100644 index 9e0181c0a3..0000000000 --- a/test/files/neg/macro-invalidimpl-c.check +++ /dev/null @@ -1,4 +0,0 @@ -Impls_Macros_1.scala:8: error: macro implementation must be in statically accessible object - def foo(x: Any) = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidimpl-c/Impls_Macros_1.scala b/test/files/neg/macro-invalidimpl-c/Impls_Macros_1.scala deleted file mode 100644 index 67a0eb348b..0000000000 --- a/test/files/neg/macro-invalidimpl-c/Impls_Macros_1.scala +++ /dev/null @@ -1,9 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -class Macros { - object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? - } - - def foo(x: Any) = macro Impls.foo -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-d.check b/test/files/neg/macro-invalidimpl-d.check deleted file mode 100644 index 76a5ba9c8c..0000000000 --- a/test/files/neg/macro-invalidimpl-d.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation must be in statically accessible object - def foo(x: Any) = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidimpl-d/Impls_1.scala b/test/files/neg/macro-invalidimpl-d/Impls_1.scala deleted file mode 100644 index e0819c938c..0000000000 --- a/test/files/neg/macro-invalidimpl-d/Impls_1.scala +++ /dev/null @@ -1,7 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -trait MacroHelpers { - object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = x - } -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-d/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl-d/Macros_Test_2.scala deleted file mode 100644 index 067ab1ddec..0000000000 --- a/test/files/neg/macro-invalidimpl-d/Macros_Test_2.scala +++ /dev/null @@ -1,7 +0,0 @@ -class Macros extends MacroHelpers { - def foo(x: Any) = macro Impls.foo -} - -object Test extends App { - println(new Macros().foo(42)) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-e.check b/test/files/neg/macro-invalidimpl-e.check deleted file mode 100644 index e0910b2899..0000000000 --- a/test/files/neg/macro-invalidimpl-e.check +++ /dev/null @@ -1,13 +0,0 @@ -Macros_Test_2.scala:2: error: ambiguous reference to overloaded definition, -both method foo in object Impls of type (c: scala.reflect.macros.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing -and method foo in object Impls of type (c: scala.reflect.macros.Context)(x: c.Expr[Any])Nothing -match expected type ? - def foo(x: Any) = macro Impls.foo - ^ -Macros_Test_2.scala:3: error: ambiguous reference to overloaded definition, -both method foo in object Impls of type (c: scala.reflect.macros.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing -and method foo in object Impls of type (c: scala.reflect.macros.Context)(x: c.Expr[Any])Nothing -match expected type ? - def foo(x: Any, y: Any) = macro Impls.foo - ^ -two errors found diff --git a/test/files/neg/macro-invalidimpl-e/Impls_1.scala b/test/files/neg/macro-invalidimpl-e/Impls_1.scala deleted file mode 100644 index fd40119c31..0000000000 --- a/test/files/neg/macro-invalidimpl-e/Impls_1.scala +++ /dev/null @@ -1,6 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? - def foo(c: Ctx)(x: c.Expr[Any], y: c.Expr[Any]) = ??? -} diff --git a/test/files/neg/macro-invalidimpl-e/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl-e/Macros_Test_2.scala deleted file mode 100644 index 6edde08167..0000000000 --- a/test/files/neg/macro-invalidimpl-e/Macros_Test_2.scala +++ /dev/null @@ -1,9 +0,0 @@ -object Macros { - def foo(x: Any) = macro Impls.foo - def foo(x: Any, y: Any) = macro Impls.foo -} - -object Test extends App { - import Macros._ - foo(42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-f.check b/test/files/neg/macro-invalidimpl-f.check deleted file mode 100644 index 4e5851f566..0000000000 --- a/test/files/neg/macro-invalidimpl-f.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context)(): c.Expr[Unit] - found : (c: scala.reflect.macros.Context): c.Expr[Unit] -number of parameter sections differ - def bar1() = macro Impls.fooNullary - ^ -one error found diff --git a/test/files/neg/macro-invalidimpl-f/Impls_1.scala b/test/files/neg/macro-invalidimpl-f/Impls_1.scala deleted file mode 100644 index 334ee714be..0000000000 --- a/test/files/neg/macro-invalidimpl-f/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def fooNullary(c: Ctx) = { - import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) - c.Expr[Unit](body) - } - - def fooEmpty(c: Ctx)() = fooNullary(c) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-f/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl-f/Macros_Test_2.scala deleted file mode 100644 index 493edf1df8..0000000000 --- a/test/files/neg/macro-invalidimpl-f/Macros_Test_2.scala +++ /dev/null @@ -1,9 +0,0 @@ -object Macros { - def bar1() = macro Impls.fooNullary -} - -object Test extends App { - Macros.bar1 - Macros.bar1() - println("kkthxbai") -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-g.check b/test/files/neg/macro-invalidimpl-g.check deleted file mode 100644 index 7342f7336f..0000000000 --- a/test/files/neg/macro-invalidimpl-g.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context): c.Expr[Unit] - found : (c: scala.reflect.macros.Context)(): c.Expr[Unit] -number of parameter sections differ - def foo1 = macro Impls.fooEmpty - ^ -one error found diff --git a/test/files/neg/macro-invalidimpl-g/Impls_1.scala b/test/files/neg/macro-invalidimpl-g/Impls_1.scala deleted file mode 100644 index 334ee714be..0000000000 --- a/test/files/neg/macro-invalidimpl-g/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def fooNullary(c: Ctx) = { - import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) - c.Expr[Unit](body) - } - - def fooEmpty(c: Ctx)() = fooNullary(c) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-g/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl-g/Macros_Test_2.scala deleted file mode 100644 index 5561db9f9a..0000000000 --- a/test/files/neg/macro-invalidimpl-g/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo1 = macro Impls.fooEmpty -} - -object Test extends App { - Macros.foo1 - println("kkthxbai") -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-h.check b/test/files/neg/macro-invalidimpl-h.check deleted file mode 100644 index ea76e1aeac..0000000000 --- a/test/files/neg/macro-invalidimpl-h.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:2: error: type arguments [String] do not conform to method foo's type parameter bounds [U <: Int] - def foo = macro Impls.foo[String] - ^ -one error found diff --git a/test/files/neg/macro-invalidimpl-h/Impls_1.scala b/test/files/neg/macro-invalidimpl-h/Impls_1.scala deleted file mode 100644 index 427fd3d5c0..0000000000 --- a/test/files/neg/macro-invalidimpl-h/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U <: Int](c: Ctx) = ??? -} diff --git a/test/files/neg/macro-invalidimpl-i.check b/test/files/neg/macro-invalidimpl-i.check deleted file mode 100644 index 846ed8d134..0000000000 --- a/test/files/neg/macro-invalidimpl-i.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:4: error: macro implementation must be public - def foo = macro Impls.impl - ^ -one error found diff --git a/test/files/neg/macro-invalidimpl-i/Impls_1.scala b/test/files/neg/macro-invalidimpl-i/Impls_1.scala deleted file mode 100644 index c35d8ab3c1..0000000000 --- a/test/files/neg/macro-invalidimpl-i/Impls_1.scala +++ /dev/null @@ -1,7 +0,0 @@ -package foo - -import scala.reflect.macros.Context - -object Impls { - private[foo] def impl(c: Context) = ??? -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-i/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl-i/Macros_Test_2.scala deleted file mode 100644 index fb129c70be..0000000000 --- a/test/files/neg/macro-invalidimpl-i/Macros_Test_2.scala +++ /dev/null @@ -1,5 +0,0 @@ -package foo - -object Test extends App { - def foo = macro Impls.impl -} diff --git a/test/files/neg/macro-invalidimpl.check b/test/files/neg/macro-invalidimpl.check new file mode 100644 index 0000000000..aaf4f88fc2 --- /dev/null +++ b/test/files/neg/macro-invalidimpl.check @@ -0,0 +1,51 @@ +Macros_Test_2.scala:5: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] + def foo(x: Any) = macro impls.foo + ^ +Macros_Test_2.scala:10: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] + def foo(x: Any) = macro impls.foo + ^ +Macros_Test_2.scala:18: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] + def foo(x: Any) = macro Impls3.foo + ^ +Macros_Test_2.scala:22: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] + def foo(x: Any) = macro Impls4.foo + ^ +Macros_Test_2.scala:26: error: ambiguous reference to overloaded definition, +both method foo in object Impls5 of type (c: scala.reflect.macros.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing +and method foo in object Impls5 of type (c: scala.reflect.macros.Context)(x: c.Expr[Any])Nothing +match expected type ? + def foo(x: Any) = macro Impls5.foo + ^ +Macros_Test_2.scala:27: error: ambiguous reference to overloaded definition, +both method foo in object Impls5 of type (c: scala.reflect.macros.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing +and method foo in object Impls5 of type (c: scala.reflect.macros.Context)(x: c.Expr[Any])Nothing +match expected type ? + def foo(x: Any, y: Any) = macro Impls5.foo + ^ +Macros_Test_2.scala:31: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Unit] + found : (c: scala.reflect.macros.Context)(): c.Expr[Unit] +number of parameter sections differ + def foo1 = macro Impls6.fooEmpty + ^ +Macros_Test_2.scala:32: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context)(): c.Expr[Unit] + found : (c: scala.reflect.macros.Context): c.Expr[Unit] +number of parameter sections differ + def bar1() = macro Impls6.fooNullary + ^ +Macros_Test_2.scala:36: error: type arguments [String] do not conform to method foo's type parameter bounds [U <: Int] + def foo = macro Impls7.foo[String] + ^ +Macros_Test_2.scala:53: error: macro implementation must be public + def foo = macro Impls8.impl + ^ +10 errors found diff --git a/test/files/neg/macro-invalidimpl-a.flags b/test/files/neg/macro-invalidimpl.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-a.flags +++ b/test/files/neg/macro-invalidimpl.flags diff --git a/test/files/neg/macro-invalidimpl/Impls_1.scala b/test/files/neg/macro-invalidimpl/Impls_1.scala new file mode 100644 index 0000000000..cf78ecc65a --- /dev/null +++ b/test/files/neg/macro-invalidimpl/Impls_1.scala @@ -0,0 +1,40 @@ +import scala.reflect.macros.Context + +class Impls1 { + def foo(c: Context)(x: c.Expr[Any]) = ??? +} + +object Impls2 { + def foo(c: Context)(x: c.Expr[Any]) = ??? +} + +trait MacroHelpers { + object Impls4 { + def foo(c: Context)(x: c.Expr[Any]) = x + } +} + +object Impls5 { + def foo(c: Context)(x: c.Expr[Any]) = ??? + def foo(c: Context)(x: c.Expr[Any], y: c.Expr[Any]) = ??? +} + +object Impls6 { + def fooNullary(c: Context) = { + import c.universe._ + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works")))) + c.Expr[Unit](body) + } + + def fooEmpty(c: Context)() = fooNullary(c) +} + +object Impls7 { + def foo[U <: Int](c: Context) = ??? +} + +package foo { + object Impls8 { + private[foo] def impl(c: Context) = ??? + } +}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl/Macros_Test_2.scala new file mode 100644 index 0000000000..8aae9553f5 --- /dev/null +++ b/test/files/neg/macro-invalidimpl/Macros_Test_2.scala @@ -0,0 +1,55 @@ +import scala.reflect.macros.Context + +object Macros1 { + val impls = new Impls1 + def foo(x: Any) = macro impls.foo +} + +object Macros2 { + val impls = Impls2 + def foo(x: Any) = macro impls.foo +} + +class Macros3 { + object Impls3 { + def foo(c: Context)(x: c.Expr[Any]) = ??? + } + + def foo(x: Any) = macro Impls3.foo +} + +class Macros4 extends MacroHelpers { + def foo(x: Any) = macro Impls4.foo +} + +object Macros5 { + def foo(x: Any) = macro Impls5.foo + def foo(x: Any, y: Any) = macro Impls5.foo +} + +object Macros6 { + def foo1 = macro Impls6.fooEmpty + def bar1() = macro Impls6.fooNullary +} + +object Macros7 { + def foo = macro Impls7.foo[String] +} + +object Test extends App { + println(Macros1.foo(42)) + println(Macros2.foo(42)) + println(new Macros3().foo(42)) + println(new Macros4().foo(42)) + println(Macros5.foo(42)) + println(Macros6.foo1) + println(Macros6.bar1) + println(Macros6.bar1()) + println(Macros7.foo) +} + +package foo { + object Test extends App { + def foo = macro Impls8.impl + } +}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidret-nontree.check b/test/files/neg/macro-invalidret-nontree.check deleted file mode 100644 index 6d8336d06d..0000000000 --- a/test/files/neg/macro-invalidret-nontree.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context): c.Expr[Any] - found : (c: scala.reflect.macros.Context): Int -type mismatch for return type: Int does not conform to c.Expr[Any] - def foo = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidret-nontree/Impls_1.scala b/test/files/neg/macro-invalidret-nontree/Impls_1.scala deleted file mode 100644 index ef19b1b405..0000000000 --- a/test/files/neg/macro-invalidret-nontree/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = 2 -} diff --git a/test/files/neg/macro-invalidret-nontree/Macros_Test_2.scala b/test/files/neg/macro-invalidret-nontree/Macros_Test_2.scala deleted file mode 100644 index 96a8de2832..0000000000 --- a/test/files/neg/macro-invalidret-nontree/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo = macro Impls.foo -} - -object Test extends App { - import Macros._ - foo -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidret-nonuniversetree.check b/test/files/neg/macro-invalidret-nonuniversetree.check deleted file mode 100644 index 089bfd0dc9..0000000000 --- a/test/files/neg/macro-invalidret-nonuniversetree.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context): c.Expr[Any] - found : (c: scala.reflect.macros.Context): reflect.runtime.universe.Literal -type mismatch for return type: reflect.runtime.universe.Literal does not conform to c.Expr[Any] - def foo = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidret-nonuniversetree/Impls_1.scala b/test/files/neg/macro-invalidret-nonuniversetree/Impls_1.scala deleted file mode 100644 index f98376a2ba..0000000000 --- a/test/files/neg/macro-invalidret-nonuniversetree/Impls_1.scala +++ /dev/null @@ -1,6 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} -import scala.reflect.runtime.{universe => ru} - -object Impls { - def foo(c: Ctx) = ru.Literal(ru.Constant(42)) -} diff --git a/test/files/neg/macro-invalidret-nonuniversetree/Macros_Test_2.scala b/test/files/neg/macro-invalidret-nonuniversetree/Macros_Test_2.scala deleted file mode 100644 index 96a8de2832..0000000000 --- a/test/files/neg/macro-invalidret-nonuniversetree/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo = macro Impls.foo -} - -object Test extends App { - import Macros._ - foo -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidret.check b/test/files/neg/macro-invalidret.check new file mode 100644 index 0000000000..8c6ed4eb45 --- /dev/null +++ b/test/files/neg/macro-invalidret.check @@ -0,0 +1,13 @@ +Macros_Test_2.scala:2: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Any] + found : (c: scala.reflect.macros.Context): Int +type mismatch for return type: Int does not conform to c.Expr[Any] + def foo1 = macro Impls.foo1 + ^ +Macros_Test_2.scala:3: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Any] + found : (c: scala.reflect.macros.Context): reflect.runtime.universe.Literal +type mismatch for return type: reflect.runtime.universe.Literal does not conform to c.Expr[Any] + def foo2 = macro Impls.foo2 + ^ +two errors found diff --git a/test/files/neg/macro-invalidimpl-b.flags b/test/files/neg/macro-invalidret.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-b.flags +++ b/test/files/neg/macro-invalidret.flags diff --git a/test/files/neg/macro-invalidret/Impls_1.scala b/test/files/neg/macro-invalidret/Impls_1.scala new file mode 100644 index 0000000000..a58af1a23c --- /dev/null +++ b/test/files/neg/macro-invalidret/Impls_1.scala @@ -0,0 +1,7 @@ +import scala.reflect.macros.Context +import scala.reflect.runtime.{universe => ru} + +object Impls { + def foo1(c: Context) = 2 + def foo2(c: Context) = ru.Literal(ru.Constant(42)) +} diff --git a/test/files/neg/macro-invalidret/Macros_Test_2.scala b/test/files/neg/macro-invalidret/Macros_Test_2.scala new file mode 100644 index 0000000000..f8880fa023 --- /dev/null +++ b/test/files/neg/macro-invalidret/Macros_Test_2.scala @@ -0,0 +1,10 @@ +object Macros { + def foo1 = macro Impls.foo1 + def foo2 = macro Impls.foo2 +} + +object Test extends App { + import Macros._ + foo1 + foo2 +}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-a.check b/test/files/neg/macro-invalidshape-a.check deleted file mode 100644 index f38a90819e..0000000000 --- a/test/files/neg/macro-invalidshape-a.check +++ /dev/null @@ -1,5 +0,0 @@ -Macros_Test_2.scala:2: error: macro body has wrong shape: - required: macro [<implementation object>].<method name>[[<type args>]] - def foo(x: Any) = macro 2 - ^ -one error found diff --git a/test/files/neg/macro-invalidshape-a/Impls_1.scala b/test/files/neg/macro-invalidshape-a/Impls_1.scala deleted file mode 100644 index 4467021545..0000000000 --- a/test/files/neg/macro-invalidshape-a/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? -} diff --git a/test/files/neg/macro-invalidshape-a/Macros_Test_2.scala b/test/files/neg/macro-invalidshape-a/Macros_Test_2.scala deleted file mode 100644 index ffff17d1e7..0000000000 --- a/test/files/neg/macro-invalidshape-a/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo(x: Any) = macro 2 -} - -object Test extends App { - import Macros._ - foo(42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-b.check b/test/files/neg/macro-invalidshape-b.check deleted file mode 100644 index 976685c6bd..0000000000 --- a/test/files/neg/macro-invalidshape-b.check +++ /dev/null @@ -1,5 +0,0 @@ -Macros_Test_2.scala:2: error: macro body has wrong shape: - required: macro [<implementation object>].<method name>[[<type args>]] - def foo(x: Any) = macro Impls.foo(null)(null) - ^ -one error found diff --git a/test/files/neg/macro-invalidshape-b/Impls_1.scala b/test/files/neg/macro-invalidshape-b/Impls_1.scala deleted file mode 100644 index 4467021545..0000000000 --- a/test/files/neg/macro-invalidshape-b/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? -} diff --git a/test/files/neg/macro-invalidshape-b/Macros_Test_2.scala b/test/files/neg/macro-invalidshape-b/Macros_Test_2.scala deleted file mode 100644 index b67cd32a6e..0000000000 --- a/test/files/neg/macro-invalidshape-b/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo(x: Any) = macro Impls.foo(null)(null) -} - -object Test extends App { - import Macros._ - foo(42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-c.check b/test/files/neg/macro-invalidshape-c.check deleted file mode 100644 index 0b2e9cfe4f..0000000000 --- a/test/files/neg/macro-invalidshape-c.check +++ /dev/null @@ -1,9 +0,0 @@ -Macros_Test_2.scala:2: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - def foo(x: Any) = macro {2; Impls.foo} - ^ -Macros_Test_2.scala:2: error: missing arguments for method foo in object Impls; -follow this method with `_' if you want to treat it as a partially applied function - def foo(x: Any) = macro {2; Impls.foo} - ^ -one warning found -one error found diff --git a/test/files/neg/macro-invalidshape-c/Impls_1.scala b/test/files/neg/macro-invalidshape-c/Impls_1.scala deleted file mode 100644 index 4467021545..0000000000 --- a/test/files/neg/macro-invalidshape-c/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? -} diff --git a/test/files/neg/macro-invalidshape-c/Macros_Test_2.scala b/test/files/neg/macro-invalidshape-c/Macros_Test_2.scala deleted file mode 100644 index 552c3710c7..0000000000 --- a/test/files/neg/macro-invalidshape-c/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo(x: Any) = macro {2; Impls.foo} -} - -object Test extends App { - import Macros._ - foo(42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-d.check b/test/files/neg/macro-invalidshape-d.check deleted file mode 100644 index e43a2ca0ab..0000000000 --- a/test/files/neg/macro-invalidshape-d.check +++ /dev/null @@ -1,8 +0,0 @@ -Macros_Test_2.scala:2: warning: macro is now a reserved word; usage as an identifier is deprecated - def foo(x: Any) = {2; macro Impls.foo} - ^ -Macros_Test_2.scala:2: error: ';' expected but '.' found. - def foo(x: Any) = {2; macro Impls.foo} - ^ -one warning found -one error found diff --git a/test/files/neg/macro-invalidshape-d.flags b/test/files/neg/macro-invalidshape-d.flags deleted file mode 100644 index 83b7265eb9..0000000000 --- a/test/files/neg/macro-invalidshape-d.flags +++ /dev/null @@ -1 +0,0 @@ --deprecation -language:experimental.macros diff --git a/test/files/neg/macro-invalidshape-d/Impls_1.scala b/test/files/neg/macro-invalidshape-d/Impls_1.scala deleted file mode 100644 index 4467021545..0000000000 --- a/test/files/neg/macro-invalidshape-d/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? -} diff --git a/test/files/neg/macro-invalidshape-d/Macros_Test_2.scala b/test/files/neg/macro-invalidshape-d/Macros_Test_2.scala deleted file mode 100644 index bacd9a6e7c..0000000000 --- a/test/files/neg/macro-invalidshape-d/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo(x: Any) = {2; macro Impls.foo} -} - -object Test extends App { - import Macros._ - foo(42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape.check b/test/files/neg/macro-invalidshape.check new file mode 100644 index 0000000000..1938f5ae47 --- /dev/null +++ b/test/files/neg/macro-invalidshape.check @@ -0,0 +1,20 @@ +Macros_Test_2.scala:2: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] + def foo1(x: Any) = macro 2 + ^ +Macros_Test_2.scala:3: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] + def foo2(x: Any) = macro Impls.foo(null)(null) + ^ +Macros_Test_2.scala:4: error: missing arguments for method foo in object Impls; +follow this method with `_' if you want to treat it as a partially applied function + def foo3(x: Any) = macro {2; Impls.foo} + ^ +Macros_Test_2.scala:7: error: macro implementation reference has wrong shape. required: +macro [<static object>].<method name>[[<type args>]] or +macro [<macro bundle>].<method name>[[<type args>]] + def foo = macro impl + ^ +four errors found diff --git a/test/files/neg/macro-invalidimpl-c.flags b/test/files/neg/macro-invalidshape.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-c.flags +++ b/test/files/neg/macro-invalidshape.flags diff --git a/test/files/neg/macro-invalidimpl-b/Impls_1.scala b/test/files/neg/macro-invalidshape/Impls_1.scala index 4467021545..4467021545 100644 --- a/test/files/neg/macro-invalidimpl-b/Impls_1.scala +++ b/test/files/neg/macro-invalidshape/Impls_1.scala diff --git a/test/files/neg/macro-invalidshape/Macros_Test_2.scala b/test/files/neg/macro-invalidshape/Macros_Test_2.scala new file mode 100644 index 0000000000..cf37e14d8e --- /dev/null +++ b/test/files/neg/macro-invalidshape/Macros_Test_2.scala @@ -0,0 +1,17 @@ +object Macros { + def foo1(x: Any) = macro 2 + def foo2(x: Any) = macro Impls.foo(null)(null) + def foo3(x: Any) = macro {2; Impls.foo} + { + def impl(c: scala.reflect.macros.Context) = c.literalUnit + def foo = macro impl + foo + } +} + +object Test extends App { + import Macros._ + foo1(42) + foo2(42) + foo3(42) +}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check deleted file mode 100644 index 43b8c23b35..0000000000 --- a/test/files/neg/macro-invalidsig-context-bounds.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_1.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context): c.Expr[Any] - found : (c: scala.reflect.macros.Context)(implicit evidence$2: Numeric[U]): c.universe.Literal -macro implementations cannot have implicit parameters other than WeakTypeTag evidences - def foo[U] = macro Impls.foo[U] - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala deleted file mode 100644 index c066c485b1..0000000000 --- a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala +++ /dev/null @@ -1,9 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U: c.WeakTypeTag: Numeric](c: Ctx) = { - import c.universe._ - Literal(Constant(42)) - } -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-context-bounds/Macros_Test_1.scala b/test/files/neg/macro-invalidsig-context-bounds/Macros_Test_1.scala deleted file mode 100644 index 5b4602f328..0000000000 --- a/test/files/neg/macro-invalidsig-context-bounds/Macros_Test_1.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo[U] = macro Impls.foo[U] -} - -object Test extends App { - import Macros._ - println(foo[String]) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-badargc.check b/test/files/neg/macro-invalidsig-ctx-badargc.check deleted file mode 100644 index 1c14072a94..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-badargc.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context): c.Expr[Any] - found : : Nothing -number of parameter sections differ - def foo = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-ctx-badargc/Impls_1.scala b/test/files/neg/macro-invalidsig-ctx-badargc/Impls_1.scala deleted file mode 100644 index 4d5d29158f..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-badargc/Impls_1.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Impls { - def foo = ??? -} diff --git a/test/files/neg/macro-invalidsig-ctx-badargc/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-ctx-badargc/Macros_Test_2.scala deleted file mode 100644 index 96a8de2832..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-badargc/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo = macro Impls.foo -} - -object Test extends App { - import Macros._ - foo -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-badtype.check b/test/files/neg/macro-invalidsig-ctx-badtype.check deleted file mode 100644 index 340ace6a38..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-badtype.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context): c.Expr[Any] - found : (c: scala.reflect.api.Universe): Nothing -type mismatch for parameter c: scala.reflect.macros.Context does not conform to scala.reflect.api.Universe - def foo = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-ctx-badtype/Impls_1.scala b/test/files/neg/macro-invalidsig-ctx-badtype/Impls_1.scala deleted file mode 100644 index cf1a4cf85c..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-badtype/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.api.{Universe => Ctx} - -object Impls { - def foo(c: Ctx) = ??? -} diff --git a/test/files/neg/macro-invalidsig-ctx-badtype/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-ctx-badtype/Macros_Test_2.scala deleted file mode 100644 index 96a8de2832..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-badtype/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo = macro Impls.foo -} - -object Test extends App { - import Macros._ - foo -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-badvarargs.check b/test/files/neg/macro-invalidsig-ctx-badvarargs.check deleted file mode 100644 index a6478f03e3..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-badvarargs.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context): c.Expr[Any] - found : (cs: scala.reflect.macros.Context*): Nothing -types incompatible for parameter cs: corresponding is not a vararg parameter - def foo = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-ctx-badvarargs/Impls_1.scala b/test/files/neg/macro-invalidsig-ctx-badvarargs/Impls_1.scala deleted file mode 100644 index c4ed8be91e..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-badvarargs/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(cs: Ctx*) = ??? -} diff --git a/test/files/neg/macro-invalidsig-ctx-badvarargs/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-ctx-badvarargs/Macros_Test_2.scala deleted file mode 100644 index 96a8de2832..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-badvarargs/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo = macro Impls.foo -} - -object Test extends App { - import Macros._ - foo -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-noctx.check b/test/files/neg/macro-invalidsig-ctx-noctx.check deleted file mode 100644 index b7dc9a449b..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-noctx.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context)(x: c.Expr[Any]): c.Expr[Any] - found : (c: scala.reflect.macros.Context): Nothing -number of parameter sections differ - def foo(x: Any) = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-ctx-noctx/Impls_1.scala b/test/files/neg/macro-invalidsig-ctx-noctx/Impls_1.scala deleted file mode 100644 index 6904cfb1dc..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-noctx/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = ??? -} diff --git a/test/files/neg/macro-invalidsig-ctx-noctx/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-ctx-noctx/Macros_Test_2.scala deleted file mode 100644 index e053cf99df..0000000000 --- a/test/files/neg/macro-invalidsig-ctx-noctx/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo(x: Any) = macro Impls.foo -} - -object Test extends App { - import Macros._ - foo(42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check deleted file mode 100644 index f210eb8a32..0000000000 --- a/test/files/neg/macro-invalidsig-implicit-params.check +++ /dev/null @@ -1,7 +0,0 @@ -Impls_Macros_1.scala:18: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Unit] - found : (c: scala.reflect.macros.Context)(implicit x: c.Expr[Int]): c.Expr[Unit] -macro implementations cannot have implicit parameters other than WeakTypeTag evidences - def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U] - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala deleted file mode 100644 index 7a7293422e..0000000000 --- a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala +++ /dev/null @@ -1,19 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo_targs[T, U: c.WeakTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { - import c.{prefix => prefix} - import c.universe._ - val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.WeakTypeTag[U]].tpe))))), - Literal(Constant(()))) - c.Expr[Unit](body) - } -} - -class Macros[T] { - def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U] -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-implicit-params/Test_2.scala b/test/files/neg/macro-invalidsig-implicit-params/Test_2.scala deleted file mode 100644 index 90e850df21..0000000000 --- a/test/files/neg/macro-invalidsig-implicit-params/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - println("foo_targs:") - new Macros[Int]().foo_targs[String](42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-badargc.check b/test/files/neg/macro-invalidsig-params-badargc.check deleted file mode 100644 index 3f6d815b8e..0000000000 --- a/test/files/neg/macro-invalidsig-params-badargc.check +++ /dev/null @@ -1,7 +0,0 @@ -Impls_Macros_1.scala:8: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Any] - found : (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): Nothing -parameter lists have different length, found extra parameter y: c.Expr[Int] - def foo(x: Int) = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-params-badargc/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-params-badargc/Impls_Macros_1.scala deleted file mode 100644 index ae16612b93..0000000000 --- a/test/files/neg/macro-invalidsig-params-badargc/Impls_Macros_1.scala +++ /dev/null @@ -1,9 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(x: c.Expr[Int], y: c.Expr[Int]) = ??? -} - -object Macros { - def foo(x: Int) = macro Impls.foo -} diff --git a/test/files/neg/macro-invalidsig-params-badargc/Test_2.scala b/test/files/neg/macro-invalidsig-params-badargc/Test_2.scala deleted file mode 100644 index cbd6232073..0000000000 --- a/test/files/neg/macro-invalidsig-params-badargc/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - import Macros._ - foo(42) -}
\ 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 3ec40d7e5b..3cc1c9abf1 100644 --- a/test/files/neg/macro-invalidsig-params-badtype.check +++ b/test/files/neg/macro-invalidsig-params-badtype.check @@ -1,7 +1,7 @@ Impls_Macros_1.scala:8: error: macro implementation has wrong shape: required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Any] - found : (c: scala.reflect.macros.Context)(x: c.universe.Tree): Nothing -type mismatch for parameter x: c.Expr[Int] does not conform to c.universe.Tree + found : (c: scala.reflect.macros.Context)(x: Int): Nothing +type mismatch for parameter x: c.Expr[Int] does not conform to Int def foo(x: Int) = macro Impls.foo - ^ + ^ one error found diff --git a/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala index ab90b85881..175683d6d3 100644 --- a/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala +++ b/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo(c: Ctx)(x: c.universe.Tree) = ??? + def foo(c: Ctx)(x: Int) = ??? } object Macros { diff --git a/test/files/neg/macro-invalidsig-params-badtype/Test_2.scala b/test/files/neg/macro-invalidsig-params-badtype/Test_2.scala deleted file mode 100644 index cbd6232073..0000000000 --- a/test/files/neg/macro-invalidsig-params-badtype/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - import Macros._ - foo(42) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-badvarargs.check b/test/files/neg/macro-invalidsig-params-badvarargs.check deleted file mode 100644 index 50607ff52d..0000000000 --- a/test/files/neg/macro-invalidsig-params-badvarargs.check +++ /dev/null @@ -1,7 +0,0 @@ -Impls_Macros_1.scala:8: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any] - found : (c: scala.reflect.macros.Context)(xs: c.Expr[Int]*): Nothing -parameter lists have different length, required extra parameter y: c.Expr[Int] - def foo(x: Int, y: Int) = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-params-badvarargs/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-params-badvarargs/Impls_Macros_1.scala deleted file mode 100644 index b4c75ad0ba..0000000000 --- a/test/files/neg/macro-invalidsig-params-badvarargs/Impls_Macros_1.scala +++ /dev/null @@ -1,9 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(xs: c.Expr[Int]*) = ??? -} - -object Macros { - def foo(x: Int, y: Int) = macro Impls.foo -} diff --git a/test/files/neg/macro-invalidsig-params-badvarargs/Test_2.scala b/test/files/neg/macro-invalidsig-params-badvarargs/Test_2.scala deleted file mode 100644 index fa50ac4f73..0000000000 --- a/test/files/neg/macro-invalidsig-params-badvarargs/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - import Macros._ - foo(42, 100) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-namemismatch.check b/test/files/neg/macro-invalidsig-params-namemismatch.check deleted file mode 100644 index 4029bc8129..0000000000 --- a/test/files/neg/macro-invalidsig-params-namemismatch.check +++ /dev/null @@ -1,7 +0,0 @@ -Impls_Macros_1.scala:8: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any] - found : (c: scala.reflect.macros.Context)(y: c.Expr[Int], x: c.Expr[Int]): Nothing -parameter names differ: x != y - def foo(x: Int, y: Int) = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-params-namemismatch/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-params-namemismatch/Impls_Macros_1.scala deleted file mode 100644 index c7cf0b06c4..0000000000 --- a/test/files/neg/macro-invalidsig-params-namemismatch/Impls_Macros_1.scala +++ /dev/null @@ -1,9 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(y: c.Expr[Int], x: c.Expr[Int]) = ??? -} - -object Macros { - def foo(x: Int, y: Int) = macro Impls.foo -} diff --git a/test/files/neg/macro-invalidsig-params-namemismatch/Test_2.scala b/test/files/neg/macro-invalidsig-params-namemismatch/Test_2.scala deleted file mode 100644 index fa50ac4f73..0000000000 --- a/test/files/neg/macro-invalidsig-params-namemismatch/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - import Macros._ - foo(42, 100) -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-badtype.check b/test/files/neg/macro-invalidsig-tparams-badtype.check deleted file mode 100644 index e9f3547133..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-badtype.check +++ /dev/null @@ -1,7 +0,0 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context): c.Expr[Any] - found : (c: scala.reflect.macros.Context)(U: c.universe.Type): Nothing -number of parameter sections differ - def foo[U] = macro Impls.foo[U] - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-tparams-badtype/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-badtype/Impls_1.scala deleted file mode 100644 index dbeca178a7..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-badtype/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U](c: Ctx)(U: c.universe.Type) = ??? -} diff --git a/test/files/neg/macro-invalidsig-tparams-badtype/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-tparams-badtype/Macros_Test_2.scala deleted file mode 100644 index a82e813221..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-badtype/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo[U] = macro Impls.foo[U] -} - -object Test extends App { - import Macros._ - foo[Int] -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-a.check b/test/files/neg/macro-invalidsig-tparams-bounds-a.check deleted file mode 100644 index b6248a1c47..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-bounds-a.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:2: error: type arguments [U] do not conform to method foo's type parameter bounds [U <: String] - def foo[U] = macro Impls.foo[U] - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-a/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-bounds-a/Impls_1.scala deleted file mode 100644 index 89020de7dd..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-bounds-a/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U <: String](c: Ctx) = ??? -} diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-a/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-tparams-bounds-a/Macros_Test_2.scala deleted file mode 100644 index a82e813221..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-bounds-a/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo[U] = macro Impls.foo[U] -} - -object Test extends App { - import Macros._ - foo[Int] -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-b.check b/test/files/neg/macro-invalidsig-tparams-bounds-b.check deleted file mode 100644 index 74eb522cdd..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-bounds-b.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:2: error: type arguments [U] do not conform to method foo's type parameter bounds [U <: String] - def foo[U <: Int] = macro Impls.foo[U] - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-b/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-bounds-b/Impls_1.scala deleted file mode 100644 index 89020de7dd..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-bounds-b/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U <: String](c: Ctx) = ??? -} diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-b/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-tparams-bounds-b/Macros_Test_2.scala deleted file mode 100644 index eed6369a16..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-bounds-b/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo[U <: Int] = macro Impls.foo[U] -} - -object Test extends App { - import Macros._ - foo[Int] -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a.check b/test/files/neg/macro-invalidsig-tparams-notparams-a.check deleted file mode 100644 index 61a5628b7e..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[U])Nothing - def foo = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala deleted file mode 100644 index f8b3c92869..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala +++ /dev/null @@ -1,6 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U: c.WeakTypeTag](c: Ctx) = ??? -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-tparams-notparams-a/Macros_Test_2.scala deleted file mode 100644 index 96a8de2832..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo = macro Impls.foo -} - -object Test extends App { - import Macros._ - foo -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b.check b/test/files/neg/macro-invalidsig-tparams-notparams-b.check deleted file mode 100644 index a605af6beb..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] - def foo[V] = macro Impls.foo - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala deleted file mode 100644 index baf3aab9e3..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { - println(implicitly[c.WeakTypeTag[T]]) - println(implicitly[c.WeakTypeTag[U]]) - println(V) - c.literalUnit - } -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-tparams-notparams-b/Macros_Test_2.scala deleted file mode 100644 index 7d02bf613a..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b/Macros_Test_2.scala +++ /dev/null @@ -1,11 +0,0 @@ -class D[T] { - class C[U] { - def foo[V] = macro Impls.foo - } -} - -object Test extends App { - val outer1 = new D[Int] - val outer2 = new outer1.C[String] - outer2.foo[Boolean] -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c.check b/test/files/neg/macro-invalidsig-tparams-notparams-c.check deleted file mode 100644 index 0be0b6fad1..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] - def foo[V] = macro Impls.foo[V] - ^ -one error found diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala deleted file mode 100644 index 44b4ed6ab3..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala +++ /dev/null @@ -1,12 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { - import c.universe._ - println(implicitly[c.WeakTypeTag[T]]) - println(implicitly[c.WeakTypeTag[U]]) - println(V) - c.literalUnit - } -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c/Macros_Test_2.scala b/test/files/neg/macro-invalidsig-tparams-notparams-c/Macros_Test_2.scala deleted file mode 100644 index 109e142e52..0000000000 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c/Macros_Test_2.scala +++ /dev/null @@ -1,11 +0,0 @@ -class D[T] { - class C[U] { - def foo[V] = macro Impls.foo[V] - } -} - -object Test extends App { - val outer1 = new D[Int] - val outer2 = new outer1.C[String] - outer2.foo[Boolean] -}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig.check b/test/files/neg/macro-invalidsig.check new file mode 100644 index 0000000000..cbdaf51081 --- /dev/null +++ b/test/files/neg/macro-invalidsig.check @@ -0,0 +1,82 @@ +Macros_Test_2.scala:2: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Any] + found : (c: scala.reflect.macros.Context)(implicit evidence$2: Numeric[U]): c.universe.Literal +macro implementations cannot have implicit parameters other than WeakTypeTag evidences + def foo[U] = macro Impls1.foo[U] + ^ +Macros_Test_2.scala:6: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Any] + found : : Nothing +number of parameter sections differ + def foo = macro Impls2.foo + ^ +Macros_Test_2.scala:10: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Any] + found : (c: scala.reflect.api.Universe): Nothing +type mismatch for parameter c: scala.reflect.macros.Context does not conform to scala.reflect.api.Universe + def foo = macro Impls3.foo + ^ +Macros_Test_2.scala:14: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Any] + found : (cs: scala.reflect.macros.Context*): Nothing +types incompatible for parameter cs: corresponding is not a vararg parameter + def foo = macro Impls4.foo + ^ +Macros_Test_2.scala:18: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context)(x: c.Expr[Any]): c.Expr[Any] + found : (c: scala.reflect.macros.Context): Nothing +number of parameter sections differ + def foo(x: Any) = macro Impls5.foo + ^ +Macros_Test_2.scala:22: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Unit] + found : (c: scala.reflect.macros.Context)(implicit x: c.Expr[Int]): c.Expr[Unit] +macro implementations cannot have implicit parameters other than WeakTypeTag evidences + def foo[U](x: Int) = macro Impls6.foo[T, U] + ^ +Macros_Test_2.scala:26: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Any] + found : (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): Nothing +parameter lists have different length, found extra parameter y: c.Expr[Int] + def foo(x: Int) = macro Impls7.foo + ^ +Macros_Test_2.scala:30: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Any] + found : (c: scala.reflect.macros.Context)(x: c.universe.Symbol): Nothing +type mismatch for parameter x: c.Expr[Int] does not conform to c.universe.Symbol + def foo(x: Int) = macro Impls8.foo + ^ +Macros_Test_2.scala:34: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any] + found : (c: scala.reflect.macros.Context)(xs: c.Expr[Int]*): Nothing +parameter lists have different length, required extra parameter y: c.Expr[Int] + def foo(x: Int, y: Int) = macro Impls9.foo + ^ +Macros_Test_2.scala:38: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any] + found : (c: scala.reflect.macros.Context)(y: c.Expr[Int], x: c.Expr[Int]): Nothing +parameter names differ: x != y + def foo(x: Int, y: Int) = macro Impls10.foo + ^ +Macros_Test_2.scala:42: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Any] + found : (c: scala.reflect.macros.Context)(U: c.universe.Type): Nothing +number of parameter sections differ + def foo[U] = macro Impls11.foo[U] + ^ +Macros_Test_2.scala:46: error: type arguments [U] do not conform to method foo's type parameter bounds [U <: String] + def foo[U] = macro Impls12.foo[U] + ^ +Macros_Test_2.scala:50: error: type arguments [U] do not conform to method foo's type parameter bounds [U <: String] + def foo[U <: Int] = macro Impls13.foo[U] + ^ +Macros_Test_2.scala:54: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$4: c.WeakTypeTag[U])Nothing + def foo = macro Impls14.foo + ^ +Macros_Test_2.scala:59: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$5: c.WeakTypeTag[T], implicit evidence$6: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] + def foo15[V] = macro Impls15.foo + ^ +Macros_Test_2.scala:60: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$7: c.WeakTypeTag[T], implicit evidence$8: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] + def foo16[V] = macro Impls16.foo[V] + ^ +16 errors found diff --git a/test/files/neg/macro-invalidimpl-d.flags b/test/files/neg/macro-invalidsig.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-d.flags +++ b/test/files/neg/macro-invalidsig.flags diff --git a/test/files/neg/macro-invalidsig/Impls_1.scala b/test/files/neg/macro-invalidsig/Impls_1.scala new file mode 100644 index 0000000000..e7d6c18f8d --- /dev/null +++ b/test/files/neg/macro-invalidsig/Impls_1.scala @@ -0,0 +1,88 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.macros.Context + +object Impls1 { + def foo[U: c.WeakTypeTag: Numeric](c: Context) = { + import c.universe._ + Literal(Constant(42)) + } +} + +object Impls2 { + def foo = ??? +} + +object Impls3 { + def foo(c: scala.reflect.api.Universe) = ??? +} + +object Impls4 { + def foo(cs: Context*) = ??? +} + +object Impls5 { + def foo(c: Context) = ??? +} + +object Impls6 { + def foo[T, U: c.WeakTypeTag](c: Context)(implicit x: c.Expr[Int]) = { + import c.{prefix => prefix} + import c.universe._ + val body = Block(List( + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo_targs...")))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("U is: " + implicitly[c.WeakTypeTag[U]].tpe))))), + Literal(Constant(()))) + c.Expr[Unit](body) + } +} + +object Impls7 { + def foo(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = ??? +} + +object Impls8 { + def foo(c: Context)(x: c.universe.Symbol) = ??? +} + +object Impls9 { + def foo(c: Context)(xs: c.Expr[Int]*) = ??? +} + +object Impls10 { + def foo(c: Context)(y: c.Expr[Int], x: c.Expr[Int]) = ??? +} + +object Impls11 { + def foo[U](c: Context)(U: c.universe.Type) = ??? +} + +object Impls12 { + def foo[U <: String](c: Context) = ??? +} + +object Impls13 { + def foo[U <: String](c: Context) = ??? +} + +object Impls14 { + def foo[U: c.WeakTypeTag](c: Context) = ??? +} + +object Impls15 { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) + println(V) + c.literalUnit + } +} + +object Impls16 { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) + println(V) + c.literalUnit + } +}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig/Macros_Test_2.scala b/test/files/neg/macro-invalidsig/Macros_Test_2.scala new file mode 100644 index 0000000000..0a6a321431 --- /dev/null +++ b/test/files/neg/macro-invalidsig/Macros_Test_2.scala @@ -0,0 +1,83 @@ +object Macros1 { + def foo[U] = macro Impls1.foo[U] +} + +object Macros2 { + def foo = macro Impls2.foo +} + +object Macros3 { + def foo = macro Impls3.foo +} + +object Macros4 { + def foo = macro Impls4.foo +} + +object Macros5 { + def foo(x: Any) = macro Impls5.foo +} + +class Macros6[T] { + def foo[U](x: Int) = macro Impls6.foo[T, U] +} + +object Macros7 { + def foo(x: Int) = macro Impls7.foo +} + +object Macros8 { + def foo(x: Int) = macro Impls8.foo +} + +object Macros9 { + def foo(x: Int, y: Int) = macro Impls9.foo +} + +object Macros10 { + def foo(x: Int, y: Int) = macro Impls10.foo +} + +object Macros11 { + def foo[U] = macro Impls11.foo[U] +} + +object Macros12 { + def foo[U] = macro Impls12.foo[U] +} + +object Macros13 { + def foo[U <: Int] = macro Impls13.foo[U] +} + +object Macros14 { + def foo = macro Impls14.foo +} + +class D[T] { + class C[U] { + def foo15[V] = macro Impls15.foo + def foo16[V] = macro Impls16.foo[V] + } +} + +object Test extends App { + println(Macros1.foo[String]) + println(Macros2.foo) + println(Macros3.foo) + println(Macros4.foo) + println(Macros5.foo(42)) + println(new Macros6[Int]().foo[String](42)) + println(Macros7.foo(42)) + println(Macros8.foo) + println(Macros9.foo(4, 2)) + println(Macros10.foo(4, 2)) + println(Macros11.foo[Int]) + println(Macros12.foo[Int]) + println(Macros13.foo[Int]) + println(Macros14.foo) + val outer1 = new D[Int] + val outer2 = new outer1.C[String] + outer2.foo15[Boolean] + outer2.foo16[Boolean] +}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-badargs.check b/test/files/neg/macro-invalidusage-badargs.check index 294cfd0cf5..4c1115418b 100644 --- a/test/files/neg/macro-invalidusage-badargs.check +++ b/test/files/neg/macro-invalidusage-badargs.check @@ -1,6 +1,18 @@ -Macros_Test_2.scala:7: error: type mismatch; +Macros_Test_2.scala:5: error: type mismatch; found : String("42") required: Int - val s: String = foo("42") - ^ -one error found + foo("42") + ^ +Macros_Test_2.scala:6: error: too few argument lists for macro invocation + foo + ^ +Macros_Test_2.scala:7: error: Int does not take parameters + foo(4)(2) + ^ +Macros_Test_2.scala:8: error: macro applications do not support named and/or default arguments + foo() + ^ +Macros_Test_2.scala:9: error: too many arguments for macro method foo: (x: Int)Int + foo(4, 2) + ^ +5 errors found 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 a6af1bb277..0b3ca0590b 100644 --- a/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala @@ -1,8 +1,10 @@ -object Macros { - def foo(x: Int) = macro Impls.foo -} +object Macros { def foo(x: Int) = macro Impls.foo } +import Macros._ object Test extends App { - import Macros._ - val s: String = foo("42") + foo("42") + foo + foo(4)(2) + foo() + foo(4, 2) }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-badbounds-a.check b/test/files/neg/macro-invalidusage-badbounds.check index 277f407d38..277f407d38 100644 --- a/test/files/neg/macro-invalidusage-badbounds-a.check +++ b/test/files/neg/macro-invalidusage-badbounds.check diff --git a/test/files/neg/macro-invalidimpl-e.flags b/test/files/neg/macro-invalidusage-badbounds.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-e.flags +++ b/test/files/neg/macro-invalidusage-badbounds.flags diff --git a/test/files/neg/macro-invalidusage-badbounds-a/Impls_1.scala b/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala index 6ee71a3628..6ee71a3628 100644 --- a/test/files/neg/macro-invalidusage-badbounds-a/Impls_1.scala +++ b/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala diff --git a/test/files/neg/macro-invalidusage-badbounds-a/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala index 3139599108..3139599108 100644 --- a/test/files/neg/macro-invalidusage-badbounds-a/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala diff --git a/test/files/neg/macro-invalidusage-badtargs.check b/test/files/neg/macro-invalidusage-badtargs.check index 73801ab43e..6a9e1d6e6b 100644 --- a/test/files/neg/macro-invalidusage-badtargs.check +++ b/test/files/neg/macro-invalidusage-badtargs.check @@ -1,4 +1,18 @@ -Macros_Test_2.scala:7: error: macro method foo: (x: Int)Int does not take type parameters. - val s: String = foo[String](42) - ^ -one error found +Macros_Test_2.scala:11: 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 + foo2[String, String](42) + ^ +Macros_Test_2.scala:13: 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 + 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). +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) + ^ +5 errors found 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 c54093b637..fd16d163c3 100644 --- a/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala @@ -1,8 +1,16 @@ object Macros { - def foo(x: Int) = macro Impls.foo + 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 } object Test extends App { import Macros._ - val s: String = foo[String](42) + foo1[String](42) + foo2[String, String](42) + foo3[String](42) + foo4[String](42) + foo5[List](42) }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala index 8d7fdf3e8a..498bd4f18d 100644 --- a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala +++ b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works")))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-nontypeable.check b/test/files/neg/macro-invalidusage-nontypeable.check new file mode 100644 index 0000000000..88e6057e5e --- /dev/null +++ b/test/files/neg/macro-invalidusage-nontypeable.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: not found: value IDoNotExist + Macros.foo + ^ +one error found diff --git a/test/files/neg/macro-invalidimpl-f.flags b/test/files/neg/macro-invalidusage-nontypeable.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-f.flags +++ b/test/files/neg/macro-invalidusage-nontypeable.flags diff --git a/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala b/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala new file mode 100644 index 0000000000..869a5a41fa --- /dev/null +++ b/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.universe._ + val body = Ident(TermName("IDoNotExist")) + c.Expr[Int](body) + } +} + +object Macros { + def foo = macro Impls.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-c/Test_2.scala b/test/files/neg/macro-invalidusage-nontypeable/Test_2.scala index 7dffc5107d..acfddae942 100644 --- a/test/files/run/macro-def-path-dependent-c/Test_2.scala +++ b/test/files/neg/macro-invalidusage-nontypeable/Test_2.scala @@ -1,3 +1,3 @@ object Test extends App { - println("it works") + Macros.foo }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-presuper.check b/test/files/neg/macro-invalidusage-presuper.check new file mode 100644 index 0000000000..c0b1ec0248 --- /dev/null +++ b/test/files/neg/macro-invalidusage-presuper.check @@ -0,0 +1,4 @@ +Macros_Test_2.scala:3: error: only concrete field definitions allowed in early object initialization section +class D extends { def x = macro impl } with AnyRef + ^ +one error found diff --git a/test/files/neg/macro-invalidimpl-g.flags b/test/files/neg/macro-invalidusage-presuper.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-g.flags +++ b/test/files/neg/macro-invalidusage-presuper.flags diff --git a/test/files/neg/macro-invalidusage-presuper/Impls_1.scala b/test/files/neg/macro-invalidusage-presuper/Impls_1.scala new file mode 100644 index 0000000000..b39a037c47 --- /dev/null +++ b/test/files/neg/macro-invalidusage-presuper/Impls_1.scala @@ -0,0 +1,5 @@ +import scala.reflect.macros.Context + +object Impls { + def impl(c: Context) = c.literalUnit +}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-presuper/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-presuper/Macros_Test_2.scala new file mode 100644 index 0000000000..ff46a5915f --- /dev/null +++ b/test/files/neg/macro-invalidusage-presuper/Macros_Test_2.scala @@ -0,0 +1,3 @@ +import Impls._ + +class D extends { def x = macro impl } with AnyRef
\ No newline at end of file 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 895e0dca50..8c8f039225 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 override an abstract method + macro method foo cannot be used here - term macros cannot override abstract methods def foo(x: Int) = macro Impls.impl ^ one error found diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-b.check b/test/files/neg/macro-override-macro-overrides-abstract-method-b.check index cde3dbdbe8..c733555549 100644 --- a/test/files/neg/macro-override-macro-overrides-abstract-method-b.check +++ b/test/files/neg/macro-override-macro-overrides-abstract-method-b.check @@ -1,11 +1,11 @@ -Test_2.scala:3: error: anonymous class $anon inherits conflicting members: +Test_2.scala:3: error: <$anon: C with A> inherits conflicting members: macro method t in trait C of type ()Unit and method t in trait A of type ()Unit -(Note: this can be resolved by declaring an override in anonymous class $anon.) +(Note: this can be resolved by declaring an override in <$anon: C with A>.) val c2 = new C with A {} ^ Test_2.scala:5: error: overriding macro method t in trait C of type ()Unit; - method t cannot override a macro + method t cannot be used here - only term macros can override term macros val c4 = new C with A { override def t(): Unit = () } ^ two errors found diff --git a/test/files/neg/macro-override-method-overrides-macro.check b/test/files/neg/macro-override-method-overrides-macro.check index 66dc11be96..e8cba5d029 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 override a macro + method foo cannot be used here - only term macros can override term macros override def foo(x: String) = println("fooDString") ^ one error found diff --git a/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala b/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala index ec93dd4111..69ef57d18d 100644 --- a/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala +++ b/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { import c.{prefix => prefix} import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) c.Expr[Unit](body) } diff --git a/test/files/neg/macro-qmarkqmarkqmark.check b/test/files/neg/macro-qmarkqmarkqmark.check index afd49e7d90..bc3e25edaf 100644 --- a/test/files/neg/macro-qmarkqmarkqmark.check +++ b/test/files/neg/macro-qmarkqmarkqmark.check @@ -1,7 +1,7 @@ macro-qmarkqmarkqmark.scala:5: error: macro implementation is missing foo1 ^ -macro-qmarkqmarkqmark.scala:8: error: macros cannot be partially applied +macro-qmarkqmarkqmark.scala:8: error: too few argument lists for macro invocation foo2 ^ macro-qmarkqmarkqmark.scala:9: error: macro implementation is missing diff --git a/test/files/neg/macro-quasiquotes.check b/test/files/neg/macro-quasiquotes.check new file mode 100644 index 0000000000..96ef75dd32 --- /dev/null +++ b/test/files/neg/macro-quasiquotes.check @@ -0,0 +1,7 @@ +Macros_1.scala:14: error: macro implementation has wrong shape: + required: (x: Impls.this.c.Expr[Int]): Impls.this.c.Expr[Any] + found : (x: Impls.this.c.universe.Block): Impls.this.c.universe.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 + ^ +one error found diff --git a/test/files/neg/macro-quasiquotes/Macros_1.scala b/test/files/neg/macro-quasiquotes/Macros_1.scala new file mode 100644 index 0000000000..17c1034720 --- /dev/null +++ b/test/files/neg/macro-quasiquotes/Macros_1.scala @@ -0,0 +1,15 @@ +import language.experimental.macros +import scala.reflect.macros.Macro + +trait Impls extends Macro { + import c.universe._ + def impl1(x: Expr[Int]) = q"println(x)" + def impl2(x: Tree) = q"println(x)" + def impl3(x: Block) = q"println(x)" +} + +object Macros { + def m1(x: Int) = macro Impls.impl1 + def m2(x: Int) = macro Impls.impl2 + def m3(x: Int) = macro Impls.impl3 +}
\ No newline at end of file diff --git a/test/files/neg/macro-quasiquotes/Test_2.scala b/test/files/neg/macro-quasiquotes/Test_2.scala new file mode 100644 index 0000000000..c7b8948d79 --- /dev/null +++ b/test/files/neg/macro-quasiquotes/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + Macros.m1 + Macros.m2 + Macros.m3 +} diff --git a/test/files/neg/macro-without-xmacros-a/Impls_1.scala b/test/files/neg/macro-without-xmacros-a/Impls_1.scala index 8976f8e28d..c6677c4fde 100644 --- a/test/files/neg/macro-without-xmacros-a/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala @@ -3,16 +3,16 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))) } def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))) } def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3))))) } }
\ No newline at end of file diff --git a/test/files/neg/macro-without-xmacros-b/Impls_1.scala b/test/files/neg/macro-without-xmacros-b/Impls_1.scala index 8976f8e28d..c6677c4fde 100644 --- a/test/files/neg/macro-without-xmacros-b/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala @@ -3,16 +3,16 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))) } def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))) } def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3))))) } }
\ No newline at end of file diff --git a/test/files/neg/main1.check b/test/files/neg/main1.check index 1a7a13e1e9..b745105818 100644 --- a/test/files/neg/main1.check +++ b/test/files/neg/main1.check @@ -1,26 +1,28 @@ -main1.scala:3: error: Foo has a main method with parameter type Array[String], but foo1.Foo will not be a runnable program. +main1.scala:3: warning: Foo has a main method with parameter type Array[String], but foo1.Foo will not be a runnable program. Reason: companion is a trait, which means no static forwarder can be generated. object Foo { // companion is trait ^ -main1.scala:10: error: Foo has a main method with parameter type Array[String], but foo2.Foo will not be a runnable program. +main1.scala:10: warning: Foo has a main method with parameter type Array[String], but foo2.Foo will not be a runnable program. Reason: companion contains its own main method, which means no static forwarder can be generated. object Foo { // companion has its own main ^ -main1.scala:22: error: Foo has a main method with parameter type Array[String], but foo3.Foo will not be a runnable program. +main1.scala:22: warning: Foo has a main method with parameter type Array[String], but foo3.Foo will not be a runnable program. Reason: companion contains its own main method (implementation restriction: no main is allowed, regardless of signature), which means no static forwarder can be generated. object Foo { // Companion contains main, but not an interfering main. ^ -main1.scala:31: error: Foo has a main method with parameter type Array[String], but foo4.Foo will not be a runnable program. +main1.scala:31: warning: Foo has a main method with parameter type Array[String], but foo4.Foo will not be a runnable program. Reason: companion contains its own main method, which means no static forwarder can be generated. object Foo extends Foo { // Inherits main from the class ^ -main1.scala:39: error: Foo has a main method with parameter type Array[String], but foo5.Foo will not be a runnable program. +main1.scala:39: warning: Foo has a main method with parameter type Array[String], but foo5.Foo will not be a runnable program. Reason: companion contains its own main method, which means no static forwarder can be generated. object Foo extends Foo { // Overrides main from the class ^ -5 errors found +error: No warnings can be incurred under -Xfatal-warnings. +5 warnings found +one error found diff --git a/test/files/neg/migration28.check b/test/files/neg/migration28.check index d7dfacf3db..afb4db62e2 100644 --- a/test/files/neg/migration28.check +++ b/test/files/neg/migration28.check @@ -1,5 +1,7 @@ -migration28.scala:4: error: method scanRight in trait TraversableLike has changed semantics in version 2.9.0: +migration28.scala:4: warning: method scanRight in trait TraversableLike has changed semantics in version 2.9.0: The behavior of `scanRight` has changed. The previous behavior can be reproduced with scanRight.reverse. List(1,2,3,4,5).scanRight(0)(_+_) ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/migration28.scala b/test/files/neg/migration28.scala index ba73eea436..facc9b36d2 100644 --- a/test/files/neg/migration28.scala +++ b/test/files/neg/migration28.scala @@ -1,9 +1,9 @@ object Test { import scala.collection.mutable._ - + List(1,2,3,4,5).scanRight(0)(_+_) - + def main(args: Array[String]): Unit = { - + } } diff --git a/test/files/neg/names-defaults-neg-ref.check b/test/files/neg/names-defaults-neg-ref.check index 00052c72dc..61d66fd32a 100644 --- a/test/files/neg/names-defaults-neg-ref.check +++ b/test/files/neg/names-defaults-neg-ref.check @@ -1,4 +1,4 @@ -names-defaults-neg-ref.scala:3: error: in anonymous class $anon, multiple overloaded alternatives of method f define default arguments. +names-defaults-neg-ref.scala:3: error: in <$anon: A2235 with B2235>, multiple overloaded alternatives of method f define default arguments. The members with defaults are defined in trait B2235 and trait A2235. new A2235 with B2235 ^ diff --git a/test/files/neg/names-defaults-neg-warn.check b/test/files/neg/names-defaults-neg-warn.check index e1085acf76..0f4edef84e 100644 --- a/test/files/neg/names-defaults-neg-warn.check +++ b/test/files/neg/names-defaults-neg-warn.check @@ -1,7 +1,9 @@ -names-defaults-neg-warn.scala:11: error: the parameter name s has been deprecated. Use x instead. +names-defaults-neg-warn.scala:11: warning: the parameter name s has been deprecated. Use x instead. deprNam2.f(s = "dlfkj") ^ -names-defaults-neg-warn.scala:12: error: the parameter name x has been deprecated. Use s instead. +names-defaults-neg-warn.scala:12: warning: the parameter name x has been deprecated. Use s instead. deprNam2.g(x = "dlkjf") ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index ea7c323b74..cdc12c2490 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -100,7 +100,7 @@ Error occurred in an application involving default arguments. ^ names-defaults-neg.scala:86: error: module extending its companion class cannot use default constructor arguments object C extends C() - ^ + ^ names-defaults-neg.scala:90: error: deprecated parameter name x has to be distinct from any other parameter name (deprecated or not). def deprNam1(x: Int, @deprecatedName('x) y: String) = 0 ^ @@ -125,9 +125,12 @@ names-defaults-neg.scala:134: error: missing parameter type for expanded functio names-defaults-neg.scala:135: error: parameter 'a' is already specified at parameter position 1 val taf3 = testAnnFun(b = _: String, a = get(8)) ^ -names-defaults-neg.scala:136: error: wrong number of parameters; expected = 2 +names-defaults-neg.scala:136: error: missing parameter type for expanded function ((x$3) => testAnnFun(x$3, ((x$4) => b = x$4))) val taf4: (Int, String) => Unit = testAnnFun(_, b = _) - ^ + ^ +names-defaults-neg.scala:136: error: missing parameter type for expanded function ((x$4) => b = x$4) + val taf4: (Int, String) => Unit = testAnnFun(_, b = _) + ^ names-defaults-neg.scala:144: error: variable definition needs type because 'x' is used as a named argument in its body. def t3 { var x = t.f(x = 1) } ^ @@ -165,4 +168,4 @@ names-defaults-neg.scala:180: error: reference to x is ambiguous; it is both a m class u18 { var x: Int = u.f(x = 1) } ^ four warnings found -41 errors found +42 errors found diff --git a/test/files/neg/nested-annotation.check b/test/files/neg/nested-annotation.check new file mode 100644 index 0000000000..ca263943fe --- /dev/null +++ b/test/files/neg/nested-annotation.check @@ -0,0 +1,10 @@ +nested-annotation.scala:3: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class ComplexAnnotation(val value: Annotation) extends ClassfileAnnotation + ^ +nested-annotation.scala:8: error: nested classfile annotations must be defined in java; found: inline + @ComplexAnnotation(new inline) def bippy(): Int = 1 + ^ +one warning found +one error found diff --git a/test/files/neg/nested-annotation.scala b/test/files/neg/nested-annotation.scala new file mode 100644 index 0000000000..35c0cd3b75 --- /dev/null +++ b/test/files/neg/nested-annotation.scala @@ -0,0 +1,9 @@ +import annotation._ + +class ComplexAnnotation(val value: Annotation) extends ClassfileAnnotation + +class A { + // It's hard to induce this error because @ComplexAnnotation(@inline) is a parse + // error so it never gets out of the parser, but: + @ComplexAnnotation(new inline) def bippy(): Int = 1 +} diff --git a/test/files/neg/nested-fn-print.scala b/test/files/neg/nested-fn-print.scala index 9a4bd162c0..c599a235ab 100644 --- a/test/files/neg/nested-fn-print.scala +++ b/test/files/neg/nested-fn-print.scala @@ -2,7 +2,7 @@ object Test { var x1: Int => Float => Double = _ var x2: (Int => Float) => Double = _ var x3: Int => Double - + def main(args: Array[String]): Unit = { x1 = "a" x2 = "b" diff --git a/test/files/neg/newpat_unreachable.check b/test/files/neg/newpat_unreachable.check index 08453cac19..a928e3853a 100644 --- a/test/files/neg/newpat_unreachable.check +++ b/test/files/neg/newpat_unreachable.check @@ -1,27 +1,29 @@ -newpat_unreachable.scala:6: error: patterns after a variable pattern cannot match (SLS 8.1.1) +newpat_unreachable.scala:6: warning: patterns after a variable pattern cannot match (SLS 8.1.1) If you intended to match against parameter b of method contrivedExample, you must use backticks, like: case `b` => case b => println("matched b") ^ -newpat_unreachable.scala:7: error: unreachable code due to variable pattern 'b' on line 6 +newpat_unreachable.scala:7: warning: unreachable code due to variable pattern 'b' on line 6 If you intended to match against parameter c of method contrivedExample, you must use backticks, like: case `c` => case c => println("matched c") ^ -newpat_unreachable.scala:8: error: unreachable code due to variable pattern 'b' on line 6 +newpat_unreachable.scala:8: warning: unreachable code due to variable pattern 'b' on line 6 If you intended to match against value d in class A, you must use backticks, like: case `d` => case d => println("matched d") ^ -newpat_unreachable.scala:9: error: unreachable code due to variable pattern 'b' on line 6 +newpat_unreachable.scala:9: warning: unreachable code due to variable pattern 'b' on line 6 case _ => println("matched neither") ^ -newpat_unreachable.scala:22: error: patterns after a variable pattern cannot match (SLS 8.1.1) +newpat_unreachable.scala:22: warning: patterns after a variable pattern cannot match (SLS 8.1.1) If you intended to match against parameter b of method g, you must use backticks, like: case `b` => case b => 1 ^ -newpat_unreachable.scala:23: error: unreachable code due to variable pattern 'b' on line 22 +newpat_unreachable.scala:23: warning: unreachable code due to variable pattern 'b' on line 22 If you intended to match against parameter c of method h, you must use backticks, like: case `c` => case c => 2 ^ -newpat_unreachable.scala:24: error: unreachable code due to variable pattern 'b' on line 22 +newpat_unreachable.scala:24: warning: unreachable code due to variable pattern 'b' on line 22 case _ => 3 ^ -7 errors found +error: No warnings can be incurred under -Xfatal-warnings. +7 warnings found +one error found diff --git a/test/files/neg/no-implicit-to-anyref.check b/test/files/neg/no-implicit-to-anyref.check index d94b57a30a..fe417ad8b0 100644 --- a/test/files/neg/no-implicit-to-anyref.check +++ b/test/files/neg/no-implicit-to-anyref.check @@ -1,10 +1,4 @@ -no-implicit-to-anyref.scala:11: error: type mismatch; - found : Int(1) - required: AnyRef -Note: an implicit exists from scala.Int => java.lang.Integer, but -methods inherited from Object are rendered ambiguous. This is to avoid -a blanket implicit which would convert any scala.Int to any AnyRef. -You may wish to use a type ascription: `x: java.lang.Integer`. +no-implicit-to-anyref.scala:11: error: the result type of an implicit conversion must be more specific than AnyRef 1: AnyRef ^ no-implicit-to-anyref.scala:17: error: type mismatch; diff --git a/test/files/neg/nonlocal-warning.check b/test/files/neg/nonlocal-warning.check new file mode 100644 index 0000000000..5202df655a --- /dev/null +++ b/test/files/neg/nonlocal-warning.check @@ -0,0 +1,9 @@ +nonlocal-warning.scala:4: warning: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning. + catch { case x => 11 } + ^ +nonlocal-warning.scala:2: warning: catch block may intercept non-local return from method foo + def foo(l: List[Int]): Int = { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/nonlocal-warning.flags b/test/files/neg/nonlocal-warning.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/nonlocal-warning.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/nonlocal-warning.scala b/test/files/neg/nonlocal-warning.scala new file mode 100644 index 0000000000..f908a86302 --- /dev/null +++ b/test/files/neg/nonlocal-warning.scala @@ -0,0 +1,18 @@ +class Foo { + def foo(l: List[Int]): Int = { + try l foreach { _ => return 5 } + catch { case x => 11 } + 22 + } + + val pf: PartialFunction[Throwable, Unit] = { + case x if false => () + } + + def bar(l: List[Int]): Int = { + try l foreach { _ => return 5 } + catch pf + finally println() + 22 + } +} diff --git a/test/files/neg/null-unsoundness.scala b/test/files/neg/null-unsoundness.scala index 3f7e42fe17..0f8ed5e314 100644 --- a/test/files/neg/null-unsoundness.scala +++ b/test/files/neg/null-unsoundness.scala @@ -12,4 +12,3 @@ object Test extends A with App { type A = C y = 42 } - diff --git a/test/files/neg/nullary-override.check b/test/files/neg/nullary-override.check index 6b2ded2d4a..f032f4a6c2 100644 --- a/test/files/neg/nullary-override.check +++ b/test/files/neg/nullary-override.check @@ -1,4 +1,6 @@ -nullary-override.scala:2: error: non-nullary method overrides nullary method +nullary-override.scala:2: warning: non-nullary method overrides nullary method class B extends A { override def x(): Int = 4 } ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/object-not-a-value.scala b/test/files/neg/object-not-a-value.scala index 2f894a33df..207b271df2 100644 --- a/test/files/neg/object-not-a-value.scala +++ b/test/files/neg/object-not-a-value.scala @@ -1,6 +1,6 @@ object Test { import java.util._ - + def main(args: Array[String]): Unit = { List(1) map (_ + 1) } diff --git a/test/files/neg/overload-msg.scala b/test/files/neg/overload-msg.scala index 896722262d..8715c156a2 100644 --- a/test/files/neg/overload-msg.scala +++ b/test/files/neg/overload-msg.scala @@ -1,4 +1,4 @@ // type parameter shadows actual type, massive overload error confuses. -class A(x: Int) { +class A(x: Int) { def f[Int](y: Int) = x + y } diff --git a/test/files/neg/overloaded-implicit.check b/test/files/neg/overloaded-implicit.check index bdbe6a89d5..ca0870705d 100644 --- a/test/files/neg/overloaded-implicit.check +++ b/test/files/neg/overloaded-implicit.check @@ -1,7 +1,9 @@ -overloaded-implicit.scala:2: error: parameterized overloaded implicit methods are not visible as view bounds +overloaded-implicit.scala:2: warning: parameterized overloaded implicit methods are not visible as view bounds implicit def imp1[T](x: List[T]): Map[T, T] = Map() ^ -overloaded-implicit.scala:3: error: parameterized overloaded implicit methods are not visible as view bounds +overloaded-implicit.scala:3: warning: parameterized overloaded implicit methods are not visible as view bounds implicit def imp1[T](x: Set[T]): Map[T, T] = Map() ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/overloaded-implicit.flags b/test/files/neg/overloaded-implicit.flags index 7949c2afa2..9c1e74e4ef 100644 --- a/test/files/neg/overloaded-implicit.flags +++ b/test/files/neg/overloaded-implicit.flags @@ -1 +1 @@ --Xlint -Xfatal-warnings +-Xlint -Xfatal-warnings -Xdev diff --git a/test/files/neg/overloaded-implicit.scala b/test/files/neg/overloaded-implicit.scala index 9ab66cf560..68b1ceaa30 100644 --- a/test/files/neg/overloaded-implicit.scala +++ b/test/files/neg/overloaded-implicit.scala @@ -1,15 +1,15 @@ object Test { implicit def imp1[T](x: List[T]): Map[T, T] = Map() implicit def imp1[T](x: Set[T]): Map[T, T] = Map() - + def f[T <% Map[Int, Int]](x: T): Double = 1.0d // not parameterized, no warning - implicit def imp2(x: List[Int]): String = "a" + implicit def imp2(x: List[Int]): String = "a" implicit def imp2(x: Set[Int]): String = "b" - + def g[T <% String](x: T): Double = 2.0d - + def main(args: Array[String]): Unit = { // println(f(List(1))) println(g(List(1))) diff --git a/test/files/neg/override-object-no.scala b/test/files/neg/override-object-no.scala index 45961e4fa6..745cdb2332 100644 --- a/test/files/neg/override-object-no.scala +++ b/test/files/neg/override-object-no.scala @@ -25,7 +25,7 @@ package case1 { trait Quux4 extends Quux3 { override object Bar } // err } -// type parameter as-seen-from business +// type parameter as-seen-from business package case2 { // invariance (see pos for the covariant case) class Bar[T] diff --git a/test/files/neg/package-ob-case.check b/test/files/neg/package-ob-case.check index e6b2f858ef..063a120db1 100644 --- a/test/files/neg/package-ob-case.check +++ b/test/files/neg/package-ob-case.check @@ -1,5 +1,7 @@ -package-ob-case.scala:3: error: it is not recommended to define classes/objects inside of package objects. +package-ob-case.scala:3: warning: it is not recommended to define classes/objects inside of package objects. If possible, define class X in package foo instead. case class X(z: Int) { } ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/pat_unreachable.check b/test/files/neg/pat_unreachable.check index c5706b7fad..b4c0e7e104 100644 --- a/test/files/neg/pat_unreachable.check +++ b/test/files/neg/pat_unreachable.check @@ -1,13 +1,14 @@ -pat_unreachable.scala:5: error: unreachable code - case Seq(x, y, z, w) => List(z,w) // redundant! - ^ -pat_unreachable.scala:9: error: unreachable code - case Seq(x, y) => List(x, y) - ^ -pat_unreachable.scala:23: error: unreachable code +pat_unreachable.scala:22: warning: patterns after a variable pattern cannot match (SLS 8.1.1) +If you intended to match against parameter b of method contrivedExample, you must use backticks, like: case `b` => + case b => println("matched b") + ^ +pat_unreachable.scala:23: warning: unreachable code due to variable pattern 'b' on line 22 +If you intended to match against parameter c of method contrivedExample, you must use backticks, like: case `c` => case c => println("matched c") ^ -pat_unreachable.scala:24: error: unreachable code +pat_unreachable.scala:24: warning: unreachable code due to variable pattern 'b' on line 22 case _ => println("matched neither") ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/pat_unreachable.flags b/test/files/neg/pat_unreachable.flags index cb8324a345..85d8eb2ba2 100644 --- a/test/files/neg/pat_unreachable.flags +++ b/test/files/neg/pat_unreachable.flags @@ -1 +1 @@ --Xoldpatmat
\ No newline at end of file +-Xfatal-warnings diff --git a/test/files/neg/patmat-type-check.check b/test/files/neg/patmat-type-check.check index 721217c314..fedac3b746 100644 --- a/test/files/neg/patmat-type-check.check +++ b/test/files/neg/patmat-type-check.check @@ -1,12 +1,27 @@ patmat-type-check.scala:11: warning: fruitless type test: a value of type Test.Bop4[T] cannot also be a Seq[A] def s3[T](x: Bop4[T]) = x match { case Seq('b', 'o', 'b') => true } ^ +patmat-type-check.scala:11: error: pattern type is incompatible with expected type; + found : Seq[A] + required: Test.Bop4[T] + def s3[T](x: Bop4[T]) = x match { case Seq('b', 'o', 'b') => true } + ^ patmat-type-check.scala:15: warning: fruitless type test: a value of type Test.Bop5[_$1,T1,T2] cannot also be a Seq[A] def s4[T1, T2](x: Bop5[_, T1, T2]) = x match { case Seq('b', 'o', 'b') => true } ^ +patmat-type-check.scala:15: error: pattern type is incompatible with expected type; + found : Seq[A] + required: Test.Bop5[_$1,T1,T2] where type _$1 + def s4[T1, T2](x: Bop5[_, T1, T2]) = x match { case Seq('b', 'o', 'b') => true } + ^ patmat-type-check.scala:19: warning: fruitless type test: a value of type Test.Bop3[T] cannot also be a Seq[A] def f4[T](x: Bop3[T]) = x match { case Seq('b', 'o', 'b') => true } ^ +patmat-type-check.scala:19: error: pattern type is incompatible with expected type; + found : Seq[A] + required: Test.Bop3[T] + def f4[T](x: Bop3[T]) = x match { case Seq('b', 'o', 'b') => true } + ^ patmat-type-check.scala:22: error: scrutinee is incompatible with pattern type; found : Seq[A] required: String @@ -28,4 +43,4 @@ patmat-type-check.scala:30: error: scrutinee is incompatible with pattern type; def f4[T](x: Bop3[Char]) = x match { case Seq('b', 'o', 'b') => true } // fail ^ three warnings found -four errors found +7 errors found diff --git a/test/files/neg/patmat-type-check.scala b/test/files/neg/patmat-type-check.scala index cc35089430..26d0409fa0 100644 --- a/test/files/neg/patmat-type-check.scala +++ b/test/files/neg/patmat-type-check.scala @@ -1,15 +1,15 @@ object Test { def s1 = "bob".toList match { case Seq('b', 'o', 'b') => true } // list ok - + // not final, allowed - class Bop + class Bop def s2(x: Bop) = x match { case Seq('b', 'o', 'b') => true } - + // covariance, allowed final class Bop4[+T] def s3[T](x: Bop4[T]) = x match { case Seq('b', 'o', 'b') => true } - + // contravariance, allowed final class Bop5[T, U, -V] def s4[T1, T2](x: Bop5[_, T1, T2]) = x match { case Seq('b', 'o', 'b') => true } @@ -17,7 +17,7 @@ object Test // free type parameter, allowed final class Bop3[T] def f4[T](x: Bop3[T]) = x match { case Seq('b', 'o', 'b') => true } - + // String and Array are final/invariant, disallowed def f1 = "bob".reverse match { case Seq('b', 'o', 'b') => true } // fail def f2 = "bob".toArray match { case Seq('b', 'o', 'b') => true } // fail @@ -25,7 +25,7 @@ object Test // final, no type parameters, should be disallowed final class Bop2 def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail - + // final, invariant type parameter, should be disallowed def f4[T](x: Bop3[Char]) = x match { case Seq('b', 'o', 'b') => true } // fail } diff --git a/test/files/neg/patmatexhaust.check b/test/files/neg/patmatexhaust.check index 4556e6622f..2dad608451 100644 --- a/test/files/neg/patmatexhaust.check +++ b/test/files/neg/patmatexhaust.check @@ -1,40 +1,42 @@ -patmatexhaust.scala:7: error: match may not be exhaustive. +patmatexhaust.scala:7: warning: match may not be exhaustive. It would fail on the following input: Baz def ma1(x:Foo) = x match { ^ -patmatexhaust.scala:11: error: match may not be exhaustive. +patmatexhaust.scala:11: warning: match may not be exhaustive. It would fail on the following input: Bar(_) def ma2(x:Foo) = x match { ^ -patmatexhaust.scala:23: error: match may not be exhaustive. +patmatexhaust.scala:23: warning: match may not be exhaustive. It would fail on the following inputs: (Kult(_), Kult(_)), (Qult(), Qult()) def ma3(x:Mult) = (x,x) match { // not exhaustive ^ -patmatexhaust.scala:49: error: match may not be exhaustive. +patmatexhaust.scala:49: warning: match may not be exhaustive. It would fail on the following inputs: Gp(), Gu def ma4(x:Deep) = x match { // missing cases: Gu, Gp ^ -patmatexhaust.scala:55: error: unreachable code - case _ if 1 == 0 => +patmatexhaust.scala:55: warning: unreachable code + case _ if 1 == 0 => ^ -patmatexhaust.scala:53: error: match may not be exhaustive. +patmatexhaust.scala:53: warning: match may not be exhaustive. It would fail on the following input: Gp() def ma5(x:Deep) = x match { ^ -patmatexhaust.scala:75: error: match may not be exhaustive. +patmatexhaust.scala:75: warning: match may not be exhaustive. It would fail on the following input: B() def ma9(x: B) = x match { ^ -patmatexhaust.scala:100: error: match may not be exhaustive. +patmatexhaust.scala:100: warning: match may not be exhaustive. It would fail on the following input: C1() def ma10(x: C) = x match { // not exhaustive: C1 is not sealed. ^ -patmatexhaust.scala:114: error: match may not be exhaustive. +patmatexhaust.scala:114: warning: match may not be exhaustive. It would fail on the following inputs: D1, D2() def ma10(x: C) = x match { // not exhaustive: C1 has subclasses. ^ -patmatexhaust.scala:126: error: match may not be exhaustive. +patmatexhaust.scala:126: warning: match may not be exhaustive. It would fail on the following input: C1() def ma10(x: C) = x match { // not exhaustive: C1 is not abstract. ^ -10 errors found +error: No warnings can be incurred under -Xfatal-warnings. +10 warnings found +one error found diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala index ceb960ee97..aa7dac7d7d 100644 --- a/test/files/neg/patmatexhaust.scala +++ b/test/files/neg/patmatexhaust.scala @@ -22,14 +22,14 @@ class TestSealedExhaustive { // compile only def ma3(x:Mult) = (x,x) match { // not exhaustive case (Kult(_), Qult()) => // Kult missing - //case Pair(Kult(_), Kult(_)) => + //case Pair(Kult(_), Kult(_)) => case (Qult(), Kult(_)) => // Qult missing - //case Pair(Qult(), Qult()) => + //case Pair(Qult(), Qult()) => } def ma3u(x:Mult) = ((x,x) : @unchecked) match { // not exhaustive, but not checked! - case (Kult(_), Qult()) => - case (Qult(), Kult(_)) => + case (Kult(_), Qult()) => + case (Qult(), Kult(_)) => } sealed abstract class Deep @@ -37,22 +37,22 @@ class TestSealedExhaustive { // compile only case object Ga extends Deep sealed class Gp extends Deep case object Gu extends Gp - + def zma3(x:Deep) = x match { // exhaustive! case _ => } def zma4(x:Deep) = x match { // exhaustive! - case Ga => + case Ga => case _ => } def ma4(x:Deep) = x match { // missing cases: Gu, Gp - case Ga => + case Ga => } def ma5(x:Deep) = x match { case Gu => - case _ if 1 == 0 => + case _ if 1 == 0 => case Ga => } @@ -65,7 +65,7 @@ class TestSealedExhaustive { // compile only case 1::2::Nil => case _ => } - + sealed class B case class B1() extends B case object B2 extends B @@ -76,7 +76,7 @@ class TestSealedExhaustive { // compile only case B1() => true // missing B, which is not abstract so must be included case B2 => true } - + object ob1 { sealed abstract class C sealed abstract class C1 extends C @@ -89,7 +89,7 @@ class TestSealedExhaustive { // compile only case C2 | C4 => true } } - + object ob2 { sealed abstract class C abstract class C1 extends C diff --git a/test/files/neg/patternalts.scala b/test/files/neg/patternalts.scala index 56b682b0ec..539df43201 100644 --- a/test/files/neg/patternalts.scala +++ b/test/files/neg/patternalts.scala @@ -1,5 +1,5 @@ object Test { List(1) match { case List(x) | List() => Console.println(x) - } + } } diff --git a/test/files/neg/permanent-blindness.check b/test/files/neg/permanent-blindness.check index 18b4543707..cdde201ef6 100644 --- a/test/files/neg/permanent-blindness.check +++ b/test/files/neg/permanent-blindness.check @@ -1,10 +1,12 @@ -permanent-blindness.scala:10: error: imported `Bippy' is permanently hidden by definition of class Bippy in package bar +permanent-blindness.scala:10: warning: imported `Bippy' is permanently hidden by definition of class Bippy in package bar import foo.{ Bippy, Bop, Dingus } ^ -permanent-blindness.scala:10: error: imported `Bop' is permanently hidden by definition of object Bop in package bar +permanent-blindness.scala:10: warning: imported `Bop' is permanently hidden by definition of object Bop in package bar import foo.{ Bippy, Bop, Dingus } ^ -permanent-blindness.scala:10: error: imported `Dingus' is permanently hidden by definition of object Dingus in package bar +permanent-blindness.scala:10: warning: imported `Dingus' is permanently hidden by definition of object Dingus in package bar import foo.{ Bippy, Bop, Dingus } ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/predef-masking.scala b/test/files/neg/predef-masking.scala index 67b69aa169..6f4f4859d0 100644 --- a/test/files/neg/predef-masking.scala +++ b/test/files/neg/predef-masking.scala @@ -1,5 +1,5 @@ // Testing predef masking -import Predef.{ any2stringadd => _, _ } +import Predef.{ StringAdd => _, _ } object StringPlusConfusion { // Would love to do something about this error message, but by the diff --git a/test/files/neg/protected-constructors.check b/test/files/neg/protected-constructors.check index f137158ed6..f44d7db9b9 100644 --- a/test/files/neg/protected-constructors.check +++ b/test/files/neg/protected-constructors.check @@ -3,23 +3,20 @@ protected-constructors.scala:17: error: too many arguments for constructor Foo1: ^ protected-constructors.scala:18: error: constructor Foo2 in class Foo2 cannot be accessed in object P Access to protected constructor Foo2 not permitted because - enclosing object P in package hungus is not a subclass of + enclosing object P in package hungus is not a subclass of class Foo2 in package dingus where target is defined val foo2 = new Foo2("abc") ^ protected-constructors.scala:19: error: class Foo3 in object Ding cannot be accessed in object dingus.Ding Access to protected class Foo3 not permitted because - enclosing object P in package hungus is not a subclass of + enclosing object P in package hungus is not a subclass of object Ding in package dingus where target is defined val foo3 = new Ding.Foo3("abc") ^ protected-constructors.scala:15: error: class Foo3 in object Ding cannot be accessed in object dingus.Ding Access to protected class Foo3 not permitted because - enclosing object P in package hungus is not a subclass of + enclosing object P in package hungus is not a subclass of object Ding in package dingus where target is defined class Bar3 extends Ding.Foo3("abc") ^ -protected-constructors.scala:15: error: too many arguments for constructor Object: ()Object - class Bar3 extends Ding.Foo3("abc") - ^ -5 errors found +four errors found diff --git a/test/files/neg/protected-constructors.scala b/test/files/neg/protected-constructors.scala index f2662ee67c..2838caf09c 100644 --- a/test/files/neg/protected-constructors.scala +++ b/test/files/neg/protected-constructors.scala @@ -8,7 +8,7 @@ package dingus { package hungus { import dingus._ - + object P { class Bar1 extends Foo1("abc") class Bar2 extends Foo2("abc") diff --git a/test/files/neg/protected-static-fail.check b/test/files/neg/protected-static-fail.check index e149bc016f..9f0bc92e7d 100644 --- a/test/files/neg/protected-static-fail.check +++ b/test/files/neg/protected-static-fail.check @@ -3,13 +3,13 @@ S.scala:5: error: method f in object J cannot be accessed in object bippy.J ^ S.scala:6: error: method f1 in object S1 cannot be accessed in object bippy.S1 Access to protected method f1 not permitted because - enclosing object Test in package bippy is not a subclass of + enclosing object Test in package bippy is not a subclass of object S1 in package bippy where target is defined S1.f1() ^ S.scala:8: error: method f2 in class S2 cannot be accessed in bippy.S2 Access to protected method f2 not permitted because - enclosing object Test in package bippy is not a subclass of + enclosing object Test in package bippy is not a subclass of class S2 in package bippy where target is defined x.f2() ^ diff --git a/test/files/neg/quasiquotes-syntax-error-position.check b/test/files/neg/quasiquotes-syntax-error-position.check new file mode 100644 index 0000000000..3bd813b1bb --- /dev/null +++ b/test/files/neg/quasiquotes-syntax-error-position.check @@ -0,0 +1,32 @@ +quasiquotes-syntax-error-position.scala:5: error: '=' expected but identifier found. + q"def $a f" + ^ +quasiquotes-syntax-error-position.scala:6: error: illegal start of simple expression + q"$a(" + ^ +quasiquotes-syntax-error-position.scala:7: error: '}' expected but end of quote found. + q"class $t { def foo = $a" + ^ +quasiquotes-syntax-error-position.scala:8: error: '.' expected but splicee found. + q"import $t $t" + ^ +quasiquotes-syntax-error-position.scala:9: error: illegal start of definition + q"package p" + ^ +quasiquotes-syntax-error-position.scala:10: error: ';' expected but '@' found. + q"foo@$a" + ^ +quasiquotes-syntax-error-position.scala:11: error: case classes without a parameter list are not allowed; +use either case objects or case classes with an explicit `()' as a parameter list. + q"case class A" + ^ +quasiquotes-syntax-error-position.scala:12: error: identifier expected but ']' found. + tq"$t => $t $t]" + ^ +quasiquotes-syntax-error-position.scala:13: error: end of quote expected but 'case' found. + cq"pattern => body ; case pattern2 =>" + ^ +quasiquotes-syntax-error-position.scala:14: error: ')' expected but end of quote found. + pq"$a(bar" + ^ +10 errors found diff --git a/test/files/neg/quasiquotes-syntax-error-position.scala b/test/files/neg/quasiquotes-syntax-error-position.scala new file mode 100644 index 0000000000..b97af52cfc --- /dev/null +++ b/test/files/neg/quasiquotes-syntax-error-position.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ +object test extends App { + val a = TermName("a") + val t = TypeName("t") + q"def $a f" + q"$a(" + q"class $t { def foo = $a" + q"import $t $t" + q"package p" + q"foo@$a" + q"case class A" + tq"$t => $t $t]" + cq"pattern => body ; case pattern2 =>" + pq"$a(bar" +}
\ No newline at end of file diff --git a/test/files/neg/raw-types-stubs.check b/test/files/neg/raw-types-stubs.check new file mode 100644 index 0000000000..f1b26a23b7 --- /dev/null +++ b/test/files/neg/raw-types-stubs.check @@ -0,0 +1,11 @@ +S_3.scala:1: error: class Sub needs to be abstract, since: +it has 2 unimplemented members. +/** As seen from class Sub, the missing signatures are as follows. + * For convenience, these are usable as stub implementations. + */ + def raw(x$1: M_1[_ <: String]): Unit = ??? + def raw(x$1: Any): Unit = ??? + +class Sub extends Raw_2 { } + ^ +one error found diff --git a/test/files/neg/raw-types-stubs/M_1.java b/test/files/neg/raw-types-stubs/M_1.java new file mode 100644 index 0000000000..6ea0d2e593 --- /dev/null +++ b/test/files/neg/raw-types-stubs/M_1.java @@ -0,0 +1,3 @@ +public class M_1<K extends String> { } + + diff --git a/test/files/neg/raw-types-stubs/Raw_2.java b/test/files/neg/raw-types-stubs/Raw_2.java new file mode 100644 index 0000000000..eff7df790e --- /dev/null +++ b/test/files/neg/raw-types-stubs/Raw_2.java @@ -0,0 +1,4 @@ +public abstract class Raw_2 { + public abstract void raw(Object list); + public abstract void raw(M_1 list); +} diff --git a/test/files/neg/raw-types-stubs/S_3.scala b/test/files/neg/raw-types-stubs/S_3.scala new file mode 100644 index 0000000000..618eedc888 --- /dev/null +++ b/test/files/neg/raw-types-stubs/S_3.scala @@ -0,0 +1 @@ +class Sub extends Raw_2 { } diff --git a/test/files/neg/saito.scala b/test/files/neg/saito.scala index bfabb4edf4..b4fcd598e4 100644 --- a/test/files/neg/saito.scala +++ b/test/files/neg/saito.scala @@ -2,13 +2,13 @@ class B {} class A { self: B => def m(): B = { this - } + } } object Exec{ def main(args: Array[String]): Unit = { val a: A = new A; // should not be allowed - val b: B = a.m(); + val b: B = a.m(); } } diff --git a/test/files/neg/sealed-final-neg.check b/test/files/neg/sealed-final-neg.check new file mode 100644 index 0000000000..500d23f49a --- /dev/null +++ b/test/files/neg/sealed-final-neg.check @@ -0,0 +1,4 @@ +sealed-final-neg.scala:41: error: expected class or object definition +"Due to SI-6142 this emits no warnings, so we'll just break it until that's fixed." +^ +one error found diff --git a/test/files/neg/sealed-final-neg.flags b/test/files/neg/sealed-final-neg.flags new file mode 100644 index 0000000000..cfabf7a5b4 --- /dev/null +++ b/test/files/neg/sealed-final-neg.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Yinline-warnings -optimise
\ No newline at end of file diff --git a/test/files/neg/sealed-final-neg.scala b/test/files/neg/sealed-final-neg.scala new file mode 100644 index 0000000000..bc25330e13 --- /dev/null +++ b/test/files/neg/sealed-final-neg.scala @@ -0,0 +1,41 @@ +package neg1 { + sealed abstract class Foo { + @inline def bar(x: Int) = x + 1 + } + object Foo { + def mkFoo(): Foo = new Baz2 + } + + object Baz1 extends Foo + final class Baz2 extends Foo + final class Baz3 extends Foo { + override def bar(x: Int) = x - 1 + } + + object Test { + // bar can't be inlined - it is overridden in Baz3 + def f = Foo.mkFoo() bar 10 + } +} + +package neg2 { + sealed abstract class Foo { + @inline def bar(x: Int) = x + 1 + } + object Foo { + def mkFoo(): Foo = new Baz2 + } + + object Baz1 extends Foo + final class Baz2 extends Foo + class Baz3 extends Foo { + override def bar(x: Int) = x - 1 + } + + object Test { + // bar can't be inlined - Baz3 is not final + def f = Foo.mkFoo() bar 10 + } +} + +"Due to SI-6142 this emits no warnings, so we'll just break it until that's fixed." diff --git a/test/files/neg/sealed-java-enums.check b/test/files/neg/sealed-java-enums.check index 20d00c8e91..a3c39ec5cd 100644 --- a/test/files/neg/sealed-java-enums.check +++ b/test/files/neg/sealed-java-enums.check @@ -1,5 +1,7 @@ -sealed-java-enums.scala:5: error: match may not be exhaustive. +sealed-java-enums.scala:5: warning: match may not be exhaustive. It would fail on the following inputs: BLOCKED, TERMINATED, TIMED_WAITING def f(state: State) = state match { ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/sensitive.scala b/test/files/neg/sensitive.scala index fa1b940844..a084a0a8ca 100644 --- a/test/files/neg/sensitive.scala +++ b/test/files/neg/sensitive.scala @@ -5,8 +5,8 @@ object Admin extends Certificate; class SecurityViolationException extends Exception object Sensitive { - def makeSensitive(credentials: Certificate): Sensitive = - if (credentials == Admin) new Sensitive() + def makeSensitive(credentials: Certificate): Sensitive = + if (credentials == Admin) new Sensitive() else throw new SecurityViolationException } class Sensitive private () { @@ -16,4 +16,3 @@ object Attacker { val x = Sensitive.makeSensitive(null) val y = new Sensitive() } - diff --git a/test/files/neg/serialversionuid-not-const.check b/test/files/neg/serialversionuid-not-const.check new file mode 100644 index 0000000000..9c383d97ad --- /dev/null +++ b/test/files/neg/serialversionuid-not-const.check @@ -0,0 +1,10 @@ +serialversionuid-not-const.scala:1: error: annotation argument needs to be a constant; found: 13L.toLong +@SerialVersionUID(13l.toLong) class C1 extends Serializable + ^ +serialversionuid-not-const.scala:3: error: annotation argument needs to be a constant; found: 13.asInstanceOf[Long] +@SerialVersionUID(13.asInstanceOf[Long]) class C3 extends Serializable + ^ +serialversionuid-not-const.scala:4: error: annotation argument needs to be a constant; found: Test.bippy +@SerialVersionUID(Test.bippy) class C4 extends Serializable + ^ +three errors found diff --git a/test/files/neg/serialversionuid-not-const.scala b/test/files/neg/serialversionuid-not-const.scala new file mode 100644 index 0000000000..f0e3ef4e7e --- /dev/null +++ b/test/files/neg/serialversionuid-not-const.scala @@ -0,0 +1,16 @@ +@SerialVersionUID(13l.toLong) class C1 extends Serializable +@SerialVersionUID(13l) class C2 extends Serializable +@SerialVersionUID(13.asInstanceOf[Long]) class C3 extends Serializable +@SerialVersionUID(Test.bippy) class C4 extends Serializable + +object Test { + val bippy = 13L + + def show(c: Class[_]) = println(java.io.ObjectStreamClass.lookup(c).getSerialVersionUID) + def main(args: Array[String]): Unit = { + show(classOf[C1]) + show(classOf[C2]) + show(classOf[C3]) + show(classOf[C4]) + } +} diff --git a/test/files/neg/spec-overrides.scala b/test/files/neg/spec-overrides.scala index f77dadea5d..713ce27bd3 100644 --- a/test/files/neg/spec-overrides.scala +++ b/test/files/neg/spec-overrides.scala @@ -15,7 +15,7 @@ class FX2 extends P { object Test extends App { val fx = new FX val p = new P - + println(fx.a(3)) println((fx: P).a(3)) println((fx: P).a(3.0)) diff --git a/test/files/neg/specification-scopes.check b/test/files/neg/specification-scopes.check index 7af9842379..ab986135e5 100644 --- a/test/files/neg/specification-scopes.check +++ b/test/files/neg/specification-scopes.check @@ -1,5 +1,5 @@ P_2.scala:14: error: reference to x is ambiguous; -it is both defined in object C and imported subsequently by +it is both defined in object C and imported subsequently by import Q.X._ println("L14: "+x) // reference to 'x' is ambiguous here ^ diff --git a/test/files/neg/stmt-expr-discard.check b/test/files/neg/stmt-expr-discard.check index 2d6420a61d..1207e6da50 100644 --- a/test/files/neg/stmt-expr-discard.check +++ b/test/files/neg/stmt-expr-discard.check @@ -1,7 +1,9 @@ -stmt-expr-discard.scala:3: error: a pure expression does nothing in statement position; you may be omitting necessary parentheses +stmt-expr-discard.scala:3: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 2 ^ -stmt-expr-discard.scala:4: error: a pure expression does nothing in statement position; you may be omitting necessary parentheses +stmt-expr-discard.scala:4: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - 4 ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/structural.scala b/test/files/neg/structural.scala index bfca37b22a..d783399317 100644 --- a/test/files/neg/structural.scala +++ b/test/files/neg/structural.scala @@ -1,54 +1,54 @@ object Test extends App { - + def f(x: { type D; def m: D }): Null = null - + class Tata - + abstract class Toto[A <: Object] { type B <: Object - + def f1[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: A): Object; val x: A }) = x.m[Tata](x.x) //fail def f2[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: B): Object; val x: B }) = x.m[Tata](x.x) //fail def f3[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: C): Object; val x: C }) = x.m[Tata](x.x) //fail def f4[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: D): Object; val x: D }) = x.m[Tata](x.x) //fail def f5[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: E): Object; val x: Tata }) = x.m[Tata](x.x) //suceed - + def f6[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): A }) = x.m[Tata](null) //suceed def f7[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): B }) = x.m[Tata](null) //suceed def f8[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): C }) = x.m[Tata](null) //suceed def f9[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): D }) = x.m[Tata](null) //fail def f0[C <: Object](x: Object{ type D <: Object; def m[E >: Null <: Object](x: Object): E }) = x.m[Tata](null) //suceed - + } - + val tata = new Tata val toto = new Toto[Tata] { type B = Tata } - + //toto.f1[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Tata): Object = null; val x = tata }) //toto.f2[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Tata): Object = null; val x = tata }) //toto.f3[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Tata): Object = null; val x = tata }) //toto.f4[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: D): Object = null; val x = tata }) toto.f5[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: E): Object = null; val x: Test.Tata = tata }) - + toto.f6[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): Tata = null }) toto.f7[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): Tata = null }) toto.f8[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): Tata = null }) //toto.f9[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): D = null }) toto.f0[Tata](new Object{ type D = Tata; def m[E >: Null <: Object](x: Object): E = null }) - + /* Bug #1246 */ type Summable[T] = { def +(v : T) : T } def sum[T <: Summable[T]](xs : List[T]) = xs.reduceLeft[T](_ + _) - + /* Bug #1004 & #967 */ type S1 = { def f(p: this.type): Unit } val s1 = new { def f(p: this.type): Unit = () } - + type S2 = { type T; def f(p: T): Unit } //val s2: S2 = new { type T = A; def f(p: T): Unit = () } - + def s3[U >: Null <: Object](p: { def f(p: U): Unit; def u: U }) = () - + } diff --git a/test/files/neg/switch.check b/test/files/neg/switch.check index e4730b6459..f968d3a448 100644 --- a/test/files/neg/switch.check +++ b/test/files/neg/switch.check @@ -1,7 +1,9 @@ -switch.scala:38: error: could not emit switch for @switch annotated match +switch.scala:38: warning: could not emit switch for @switch annotated match def fail2(c: Char) = (c: @switch @unchecked) match { ^ -switch.scala:45: error: could not emit switch for @switch annotated match +switch.scala:45: warning: could not emit switch for @switch annotated match def fail3(c: Char) = (c: @unchecked @switch) match { ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/switch.scala b/test/files/neg/switch.scala index 198583fe41..a66ed768fa 100644 --- a/test/files/neg/switch.scala +++ b/test/files/neg/switch.scala @@ -16,44 +16,44 @@ object Main { case 'f' | 'g' => true case _ => false } - + def succ2(c: Char) = (c: @switch) match { case 'A' | 'B' | 'C' => true case Other.C2 => true case Other.C4 => true case _ => false } - + // has a guard, but since SI-5830 that's ok def succ_guard(c: Char) = (c: @switch) match { case 'A' | 'B' | 'C' => true case x if x == 'A' => true case _ => false } - + // throwing in @unchecked on the next two to make sure // multiple annotations are processed correctly - + // thinks a val in an object is constant... so naive def fail2(c: Char) = (c: @switch @unchecked) match { case 'A' => true case Other.C1 => true case _ => false } - + // more naivete def fail3(c: Char) = (c: @unchecked @switch) match { case 'A' => true case Other.C3 => true case _ => false } - + // guard case done correctly def succ3(c: Char) = (c: @switch) match { case 'A' | 'B' | 'C' => true case x => x == 'A' } - + // some ints just to mix it up a bit def succ4(x: Int, y: Int) = ((x+y): @switch) match { case 1 => 5 @@ -62,5 +62,5 @@ object Main { case 4 => 50 case 5|6|7|8 => 100 case _ => -1 - } + } } diff --git a/test/files/neg/t0117.scala b/test/files/neg/t0117.scala index c73227d26d..4cd9ad6ef1 100644 --- a/test/files/neg/t0117.scala +++ b/test/files/neg/t0117.scala @@ -3,4 +3,3 @@ trait B extends A { println(super[A].a) } object Test extends App { new B {} } - diff --git a/test/files/neg/t0152.scala b/test/files/neg/t0152.scala index dc77ac31a3..d86d59e974 100644 --- a/test/files/neg/t0152.scala +++ b/test/files/neg/t0152.scala @@ -8,6 +8,6 @@ trait PlusOne extends Value[Int] { object Test extends App { object boom extends Value[java.lang.String]("foo") with PlusOne - + println(boom.value) // class cast exception! } diff --git a/test/files/neg/t0218.check b/test/files/neg/t0218.check index 6bb759156f..a22583d23b 100644 --- a/test/files/neg/t0218.check +++ b/test/files/neg/t0218.check @@ -1,4 +1,4 @@ t0218.scala:10: error: class type required but APQ.this.P found - List(new PP) + List(new PP) ^ one error found diff --git a/test/files/neg/t0218.scala b/test/files/neg/t0218.scala index 3d1f52e39a..319be82a7a 100644 --- a/test/files/neg/t0218.scala +++ b/test/files/neg/t0218.scala @@ -1,4 +1,4 @@ -trait APQ { +trait APQ { class Placement { } @@ -7,6 +7,6 @@ trait APQ { type PP = P def pq(numQueens: Int, numRows: Int) : List[Placement] = { - List(new PP) + List(new PP) } } diff --git a/test/files/neg/t0503.scala b/test/files/neg/t0503.scala index a9b5dcb1dd..322e1ad132 100644 --- a/test/files/neg/t0503.scala +++ b/test/files/neg/t0503.scala @@ -1,3 +1,3 @@ val x = new { } with { } -trait A +trait A val y = new { } with A diff --git a/test/files/neg/t0764.check b/test/files/neg/t0764.check index e14c7705b8..6156b52712 100644 --- a/test/files/neg/t0764.check +++ b/test/files/neg/t0764.check @@ -1,6 +1,7 @@ t0764.scala:13: error: type mismatch; found : Node{type T = _1.type} where val _1: Node{type T = NextType} required: Node{type T = Main.this.AType} + (which expands to) Node{type T = Node{type T = NextType}} new Main[AType]( (value: AType).prepend ) ^ one error found diff --git a/test/files/neg/t0764.scala b/test/files/neg/t0764.scala index 9aebe04b79..f2cc65cf7d 100644 --- a/test/files/neg/t0764.scala +++ b/test/files/neg/t0764.scala @@ -2,13 +2,13 @@ class Top[A] { type AType = A } -trait Node extends NotNull { outer => +trait Node { outer => type T <: Node def prepend = new Node { type T = outer.type } } class Main[NextType <: Node](value: Node { type T = NextType }) extends Top[Node { type T = NextType }] { - + new Main[AType]( (value: AType).prepend ) } diff --git a/test/files/neg/t0816.scala b/test/files/neg/t0816.scala index 738a634166..0128a0ad72 100644 --- a/test/files/neg/t0816.scala +++ b/test/files/neg/t0816.scala @@ -6,7 +6,7 @@ case class Ctest(override val data: String) extends Btest(data, true) class testCaseClass { def test(x: Atest) = x match { - case Ctest(data) => Console.println("C") + case Ctest(data) => Console.println("C") case Btest(data, b) => Console.println("B") } } diff --git a/test/files/neg/t1010.scala b/test/files/neg/t1010.scala index 7a1e6615e5..fd142978ec 100644 --- a/test/files/neg/t1010.scala +++ b/test/files/neg/t1010.scala @@ -6,9 +6,9 @@ class MailBox { abstract class Actor { private val in = new MailBox - def send(msg: in.Message) = error("foo") + def send(msg: in.Message) = sys.error("foo") - def unstable: Actor = error("foo") + def unstable: Actor = sys.error("foo") def dubiousSend(msg: MailBox#Message): Nothing = unstable.send(msg) // in.Message becomes unstable.Message, but that's ok since Message is a concrete type member diff --git a/test/files/neg/t1011.check b/test/files/neg/t1011.check deleted file mode 100644 index d9c8123549..0000000000 --- a/test/files/neg/t1011.check +++ /dev/null @@ -1,4 +0,0 @@ -t1011.scala:8: error: not found: value entity - <dl><code>{Text(entity)}</code> - ^ -one error found diff --git a/test/files/neg/t1011.scala b/test/files/neg/t1011.scala deleted file mode 100644 index 57a6ad7b45..0000000000 --- a/test/files/neg/t1011.scala +++ /dev/null @@ -1,127 +0,0 @@ -package test; -import scala.xml._; - -abstract class Test { - //val entity : String; - def primitiveHeader : NodeSeq = - Group({ - <dl><code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code> - <code>{Text(entity)}</code></dl> - } ++ // 3 seconds - {}++ // 5 seconds - {}++ // 10 seconds - {}++ // 20 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 5 seconds - {}++ // 10 seconds - {}++ // 20 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 5 seconds - {}++ // 10 seconds - {}++ // 20 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - {}++ // 40 seconds - <hr/>); -} diff --git a/test/files/neg/t1017.check b/test/files/neg/t1017.check deleted file mode 100644 index 52101c7f6e..0000000000 --- a/test/files/neg/t1017.check +++ /dev/null @@ -1,4 +0,0 @@ -t1017.scala:3: error: not found: value foo -<x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x>{ foo }</x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x> - ^ -one error found diff --git a/test/files/neg/t1017.scala b/test/files/neg/t1017.scala deleted file mode 100644 index e389f308c3..0000000000 --- a/test/files/neg/t1017.scala +++ /dev/null @@ -1,4 +0,0 @@ -// 'foo' is not defined -object Test { -<x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x>{ foo }</x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x> -} diff --git a/test/files/neg/t1112.check b/test/files/neg/t1112.check index e69be3ef2c..5e3821b153 100644 --- a/test/files/neg/t1112.check +++ b/test/files/neg/t1112.check @@ -1,4 +1,4 @@ -t1112.scala:12: error: too many arguments for method call: (p: Int)(f: => () => Unit)Unit +t1112.scala:12: error: too many arguments for method call: (p: Int)(f: => Test.this.Type1)Unit call(0,() => System.out.println("here we are")) ^ one error found diff --git a/test/files/neg/t1112.scala b/test/files/neg/t1112.scala index b2a374c785..1a88629faf 100644 --- a/test/files/neg/t1112.scala +++ b/test/files/neg/t1112.scala @@ -1,13 +1,13 @@ // checks that error doesn't crash the compiler -// (due to isFunctionType normalizing Type1 to a function type, +// (due to isFunctionType normalizing Type1 to a function type, // but then the code that used that test not using the normalized type for further operations) class Test { type Type1 = () => Unit - + def call(p: Int)(f: => Type1) = { f() } - + def run = { call(0,() => System.out.println("here we are")) } diff --git a/test/files/neg/t112706A.check b/test/files/neg/t112706A.check index 30d0c3ec91..ad403ab134 100644 --- a/test/files/neg/t112706A.check +++ b/test/files/neg/t112706A.check @@ -1,6 +1,6 @@ t112706A.scala:5: error: constructor cannot be instantiated to expected type; found : (T1, T2) required: String - case Tuple2(node,_) => + case Tuple2(node,_) => ^ one error found diff --git a/test/files/neg/t112706A.scala b/test/files/neg/t112706A.scala index b7799af96d..11304720bc 100644 --- a/test/files/neg/t112706A.scala +++ b/test/files/neg/t112706A.scala @@ -2,7 +2,7 @@ package test; trait Test { def foo(p : List[Tuple2[String,String]]) = { for (t <- p) t._1 match { - case Tuple2(node,_) => + case Tuple2(node,_) => } } } diff --git a/test/files/neg/t1181.check b/test/files/neg/t1181.check index 3724752a85..13b73d5381 100644 --- a/test/files/neg/t1181.check +++ b/test/files/neg/t1181.check @@ -1,8 +1,10 @@ t1181.scala:8: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses case (Nil, Nil) => map ^ -t1181.scala:9: error: missing parameter type +t1181.scala:9: error: type mismatch; + found : scala.collection.immutable.Map[Symbol,Symbol] + required: Symbol _ => buildMap(map.updated(keyList.head, valueList.head), keyList.tail, valueList.tail) - ^ + ^ one warning found one error found diff --git a/test/files/neg/t1183.scala b/test/files/neg/t1183.scala index 024c4abd54..23868ab401 100644 --- a/test/files/neg/t1183.scala +++ b/test/files/neg/t1183.scala @@ -9,7 +9,7 @@ object Test { case class Bar(i:Int) } - + class Test717 { val foo1 = new Foo(1) @@ -27,7 +27,7 @@ object Test { class Baz object Bam object Bar - + def unapply(s : String) : Option[Bar] = Some(new Bar(s)) } diff --git a/test/files/neg/t1224.check b/test/files/neg/t1224.check index fb61275911..ab8a6f1130 100644 --- a/test/files/neg/t1224.check +++ b/test/files/neg/t1224.check @@ -1,4 +1,4 @@ -t1224.scala:4: error: illegal cyclic reference involving type T +t1224.scala:4: error: lower bound C[A.this.T] does not conform to upper bound C[C[A.this.T]] type T >: C[T] <: C[C[T]] ^ one error found diff --git a/test/files/neg/t1224.flags b/test/files/neg/t1224.flags new file mode 100644 index 0000000000..ca20f55172 --- /dev/null +++ b/test/files/neg/t1224.flags @@ -0,0 +1 @@ +-Ybreak-cycles diff --git a/test/files/neg/t1432.check b/test/files/neg/t1432.check index 180cb05e67..e41f3453fe 100644 --- a/test/files/neg/t1432.check +++ b/test/files/neg/t1432.check @@ -1,6 +1,8 @@ -t1432.scala:10: error: type mismatch; - found : (Int, Bug_NoUnique.Wrap[Bug_NoUnique.Wrap[Unit]] => Double) - required: (Int, Unit => Double) +t1432.scala:12: error: type mismatch; + found : (Int, Bug_NoUnique.Alias2[Bug_NoUnique.Wrap[Unit]] => Double) + (which expands to) (Int, Bug_NoUnique.Wrap[Bug_NoUnique.Wrap[Unit]] => Double) + required: Bug_NoUnique.TypeCon[Unit] + (which expands to) (Int, Unit => Double) def test(x : TypeCon[Wrap[Unit]]) : TypeCon[Unit] = wrap(x) ^ one error found diff --git a/test/files/neg/t1432.scala b/test/files/neg/t1432.scala index 638f36554f..bdf2331280 100644 --- a/test/files/neg/t1432.scala +++ b/test/files/neg/t1432.scala @@ -4,7 +4,9 @@ object Bug_NoUnique { case class Wrap[E](parent:E) {} - def wrap[E,A,Y](v : (A,E=>Y)) : (A,Wrap[E]=>Y) = + type Alias2[E] = Wrap[E] + + def wrap[E,A,Y](v : (A,E=>Y)) : (A,Alias2[E]=>Y) = throw new Error("Body here") def test(x : TypeCon[Wrap[Unit]]) : TypeCon[Unit] = wrap(x) diff --git a/test/files/neg/t1477.scala b/test/files/neg/t1477.scala index ab13f14b06..a9a6d678ca 100644 --- a/test/files/neg/t1477.scala +++ b/test/files/neg/t1477.scala @@ -8,7 +8,7 @@ object Test extends App { type V <: D val y: V#T = new B { } } - + trait Middle extends C { type V <: (D with U) } diff --git a/test/files/neg/t1523.scala b/test/files/neg/t1523.scala index b8754f4e15..219fb0c060 100644 --- a/test/files/neg/t1523.scala +++ b/test/files/neg/t1523.scala @@ -1,5 +1,5 @@ -object test { +object test { def bug(x: Any) = x - + def go() = bug("a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a") } diff --git a/test/files/neg/t1623.scala b/test/files/neg/t1623.scala index d02fc2ed9e..f5189aa4ca 100644 --- a/test/files/neg/t1623.scala +++ b/test/files/neg/t1623.scala @@ -1,7 +1,7 @@ package test -trait A -trait B +trait A +trait B class BImpl extends B { this: A => diff --git a/test/files/neg/t1705.scala b/test/files/neg/t1705.scala index bf1fcea815..fabdca0ec6 100644 --- a/test/files/neg/t1705.scala +++ b/test/files/neg/t1705.scala @@ -17,7 +17,7 @@ object crashing { } } } -/* +/* Infinite loop in Typer.addLocals. Printing all calls to it: diff --git a/test/files/neg/t1845.scala b/test/files/neg/t1845.scala index dab448b7dd..4d3966484d 100644 --- a/test/files/neg/t1845.scala +++ b/test/files/neg/t1845.scala @@ -1,10 +1,10 @@ -import scala.util.parsing.combinator.syntactical.TokenParsers -import scala.util.parsing.combinator.lexical.StdLexical -import scala.util.parsing.combinator.token._ +class Tokens { abstract class Token } +trait TokenParsers { val lexical: Tokens } + class MyTokenParsers extends TokenParsers { import lexical._ - type Tokens = StdTokens - type Elem = lexical.Token - val lexical = new StdLexical + + + val lexical = new Tokens } diff --git a/test/files/neg/t1878-typer.check b/test/files/neg/t1878-typer.check deleted file mode 100644 index e3a20d0be7..0000000000 --- a/test/files/neg/t1878-typer.check +++ /dev/null @@ -1,4 +0,0 @@ -t1878-typer.scala:4: error: _* may only come last - case <p> { _* } </p> => - ^ -one error found diff --git a/test/files/neg/t1878-typer.scala b/test/files/neg/t1878-typer.scala deleted file mode 100644 index 1eb0cb7dff..0000000000 --- a/test/files/neg/t1878-typer.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends App { - // illegal - bug #1764 - null match { - case <p> { _* } </p> => - } -} diff --git a/test/files/neg/t1878.scala b/test/files/neg/t1878.scala index 99fee48a96..b29186afc0 100644 --- a/test/files/neg/t1878.scala +++ b/test/files/neg/t1878.scala @@ -1,13 +1,13 @@ object Test extends App { - // illegal + // illegal val err1 = "" match { case Seq(f @ _*, ',') => f } - + // no error val List(List(arg1, _*), _) = List(List(1,2,3), List(4,5,6)) - + // illegal val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) - + /* see t1878-typer.scala // illegal - bug #1764 null match { diff --git a/test/files/neg/t1909-object.check b/test/files/neg/t1909-object.check new file mode 100644 index 0000000000..401c1f7ebf --- /dev/null +++ b/test/files/neg/t1909-object.check @@ -0,0 +1,4 @@ +t1909-object.scala:4: error: !!! SI-1909 Unable to STATICally lift object InnerTrouble$1, which is defined in the self- or super-constructor call of class Kaboom. A VerifyError is likely. + object InnerTrouble + ^ +one error found diff --git a/test/files/neg/t1909-object.flags b/test/files/neg/t1909-object.flags new file mode 100644 index 0000000000..eb8b40661b --- /dev/null +++ b/test/files/neg/t1909-object.flags @@ -0,0 +1 @@ +-Xdev -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t1909-object.scala b/test/files/neg/t1909-object.scala new file mode 100644 index 0000000000..d6011ba4a5 --- /dev/null +++ b/test/files/neg/t1909-object.scala @@ -0,0 +1,12 @@ +class Kaboom(a: Any) { + def this() = { + this({ + object InnerTrouble + InnerTrouble + }) + } +} + +object Test extends App { + new Kaboom() +}
\ No newline at end of file diff --git a/test/files/neg/t1980.check b/test/files/neg/t1980.check new file mode 100644 index 0000000000..2fa27fa462 --- /dev/null +++ b/test/files/neg/t1980.check @@ -0,0 +1,12 @@ +t1980.scala:2: warning: by-name parameters will be evaluated eagerly when called as a right-associative infix operator. For more details, see SI-1980. + def op1_:(x: => Any) = () // warn + ^ +t1980.scala:3: warning: by-name parameters will be evaluated eagerly when called as a right-associative infix operator. For more details, see SI-1980. + def op2_:(x: Any, y: => Any) = () // warn + ^ +t1980.scala:4: warning: by-name parameters will be evaluated eagerly when called as a right-associative infix operator. For more details, see SI-1980. + def op3_:(x: Any, y: => Any)(a: Any) = () // warn + ^ +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/t1980.flags b/test/files/neg/t1980.flags new file mode 100644 index 0000000000..7949c2afa2 --- /dev/null +++ b/test/files/neg/t1980.flags @@ -0,0 +1 @@ +-Xlint -Xfatal-warnings diff --git a/test/files/neg/t1980.scala b/test/files/neg/t1980.scala new file mode 100644 index 0000000000..132865e694 --- /dev/null +++ b/test/files/neg/t1980.scala @@ -0,0 +1,9 @@ +object Test { + def op1_:(x: => Any) = () // warn + def op2_:(x: Any, y: => Any) = () // warn + def op3_:(x: Any, y: => Any)(a: Any) = () // warn + + def op4() = () // no warn + def op5(x: => Any) = () // no warn + def op6_:(x: Any)(a: => Any) = () // no warn +} diff --git a/test/files/neg/t2148.check b/test/files/neg/t2148.check index 5113b48e51..27b5dce507 100644 --- a/test/files/neg/t2148.check +++ b/test/files/neg/t2148.check @@ -1,4 +1,4 @@ -t2148.scala:9: error: type A is not a stable prefix +t2148.scala:9: error: A is not a legal prefix for a constructor val b = new A with A#A1 ^ one error found diff --git a/test/files/neg/t2148.scala b/test/files/neg/t2148.scala index c0521d9864..25788be84a 100644 --- a/test/files/neg/t2148.scala +++ b/test/files/neg/t2148.scala @@ -1,6 +1,6 @@ -class A { +class A { var i = 0 - trait A1 extends A { + trait A1 extends A { i += 1 } } diff --git a/test/files/neg/t2421b.scala b/test/files/neg/t2421b.scala index a8d22f285e..d8159a8c37 100644 --- a/test/files/neg/t2421b.scala +++ b/test/files/neg/t2421b.scala @@ -12,6 +12,6 @@ object Test { f } -/* bug: +/* bug: error: type arguments [Test2.A] do not conform to method b's type parameter bounds [X <: Test2.B] */
\ No newline at end of file diff --git a/test/files/neg/t2441.scala b/test/files/neg/t2441.scala index a8c9e728a2..6784ebb333 100644 --- a/test/files/neg/t2441.scala +++ b/test/files/neg/t2441.scala @@ -1,5 +1,5 @@ trait X -trait A { +trait A { def f: Option[X] def g: Option[X] } @@ -8,7 +8,7 @@ object B { } class B extends A { private class Bippy - + override def f = Some(new B.Y) override def g: Option[X] = Some(new B.Y) } diff --git a/test/files/neg/t2442.check b/test/files/neg/t2442.check index 714816fd62..9ff0b44661 100644 --- a/test/files/neg/t2442.check +++ b/test/files/neg/t2442.check @@ -1,9 +1,11 @@ -t2442.scala:4: error: match may not be exhaustive. +t2442.scala:4: warning: match may not be exhaustive. It would fail on the following input: THREE def f(e: MyEnum) = e match { ^ -t2442.scala:11: error: match may not be exhaustive. +t2442.scala:11: warning: match may not be exhaustive. It would fail on the following input: BLUE def g(e: MySecondEnum) = e match { ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t2641.check b/test/files/neg/t2641.check index 909f4f0cf3..a0a960f0ea 100644 --- a/test/files/neg/t2641.check +++ b/test/files/neg/t2641.check @@ -1,15 +1,7 @@ t2641.scala:18: error: wrong number of type arguments for ManagedSeq, should be 2 with TraversableViewLike[A, ManagedSeqStrict[A], ManagedSeq[A]] ^ -t2641.scala:16: error: illegal inheritance; - self-type ManagedSeq does not conform to ManagedSeqStrict[A]'s selftype ManagedSeqStrict[A] - extends ManagedSeqStrict[A] - ^ -t2641.scala:17: error: illegal inheritance; - self-type ManagedSeq does not conform to scala.collection.TraversableView[A,ManagedSeqStrict[A]]'s selftype scala.collection.TraversableView[A,ManagedSeqStrict[A]] - with TraversableView[A, ManagedSeqStrict[A]] - ^ -t2641.scala:27: error: value managedIterator is not a member of ManagedSeq +t2641.scala:27: error: value managedIterator is not a member of ManagedSeq[A,Coll] override def managedIterator = self.managedIterator slice (from, until) ^ -four errors found +two errors found diff --git a/test/files/neg/t2641.scala b/test/files/neg/t2641.scala index 626d5d7852..bc048e039e 100644 --- a/test/files/neg/t2641.scala +++ b/test/files/neg/t2641.scala @@ -8,7 +8,7 @@ abstract class ManagedSeqStrict[+A] with GenericTraversableTemplate[A, ManagedSeqStrict] { override def companion: GenericCompanion[ManagedSeqStrict] = null - + override def foreach[U](f: A => U): Unit = () } @@ -17,9 +17,9 @@ trait ManagedSeq[+A, +Coll] with TraversableView[A, ManagedSeqStrict[A]] with TraversableViewLike[A, ManagedSeqStrict[A], ManagedSeq[A]] { self => - + override def underlying = throw new Exception("no underlying") - + //trait Transformed[+B] extends ManagedSeq[B] with super.Transformed[B] trait Transformed[+B] extends ManagedSeq[B, Coll] with super.Transformed[B] diff --git a/test/files/neg/t2796.check b/test/files/neg/t2796.check index aeb18497ed..22ee35a7e6 100644 --- a/test/files/neg/t2796.check +++ b/test/files/neg/t2796.check @@ -1,4 +1,9 @@ -t2796.scala:7: error: Implementation restriction: early definitions in traits are not initialized before the super class is initialized. +t2796.scala:11: warning: early type members are deprecated. Move them to the regular body: the semantics are the same. + type X = Int // warn + ^ +t2796.scala:7: warning: Implementation restriction: early definitions in traits are not initialized before the super class is initialized. val abstractVal = "T1.abstractVal" // warn ^ +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found one error found diff --git a/test/files/neg/t2796.flags b/test/files/neg/t2796.flags index e8fb65d50c..d1b831ea87 100644 --- a/test/files/neg/t2796.flags +++ b/test/files/neg/t2796.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-deprecation -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t2796.scala b/test/files/neg/t2796.scala index 3bcc9df562..fa2f2358b9 100644 --- a/test/files/neg/t2796.scala +++ b/test/files/neg/t2796.scala @@ -8,10 +8,9 @@ trait T1 extends { } with Base trait T2 extends { - type X = Int // okay + type X = Int // warn } with Base - class C1 extends { val abstractVal = "C1.abstractVal" // okay } with Base diff --git a/test/files/neg/t284.check b/test/files/neg/t284.check index 37801af1b5..7c2e9be03e 100644 --- a/test/files/neg/t284.check +++ b/test/files/neg/t284.check @@ -1,8 +1,6 @@ t284.scala:2: warning: Detected apparent refinement of Unit; are you missing an '=' sign? - def f1(a: T): Unit { } - ^ -t284.scala:5: error: Unmatched closing brace '}' ignored here - } - ^ + def f1(a: T): Unit { } + ^ +error: No warnings can be incurred under -Xfatal-warnings. one warning found one error found diff --git a/test/files/neg/t284.flags b/test/files/neg/t284.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/t284.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t284.scala b/test/files/neg/t284.scala index a210130102..f75bc3d4ba 100644 --- a/test/files/neg/t284.scala +++ b/test/files/neg/t284.scala @@ -1,6 +1,5 @@ trait B[T] { - def f1(a: T): Unit { } - def f2(a: T): Unit - def f3(a: T) { } - } + def f1(a: T): Unit { } + def f2(a: T): Unit + def f3(a: T) { } } diff --git a/test/files/neg/t2870.scala b/test/files/neg/t2870.scala index 59fba3e76d..4de19242e3 100755 --- a/test/files/neg/t2870.scala +++ b/test/files/neg/t2870.scala @@ -1,9 +1,9 @@ class Jars(jar: Jar) -object Jars { +object Jars { import scala.util.Properties.javaClassPath - val scala = fromClasspathString(javaClassPath) - + val scala = fromClasspathString(javaClassPath) + def fromClasspathString(s: String): Jars = null } diff --git a/test/files/neg/t2910.scala b/test/files/neg/t2910.scala index fa51038dcd..d9a781032c 100644 --- a/test/files/neg/t2910.scala +++ b/test/files/neg/t2910.scala @@ -10,7 +10,7 @@ object Junk { val z = 0 lazy val s = "abc" } - + def test4() { lazy val x = { x @@ -35,5 +35,5 @@ object Test { lazy val f: Int = g var x: Int = f lazy val g: Int = x - } + } } diff --git a/test/files/neg/t3015.check b/test/files/neg/t3015.check index 6948392bb0..729db844e7 100644 --- a/test/files/neg/t3015.check +++ b/test/files/neg/t3015.check @@ -1,6 +1,6 @@ t3015.scala:7: error: scrutinee is incompatible with pattern type; found : _$1 required: String - val b(foo) = "foo" + val b(foo) = "foo" ^ one error found diff --git a/test/files/neg/t3015.scala b/test/files/neg/t3015.scala index 9af8f30c65..adfa15b388 100644 --- a/test/files/neg/t3015.scala +++ b/test/files/neg/t3015.scala @@ -4,5 +4,5 @@ class UnApp[P] { object Test extends App { val b: UnApp[_] = new UnApp[String] - val b(foo) = "foo" + val b(foo) = "foo" } diff --git a/test/files/neg/t3098.check b/test/files/neg/t3098.check index 85829747b9..5343b128f0 100644 --- a/test/files/neg/t3098.check +++ b/test/files/neg/t3098.check @@ -1,5 +1,7 @@ -b.scala:3: error: match may not be exhaustive. +b.scala:3: warning: match may not be exhaustive. It would fail on the following input: (_ : C) def f = (null: T) match { ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/t3118.scala b/test/files/neg/t3118.scala index 75f3b8f50c..9be24c1ed4 100644 --- a/test/files/neg/t3118.scala +++ b/test/files/neg/t3118.scala @@ -1,8 +1,8 @@ class O1 { private[this] case class C() - + val x = new O1 - + println(x.C()) // should not be accessible println(new x.C) // is correctly not accessible } diff --git a/test/files/neg/t3160ambiguous.check b/test/files/neg/t3160ambiguous.check new file mode 100644 index 0000000000..73a0c6d5db --- /dev/null +++ b/test/files/neg/t3160ambiguous.check @@ -0,0 +1,7 @@ +t3160ambiguous.scala:8: error: reference to List is ambiguous; +it is imported twice in the same scope by +import scala.collection.immutable._ +and import Bippy._ + def f(x: List[Any]): String = ??? // ambiguous, because Bippy.List is accessible + ^ +one error found diff --git a/test/files/neg/t3160ambiguous.scala b/test/files/neg/t3160ambiguous.scala new file mode 100644 index 0000000000..57745e60d8 --- /dev/null +++ b/test/files/neg/t3160ambiguous.scala @@ -0,0 +1,15 @@ +object Bippy { + private class List[+T] +} +class Bippy { + import Bippy._ + import scala.collection.immutable._ + + def f(x: List[Any]): String = ??? // ambiguous, because Bippy.List is accessible +} +class Other { + import Bippy._ + import scala.collection.immutable._ + + def f(x: List[Any]): String = ??? // unambiguous, because Bippy.List is inaccessible +} diff --git a/test/files/neg/t3224.check b/test/files/neg/t3224.check index 29304c567a..69b02c8862 100644 --- a/test/files/neg/t3224.check +++ b/test/files/neg/t3224.check @@ -1,6 +1,26 @@ -t3224.scala:29: error: polymorphic expression cannot be instantiated to expected type; +t3224.scala:30: error: polymorphic expression cannot be instantiated to expected type; found : [T]Array[T] required: List[?] - println(Texts textL Array()); println(Texts textL Array(1)); println(Texts textL Array(1, 1)) - ^ -one error found + println(Texts textL Array()) + ^ +t3224.scala:34: error: type mismatch; + found : List[Nothing] + required: Array[?] + println(Texts textA List()) + ^ +t3224.scala:35: error: type mismatch; + found : List[Int] + required: Array[?] + println(Texts textA List(1)) + ^ +t3224.scala:36: error: type mismatch; + found : List[Int] + required: Array[?] + println(Texts textA List(1, 1)); + ^ +t3224.scala:48: error: polymorphic expression cannot be instantiated to expected type; + found : [T]Array[T] + required: List[?] + assert(size(Array()) == 0) + ^ +5 errors found diff --git a/test/files/neg/t3224.scala b/test/files/neg/t3224.scala index 774de3335a..b7af8a67b5 100755 --- a/test/files/neg/t3224.scala +++ b/test/files/neg/t3224.scala @@ -1,30 +1,50 @@ object Texts{ - def textL[T](list: List[T]) = { - list match{ - case List() => "Empty" - case List(_) => "One" + def textL[T](list: List[T]) = { + list match{ + case List() => "Empty" + case List(_) => "One" case List(_*) => "Many" } } - def textA[T](array: Array[T]) = { - array match{ - case Array() => "Empty" - case Array(_) => "One" + def textA[T](array: Array[T]) = { + array match{ + case Array() => "Empty" + case Array(_) => "One" case Array(_*) => "Many" } } } object Test extends App { + { + implicit def array2list[T](array: Array[T]) = { + println(array.toList.size) + array.toList + } + + println(Texts textL List()) + println(Texts textL List(1)) + println(Texts textL List(1, 1)); + + println(Texts textL Array()) + println(Texts textL Array(1)) + println(Texts textL Array(1, 1)) - implicit def array2list[T](array: Array[T]) = { - println(array.toList.size) - array.toList + println(Texts textA List()) + println(Texts textA List(1)) + println(Texts textA List(1, 1)); + + println(Texts textA Array()) + println(Texts textA Array(1)) + println(Texts textA Array(1, 1)) } - - println(Texts textL List()); println(Texts textL List(1)); println(Texts textL List(1, 1)); + { + implicit def array2list[T](array: Array[T]) = array.toList + def size[T](list: List[T]) = list.size - println(Texts textL Array()); println(Texts textL Array(1)); println(Texts textL Array(1, 1)) + assert(size(array2list(Array())) == 0) + assert(size(Array()) == 0) + } } diff --git a/test/files/neg/t3234.check b/test/files/neg/t3234.check index 4339950ecb..8f0d624ed9 100644 --- a/test/files/neg/t3234.check +++ b/test/files/neg/t3234.check @@ -1,2 +1,6 @@ -error: there were 1 inliner warning(s); re-run with -Yinline-warnings for details +t3234.scala:17: warning: At the end of the day, could not inline @inline-marked method foo3 + println(foo(42) + foo2(11) + foo3(2)) + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/t3234.flags b/test/files/neg/t3234.flags index c9cefdc4b9..cc3d9fb6f0 100644 --- a/test/files/neg/t3234.flags +++ b/test/files/neg/t3234.flags @@ -1 +1 @@ --Yinline -Xfatal-warnings
\ No newline at end of file +-Yinline -Yinline-warnings -Xfatal-warnings diff --git a/test/files/neg/t3234.scala b/test/files/neg/t3234.scala index 443d0467f0..1553f1fa05 100644 --- a/test/files/neg/t3234.scala +++ b/test/files/neg/t3234.scala @@ -1,6 +1,6 @@ trait Trait1 { // need more work before this one works - // @inline + // @inline def foo2(n: Int) = n*n } diff --git a/test/files/neg/t3399.scala b/test/files/neg/t3399.scala index b1fe4e5ee2..3edaa0724f 100644 --- a/test/files/neg/t3399.scala +++ b/test/files/neg/t3399.scala @@ -10,7 +10,7 @@ object Nats { type FoldR[Init <: Type, Type, F <: Fold[Nat, Type]] = F#Apply[Succ[N], N#FoldR[Init, Type, F]] } - + type Add[A <: Nat, B <: Nat] = A#FoldR[B, Nat, Inc] trait Fold[-Elem, Value] { type Apply[N <: Elem, Acc <: Value] <: Value @@ -18,7 +18,7 @@ object Nats { type Inc = Fold[Any, Nat] { type Apply[N <: Any, Acc <: Nat] = Succ[Acc] } - + type _1 = Succ[_0] implicitly[ Add[_1, _1] =:= _1] }
\ No newline at end of file diff --git a/test/files/neg/t3453.scala b/test/files/neg/t3453.scala index 0f1c6e0282..090b777151 100644 --- a/test/files/neg/t3453.scala +++ b/test/files/neg/t3453.scala @@ -25,7 +25,7 @@ object O { class T2a { import O._ - + def x: B = { val aToB = 3 // ok: doesn't compile, because aToB method requires 'T.this.' prefix @@ -39,7 +39,7 @@ class T2a { class T2b { import O.aToB - + def x: B = { val aToB = 3 // ok: doesn't compile, because aToB method requires 'T.this.' prefix @@ -53,7 +53,7 @@ class T2b { class T3 { implicit def aToB(a: A): B = new B - + def x: B = { val aToB = 3 // ok: doesn't compile, because aToB method requires 'T.this.' prefix diff --git a/test/files/neg/t3507-old.scala b/test/files/neg/t3507-old.scala index 32688d3934..9a8c7c5462 100644 --- a/test/files/neg/t3507-old.scala +++ b/test/files/neg/t3507-old.scala @@ -8,7 +8,7 @@ class A { object Test { var a: A = new A // mutable val c /*: object _1.b.c forSome { val _1: A } */ = a.m // widening using existential - + def mani[T: Manifest](x: T) = () mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier // --> _1 is not in scope here diff --git a/test/files/neg/t3631.check b/test/files/neg/t3631.check deleted file mode 100644 index 6d8feca1ed..0000000000 --- a/test/files/neg/t3631.check +++ /dev/null @@ -1,4 +0,0 @@ -t3631.scala:3: error: Implementation restriction: case classes cannot have more than 22 parameters. -case class X23(x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int, x23: Int) { } - ^ -one error found diff --git a/test/files/neg/t3683a.check b/test/files/neg/t3683a.check index 3de3ad784e..6386265ebc 100644 --- a/test/files/neg/t3683a.check +++ b/test/files/neg/t3683a.check @@ -1,5 +1,7 @@ -t3683a.scala:14: error: match may not be exhaustive. +t3683a.scala:14: warning: match may not be exhaustive. It would fail on the following input: XX() w match { ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/t3683b.scala b/test/files/neg/t3683b.scala index fbf75b6856..646e418121 100644 --- a/test/files/neg/t3683b.scala +++ b/test/files/neg/t3683b.scala @@ -8,7 +8,7 @@ case class Z[T >: Bar <: Foo]( z1: W[T] ) extends W[T] -object Main { +object Main { // should fail for including X() def f1(w: W[Bar]): Int = { w match { diff --git a/test/files/neg/t3692-new.check b/test/files/neg/t3692-new.check index 5aa991c105..9b96449930 100644 --- a/test/files/neg/t3692-new.check +++ b/test/files/neg/t3692-new.check @@ -7,8 +7,13 @@ t3692-new.scala:15: warning: non-variable type argument Int in type pattern Map[ t3692-new.scala:16: warning: non-variable type argument Int in type pattern Map[T,Int] is unchecked since it is eliminated by erasure case m2: Map[T, Int] => new java.util.HashMap[T, Integer] ^ -t3692-new.scala:16: error: unreachable code - case m2: Map[T, Int] => new java.util.HashMap[T, Integer] +t3692-new.scala:15: warning: unreachable code + case m1: Map[Int, V] => new java.util.HashMap[Integer, V] ^ -three warnings found +t3692-new.scala:4: warning: Tester has a main method with parameter type Array[String], but Tester will not be a runnable program. + Reason: main method must have exact signature (Array[String])Unit +object Tester { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +5 warnings found one error found diff --git a/test/files/neg/t3692-new.flags b/test/files/neg/t3692-new.flags index cb8324a345..85d8eb2ba2 100644 --- a/test/files/neg/t3692-new.flags +++ b/test/files/neg/t3692-new.flags @@ -1 +1 @@ --Xoldpatmat
\ No newline at end of file +-Xfatal-warnings diff --git a/test/files/neg/t3692-old.check b/test/files/neg/t3692-old.check deleted file mode 100644 index 9f3ae516aa..0000000000 --- a/test/files/neg/t3692-old.check +++ /dev/null @@ -1,14 +0,0 @@ -t3692-old.scala:13: warning: non-variable type argument Int in type pattern Map[Int,Int] is unchecked since it is eliminated by erasure - case m0: Map[Int, Int] => new java.util.HashMap[Integer, Integer] - ^ -t3692-old.scala:14: warning: non-variable type argument Int in type pattern Map[Int,V] is unchecked since it is eliminated by erasure - case m1: Map[Int, V] => new java.util.HashMap[Integer, V] - ^ -t3692-old.scala:15: warning: non-variable type argument Int in type pattern Map[T,Int] is unchecked since it is eliminated by erasure - case m2: Map[T, Int] => new java.util.HashMap[T, Integer] - ^ -t3692-old.scala:15: error: unreachable code - case m2: Map[T, Int] => new java.util.HashMap[T, Integer] - ^ -three warnings found -one error found diff --git a/test/files/neg/t3692-old.flags b/test/files/neg/t3692-old.flags deleted file mode 100644 index cb8324a345..0000000000 --- a/test/files/neg/t3692-old.flags +++ /dev/null @@ -1 +0,0 @@ --Xoldpatmat
\ No newline at end of file diff --git a/test/files/neg/t3692-old.scala b/test/files/neg/t3692-old.scala deleted file mode 100644 index 151535ae94..0000000000 --- a/test/files/neg/t3692-old.scala +++ /dev/null @@ -1,19 +0,0 @@ -import java.lang.Integer - -object ManifestTester { - def main(args: Array[String]) = { - val map = Map("John" -> 1, "Josh" -> 2) - new ManifestTester().toJavaMap(map) - } -} - -class ManifestTester { - private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: Manifest[T], m2: Manifest[V]): java.util.Map[_, _] = { - map match { - case m0: Map[Int, Int] => new java.util.HashMap[Integer, Integer] - case m1: Map[Int, V] => new java.util.HashMap[Integer, V] - case m2: Map[T, Int] => new java.util.HashMap[T, Integer] - case _ => new java.util.HashMap[T, V] - } - } -}
\ No newline at end of file diff --git a/test/files/neg/t3714-neg.check b/test/files/neg/t3714-neg.check index 2db0655502..4f29716968 100644 --- a/test/files/neg/t3714-neg.check +++ b/test/files/neg/t3714-neg.check @@ -1,12 +1,12 @@ t3714-neg.scala:17: error: value break in class BreakImpl cannot be accessed in BreakImpl Access to protected value break not permitted because - enclosing object Test is not a subclass of + enclosing object Test is not a subclass of class BreakImpl where target is defined case b: BreakImpl => b.break ^ t3714-neg.scala:25: error: value break in class BreakImpl cannot be accessed in BreakImpl Access to protected value break not permitted because - enclosing object Test is not a subclass of + enclosing object Test is not a subclass of class BreakImpl where target is defined case b: BreakImpl => b.break ^ diff --git a/test/files/neg/t3714-neg.scala b/test/files/neg/t3714-neg.scala index 4b56f9348c..753b367ec0 100644 --- a/test/files/neg/t3714-neg.scala +++ b/test/files/neg/t3714-neg.scala @@ -29,7 +29,7 @@ object Test { case BreakImpl(x) => x case _ => -1 } - + def main(args: Array[String]) { val break = BreakImpl(22) assert(f1(break) == 22) diff --git a/test/files/neg/t3736.scala b/test/files/neg/t3736.scala index 1efa397928..cf0920912a 100644 --- a/test/files/neg/t3736.scala +++ b/test/files/neg/t3736.scala @@ -7,14 +7,14 @@ object Test { def f5 = super.!=(new AnyRef) def f6 = super.## } - + // Ill-advised overloads to be sure... class B { def ##(x: String) = true def ==(x1: String, xs: List[_]) = true def !=(x1: String, xs: List[_]) = true } - + class C extends B { override def ##(x: String) = super.##(x) override def ==(x1: String, xs: List[_]) = super.==(x1, xs) diff --git a/test/files/neg/t3757/B.scala b/test/files/neg/t3757/B.scala index 68766a9f6e..7c78fb634e 100644 --- a/test/files/neg/t3757/B.scala +++ b/test/files/neg/t3757/B.scala @@ -1,5 +1,5 @@ package b -class B extends a.A { +class B extends a.A { override def foo = "B" }
\ No newline at end of file diff --git a/test/files/neg/t3776.check b/test/files/neg/t3776.check index 4a5284cf0f..0dfe129596 100644 --- a/test/files/neg/t3776.check +++ b/test/files/neg/t3776.check @@ -1,4 +1,4 @@ t3776.scala:8: error: value someOperation is not a member of _$1 - def parsedAs[T](v: T) = MyParser.parse(pattern, a).get someOperation v + def parsedAs[T](v: T) = MyParser.parse(pattern, a).get someOperation v ^ one error found diff --git a/test/files/neg/t3776.scala b/test/files/neg/t3776.scala index 454f914316..e24b2fea63 100644 --- a/test/files/neg/t3776.scala +++ b/test/files/neg/t3776.scala @@ -1,10 +1,10 @@ -import util.parsing.combinator.{PackratParsers, RegexParsers} - -object MyParser extends RegexParsers with PackratParsers { +object MyParser { + implicit def literal(s: String): Parser[String] = ??? + trait Parser[+T] + def parse[T](p: Parser[T], in: java.lang.CharSequence): Option[T] = ??? } - object Test { class ParsedAs(a: String) (implicit pattern: MyParser.Parser[_]) { - def parsedAs[T](v: T) = MyParser.parse(pattern, a).get someOperation v + def parsedAs[T](v: T) = MyParser.parse(pattern, a).get someOperation v } } diff --git a/test/files/neg/t3816.scala b/test/files/neg/t3816.scala index b7f3fde699..31b0825f1d 100644 --- a/test/files/neg/t3816.scala +++ b/test/files/neg/t3816.scala @@ -1,7 +1,7 @@ class B { def ::(a: List[Int]) { a match { - case x::xs => + case x::xs => case _ => } } @@ -32,11 +32,11 @@ object Test { } } - var foo = 0 + var foo = 0 def testFail2( x: Any ) = { x match { case Some( `foo` ) => case _ => } - } + } } diff --git a/test/files/neg/t3934.check b/test/files/neg/t3934.check index 405ed2e879..8b06799f0d 100644 --- a/test/files/neg/t3934.check +++ b/test/files/neg/t3934.check @@ -1,6 +1,6 @@ t3934.scala:15: error: method f2 in class J cannot be accessed in test.J Access to protected method f2 not permitted because - enclosing class S1 in package nest is not a subclass of + enclosing class S1 in package nest is not a subclass of class J in package test where target is defined def g2(x: J) = x.f2() ^ diff --git a/test/files/neg/t3977.check b/test/files/neg/t3977.check index 9da118ee91..72335a0926 100644 --- a/test/files/neg/t3977.check +++ b/test/files/neg/t3977.check @@ -1,4 +1,4 @@ t3977.scala:12: error: could not find implicit value for parameter w: False#If[E] - new NotNull + new NoNull ^ one error found diff --git a/test/files/neg/t3977.scala b/test/files/neg/t3977.scala index f55a832c52..11a8cdba4b 100644 --- a/test/files/neg/t3977.scala +++ b/test/files/neg/t3977.scala @@ -7,7 +7,7 @@ trait False extends Bool { } class Field[E, N <: Bool](implicit val w: N#If[E]) { - type NotNull = Field[E, False] + type NoNull = Field[E, False] - new NotNull -}
\ No newline at end of file + new NoNull +} diff --git a/test/files/neg/t3987.scala b/test/files/neg/t3987.scala index c97d57b38f..1226d80228 100644 --- a/test/files/neg/t3987.scala +++ b/test/files/neg/t3987.scala @@ -1,7 +1,7 @@ class Gox { object Zed { } class Zed { } -} +} object Test { type GoxZed = t#Zed forSome { type t <: Gox } diff --git a/test/files/neg/t4079/t4079_1.scala b/test/files/neg/t4079/t4079_1.scala index 8dc73556c7..cbae864788 100644 --- a/test/files/neg/t4079/t4079_1.scala +++ b/test/files/neg/t4079/t4079_1.scala @@ -9,7 +9,7 @@ trait ComposeT[F[_],G[_]] { case class Compose[F[_],G[_]]() { def Functor(implicit f: Functor[F], g: Functor[G]): Functor[ComposeT[F,G]#Apply] = new Functor[ComposeT[F,G]#Apply] { - def map[A,B](c: ComposeT[F,G]#Apply[A], h: A => B) = + def map[A,B](c: ComposeT[F,G]#Apply[A], h: A => B) = f.map(c, (x:G[A]) => g.map(x,h)) } } @@ -19,10 +19,10 @@ object Cat { } object Functors { - implicit val List = new Functor[List] { + implicit val List = new Functor[List] { def map[A,B](fa: List[A], f: A => B): List[B] = fa map f } - implicit val Option = new Functor[Option] { + implicit val Option = new Functor[Option] { def map[A,B](fa: Option[A], f: A => B): Option[B] = fa map f } } diff --git a/test/files/neg/t409.check b/test/files/neg/t409.check index 433d64d25d..0edc0d03cd 100644 --- a/test/files/neg/t409.check +++ b/test/files/neg/t409.check @@ -1,4 +1,4 @@ -t409.scala:6: error: traits or objects may not have parameters +t409.scala:6: error: class Case1 needs to be a trait to be mixed in class Toto extends Expr with Case1(12); - ^ + ^ one error found diff --git a/test/files/neg/t4098.check b/test/files/neg/t4098.check index 7d69cf151c..232c082ec9 100644 --- a/test/files/neg/t4098.check +++ b/test/files/neg/t4098.check @@ -1,5 +1,5 @@ t4098.scala:3: error: forward reference not allowed from self constructor invocation - this(b) + this(b) ^ t4098.scala:8: error: forward reference not allowed from self constructor invocation this(b) diff --git a/test/files/neg/t4098.scala b/test/files/neg/t4098.scala index 744d6191b5..2e6d167646 100644 --- a/test/files/neg/t4098.scala +++ b/test/files/neg/t4098.scala @@ -1,6 +1,6 @@ -class A(a: Any) { - def this() = { - this(b) +class A(a: Any) { + def this() = { + this(b) def b = new {} } diff --git a/test/files/neg/t4134.scala b/test/files/neg/t4134.scala index 678e4806ef..18f813dd1d 100644 --- a/test/files/neg/t4134.scala +++ b/test/files/neg/t4134.scala @@ -3,16 +3,16 @@ trait T1 { def f: String -} +} trait T2 extends T1 { abstract override def f: String = "goo" def something = super.f // So the "abstract override" is needed -} +} trait Q1 { def f: String = "bippy" -} +} //trait T3 extends Q1 with T2 { trait T3 extends T2 with Q1 { diff --git a/test/files/neg/t414.scala b/test/files/neg/t414.scala index 2bc83eedcb..1662b9a105 100644 --- a/test/files/neg/t414.scala +++ b/test/files/neg/t414.scala @@ -3,7 +3,7 @@ case class Node[a](left: IntMap[a], keyVal: Pair[Int, a], right: IntMap[a]) exte abstract class IntMap[a] { def lookup(key: Int): a = this match { case Empty => - error("clef inexistante") + sys.error("clef inexistante") case _ => }; diff --git a/test/files/neg/t4158.check b/test/files/neg/t4158.check index 3ee2627c5b..af281c52cd 100644 --- a/test/files/neg/t4158.check +++ b/test/files/neg/t4158.check @@ -1,19 +1,7 @@ -t4158.scala:3: error: type mismatch; - found : Null(null) - required: Int -Note that implicit conversions are not applicable because they are ambiguous: - both method Integer2intNullConflict in class LowPriorityImplicits of type (x: Null)Int - and method Integer2int in object Predef of type (x: Integer)Int - are possible conversion functions from Null(null) to Int +t4158.scala:3: error: an expression of type Null is ineligible for implicit conversion var y = null: Int ^ -t4158.scala:2: error: type mismatch; - found : Null(null) - required: Int -Note that implicit conversions are not applicable because they are ambiguous: - both method Integer2intNullConflict in class LowPriorityImplicits of type (x: Null)Int - and method Integer2int in object Predef of type (x: Integer)Int - are possible conversion functions from Null(null) to Int +t4158.scala:2: error: an expression of type Null is ineligible for implicit conversion var x: Int = null ^ two errors found diff --git a/test/files/neg/t4174.scala b/test/files/neg/t4174.scala index f5242950c2..b4a5ab29da 100644 --- a/test/files/neg/t4174.scala +++ b/test/files/neg/t4174.scala @@ -2,7 +2,7 @@ class C object Test { def foo(c: C) = 0 - + def main(args: Array[String]): Unit = { foo(new C { override def bar = 1 }) } diff --git a/test/files/neg/t4196.scala b/test/files/neg/t4196.scala index ac00b19bee..06e1f28d54 100644 --- a/test/files/neg/t4196.scala +++ b/test/files/neg/t4196.scala @@ -1,6 +1,6 @@ object Weird { - { (s: String) => + { (s: String) => val foo = Some(s); // to illustrate that vals are printed in the error - foo + foo }.apply("first param") ("spurious param") }
\ No newline at end of file diff --git a/test/files/neg/t421.check b/test/files/neg/t421.check index e81df52ab0..dc5fa425ac 100644 --- a/test/files/neg/t421.check +++ b/test/files/neg/t421.check @@ -1,4 +1,4 @@ t421.scala:5: error: star patterns must correspond with varargs parameters - case Bar("foo",_*) => error("huh?"); + case Bar("foo",_*) => sys.error("huh?"); ^ one error found diff --git a/test/files/neg/t421.scala b/test/files/neg/t421.scala index 43f6c9dafd..9a327be896 100644 --- a/test/files/neg/t421.scala +++ b/test/files/neg/t421.scala @@ -2,7 +2,7 @@ object foo { case class Bar(a:String, b:AnyRef, c:String*); Bar("foo","meets","bar") match { - case Bar("foo",_*) => error("huh?"); + case Bar("foo",_*) => sys.error("huh?"); } } diff --git a/test/files/neg/t4217.check b/test/files/neg/t4217.check index e8cd5fd69e..6c49ec3354 100644 --- a/test/files/neg/t4217.check +++ b/test/files/neg/t4217.check @@ -1,4 +1,4 @@ t4217.scala:2: error: 'case' expected but '}' found. - 42 match { } + 42 match { } ^ one error found diff --git a/test/files/neg/t4217.scala b/test/files/neg/t4217.scala index 9343a9be54..0817df2cb7 100644 --- a/test/files/neg/t4217.scala +++ b/test/files/neg/t4217.scala @@ -1,3 +1,3 @@ object A extends App { - 42 match { } + 42 match { } } diff --git a/test/files/neg/t4221.scala b/test/files/neg/t4221.scala index c979f7936e..0a8b8add18 100644 --- a/test/files/neg/t4221.scala +++ b/test/files/neg/t4221.scala @@ -1,5 +1,5 @@ class Cl { - class Sub[TheSub <: Sub[TheSub]] + class Sub[TheSub <: Sub[TheSub]] } case class Wrapper[T](v: T) diff --git a/test/files/neg/t4271.scala b/test/files/neg/t4271.scala index 50526c8958..46ae3ad9ec 100644 --- a/test/files/neg/t4271.scala +++ b/test/files/neg/t4271.scala @@ -1,11 +1,11 @@ object foo { object Donotuseme - implicit def any2Ensuring[A](x: A) = Donotuseme + implicit def Ensuring[A](x: A) = Donotuseme implicit def doubleWrapper(x: Int) = Donotuseme implicit def floatWrapper(x: Int) = Donotuseme implicit def intWrapper(x: Int) = Donotuseme implicit def longWrapper(x: Int) = Donotuseme - implicit def any2ArrowAssoc[A](x: A) = Donotuseme + implicit def ArrowAssoc[A](x: A) = Donotuseme 3 to 5 5 ensuring true 3 -> 5 diff --git a/test/files/neg/t4302.check b/test/files/neg/t4302.check index 450d28bbc5..ea48729276 100644 --- a/test/files/neg/t4302.check +++ b/test/files/neg/t4302.check @@ -1,4 +1,6 @@ -t4302.scala:2: error: abstract type T is unchecked since it is eliminated by erasure +t4302.scala:2: warning: abstract type T is unchecked since it is eliminated by erasure def hasMatch[T](x: AnyRef) = x.isInstanceOf[T] ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/t4417.check b/test/files/neg/t4417.check index 4e3f6c0b10..dbd0f1df46 100644 --- a/test/files/neg/t4417.check +++ b/test/files/neg/t4417.check @@ -1,6 +1,6 @@ t4417.scala:11: error: constructor Pixel$mcD$sp in class Pixel$mcD$sp cannot be accessed in object Pixel Access to protected constructor Pixel$mcD$sp not permitted because - enclosing object Pixel is not a subclass of + enclosing object Pixel is not a subclass of class Pixel$mcD$sp where target is defined def apply(v: Double): Pixel1d = new Pixel1d(v) ^ diff --git a/test/files/neg/t4417.scala b/test/files/neg/t4417.scala index 7f104e58bf..3f6ddc8153 100644 --- a/test/files/neg/t4417.scala +++ b/test/files/neg/t4417.scala @@ -2,12 +2,12 @@ -class Pixel[@specialized T] protected (var v: T) +class Pixel[@specialized T] protected (var v: T) object Pixel { type Pixel1d = Pixel[Double] - + def apply(v: Double): Pixel1d = new Pixel1d(v) } diff --git a/test/files/neg/t4425.check b/test/files/neg/t4425.check index 0f2fe6f2d1..95b88a6b3d 100644 --- a/test/files/neg/t4425.check +++ b/test/files/neg/t4425.check @@ -1,4 +1,13 @@ -t4425.scala:3: error: isInstanceOf cannot test if value types are references. +t4425.scala:3: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method +Note: def unapply(x: Int)(y: Option[Int]): None.type exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list 42 match { case _ X _ => () } ^ -one error found +t4425.scala:8: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method +Note: def unapply(x: Int)(y: Int): Some[(Int, Int)] exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list + 42 match { case _ X _ => () } + ^ +t4425.scala:13: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method +Note: def unapply(x: String)(y: String): Some[(Int, Int)] exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list + "" match { case _ X _ => () } + ^ +three errors found diff --git a/test/files/neg/t4425.scala b/test/files/neg/t4425.scala index d8cc6922f7..1714955c27 100644 --- a/test/files/neg/t4425.scala +++ b/test/files/neg/t4425.scala @@ -2,3 +2,13 @@ object Foo { object X { def unapply(x : Int)(y : Option[Int] = None) = None } 42 match { case _ X _ => () } } + +object Foo2 { + object X { def unapply(x : Int)(y: Int) = Some((2,2)) } + 42 match { case _ X _ => () } +} + +object Foo3 { + object X { def unapply(x : String)(y: String) = Some((2,2)) } + "" match { case _ X _ => () } +}
\ No newline at end of file diff --git a/test/files/neg/t4425b.check b/test/files/neg/t4425b.check new file mode 100644 index 0000000000..1186e8b609 --- /dev/null +++ b/test/files/neg/t4425b.check @@ -0,0 +1,61 @@ +t4425b.scala:5: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method +Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list + println( "" match { case _ X _ => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:6: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method +Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list + println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:7: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method +Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list + println( "" match { case X(_) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:8: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method +Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list + println((X: Any) match { case X(_) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:9: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method +Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:10: error: object X is not a case class constructor, nor does it have an unapply/unapplySeq method +Note: def unapply(x: String)(y: String): Nothing exists in object X, but it cannot be used as an extractor due to its second non-implicit parameter list + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:18: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println( "" match { case _ X _ => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:19: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:22: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:22: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:23: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:23: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:31: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println( "" match { case _ X _ => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:32: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:35: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:35: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:36: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +t4425b.scala:36: error: wrong number of patterns for object X offering Nothing: expected 1, found 2 + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + ^ +18 errors found diff --git a/test/files/neg/t4425b.scala b/test/files/neg/t4425b.scala new file mode 100644 index 0000000000..861e9521f6 --- /dev/null +++ b/test/files/neg/t4425b.scala @@ -0,0 +1,38 @@ +object Test1 { + object X { def unapply(x : String)(y: String) = throw new Exception } + + def f1() { + println( "" match { case _ X _ => "ok" ; case _ => "fail" }) + println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" }) + println( "" match { case X(_) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_) => "ok" ; case _ => "fail" }) + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + } +} + +object Test2 { + object X { def unapply(x : String) = throw new Exception } + + def f1() { + println( "" match { case _ X _ => "ok" ; case _ => "fail" }) + println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" }) + println( "" match { case X(_) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_) => "ok" ; case _ => "fail" }) + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + } +} + +object Test3 { + object X { def unapply(x : String) = None } + + def f1() { + println( "" match { case _ X _ => "ok" ; case _ => "fail" }) + println((X: Any) match { case _ X _ => "ok" ; case _ => "fail" }) + println( "" match { case X(_) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_) => "ok" ; case _ => "fail" }) + println( "" match { case X(_, _) => "ok" ; case _ => "fail" }) + println((X: Any) match { case X(_, _) => "ok" ; case _ => "fail" }) + } +} diff --git a/test/files/neg/t4431.scala b/test/files/neg/t4431.scala index 91e4abfe36..5fbb239e04 100644 --- a/test/files/neg/t4431.scala +++ b/test/files/neg/t4431.scala @@ -7,7 +7,7 @@ object Test { // this earns a VerifyError. trait C { def wait (): Unit } class D { } - + def main(args: Array[String]): Unit = { new B with A { } new BB diff --git a/test/files/neg/t4440.check b/test/files/neg/t4440.check index 2861dc3040..10e7188e32 100644 --- a/test/files/neg/t4440.check +++ b/test/files/neg/t4440.check @@ -1,13 +1,15 @@ -t4440.scala:12: error: The outer reference in this type test cannot be checked at run time. +t4440.scala:12: warning: The outer reference in this type test cannot be checked at run time. case _: b.Inner => println("b") ^ -t4440.scala:13: error: The outer reference in this type test cannot be checked at run time. +t4440.scala:13: warning: The outer reference in this type test cannot be checked at run time. case _: a.Inner => println("a") // this is the case we want ^ -t4440.scala:16: error: The outer reference in this type test cannot be checked at run time. +t4440.scala:16: warning: The outer reference in this type test cannot be checked at run time. case _: a.Inner => println("a") ^ -t4440.scala:17: error: The outer reference in this type test cannot be checked at run time. +t4440.scala:17: warning: The outer reference in this type test cannot be checked at run time. case _: b.Inner => println("b") // this is the case we want ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/t4457_1.scala b/test/files/neg/t4457_1.scala index 91d9bc9f51..11f12379f6 100644 --- a/test/files/neg/t4457_1.scala +++ b/test/files/neg/t4457_1.scala @@ -22,7 +22,7 @@ object ImplicitConvAmbiguity2 { def aFunc[A](a: NQ[A]) = new BB[A] def bFunc[T](e1: N[T]) = {} - + def typeMe1 { val x = aFunc(4F) bFunc(x) diff --git a/test/files/neg/t4457_2.scala b/test/files/neg/t4457_2.scala index b2e7505cf2..f3a170f1f2 100644 --- a/test/files/neg/t4457_2.scala +++ b/test/files/neg/t4457_2.scala @@ -22,7 +22,7 @@ object ImplicitConvAmbiguity2 { def aFunc[A](a: NQ[A]) = new BB[A] def bFunc[T](e1: N[T]) = {} - + def typeMe2 { val x = aFunc(4F) bFunc(x) diff --git a/test/files/neg/t4460a.check b/test/files/neg/t4460a.check new file mode 100644 index 0000000000..b711e7acb1 --- /dev/null +++ b/test/files/neg/t4460a.check @@ -0,0 +1,4 @@ +t4460a.scala:6: error: called constructor's definition must precede calling constructor's definition + def this() = this() // was binding to Predef.<init> !! + ^ +one error found diff --git a/test/files/neg/t4460a.scala b/test/files/neg/t4460a.scala new file mode 100644 index 0000000000..0a7a22178d --- /dev/null +++ b/test/files/neg/t4460a.scala @@ -0,0 +1,7 @@ +trait A + +class B(val x: Int) { + self: A => + + def this() = this() // was binding to Predef.<init> !! +} diff --git a/test/files/neg/t4460b.check b/test/files/neg/t4460b.check new file mode 100644 index 0000000000..f0e703fd10 --- /dev/null +++ b/test/files/neg/t4460b.check @@ -0,0 +1,4 @@ +t4460b.scala:7: error: called constructor's definition must precede calling constructor's definition + def this() = this() // was binding to Predef.<init> !! + ^ +one error found diff --git a/test/files/neg/t4460b.scala b/test/files/neg/t4460b.scala new file mode 100644 index 0000000000..1233017dd4 --- /dev/null +++ b/test/files/neg/t4460b.scala @@ -0,0 +1,9 @@ +trait A + +class Outer() { + class B(val x: Int) { + self: A => + + def this() = this() // was binding to Predef.<init> !! + } +} diff --git a/test/files/neg/t4460c.check b/test/files/neg/t4460c.check new file mode 100644 index 0000000000..4e96711b8b --- /dev/null +++ b/test/files/neg/t4460c.check @@ -0,0 +1,7 @@ +t4460c.scala:4: error: overloaded method constructor B with alternatives: + (a: String)B <and> + (x: Int)B + cannot be applied to () + def this(a: String) = this() + ^ +one error found diff --git a/test/files/neg/t4460c.scala b/test/files/neg/t4460c.scala new file mode 100644 index 0000000000..1ae258508e --- /dev/null +++ b/test/files/neg/t4460c.scala @@ -0,0 +1,7 @@ +class B(val x: Int) { + self: A => + + def this(a: String) = this() +} + +class A() diff --git a/test/files/neg/t4515.check b/test/files/neg/t4515.check index a60d16295f..64e7cc1ca7 100644 --- a/test/files/neg/t4515.check +++ b/test/files/neg/t4515.check @@ -1,6 +1,6 @@ t4515.scala:37: error: type mismatch; - found : _0(in value $anonfun) where type _0(in value $anonfun) - required: (some other)_0(in value $anonfun) + found : _$1 where type _$1 + required: _$2 handler.onEvent(target, ctx.getEvent, node, ctx) ^ one error found diff --git a/test/files/neg/t4515.scala b/test/files/neg/t4515.scala index 63049f201d..4efe45f4fb 100644 --- a/test/files/neg/t4515.scala +++ b/test/files/neg/t4515.scala @@ -16,7 +16,7 @@ object Main { ctx: PushEventContext[EventType]): Unit } val handlers = new HashMap[DerivedPushNode[_], HandlerBase[_]] - + object TimerPushService { private val INSTANCE: TimerPushService = new TimerPushService def get: TimerPushService = INSTANCE diff --git a/test/files/neg/t4537.check b/test/files/neg/t4537.check deleted file mode 100644 index 931bcd0405..0000000000 --- a/test/files/neg/t4537.check +++ /dev/null @@ -1,4 +0,0 @@ -c.scala:7: error: object Settings in package a cannot be accessed in package a - println(Settings.Y) - ^ -one error found diff --git a/test/files/neg/t4537/c.scala b/test/files/neg/t4537/c.scala deleted file mode 100644 index 379599112d..0000000000 --- a/test/files/neg/t4537/c.scala +++ /dev/null @@ -1,8 +0,0 @@ -package b -package c - -import a._ - -object Test { - println(Settings.Y) -}
\ No newline at end of file diff --git a/test/files/neg/t4541b.scala b/test/files/neg/t4541b.scala index 7a21ffc156..ba406cad6d 100644 --- a/test/files/neg/t4541b.scala +++ b/test/files/neg/t4541b.scala @@ -8,7 +8,7 @@ final class SparseArray[@specialized(Int) T](private var data: Array[T]) extends def use(inData: Array[T]) = { data = inData; } - + def set(that: SparseArray[T]) = { use(that.data.clone) } diff --git a/test/files/neg/t4584.check b/test/files/neg/t4584.check index 419f5704b1..97d07afa0e 100644 --- a/test/files/neg/t4584.check +++ b/test/files/neg/t4584.check @@ -1,7 +1,7 @@ t4584.scala:1: error: error in unicode escape -class A { val /u2 +class A { val \u2 ^ -t4584.scala:1: error: illegal character '/uffff' -class A { val /u2 +t4584.scala:1: error: illegal character '\uffff' +class A { val \u2 ^ two errors found diff --git a/test/files/neg/t4691_exhaust_extractor.check b/test/files/neg/t4691_exhaust_extractor.check index cd12e56f86..6396944145 100644 --- a/test/files/neg/t4691_exhaust_extractor.check +++ b/test/files/neg/t4691_exhaust_extractor.check @@ -1,13 +1,15 @@ -t4691_exhaust_extractor.scala:17: error: match may not be exhaustive. +t4691_exhaust_extractor.scala:17: warning: match may not be exhaustive. It would fail on the following input: Bar3() def f1(x: Foo) = x match { ^ -t4691_exhaust_extractor.scala:23: error: match may not be exhaustive. +t4691_exhaust_extractor.scala:23: warning: match may not be exhaustive. It would fail on the following input: Bar3() def f2(x: Foo) = x match { ^ -t4691_exhaust_extractor.scala:29: error: match may not be exhaustive. +t4691_exhaust_extractor.scala:29: warning: match may not be exhaustive. It would fail on the following input: Bar3() def f3(x: Foo) = x match { ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/t4727.check b/test/files/neg/t4727.check index 8a4536fec3..a17cdde044 100644 --- a/test/files/neg/t4727.check +++ b/test/files/neg/t4727.check @@ -1,10 +1,4 @@ -t4727.scala:5: error: type mismatch; - found : Null - required: Int -Note that implicit conversions are not applicable because they are ambiguous: - both method Integer2intNullConflict in class LowPriorityImplicits of type (x: Null)Int - and method Integer2int in object Predef of type (x: Integer)Int - are possible conversion functions from Null to Int +t4727.scala:5: error: an expression of type Null is ineligible for implicit conversion Error occurred in an application involving default arguments. new C[Int] ^ diff --git a/test/files/neg/t4749.check b/test/files/neg/t4749.check index 93ad3935fa..63d5c21532 100644 --- a/test/files/neg/t4749.check +++ b/test/files/neg/t4749.check @@ -1,28 +1,30 @@ -t4749.scala:2: error: Fail1 has a main method with parameter type Array[String], but bippy.Fail1 will not be a runnable program. +t4749.scala:2: warning: Fail1 has a main method with parameter type Array[String], but bippy.Fail1 will not be a runnable program. Reason: main method must have exact signature (Array[String])Unit object Fail1 { ^ -t4749.scala:6: error: Fail2 has a main method with parameter type Array[String], but bippy.Fail2 will not be a runnable program. +t4749.scala:6: warning: Fail2 has a main method with parameter type Array[String], but bippy.Fail2 will not be a runnable program. Reason: main methods cannot be generic. object Fail2 { ^ -t4749.scala:13: error: Fail3 has a main method with parameter type Array[String], but bippy.Fail3 will not be a runnable program. +t4749.scala:13: warning: Fail3 has a main method with parameter type Array[String], but bippy.Fail3 will not be a runnable program. Reason: main methods cannot refer to type parameters or abstract types. object Fail3 extends Bippy[Unit] { } ^ -t4749.scala:16: error: Fail4 has a main method with parameter type Array[String], but bippy.Fail4 will not be a runnable program. +t4749.scala:16: warning: Fail4 has a main method with parameter type Array[String], but bippy.Fail4 will not be a runnable program. Reason: companion is a trait, which means no static forwarder can be generated. object Fail4 { ^ -t4749.scala:21: error: Fail5 has a main method with parameter type Array[String], but bippy.Fail5 will not be a runnable program. +t4749.scala:21: warning: Fail5 has a main method with parameter type Array[String], but bippy.Fail5 will not be a runnable program. Reason: companion contains its own main method, which means no static forwarder can be generated. - object Fail5 extends Fail5 { } + object Fail5 extends Fail5 { } ^ -t4749.scala:26: error: Fail6 has a main method with parameter type Array[String], but bippy.Fail6 will not be a runnable program. +t4749.scala:26: warning: Fail6 has a main method with parameter type Array[String], but bippy.Fail6 will not be a runnable program. Reason: companion contains its own main method (implementation restriction: no main is allowed, regardless of signature), which means no static forwarder can be generated. object Fail6 { ^ -6 errors found +error: No warnings can be incurred under -Xfatal-warnings. +6 warnings found +one error found diff --git a/test/files/neg/t4749.scala b/test/files/neg/t4749.scala index 0973c36097..2c67e2ea96 100644 --- a/test/files/neg/t4749.scala +++ b/test/files/neg/t4749.scala @@ -18,7 +18,7 @@ package bippy { } trait Fail4 { } - object Fail5 extends Fail5 { } + object Fail5 extends Fail5 { } class Fail5 { def main(args: Array[String]): Unit = () } diff --git a/test/files/neg/t4762.check b/test/files/neg/t4762.check index 5e67f2022a..a0525f6226 100644 --- a/test/files/neg/t4762.check +++ b/test/files/neg/t4762.check @@ -1,7 +1,9 @@ -t4762.scala:15: error: private[this] value x in class B shadows mutable x inherited from class A. Changes to x will not be visible within class B - you may want to give them distinct names. +t4762.scala:15: warning: private[this] value x in class B shadows mutable x inherited from class A. Changes to x will not be visible within class B - you may want to give them distinct names. /* (99,99) */ (this.x, this.y), ^ -t4762.scala:48: error: private[this] value x in class Derived shadows mutable x inherited from class Base. Changes to x will not be visible within class Derived - you may want to give them distinct names. +t4762.scala:48: warning: private[this] value x in class Derived shadows mutable x inherited from class Base. Changes to x will not be visible within class Derived - you may want to give them distinct names. class Derived( x : Int ) extends Base( x ) { override def toString = x.toString } ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t4851.check b/test/files/neg/t4851.check index 9633fdffed..4f2919807e 100644 --- a/test/files/neg/t4851.check +++ b/test/files/neg/t4851.check @@ -1,49 +1,51 @@ -S.scala:2: error: Adapting argument list by inserting (): leaky (Object-receiving) target makes this especially dangerous. +S.scala:2: warning: Adapting argument list by inserting (): leaky (Object-receiving) target makes this especially dangerous. signature: J(x: Any): J given arguments: <none> after adaptation: new J((): Unit) val x1 = new J ^ -S.scala:3: error: Adapting argument list by inserting (): leaky (Object-receiving) target makes this especially dangerous. +S.scala:3: warning: Adapting argument list by inserting (): leaky (Object-receiving) target makes this especially dangerous. signature: J(x: Any): J given arguments: <none> after adaptation: new J((): Unit) val x2 = new J() ^ -S.scala:4: error: Adapting argument list by creating a 5-tuple: this may not be what you want. +S.scala:4: warning: Adapting argument list by creating a 5-tuple: this may not be what you want. signature: J(x: Any): J given arguments: 1, 2, 3, 4, 5 after adaptation: new J((1, 2, 3, 4, 5): (Int, Int, Int, Int, Int)) val x3 = new J(1, 2, 3, 4, 5) ^ -S.scala:6: error: Adapting argument list by creating a 3-tuple: this may not be what you want. +S.scala:6: warning: Adapting argument list by creating a 3-tuple: this may not be what you want. signature: Some.apply[A](x: A): Some[A] given arguments: 1, 2, 3 after adaptation: Some((1, 2, 3): (Int, Int, Int)) val y1 = Some(1, 2, 3) ^ -S.scala:7: error: Adapting argument list by creating a 3-tuple: this may not be what you want. +S.scala:7: warning: Adapting argument list by creating a 3-tuple: this may not be what you want. signature: Some(x: A): Some[A] given arguments: 1, 2, 3 after adaptation: new Some((1, 2, 3): (Int, Int, Int)) val y2 = new Some(1, 2, 3) ^ -S.scala:9: error: Adapting argument list by inserting (): this is unlikely to be what you want. +S.scala:9: warning: Adapting argument list by inserting (): this is unlikely to be what you want. signature: J2[T](x: T): J2[T] given arguments: <none> after adaptation: new J2((): Unit) val z1 = new J2 ^ -S.scala:10: error: Adapting argument list by inserting (): this is unlikely to be what you want. +S.scala:10: warning: Adapting argument list by inserting (): this is unlikely to be what you want. signature: J2[T](x: T): J2[T] given arguments: <none> after adaptation: new J2((): Unit) val z2 = new J2() ^ -S.scala:14: error: Adapting argument list by creating a 3-tuple: this may not be what you want. +S.scala:14: warning: Adapting argument list by creating a 3-tuple: this may not be what you want. signature: Test.anyId(a: Any): Any given arguments: 1, 2, 3 after adaptation: Test.anyId((1, 2, 3): (Int, Int, Int)) val w1 = anyId(1, 2 ,3) ^ -8 errors found +error: No warnings can be incurred under -Xfatal-warnings. +8 warnings found +one error found diff --git a/test/files/neg/t4851/J.java b/test/files/neg/t4851/J.java index dbf8b8288e..9c35b8a16e 100644 --- a/test/files/neg/t4851/J.java +++ b/test/files/neg/t4851/J.java @@ -1,14 +1,14 @@ public class J { Object x; - + public J(Object x) { this.x = x; } - + public J(int x1, int x2, int x3, int x4, int x5, int x6) { this.x = null; } - + public String toString() { return "J:" + x.getClass(); } diff --git a/test/files/neg/t4851/J2.java b/test/files/neg/t4851/J2.java index c3a7231315..82954d9489 100644 --- a/test/files/neg/t4851/J2.java +++ b/test/files/neg/t4851/J2.java @@ -1,10 +1,10 @@ public class J2<T> { T x; - + public <T> J(T x) { this.x = x; } - + public String toString() { return "J2:" + x.getClass(); } diff --git a/test/files/neg/t4851/S.scala b/test/files/neg/t4851/S.scala index 0a442ac7a9..779ba376b0 100644 --- a/test/files/neg/t4851/S.scala +++ b/test/files/neg/t4851/S.scala @@ -5,7 +5,7 @@ object Test { val y1 = Some(1, 2, 3) val y2 = new Some(1, 2, 3) - + val z1 = new J2 val z2 = new J2() val z3 = new J2(()) @@ -18,7 +18,7 @@ object Test { println(x2) println(x3) println(y1) - + println(z1) println(z2) println(z3) diff --git a/test/files/neg/t4877.scala b/test/files/neg/t4877.scala index 9cad156f84..5d97877518 100644 --- a/test/files/neg/t4877.scala +++ b/test/files/neg/t4877.scala @@ -13,7 +13,7 @@ class B { def bar(x: Int): Mom def bippy(): List[Mom] } - + val x: Bippy = new AnyRef { type Mom = String def bar(x: Int) = 55 diff --git a/test/files/neg/t5120.scala b/test/files/neg/t5120.scala index c7063b7d15..f28b2cfb4f 100644 --- a/test/files/neg/t5120.scala +++ b/test/files/neg/t5120.scala @@ -6,7 +6,7 @@ class Cell[T](x0: T) { object Test { val str: Cell[String] = new Cell("a") val other: Cell[Int] = new Cell(0) - + def main(args: Array[String]): Unit = { List(str, other) foreach (_.x1 = new AnyRef) str.x1.length diff --git a/test/files/neg/t5152.scala b/test/files/neg/t5152.scala index 5efc76af24..56df31ed41 100644 --- a/test/files/neg/t5152.scala +++ b/test/files/neg/t5152.scala @@ -2,16 +2,16 @@ object Test { new C new C1 new C2 - + class A[E[_]] { } class B[E[_]] extends A[B] { } // B is depth 2 but A requires 1 - class C extends B { } - + class C extends B { } + class A1[E[F[G[_]]]] { } class B1[E[_]] extends A1[B1] // B1 is depth 2 but A1 requires 3 class C1 extends B1 { } - + class A2[E[_]] { } class B2[E] extends A2[B2] { } // this one is correct - class C2 extends B2 { } + class C2 extends B2 { } } diff --git a/test/files/neg/t5182.check b/test/files/neg/t5182.check new file mode 100644 index 0000000000..3161f92680 --- /dev/null +++ b/test/files/neg/t5182.check @@ -0,0 +1,7 @@ +t5182.scala:2: error: unknown annotation argument name: qwe + @java.lang.Deprecated(qwe = "wer") def ok(q:Int) = 1 + ^ +t5182.scala:3: error: classfile annotation arguments have to be supplied as named arguments + @java.lang.Deprecated("wer") def whereAmI(q:Int) = 1 + ^ +two errors found diff --git a/test/files/neg/t5182.flags b/test/files/neg/t5182.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t5182.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t5182.scala b/test/files/neg/t5182.scala new file mode 100644 index 0000000000..0687e99efb --- /dev/null +++ b/test/files/neg/t5182.scala @@ -0,0 +1,5 @@ +class test { + @java.lang.Deprecated(qwe = "wer") def ok(q:Int) = 1 + @java.lang.Deprecated("wer") def whereAmI(q:Int) = 1 + @java.lang.Deprecated() def bippy(q:Int) = 1 +} diff --git a/test/files/neg/t520.scala b/test/files/neg/t520.scala index 949a509518..076aca3122 100644 --- a/test/files/neg/t520.scala +++ b/test/files/neg/t520.scala @@ -4,6 +4,6 @@ object test { assert(keyword != null); } - def verifyKeyword(source : java.io.File, pos : Int) = + def verifyKeyword(source : java.io.File, pos : Int) = verifyKeyword("", source, pos); } diff --git a/test/files/neg/t5352.check b/test/files/neg/t5352.check index d24b0e8ee1..1675da9e9a 100644 --- a/test/files/neg/t5352.check +++ b/test/files/neg/t5352.check @@ -6,7 +6,7 @@ t5352.scala:11: error: type mismatch; ^ t5352.scala:14: error: method f in class Bar1 cannot be accessed in boop.Bar1 Access to protected method f not permitted because - enclosing object boop is not a subclass of + enclosing object boop is not a subclass of class Bar1 in object boop where target is defined (new Bar1).f ^ diff --git a/test/files/neg/t5352.scala b/test/files/neg/t5352.scala index 6ee41f5680..ed74a840f0 100644 --- a/test/files/neg/t5352.scala +++ b/test/files/neg/t5352.scala @@ -2,7 +2,7 @@ object boop { abstract class Bar { protected def f(): Any } class Bar1 extends Bar { protected def f(): Int = 5 } class Bar2 extends Bar { protected def f(): Int = 5 } - + val xs = List(new Bar1, new Bar2) type BarF = { def f(): Int } diff --git a/test/files/neg/t5357.scala b/test/files/neg/t5357.scala index 369a5568a4..6a52283dd6 100644 --- a/test/files/neg/t5357.scala +++ b/test/files/neg/t5357.scala @@ -1,7 +1,7 @@ trait M case class N() extends M { - def mytest(x: M) = x match { + def mytest(x: M) = x match { case A: N => 1 case _ => 0 } diff --git a/test/files/neg/t5426.check b/test/files/neg/t5426.check index d9e192d3f0..98f3ddaaae 100644 --- a/test/files/neg/t5426.check +++ b/test/files/neg/t5426.check @@ -1,13 +1,15 @@ -t5426.scala:2: error: comparing values of types Some[Int] and Int using `==' will always yield false +t5426.scala:2: warning: comparing values of types Some[Int] and Int using `==' will always yield false def f1 = Some(5) == 5 ^ -t5426.scala:3: error: comparing values of types Int and Some[Int] using `==' will always yield false +t5426.scala:3: warning: comparing values of types Int and Some[Int] using `==' will always yield false def f2 = 5 == Some(5) ^ -t5426.scala:8: error: comparing values of types Int and Some[Int] using `==' will always yield false +t5426.scala:8: warning: comparing values of types Int and Some[Int] using `==' will always yield false (x1 == x2) ^ -t5426.scala:9: error: comparing values of types Some[Int] and Int using `==' will always yield false +t5426.scala:9: warning: comparing values of types Some[Int] and Int using `==' will always yield false (x2 == x1) ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/t5426.scala b/test/files/neg/t5426.scala index f2fb5cc12c..af0f981969 100644 --- a/test/files/neg/t5426.scala +++ b/test/files/neg/t5426.scala @@ -1,10 +1,10 @@ class A { def f1 = Some(5) == 5 def f2 = 5 == Some(5) - + val x1 = 5 val x2 = Some(5) - + (x1 == x2) (x2 == x1) } diff --git a/test/files/neg/t5440.check b/test/files/neg/t5440.check index a862350a05..1c4592ccec 100644 --- a/test/files/neg/t5440.check +++ b/test/files/neg/t5440.check @@ -1,5 +1,7 @@ -t5440.scala:3: error: match may not be exhaustive. +t5440.scala:3: warning: match may not be exhaustive. It would fail on the following inputs: (List(_), Nil), (Nil, List(_)) (list1, list2) match { ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/t5455.scala b/test/files/neg/t5455.scala index 22d6c442c9..6e54335787 100644 --- a/test/files/neg/t5455.scala +++ b/test/files/neg/t5455.scala @@ -1,13 +1,13 @@ trait Test { def root: Test - + @annotation.tailrec final lazy val bar: Thing[Int] = { if (this eq root) Thing(() => System.identityHashCode(bar)) else root.bar } - + def f = bar.f() } diff --git a/test/files/neg/t5497.check b/test/files/neg/t5497.check index fef6d38da0..4d6d52b519 100644 --- a/test/files/neg/t5497.check +++ b/test/files/neg/t5497.check @@ -1,4 +1,4 @@ t5497.scala:3: error: not found: value sq - case other => println(null.asInstanceOf[sq.Filter].tableName) + case other => println(null.asInstanceOf[sq.Filter].tableName) ^ one error found diff --git a/test/files/neg/t5497.scala b/test/files/neg/t5497.scala index 40d47de12d..c846b1ba57 100644 --- a/test/files/neg/t5497.scala +++ b/test/files/neg/t5497.scala @@ -1,5 +1,5 @@ object TestQueryable extends App{ ({ - case other => println(null.asInstanceOf[sq.Filter].tableName) + case other => println(null.asInstanceOf[sq.Filter].tableName) } : Any => Unit)(null) } diff --git a/test/files/neg/t5529.check b/test/files/neg/t5529.check index 5d2175fa79..da3f84e1ec 100644 --- a/test/files/neg/t5529.check +++ b/test/files/neg/t5529.check @@ -4,7 +4,4 @@ t5529.scala:12: error: File is already defined as class File t5529.scala:10: error: class type required but test.Test.File found sealed class Dir extends File { } ^ -t5529.scala:10: error: test.Test.File does not have a constructor - sealed class Dir extends File { } - ^ -three errors found +two errors found diff --git a/test/files/neg/t556.check b/test/files/neg/t556.check index c278e13991..5135dc92ef 100644 --- a/test/files/neg/t556.check +++ b/test/files/neg/t556.check @@ -1,4 +1,4 @@ -t556.scala:3: error: wrong number of parameters; expected = 1 +t556.scala:3: error: missing parameter type def g:Int = f((x,y)=>x) - ^ + ^ one error found diff --git a/test/files/neg/t5572.scala b/test/files/neg/t5572.scala index 2da1209c61..4169df4216 100644 --- a/test/files/neg/t5572.scala +++ b/test/files/neg/t5572.scala @@ -16,7 +16,7 @@ class Test { Z.transf(a, b) match { case sth => run(sth, b) - } + } } def run(x: X, z: B): Unit = () diff --git a/test/files/neg/t558.scala b/test/files/neg/t558.scala index 4941a06c3b..58b030347c 100644 --- a/test/files/neg/t558.scala +++ b/test/files/neg/t558.scala @@ -11,7 +11,7 @@ abstract class NewModel { val parent : SymbolURL; final val top = parent.top; final val source = top.file; - + } abstract class RootURL extends SymbolURL { final val top : RootURL = this; diff --git a/test/files/neg/t5580b.check b/test/files/neg/t5580b.check new file mode 100644 index 0000000000..45fde46ff9 --- /dev/null +++ b/test/files/neg/t5580b.check @@ -0,0 +1,6 @@ +t5580b.scala:11: error: polymorphic expression cannot be instantiated to expected type; + found : [A]scala.collection.mutable.Set[A] + required: scala.collection.mutable.Map[bar,scala.collection.mutable.Set[bar]] + if (map.get(tmp).isEmpty) map.put(tmp,collection.mutable.Set()) + ^ +one error found diff --git a/test/files/pos/t5580b.scala b/test/files/neg/t5580b.scala index d5a4a0a2b2..2161da4584 100644 --- a/test/files/pos/t5580b.scala +++ b/test/files/neg/t5580b.scala @@ -1,9 +1,3 @@ -/** It's a pos test because it does indeed compile, - * not so much because I'm glad it does. Testing - * that error messages created and discarded during - * implicit search don't blow it up. - */ - import scala.collection.mutable.WeakHashMap import scala.collection.JavaConversions._ diff --git a/test/files/neg/t563.scala b/test/files/neg/t563.scala index d367e2a73c..204ad3cbdd 100644 --- a/test/files/neg/t563.scala +++ b/test/files/neg/t563.scala @@ -1,6 +1,6 @@ object Test { def map[A,R](a : List[A], f : A => R) : List[R] = a.map(f); - + def split(sn : Iterable[List[Option[Int]]]) : Unit = for (n <- sn) map(n,ptr => Option(ptr.get)); diff --git a/test/files/neg/t5663-badwarneq.check b/test/files/neg/t5663-badwarneq.check index 242be8de68..732e4f44d0 100644 --- a/test/files/neg/t5663-badwarneq.check +++ b/test/files/neg/t5663-badwarneq.check @@ -1,40 +1,42 @@ -t5663-badwarneq.scala:47: error: comparing case class values of types Some[Int] and None.type using `==' will always yield false +t5663-badwarneq.scala:47: warning: comparing case class values of types Some[Int] and None.type using `==' will always yield false println(new Some(1) == None) // Should complain on type, was: spuriously complains on fresh object ^ -t5663-badwarneq.scala:48: error: comparing case class values of types Some[Int] and Thing using `==' will always yield false +t5663-badwarneq.scala:48: warning: comparing case class values of types Some[Int] and Thing using `==' will always yield false println(Some(1) == new Thing(1)) // Should complain on type, was: spuriously complains on fresh object ^ -t5663-badwarneq.scala:56: error: ThingOne and Thingy are unrelated: they will most likely never compare equal +t5663-badwarneq.scala:56: warning: ThingOne and Thingy are unrelated: they will most likely never compare equal println(t1 == t2) // true, but apparently unrelated, a compromise warning ^ -t5663-badwarneq.scala:57: error: ThingThree and Thingy are unrelated: they will most likely never compare equal +t5663-badwarneq.scala:57: warning: ThingThree and Thingy are unrelated: they will most likely never compare equal println(t4 == t2) // true, complains because ThingThree is final and Thingy not a subclass, stronger claim than unrelated ^ -t5663-badwarneq.scala:60: error: comparing case class values of types ThingTwo and Some[Int] using `==' will always yield false +t5663-badwarneq.scala:60: warning: comparing case class values of types ThingTwo and Some[Int] using `==' will always yield false println(t3 == Some(1)) // false, warn on different cases ^ -t5663-badwarneq.scala:61: error: comparing values of types ThingOne and Cousin using `==' will always yield false +t5663-badwarneq.scala:61: warning: comparing values of types ThingOne and Cousin using `==' will always yield false println(t1 == c) // should warn ^ -t5663-badwarneq.scala:69: error: comparing case class values of types Simple and SimpleSibling.type using `==' will always yield false +t5663-badwarneq.scala:69: warning: comparing case class values of types Simple and SimpleSibling.type using `==' will always yield false println(new Simple() == SimpleSibling) // like Some(1) == None, but needn't be final case ^ -t5663-badwarneq.scala:72: error: ValueClass1 and Int are unrelated: they will never compare equal +t5663-badwarneq.scala:72: warning: ValueClass1 and Int are unrelated: they will never compare equal println(new ValueClass1(5) == 5) // bad ^ -t5663-badwarneq.scala:74: error: comparing values of types Int and ValueClass1 using `==' will always yield false +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:78: error: ValueClass2[String] and String are unrelated: they will never compare equal +t5663-badwarneq.scala:78: warning: ValueClass2[String] and String are unrelated: they will never compare equal println(new ValueClass2("abc") == "abc") // bad ^ -t5663-badwarneq.scala:79: error: ValueClass2[Int] and ValueClass1 are unrelated: they will never compare equal +t5663-badwarneq.scala:79: warning: ValueClass2[Int] and ValueClass1 are unrelated: they will never compare equal println(new ValueClass2(5) == new ValueClass1(5)) // bad - different value classes ^ -t5663-badwarneq.scala:81: error: comparing values of types ValueClass3 and ValueClass2[Int] using `==' will always yield false +t5663-badwarneq.scala:81: warning: comparing values of types ValueClass3 and ValueClass2[Int] using `==' will always yield false println(ValueClass3(5) == new ValueClass2(5)) // bad ^ -t5663-badwarneq.scala:82: error: comparing values of types ValueClass3 and Int using `==' will always yield false +t5663-badwarneq.scala:82: warning: comparing values of types ValueClass3 and Int using `==' will always yield false println(ValueClass3(5) == 5) // bad ^ -13 errors found +error: No warnings can be incurred under -Xfatal-warnings. +13 warnings found +one error found diff --git a/test/files/neg/t5689.check b/test/files/neg/t5689.check index 50aaa7dbfe..ad9b79cdcb 100644 --- a/test/files/neg/t5689.check +++ b/test/files/neg/t5689.check @@ -3,5 +3,5 @@ t5689.scala:4: error: macro implementation has wrong shape: found : (c: scala.reflect.macros.Context)(i: c.Expr[Double]): c.Expr[Int] type mismatch for return type: c.Expr[Int] does not conform to c.Expr[String] def returnsString(i: Double): String = macro returnsIntImpl - ^ + ^ one error found diff --git a/test/files/neg/t5696.check b/test/files/neg/t5696.check index 72b7781fc4..e0fb61b839 100644 --- a/test/files/neg/t5696.check +++ b/test/files/neg/t5696.check @@ -15,5 +15,5 @@ t5696.scala:38: error: too many argument lists for constructor invocation ^ t5696.scala:46: error: too many argument lists for constructor invocation object x extends G(1)(2) {} - ^ + ^ 6 errors found diff --git a/test/files/neg/t5753.check b/test/files/neg/t5753.check index 76602de17d..379416c179 100644 --- a/test/files/neg/t5753.check +++ b/test/files/neg/t5753.check @@ -1,4 +1,5 @@ -Test_2.scala:9: error: macro implementation not found: foo (the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them) +Test_2.scala:9: error: macro implementation not found: foo +(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them) println(foo(42)) ^ one error found diff --git a/test/files/neg/t576.scala b/test/files/neg/t576.scala index fa7ee6019f..fd83217a45 100644 --- a/test/files/neg/t576.scala +++ b/test/files/neg/t576.scala @@ -4,16 +4,16 @@ abstract class BaseListXXX { type Node <: BaseNode; abstract class BaseNode { } -} +} trait PriorityTreeXXX extends BaseListXXX { type Node <: BasicTreeNode; - + trait BasicTreeNode extends BaseNode { - def sibling: Node; + def sibling: Node; def insert(dir : Int, node : Node) = { if (true) sibling.insert(node); //else insert(node); - + } def insert(node : Node) : Unit = {} } diff --git a/test/files/neg/t5762.check b/test/files/neg/t5762.check index 10064032aa..2a2f12144a 100644 --- a/test/files/neg/t5762.check +++ b/test/files/neg/t5762.check @@ -1,13 +1,15 @@ -t5762.scala:6: error: non-variable type argument Int in type pattern D[Int] is unchecked since it is eliminated by erasure +t5762.scala:6: warning: non-variable type argument Int in type pattern D[Int] is unchecked since it is eliminated by erasure case _: D[Int] if bippy => 1 ^ -t5762.scala:7: error: non-variable type argument String in type pattern D[String] is unchecked since it is eliminated by erasure +t5762.scala:7: warning: non-variable type argument String in type pattern D[String] is unchecked since it is eliminated by erasure case _: D[String] => 2 ^ -t5762.scala:20: error: non-variable type argument D[Int] in type pattern D[D[Int]] is unchecked since it is eliminated by erasure +t5762.scala:20: warning: non-variable type argument D[Int] in type pattern D[D[Int]] is unchecked since it is eliminated by erasure case _: D[D[Int]] if bippy => 1 ^ -t5762.scala:21: error: non-variable type argument D[String] in type pattern D[D[String]] is unchecked since it is eliminated by erasure +t5762.scala:21: warning: non-variable type argument D[String] in type pattern D[D[String]] is unchecked since it is eliminated by erasure case _: D[D[String]] => 2 ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/t5830.check b/test/files/neg/t5830.check index 726fac2a1e..58c3a1be38 100644 --- a/test/files/neg/t5830.check +++ b/test/files/neg/t5830.check @@ -1,7 +1,9 @@ -t5830.scala:6: error: unreachable code +t5830.scala:6: warning: unreachable code case 'a' => println("b") // unreachable ^ -t5830.scala:4: error: could not emit switch for @switch annotated match +t5830.scala:4: warning: could not emit switch for @switch annotated match def unreachable(ch: Char) = (ch: @switch) match { ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t588.scala b/test/files/neg/t588.scala index 1bc6d2680f..f30937377e 100644 --- a/test/files/neg/t588.scala +++ b/test/files/neg/t588.scala @@ -1,15 +1,15 @@ abstract class Test0 { - def visit(f: Int => Unit): Boolean + def visit(f: Int => Unit): Boolean def visit(f: Int => String): Boolean } trait Test { type TypeA <: TraitA; type TypeB <: TypeA with TraitB; - + def f(node : TypeA) : Unit; def f(brac : TypeB) : Unit; - + trait TraitA; trait TraitB; - + } diff --git a/test/files/neg/t5903a.check b/test/files/neg/t5903a.check new file mode 100644 index 0000000000..cbdcfd1bdd --- /dev/null +++ b/test/files/neg/t5903a.check @@ -0,0 +1,7 @@ +Test_2.scala:4: error: wrong number of patterns for <$anon: AnyRef> offering (SomeTree.type, SomeTree.type): expected 2, found 3 + case nq"$x + $y + $z" => println((x, y)) + ^ +Test_2.scala:4: error: not found: value x + case nq"$x + $y + $z" => println((x, y)) + ^ +two errors found diff --git a/test/files/neg/t5903a/Macros_1.scala b/test/files/neg/t5903a/Macros_1.scala new file mode 100644 index 0000000000..e82be0fc68 --- /dev/null +++ b/test/files/neg/t5903a/Macros_1.scala @@ -0,0 +1,28 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Tree +case object SomeTree extends Tree + +object NewQuasiquotes { + implicit class QuasiquoteInterpolation(c: StringContext) { + object nq { + def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl + } + } +} + +object QuasiquoteMacros { + def unapplyImpl(c: Context)(t: c.Tree) = { + import c.universe._ + q""" + new { + def isEmpty = false + def get = this + def _1 = SomeTree + def _2 = SomeTree + def unapply(t: Tree) = this + }.unapply($t) + """ + } +} diff --git a/test/files/neg/t5903a/Test_2.scala b/test/files/neg/t5903a/Test_2.scala new file mode 100644 index 0000000000..4d78dfb5e5 --- /dev/null +++ b/test/files/neg/t5903a/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import NewQuasiquotes._ + SomeTree match { + case nq"$x + $y + $z" => println((x, y)) + } +} diff --git a/test/files/neg/t5903b.check b/test/files/neg/t5903b.check new file mode 100644 index 0000000000..faeb73ad03 --- /dev/null +++ b/test/files/neg/t5903b.check @@ -0,0 +1,9 @@ +Test_2.scala:4: error: type mismatch; + found : Int + required: String + case t"$x" => println(x) + ^ +Test_2.scala:4: error: not found: value x + case t"$x" => println(x) + ^ +two errors found diff --git a/test/files/neg/t5903b/Macros_1.scala b/test/files/neg/t5903b/Macros_1.scala new file mode 100644 index 0000000000..b1b875969d --- /dev/null +++ b/test/files/neg/t5903b/Macros_1.scala @@ -0,0 +1,23 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Interpolation { + implicit class TestInterpolation(c: StringContext) { + object t { + def unapply[T](x: T) = macro Macros.unapplyImpl[T] + } + } +} + +object Macros { + def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { + import c.universe._ + q""" + new { + def isEmpty = false + def get = "2" + def unapply(x: String) = this + }.unapply($x) + """ + } +} diff --git a/test/files/neg/t5903b/Test_2.scala b/test/files/neg/t5903b/Test_2.scala new file mode 100644 index 0000000000..0f6f80d327 --- /dev/null +++ b/test/files/neg/t5903b/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import Interpolation._ + 2 match { + case t"$x" => println(x) + } +} diff --git a/test/files/neg/t5903c.check b/test/files/neg/t5903c.check new file mode 100644 index 0000000000..c9476edd11 --- /dev/null +++ b/test/files/neg/t5903c.check @@ -0,0 +1,7 @@ +Test_2.scala:4: error: String is not supported + case t"$x" => println(x) + ^ +Test_2.scala:4: error: not found: value x + case t"$x" => println(x) + ^ +two errors found diff --git a/test/files/neg/t5903c/Macros_1.scala b/test/files/neg/t5903c/Macros_1.scala new file mode 100644 index 0000000000..70efab3101 --- /dev/null +++ b/test/files/neg/t5903c/Macros_1.scala @@ -0,0 +1,26 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Interpolation { + implicit class TestInterpolation(c: StringContext) { + object t { + def unapply[T](x: T) = macro Macros.unapplyImpl[T] + } + } +} + +object Macros { + def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { + import c.universe._ + if (!(c.weakTypeOf[Int] =:= c.weakTypeOf[T])) c.abort(c.enclosingPosition, s"${c.weakTypeOf[T]} is not supported") + else { + q""" + new { + def isEmpty = false + def get = 2 + def unapply(x: Int) = this + }.unapply($x) + """ + } + } +} diff --git a/test/files/neg/t5903c/Test_2.scala b/test/files/neg/t5903c/Test_2.scala new file mode 100644 index 0000000000..a1fd31dd49 --- /dev/null +++ b/test/files/neg/t5903c/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import Interpolation._ + "2" match { + case t"$x" => println(x) + } +} diff --git a/test/files/neg/t5903d.check b/test/files/neg/t5903d.check new file mode 100644 index 0000000000..d5d3fdcc28 --- /dev/null +++ b/test/files/neg/t5903d.check @@ -0,0 +1,7 @@ +Test_2.scala:4: error: extractor macros can only expand into extractor calls + case t"$x" => println(x) + ^ +Test_2.scala:4: error: not found: value x + case t"$x" => println(x) + ^ +two errors found diff --git a/test/files/neg/t5903d/Macros_1.scala b/test/files/neg/t5903d/Macros_1.scala new file mode 100644 index 0000000000..15ff226cff --- /dev/null +++ b/test/files/neg/t5903d/Macros_1.scala @@ -0,0 +1,23 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Interpolation { + implicit class TestInterpolation(c: StringContext) { + object t { + def unapply(x: Int) = macro Macros.unapplyImpl + } + } +} + +object Macros { + def unapplyImpl(c: Context)(x: c.Tree) = { + import c.universe._ + q""" + class Match(x: Int) { + def isEmpty = false + def get = x + } + new { def unapply(x: Int) = new Match(x) }.unapply($x) + """ + } +} diff --git a/test/files/neg/t5903d/Test_2.scala b/test/files/neg/t5903d/Test_2.scala new file mode 100644 index 0000000000..95c717a9d8 --- /dev/null +++ b/test/files/neg/t5903d/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import Interpolation._ + 42 match { + case t"$x" => println(x) + } +} diff --git a/test/files/neg/t5903e.check b/test/files/neg/t5903e.check new file mode 100644 index 0000000000..3bdeb091a0 --- /dev/null +++ b/test/files/neg/t5903e.check @@ -0,0 +1,4 @@ +Test_2.scala:4: error: value class may not be a member of another class + case t"$x" => println(x) + ^ +one error found diff --git a/test/files/neg/t5903e/Macros_1.scala b/test/files/neg/t5903e/Macros_1.scala new file mode 100644 index 0000000000..4e1ce89c9f --- /dev/null +++ b/test/files/neg/t5903e/Macros_1.scala @@ -0,0 +1,25 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Interpolation { + implicit class TestInterpolation(c: StringContext) { + object t { + def unapply(x: Int) = macro Macros.unapplyImpl + } + } +} + +object Macros { + def unapplyImpl(c: Context)(x: c.Tree) = { + import c.universe._ + q""" + new { + class Match(x: Int) extends AnyVal { + def isEmpty = false + def get = x + } + def unapply(x: Int) = new Match(x) + }.unapply($x) + """ + } +} diff --git a/test/files/neg/t5903e/Test_2.scala b/test/files/neg/t5903e/Test_2.scala new file mode 100644 index 0000000000..d69d472436 --- /dev/null +++ b/test/files/neg/t5903e/Test_2.scala @@ -0,0 +1,6 @@ +class C { + import Interpolation._ + 42 match { + case t"$x" => println(x) + } +} diff --git a/test/files/neg/t591.scala b/test/files/neg/t591.scala index 5f2397e6a9..0f0b02395c 100644 --- a/test/files/neg/t591.scala +++ b/test/files/neg/t591.scala @@ -1,17 +1,17 @@ abstract class BaseList { type Node <: BaseNode; - - + + abstract class BaseNode { protected def self : Node; private[BaseList] def self00 = self; def dirty : Unit = {} def replaceWith(node : Node) = {} } - + implicit def baseNode2Node(bnode : BaseNode): Node = bnode.self00; - + } @@ -20,22 +20,22 @@ trait BaseFlow extends BaseList { type Flow <: FlowBase; type Output <: OutputBase; type Input <: InputBase; - + abstract class FlowBase { - + } trait OutputBase extends FlowBase { - + } trait InputBase extends FlowBase { - + } - + trait BFNode extends BaseNode { private var input : Input = _; private var output : Output = _; - + def input_=(in : Input) = {} - + } } diff --git a/test/files/neg/t5954.check b/test/files/neg/t5954.check new file mode 100644 index 0000000000..3950d14e4e --- /dev/null +++ b/test/files/neg/t5954.check @@ -0,0 +1,18 @@ +t5954.scala:36: warning: class D should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. + case class D() + ^ +t5954.scala:35: warning: object C should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. + object C + ^ +t5954.scala:34: warning: trait C should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. + trait C + ^ +t5954.scala:33: warning: object B should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. + object B + ^ +t5954.scala:32: warning: class B should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. + class B + ^ +error: No warnings can be incurred under -Xfatal-warnings. +5 warnings found +one error found diff --git a/test/files/neg/t5954.flags b/test/files/neg/t5954.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t5954.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t5954.scala b/test/files/neg/t5954.scala new file mode 100644 index 0000000000..3ccb5ed3ff --- /dev/null +++ b/test/files/neg/t5954.scala @@ -0,0 +1,46 @@ +// if you ever think you've fixed the underlying reason for the warning +// imposed by SI-5954, then here's a test that should pass with two "succes"es +// +//import scala.tools.partest._ +// +//object Test extends DirectTest { +// def code = ??? +// +// def problemCode = """ +// package object A { +// class B +// object B +// case class C() +// } +// """ +// +// def compileProblemCode() = { +// val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") +// compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(problemCode) +// } +// +// def show() : Unit = { +// for (i <- 0 until 2) { +// compileProblemCode() +// println(s"success ${i + 1}") +// } +// } +//} + +package object A { + // these should be prevented by the implementation restriction + class B + object B + trait C + object C + case class D() + // all the rest of these should be ok + class E + object F + val g = "omg" + var h = "wtf" + def i = "lol" + type j = String + class K(val k : Int) extends AnyVal + implicit class L(val l : Int) +} diff --git a/test/files/neg/t5956.check b/test/files/neg/t5956.check index 6641dac97f..f5ae42c799 100644 --- a/test/files/neg/t5956.check +++ b/test/files/neg/t5956.check @@ -1,20 +1,7 @@ -t5956.scala:1: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. -object O { case class C[T]; class C } - ^ -t5956.scala:2: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. -object T { case class C[T]; case class C } - ^ -t5956.scala:2: warning: case classes without a parameter list have been deprecated; -use either case objects or case classes with `()' as parameter list. -object T { case class C[T]; case class C } - ^ t5956.scala:1: error: C is already defined as case class C -object O { case class C[T]; class C } - ^ +object O { case class C[T](); class C() } + ^ t5956.scala:2: error: C is already defined as case class C -object T { case class C[T]; case class C } - ^ -three warnings found +object T { case class C[T](); case class C() } + ^ two errors found diff --git a/test/files/neg/t5956.scala b/test/files/neg/t5956.scala index d985fa97a4..3cc10f3e19 100644 --- a/test/files/neg/t5956.scala +++ b/test/files/neg/t5956.scala @@ -1,2 +1,2 @@ -object O { case class C[T]; class C } -object T { case class C[T]; case class C } +object O { case class C[T](); class C() } +object T { case class C[T](); case class C() } diff --git a/test/files/neg/t5969.scala b/test/files/neg/t5969.scala index 62f87fd7ab..d010cacd1b 100644 --- a/test/files/neg/t5969.scala +++ b/test/files/neg/t5969.scala @@ -4,7 +4,7 @@ class A { def f(x: Any) = x def g(x: C1): String = "A" def g(x: C2): String = "B" - + def crash() = f(List[String]() flatMap { x => if (false) List(g(x)) else List[C1]() map g }) diff --git a/test/files/neg/t6011.check b/test/files/neg/t6011.check index 5b5a861e5b..cb7f189031 100644 --- a/test/files/neg/t6011.check +++ b/test/files/neg/t6011.check @@ -1,10 +1,12 @@ -t6011.scala:4: error: unreachable code +t6011.scala:4: warning: unreachable code case 'a' | 'c' => 1 // unreachable ^ -t6011.scala:10: error: unreachable code +t6011.scala:10: warning: unreachable code case 'b' | 'a' => 1 // unreachable ^ -t6011.scala:8: error: could not emit switch for @switch annotated match +t6011.scala:8: warning: could not emit switch for @switch annotated match def f2(ch: Char): Any = (ch: @annotation.switch) match { ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/t6048.check b/test/files/neg/t6048.check index 5bdf2eca88..5e11d24fde 100644 --- a/test/files/neg/t6048.check +++ b/test/files/neg/t6048.check @@ -1,13 +1,15 @@ -t6048.scala:3: error: unreachable code +t6048.scala:3: warning: unreachable code case _ if false => x // unreachable ^ -t6048.scala:8: error: unreachable code +t6048.scala:8: warning: unreachable code case _ if false => x // unreachable ^ -t6048.scala:13: error: patterns after a variable pattern cannot match (SLS 8.1.1) +t6048.scala:13: warning: patterns after a variable pattern cannot match (SLS 8.1.1) case _ => x ^ -t6048.scala:14: error: unreachable code due to variable pattern on line 13 +t6048.scala:14: warning: unreachable code due to variable pattern on line 13 case 5 if true => x // unreachable ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/t608.scala b/test/files/neg/t608.scala index 1f12764dd1..34dc4c0352 100644 --- a/test/files/neg/t608.scala +++ b/test/files/neg/t608.scala @@ -2,7 +2,7 @@ trait CrashDueToTypeError { def id[a](x :a) :a = x trait Bifunctor { - type a; // content + type a; // content type s <: Bifunctor // uncomment this-vvvvvvvvvvvvvvvvvvvvvvvvvvvv, and it compiles diff --git a/test/files/neg/t6083.check b/test/files/neg/t6083.check new file mode 100644 index 0000000000..c9b5ba05d3 --- /dev/null +++ b/test/files/neg/t6083.check @@ -0,0 +1,10 @@ +t6083.scala:6: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class annot(value: String) extends annotation.ClassfileAnnotation + ^ +t6083.scala:7: error: annotation argument needs to be a constant; found: conv.i2s(101) +@annot(101) class C + ^ +one warning found +one error found diff --git a/test/files/neg/t6083.scala b/test/files/neg/t6083.scala new file mode 100644 index 0000000000..1de18e6527 --- /dev/null +++ b/test/files/neg/t6083.scala @@ -0,0 +1,7 @@ +object conv { + implicit def i2s(i: Int): String = "" +} +import conv._ + +class annot(value: String) extends annotation.ClassfileAnnotation +@annot(101) class C diff --git a/test/files/neg/t6123-explaintypes-macros.check b/test/files/neg/t6123-explaintypes-macros.check new file mode 100644 index 0000000000..ebcb8069d5 --- /dev/null +++ b/test/files/neg/t6123-explaintypes-macros.check @@ -0,0 +1,9 @@ +c.universe.Expr[Any]* <: c.universe.Expr[String]*? +false +BadMac_2.scala:6: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] + found : (c: scala.reflect.macros.Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] +type mismatch for parameter params: c.Expr[Any]* does not conform to c.Expr[String]* + def printf(format: String, params: Any*): Unit = macro printf_impl + ^ +one error found diff --git a/test/files/neg/t6123-explaintypes-macros/BadMac_2.flags b/test/files/neg/t6123-explaintypes-macros/BadMac_2.flags new file mode 100644 index 0000000000..b36707c7cf --- /dev/null +++ b/test/files/neg/t6123-explaintypes-macros/BadMac_2.flags @@ -0,0 +1 @@ +-explaintypes diff --git a/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala b/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala new file mode 100644 index 0000000000..38b8e24444 --- /dev/null +++ b/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala @@ -0,0 +1,8 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context + +// explain some macro types to me +object BadMac { + def printf(format: String, params: Any*): Unit = macro printf_impl + def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] = ??? +} diff --git a/test/files/neg/t6123-explaintypes-macros/Macros.flags b/test/files/neg/t6123-explaintypes-macros/Macros.flags new file mode 100644 index 0000000000..b36707c7cf --- /dev/null +++ b/test/files/neg/t6123-explaintypes-macros/Macros.flags @@ -0,0 +1 @@ +-explaintypes diff --git a/test/files/neg/t6123-explaintypes-macros/Macros.scala b/test/files/neg/t6123-explaintypes-macros/Macros.scala new file mode 100644 index 0000000000..a12c277c86 --- /dev/null +++ b/test/files/neg/t6123-explaintypes-macros/Macros.scala @@ -0,0 +1,10 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def printf(format: String, params: Any*): Unit = macro printf_impl + def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = ??? +} + +// something trivial to run +object Test extends App diff --git a/test/files/neg/t6162-inheritance.check b/test/files/neg/t6162-inheritance.check index a7d3cc3238..13c78030d9 100644 --- a/test/files/neg/t6162-inheritance.check +++ b/test/files/neg/t6162-inheritance.check @@ -1,10 +1,18 @@ -t6162-inheritance.scala:6: error: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. +usage.scala:3: warning: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. class SubFoo extends Foo ^ -t6162-inheritance.scala:11: error: inheritance from trait T in package t6126 is deprecated +usage.scala:5: warning: inheritance from trait T in package t6126 is deprecated object SubT extends T ^ -t6162-inheritance.scala:17: error: inheritance from trait S in package t6126 is deprecated +usage.scala:8: warning: inheritance from trait S in package t6126 is deprecated new S { ^ -three errors found +usage.scala:3: warning: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. +class SubFoo extends Foo + ^ +usage.scala:5: warning: inheritance from trait T in package t6126 is deprecated +object SubT extends T + ^ +error: No warnings can be incurred under -Xfatal-warnings. +5 warnings found +one error found diff --git a/test/files/neg/t6162-inheritance/defn.scala b/test/files/neg/t6162-inheritance/defn.scala new file mode 100644 index 0000000000..bb582d27b0 --- /dev/null +++ b/test/files/neg/t6162-inheritance/defn.scala @@ -0,0 +1,10 @@ +package scala.t6126 + +@deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") +class Foo + +@deprecatedInheritance() +trait T + +@deprecatedInheritance() +trait S diff --git a/test/files/neg/t6162-inheritance/usage.scala b/test/files/neg/t6162-inheritance/usage.scala new file mode 100644 index 0000000000..097e4f5903 --- /dev/null +++ b/test/files/neg/t6162-inheritance/usage.scala @@ -0,0 +1,10 @@ +package scala.t6126 + +class SubFoo extends Foo + +object SubT extends T + +object O { + new S { + } +} diff --git a/test/files/neg/t6162-overriding.check b/test/files/neg/t6162-overriding.check index e774888d36..6bff75d88d 100644 --- a/test/files/neg/t6162-overriding.check +++ b/test/files/neg/t6162-overriding.check @@ -1,7 +1,9 @@ -t6162-overriding.scala:14: error: overriding method bar in class Bar is deprecated: `bar` will be made private in a future version. +t6162-overriding.scala:14: warning: overriding method bar in class Bar is deprecated: `bar` will be made private in a future version. override def bar = 43 ^ -t6162-overriding.scala:15: error: overriding method baz in class Bar is deprecated +t6162-overriding.scala:15: warning: overriding method baz in class Bar is deprecated override def baz = 43 ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t6231.check b/test/files/neg/t6231.check index b27961d393..2428bf66d0 100644 --- a/test/files/neg/t6231.check +++ b/test/files/neg/t6231.check @@ -1,6 +1,6 @@ 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 anonymous class anonfun$qux$1. You can manually assign it to a val inside the trait, -and refer that that val in anonymous class anonfun$qux$1. For more details, see SI-6231. +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/t6260.check b/test/files/neg/t6260.check index 46e9bd1dfc..60c4add143 100644 --- a/test/files/neg/t6260.check +++ b/test/files/neg/t6260.check @@ -1,10 +1,10 @@ -t6260.scala:3: error: bridge generated for member method apply: (bx: Box[X])Box[Y] in anonymous class $anonfun +t6260.scala:3: error: bridge generated for member method apply: (bx: Box[X])Box[Y] in <$anon: Box[X] => Box[Y]> which overrides method apply: (v1: T1)R in trait Function1 clashes with definition of the member itself; both have erased type (v1: Object)Object ((bx: Box[X]) => new Box(f(bx.x)))(this) ^ -t6260.scala:8: error: bridge generated for member method apply: (bx: Box[X])Box[Y] in anonymous class $anonfun +t6260.scala:8: error: bridge generated for member method apply: (bx: Box[X])Box[Y] in <$anon: Box[X] => Box[Y]> which overrides method apply: (v1: T1)R in trait Function1 clashes with definition of the member itself; both have erased type (v1: Object)Object diff --git a/test/files/neg/t6264.check b/test/files/neg/t6264.check index 438be4c39f..c0975a80b2 100644 --- a/test/files/neg/t6264.check +++ b/test/files/neg/t6264.check @@ -1,4 +1,6 @@ -t6264.scala:3: error: non-variable type argument Tuple1[_] in type Tuple2[_, Tuple1[_]] is unchecked since it is eliminated by erasure +t6264.scala:3: warning: non-variable type argument Tuple1[_] in type Tuple2[_, Tuple1[_]] is unchecked since it is eliminated by erasure x.isInstanceOf[Tuple2[_, Tuple1[_]]] ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/t6276.check b/test/files/neg/t6276.check index 0b3dfa5531..f275de9d0a 100644 --- a/test/files/neg/t6276.check +++ b/test/files/neg/t6276.check @@ -1,19 +1,21 @@ -t6276.scala:4: error: method a in class C does nothing other than call itself recursively +t6276.scala:4: warning: method a in class C does nothing other than call itself recursively def a: Any = a // warn ^ -t6276.scala:5: error: value b in class C does nothing other than call itself recursively +t6276.scala:5: warning: value b in class C does nothing other than call itself recursively val b: Any = b // warn ^ -t6276.scala:7: error: method c in class C does nothing other than call itself recursively +t6276.scala:7: warning: method c in class C does nothing other than call itself recursively def c: Any = this.c // warn ^ -t6276.scala:8: error: method d in class C does nothing other than call itself recursively +t6276.scala:8: warning: method d in class C does nothing other than call itself recursively def d: Any = C.this.d // warn ^ -t6276.scala:13: error: method a does nothing other than call itself recursively +t6276.scala:13: warning: method a does nothing other than call itself recursively def a: Any = a // warn ^ -t6276.scala:22: error: method a does nothing other than call itself recursively +t6276.scala:22: warning: method a does nothing other than call itself recursively def a = a // warn ^ -6 errors found +error: No warnings can be incurred under -Xfatal-warnings. +6 warnings found +one error found diff --git a/test/files/neg/t6289.check b/test/files/neg/t6289.check new file mode 100644 index 0000000000..f6f43cabd3 --- /dev/null +++ b/test/files/neg/t6289.check @@ -0,0 +1,10 @@ +#partest java6 +t6289/J.java:2: method does not override or implement a method from a supertype + @Override public void foo() { } + ^ +1 error +#partest java7 +t6289/J.java:2: error: method does not override or implement a method from a supertype + @Override public void foo() { } + ^ +1 error diff --git a/test/files/neg/t6289.flags b/test/files/neg/t6289.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t6289.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t6289/J.java b/test/files/neg/t6289/J.java new file mode 100644 index 0000000000..83f50c9ae2 --- /dev/null +++ b/test/files/neg/t6289/J.java @@ -0,0 +1,5 @@ +public class J { + @Override public void foo() { } + + public void bar() { foo(); } +} diff --git a/test/files/neg/t6289/SUT_5.scala b/test/files/neg/t6289/SUT_5.scala new file mode 100644 index 0000000000..0a996352c0 --- /dev/null +++ b/test/files/neg/t6289/SUT_5.scala @@ -0,0 +1,5 @@ + +/** The System Under Test. + * We bail on the earlier round that generates the first error. + */ +class SUT extends J diff --git a/test/files/neg/t6323a.check b/test/files/neg/t6323a.check index 4d682e5422..b649cfc86f 100644 --- a/test/files/neg/t6323a.check +++ b/test/files/neg/t6323a.check @@ -5,7 +5,7 @@ t6323a.scala:11: materializing requested reflect.runtime.universe.type.TypeTag[T val value = u.typeOf[Test] ^ t6323a.scala:11: `package`.this.materializeTypeTag[Test](scala.reflect.runtime.`package`.universe) is not a valid implicit value for reflect.runtime.universe.TypeTag[Test] because: -failed to typecheck the materialized tag: +failed to typecheck the materialized tag: cannot create a TypeTag referring to local class Test.Test: use WeakTypeTag instead val value = u.typeOf[Test] ^ diff --git a/test/files/neg/t6355.check b/test/files/neg/t6355.check new file mode 100644 index 0000000000..607829d99a --- /dev/null +++ b/test/files/neg/t6355.check @@ -0,0 +1,7 @@ +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/t6355.scala b/test/files/neg/t6355.scala new file mode 100644 index 0000000000..0500ed04c6 --- /dev/null +++ b/test/files/neg/t6355.scala @@ -0,0 +1,19 @@ +package foo + +import scala.language.dynamics + +class DoesntExtendDynamic { + def applyDynamic(name: String)(s: String): Int = 1 + def applyDynamic(name: String)(x: Int): Int = 2 +} + +class A extends Dynamic { + def applyDynamic(name: String)(s: String): Int = 1 + def applyDynamic(name: String)(x: Int): Int = 2 +} + +class B extends Dynamic { + def applyDynamic[T1](name: String)(x: T1): Int = 1 + def applyDynamic[T1, T2](name: String)(x: T1, y: T2): Int = 2 + def applyDynamic[T1, T2](name: String)(x: String, y: T1, z: T2): Int = 3 +} diff --git a/test/files/neg/t6375.check b/test/files/neg/t6375.check new file mode 100644 index 0000000000..89d7d8060f --- /dev/null +++ b/test/files/neg/t6375.check @@ -0,0 +1,27 @@ +t6375.scala:6: warning: no valid targets for annotation on value x1 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @getter) + @Bippy val x1: Int // warn + ^ +t6375.scala:7: warning: no valid targets for annotation on value x2 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.field @getter) + @(Bippy @field) val x2: Int // warn + ^ +t6375.scala:9: warning: no valid targets for annotation on value x4 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.setter @getter) + @(Bippy @setter) val x4: Int // warn + ^ +t6375.scala:10: warning: no valid targets for annotation on value x5 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.param @getter) + @(Bippy @param) val x5: Int // warn + ^ +t6375.scala:20: warning: no valid targets for annotation on value q1 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.getter @field) + @(Bippy @getter) private[this] val q1: Int = 1 // warn + ^ +t6375.scala:40: warning: no valid targets for annotation on value p2 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.getter @param) + @(Bippy @getter) p2: Int, // warn + ^ +t6375.scala:41: warning: no valid targets for annotation on value p3 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.setter @param) + @(Bippy @setter) p3: Int, // warn + ^ +t6375.scala:42: warning: no valid targets for annotation on value p4 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.field @param) + @(Bippy @field) p4: Int // warn + ^ +error: No warnings can be incurred under -Xfatal-warnings. +8 warnings found +one error found diff --git a/test/files/neg/t6375.flags b/test/files/neg/t6375.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t6375.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t6375.scala b/test/files/neg/t6375.scala new file mode 100644 index 0000000000..21634df688 --- /dev/null +++ b/test/files/neg/t6375.scala @@ -0,0 +1,67 @@ +import scala.annotation.meta._ + +class Bippy extends scala.annotation.StaticAnnotation + +abstract class Foo { + @Bippy val x1: Int // warn + @(Bippy @field) val x2: Int // warn + @(Bippy @getter) val x3: Int // no warn + @(Bippy @setter) val x4: Int // warn + @(Bippy @param) val x5: Int // warn +} + +object Bar extends Foo { + val x1 = 1 + val x2 = 2 + val x3 = 3 + val x4 = 4 + val x5 = 5 + + @(Bippy @getter) private[this] val q1: Int = 1 // warn + @(Bippy @getter) private val q2: Int = 1 // no warn + + def f1(@(Bippy @param) x: Int): Int = 0 // no warn + def f2(@(Bippy @getter) x: Int): Int = 0 // warn - todo + def f3(@(Bippy @setter) x: Int): Int = 0 // warn - todo + def f4(@(Bippy @field) x: Int): Int = 0 // warn - todo + def f5(@Bippy x: Int): Int = 0 // no warn + + @(Bippy @companionClass) def g1(x: Int): Int = 0 // warn - todo + @(Bippy @companionObject) def g2(x: Int): Int = 0 // warn - todo + @(Bippy @companionMethod) def g3(x: Int): Int = 0 // no warn + @Bippy def g4(x: Int): Int = 0 // no warn + + @(Bippy @companionObject @companionMethod) def g5(x: Int): Int = 0 // no warn +} + +class Dingo( + @Bippy p0: Int, // no warn + @(Bippy @param) p1: Int, // no warn + @(Bippy @getter) p2: Int, // warn + @(Bippy @setter) p3: Int, // warn + @(Bippy @field) p4: Int // warn +) + +class ValDingo( + @Bippy val p0: Int, // no warn + @(Bippy @param) val p1: Int, // no warn + @(Bippy @getter) val p2: Int, // no warn + @(Bippy @setter) val p3: Int, // warn - todo + @(Bippy @field) val p4: Int // no warn +) + +class VarDingo( + @Bippy var p0: Int, // no warn + @(Bippy @param) var p1: Int, // no warn + @(Bippy @getter) var p2: Int, // no warn + @(Bippy @setter) var p3: Int, // no warn + @(Bippy @field) var p4: Int // no warn +) + +case class CaseDingo( + @Bippy p0: Int, // no warn + @(Bippy @param) p1: Int, // no warn + @(Bippy @getter) p2: Int, // no warn + @(Bippy @setter) p3: Int, // warn - todo + @(Bippy @field) p4: Int // no warn +) diff --git a/test/files/neg/t6406-regextract.check b/test/files/neg/t6406-regextract.check new file mode 100644 index 0000000000..19425a68b0 --- /dev/null +++ b/test/files/neg/t6406-regextract.check @@ -0,0 +1,6 @@ +t6406-regextract.scala:4: warning: method unapplySeq in class Regex is deprecated: Extracting a match result from anything but a CharSequence or Match is deprecated + List(1) collect { case r(i) => i } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t6406-regextract.flags b/test/files/neg/t6406-regextract.flags new file mode 100644 index 0000000000..7de3c0f3ee --- /dev/null +++ b/test/files/neg/t6406-regextract.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation diff --git a/test/files/neg/t6406-regextract.scala b/test/files/neg/t6406-regextract.scala new file mode 100644 index 0000000000..0f5dad908d --- /dev/null +++ b/test/files/neg/t6406-regextract.scala @@ -0,0 +1,5 @@ + +object Test extends App { + val r = "(\\d+)".r + List(1) collect { case r(i) => i } +} diff --git a/test/files/neg/t6446-additional.check b/test/files/neg/t6446-additional.check new file mode 100755 index 0000000000..6dfe072913 --- /dev/null +++ b/test/files/neg/t6446-additional.check @@ -0,0 +1,38 @@ + phase name id description + ---------- -- ----------- + parser 1 parse source into ASTs, perform simple desugaring + namer 2 resolve names, attach symbols to named trees +packageobjects 3 load package objects + typer 4 the meat and potatoes: type the trees + patmat 5 translate match expressions +superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code +#partest -optimise + inliner 23 optimization: do inlining +inlinehandlers 24 optimization: inline exception handlers + closelim 25 optimization: eliminate uncalled closures + constopt 26 optimization: optimize null and other constants + dce 27 optimization: eliminate dead code + jvm 28 generate JVM bytecode + ploogin 29 A sample phase that does so many things it's kind of hard... + terminal 30 the last phase during a compilation run +#partest !-optimise + jvm 23 generate JVM bytecode + ploogin 24 A sample phase that does so many things it's kind of hard... + terminal 25 the last phase during a compilation run +#partest diff --git a/test/files/neg/t6446-additional/ploogin_1.scala b/test/files/neg/t6446-additional/ploogin_1.scala new file mode 100644 index 0000000000..ed6adfc1cf --- /dev/null +++ b/test/files/neg/t6446-additional/ploogin_1.scala @@ -0,0 +1,31 @@ + +package t6446 + +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) extends Plugin { + import global._ + + val name = "ploogin" + 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) { + // kewl kode + } + } + } +} diff --git a/test/files/neg/t6446-additional/sample_2.flags b/test/files/neg/t6446-additional/sample_2.flags new file mode 100644 index 0000000000..4d518c2286 --- /dev/null +++ b/test/files/neg/t6446-additional/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xshow-phases diff --git a/test/files/neg/t6446-additional/sample_2.scala b/test/files/neg/t6446-additional/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t6446-additional/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t6446-additional/scalac-plugin.xml b/test/files/neg/t6446-additional/scalac-plugin.xml new file mode 100644 index 0000000000..e849bb5919 --- /dev/null +++ b/test/files/neg/t6446-additional/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> +<name>sample-plugin</name> +<classname>t6446.Ploogin</classname> +</plugin> diff --git a/test/files/neg/t6446-list.check b/test/files/neg/t6446-list.check new file mode 100755 index 0000000000..fa5c581941 --- /dev/null +++ b/test/files/neg/t6446-list.check @@ -0,0 +1 @@ +ploogin - A sample plugin for testing. diff --git a/test/files/neg/t6446-list/ploogin_1.scala b/test/files/neg/t6446-list/ploogin_1.scala new file mode 100644 index 0000000000..ed6adfc1cf --- /dev/null +++ b/test/files/neg/t6446-list/ploogin_1.scala @@ -0,0 +1,31 @@ + +package t6446 + +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) extends Plugin { + import global._ + + val name = "ploogin" + 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) { + // kewl kode + } + } + } +} diff --git a/test/files/neg/t6446-list/sample_2.flags b/test/files/neg/t6446-list/sample_2.flags new file mode 100644 index 0000000000..9cb3232964 --- /dev/null +++ b/test/files/neg/t6446-list/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-list diff --git a/test/files/neg/t6446-list/sample_2.scala b/test/files/neg/t6446-list/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t6446-list/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t6446-list/scalac-plugin.xml b/test/files/neg/t6446-list/scalac-plugin.xml new file mode 100644 index 0000000000..e849bb5919 --- /dev/null +++ b/test/files/neg/t6446-list/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> +<name>sample-plugin</name> +<classname>t6446.Ploogin</classname> +</plugin> diff --git a/test/files/neg/t6446-missing.check b/test/files/neg/t6446-missing.check new file mode 100755 index 0000000000..ba5e30dc05 --- /dev/null +++ b/test/files/neg/t6446-missing.check @@ -0,0 +1,37 @@ +Warning: class not found: t6446.Ploogin + phase name id description + ---------- -- ----------- + parser 1 parse source into ASTs, perform simple desugaring + namer 2 resolve names, attach symbols to named trees +packageobjects 3 load package objects + typer 4 the meat and potatoes: type the trees + patmat 5 translate match expressions +superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code +#partest !-optimise + jvm 23 generate JVM bytecode + terminal 24 the last phase during a compilation run +#partest -optimise + inliner 23 optimization: do inlining +inlinehandlers 24 optimization: inline exception handlers + closelim 25 optimization: eliminate uncalled closures + constopt 26 optimization: optimize null and other constants + dce 27 optimization: eliminate dead code + jvm 28 generate JVM bytecode + terminal 29 the last phase during a compilation run +#partest diff --git a/test/files/neg/t6446-missing/sample_2.flags b/test/files/neg/t6446-missing/sample_2.flags new file mode 100644 index 0000000000..4d518c2286 --- /dev/null +++ b/test/files/neg/t6446-missing/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xshow-phases diff --git a/test/files/neg/t6446-missing/sample_2.scala b/test/files/neg/t6446-missing/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t6446-missing/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t6446-missing/scalac-plugin.xml b/test/files/neg/t6446-missing/scalac-plugin.xml new file mode 100644 index 0000000000..9c34d63f83 --- /dev/null +++ b/test/files/neg/t6446-missing/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> +<name>missing-plugin</name> +<classname>t6446.Ploogin</classname> +</plugin> diff --git a/test/files/neg/t6446-show-phases.check b/test/files/neg/t6446-show-phases.check new file mode 100644 index 0000000000..10a9e08b86 --- /dev/null +++ b/test/files/neg/t6446-show-phases.check @@ -0,0 +1,36 @@ + phase name id description + ---------- -- ----------- + parser 1 parse source into ASTs, perform simple desugaring + namer 2 resolve names, attach symbols to named trees +packageobjects 3 load package objects + typer 4 the meat and potatoes: type the trees + patmat 5 translate match expressions +superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code +#partest !-optimise + jvm 23 generate JVM bytecode + terminal 24 the last phase during a compilation run +#partest -optimise + inliner 23 optimization: do inlining +inlinehandlers 24 optimization: inline exception handlers + closelim 25 optimization: eliminate uncalled closures + constopt 26 optimization: optimize null and other constants + dce 27 optimization: eliminate dead code + jvm 28 generate JVM bytecode + terminal 29 the last phase during a compilation run +#partest diff --git a/test/files/neg/t6446-show-phases.flags b/test/files/neg/t6446-show-phases.flags new file mode 100644 index 0000000000..845666e100 --- /dev/null +++ b/test/files/neg/t6446-show-phases.flags @@ -0,0 +1 @@ +-Xshow-phases diff --git a/test/files/neg/t6446-show-phases.scala b/test/files/neg/t6446-show-phases.scala new file mode 100644 index 0000000000..a9afb042d2 --- /dev/null +++ b/test/files/neg/t6446-show-phases.scala @@ -0,0 +1,3 @@ + +// testing compiler flag output only +object Test extends App diff --git a/test/files/neg/t6534.check b/test/files/neg/t6534.check index 52e70cfa8a..c2e80b377a 100644 --- a/test/files/neg/t6534.check +++ b/test/files/neg/t6534.check @@ -1,9 +1,3 @@ -t6534.scala:4: warning: Implementation of equals inherited from trait Foo overridden in class Bippy1 to enforce value class semantics -class Bippy1(val x: Int) extends AnyVal with Foo { } // warn - ^ -t6534.scala:5: warning: Implementation of hashCode inherited from trait Ding overridden in class Bippy2 to enforce value class semantics -class Bippy2(val x: Int) extends AnyVal with Ding { } // warn - ^ t6534.scala:6: error: redefinition of equals method. See SIP-15, criterion 4. is not allowed in value class class Bippy3(val x: Int) extends AnyVal { override def equals(x: Any) = false } // error ^ @@ -13,5 +7,4 @@ class Bippy4(val x: Int) extends AnyVal { override def hashCode = -1 } t6534.scala:9: error: redefinition of equals method. See SIP-15, criterion 4. is not allowed in value class case class Bippy6(val x: Int) extends AnyVal { override def productPrefix = "Dingo" ; override def equals(x: Any) = false } // error ^ -two warnings found three errors found diff --git a/test/files/neg/t6566a.check b/test/files/neg/t6566a.check new file mode 100644 index 0000000000..7668f9d2fb --- /dev/null +++ b/test/files/neg/t6566a.check @@ -0,0 +1,4 @@ +t6566a.scala:2: error: covariant type T occurs in invariant position in type T of type MyType + class TypeCheat[+T] { type MyType = T } + ^ +one error found diff --git a/test/files/neg/t6566a.scala b/test/files/neg/t6566a.scala new file mode 100644 index 0000000000..74a0b38e56 --- /dev/null +++ b/test/files/neg/t6566a.scala @@ -0,0 +1,17 @@ +object WhatsYourTypeIsMyType { + class TypeCheat[+T] { type MyType = T } + + class Foo { + val tc = new TypeCheat[Foo] + var x: tc.MyType = _ + def setX() = x = new Foo + } + class Bar extends Foo { + override val tc = new TypeCheat[Bar] + def unsound = this + + setX() + println(x.unsound) + } + def main(args: Array[String]): Unit = new Bar +} diff --git a/test/files/neg/t6566b.check b/test/files/neg/t6566b.check new file mode 100644 index 0000000000..fb3fe81fca --- /dev/null +++ b/test/files/neg/t6566b.check @@ -0,0 +1,4 @@ +t6566b.scala:3: error: covariant type T occurs in invariant position in type T of type MyType + type MyType = T + ^ +one error found diff --git a/test/files/neg/t6566b.scala b/test/files/neg/t6566b.scala new file mode 100644 index 0000000000..18ddebf88b --- /dev/null +++ b/test/files/neg/t6566b.scala @@ -0,0 +1,19 @@ +object WhatsYourTypeIsMyType { + trait WithMyType[+T] { + type MyType = T + } + + class Foo extends WithMyType[Foo] { + var x: MyType = _ + def setX() = x = new Foo + } + + class Bar extends Foo with WithMyType[Bar] { + def unsound { println("iAmABar") } + + setX() + println(x.unsound) + } + + def main(args: Array[String]): Unit = new Bar +} diff --git a/test/files/neg/t6567.check b/test/files/neg/t6567.check index 4c513e64cd..a733d75354 100644 --- a/test/files/neg/t6567.check +++ b/test/files/neg/t6567.check @@ -1,7 +1,9 @@ -t6567.scala:8: error: Suspicious application of an implicit view (Test.this.a2b) in the argument to Option.apply. +t6567.scala:8: warning: Suspicious application of an implicit view (Test.this.a2b) in the argument to Option.apply. Option[B](a) ^ -t6567.scala:10: error: Suspicious application of an implicit view (Test.this.a2b) in the argument to Option.apply. +t6567.scala:10: warning: Suspicious application of an implicit view (Test.this.a2b) in the argument to Option.apply. val b: Option[B] = Option(a) ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t6574.check b/test/files/neg/t6574.check new file mode 100644 index 0000000000..c67b4ed804 --- /dev/null +++ b/test/files/neg/t6574.check @@ -0,0 +1,7 @@ +t6574.scala:4: error: could not optimize @tailrec annotated method notTailPos$extension: it contains a recursive call not in tail position + println("tail") + ^ +t6574.scala:8: error: could not optimize @tailrec annotated method differentTypeArgs$extension: it is called recursively with different type arguments + {(); new Bad[String, Unit](0)}.differentTypeArgs + ^ +two errors found diff --git a/test/files/neg/t6574.scala b/test/files/neg/t6574.scala new file mode 100644 index 0000000000..bba97ad62e --- /dev/null +++ b/test/files/neg/t6574.scala @@ -0,0 +1,10 @@ +class Bad[X, Y](val v: Int) extends AnyVal { + @annotation.tailrec final def notTailPos[Z](a: Int)(b: String) { + this.notTailPos[Z](a)(b) + println("tail") + } + + @annotation.tailrec final def differentTypeArgs { + {(); new Bad[String, Unit](0)}.differentTypeArgs + } +} diff --git a/test/files/neg/t6601.check b/test/files/neg/t6601.check new file mode 100644 index 0000000000..1410e1b11a --- /dev/null +++ b/test/files/neg/t6601.check @@ -0,0 +1,4 @@ +AccessPrivateConstructor_2.scala:2: error: constructor PrivateConstructor in class PrivateConstructor cannot be accessed in class AccessPrivateConstructor + new PrivateConstructor("") // Scalac should forbid accessing to the private constructor! + ^ +one error found diff --git a/test/files/neg/t6601/AccessPrivateConstructor_2.scala b/test/files/neg/t6601/AccessPrivateConstructor_2.scala new file mode 100644 index 0000000000..816bc10d79 --- /dev/null +++ b/test/files/neg/t6601/AccessPrivateConstructor_2.scala @@ -0,0 +1,3 @@ +class AccessPrivateConstructor { + new PrivateConstructor("") // Scalac should forbid accessing to the private constructor! +} diff --git a/test/files/neg/t6601/PrivateConstructor_1.scala b/test/files/neg/t6601/PrivateConstructor_1.scala new file mode 100644 index 0000000000..f09d7ad068 --- /dev/null +++ b/test/files/neg/t6601/PrivateConstructor_1.scala @@ -0,0 +1 @@ +class PrivateConstructor private(val s: String) extends AnyVal diff --git a/test/files/neg/t6666.check b/test/files/neg/t6666.check index 6337d4c7d9..43c8252753 100644 --- a/test/files/neg/t6666.check +++ b/test/files/neg/t6666.check @@ -1,28 +1,28 @@ -t6666.scala:23: error: Implementation restriction: access of method x$2 in object O1 from anonymous class 2, would require illegal premature access to object O1 +t6666.scala:23: error: Implementation restriction: access of method x$2 in object O1 from <$anon: Function0>, would require illegal premature access to object O1 F.byname(x) ^ -t6666.scala:30: error: Implementation restriction: access of value x$3 in object O2 from anonymous class 3, would require illegal premature access to object O2 +t6666.scala:30: error: Implementation restriction: access of value x$3 in object O2 from <$anon: Function0>, would require illegal premature access to object O2 F.byname(x) ^ -t6666.scala:37: error: Implementation restriction: access of method x$4 in object O3 from anonymous class 4, would require illegal premature access to object O3 +t6666.scala:37: error: Implementation restriction: access of method x$4 in object O3 from <$anon: Function0>, would require illegal premature access to object O3 F.hof(() => x) ^ -t6666.scala:50: error: Implementation restriction: access of method x$6 in class C1 from anonymous class 7, would require illegal premature access to the unconstructed `this` of class C1 +t6666.scala:50: error: Implementation restriction: access of method x$6 in class C1 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C1 F.byname(x) ^ -t6666.scala:54: error: Implementation restriction: access of value x$7 in class C2 from anonymous class 8, would require illegal premature access to the unconstructed `this` of class C2 +t6666.scala:54: error: Implementation restriction: access of value x$7 in class C2 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C2 F.byname(x) ^ -t6666.scala:58: error: Implementation restriction: access of method x$8 in class C3 from anonymous class 9, would require illegal premature access to the unconstructed `this` of class C3 +t6666.scala:58: error: Implementation restriction: access of method x$8 in class C3 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C3 F.hof(() => x) ^ t6666.scala:62: error: Implementation restriction: access of method x$9 in class C4 from object Nested$4, would require illegal premature access to the unconstructed `this` of class C4 object Nested { def xx = x} ^ -t6666.scala:76: error: Implementation restriction: access of method x$11 in class C11 from anonymous class 12, would require illegal premature access to the unconstructed `this` of class C11 +t6666.scala:76: error: Implementation restriction: access of method x$11 in class C11 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C11 F.byname(x) ^ -t6666.scala:95: error: Implementation restriction: access of method x$12 in class C13 from anonymous class 13, would require illegal premature access to the unconstructed `this` of class C13 +t6666.scala:95: error: Implementation restriction: access of method x$12 in class C13 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C13 F.hof(() => x) ^ t6666.scala:104: error: Implementation restriction: access of method x$13 in class C14 from object Nested$5, would require illegal premature access to the unconstructed `this` of class C14 diff --git a/test/files/neg/t6666.scala b/test/files/neg/t6666.scala index 1919ea3ca9..58c5be5405 100644 --- a/test/files/neg/t6666.scala +++ b/test/files/neg/t6666.scala @@ -118,4 +118,4 @@ class CEarly(a: Any) extends { object Nested { def xx = x} Nested.xx } -} with AnyRef
\ No newline at end of file +} with AnyRef
\ No newline at end of file diff --git a/test/files/neg/t6666c.check b/test/files/neg/t6666c.check index 8fb9f4ba14..384e52a9fc 100644 --- a/test/files/neg/t6666c.check +++ b/test/files/neg/t6666c.check @@ -4,7 +4,7 @@ class D extends C({def x = 0; object X { x }}) t6666c.scala:5: error: Implementation restriction: access of method x$2 in class D1 from object X$5, would require illegal premature access to the unconstructed `this` of class D1 class D1 extends C1({def x = 0; () => {object X { x }}}) ^ -t6666c.scala:8: error: Implementation restriction: access of method x$3 from object X$6, would require illegal premature access to the unconstructed `this` of anonymous class 2 +t6666c.scala:8: error: Implementation restriction: access of method x$3 from object X$6, would require illegal premature access to the unconstructed `this` of <$anon: Function0> class D2 extends C2({def x = 0; object X { x }}) ^ three errors found diff --git a/test/files/neg/t6666e.check b/test/files/neg/t6666e.check index 9fcc3ab718..3189612314 100644 --- a/test/files/neg/t6666e.check +++ b/test/files/neg/t6666e.check @@ -1,4 +1,4 @@ -t6666e.scala:8: error: Implementation restriction: anonymous class $anonfun requires premature access to class Crash. +t6666e.scala:8: error: Implementation restriction: <$anon: Nothing => Unit> requires premature access to class Crash. this(Nil.collect{case x =>}) ^ one error found diff --git a/test/files/neg/t6667.check b/test/files/neg/t6667.check index b04251d7c1..43313fa4fe 100644 --- a/test/files/neg/t6667.check +++ b/test/files/neg/t6667.check @@ -1,5 +1,4 @@ -t6667.scala:8: error: Search of in-scope implicits was ambiguous, and the implicit scope was searched. In Scala 2.11.0, this code will not compile. See SI-6667. -ambiguous implicit values: +t6667.scala:8: error: ambiguous implicit values: both value inScope1 in object Test of type => C and value inScope2 in object Test of type => C match expected type C diff --git a/test/files/neg/t6667.flags b/test/files/neg/t6667.flags deleted file mode 100644 index 6c1dd108ae..0000000000 --- a/test/files/neg/t6667.flags +++ /dev/null @@ -1 +0,0 @@ --Xfatal-warnings -Xlint
\ No newline at end of file diff --git a/test/files/neg/t6667b.check b/test/files/neg/t6667b.check index 5d56e776c3..99cea9a47c 100644 --- a/test/files/neg/t6667b.check +++ b/test/files/neg/t6667b.check @@ -4,8 +4,7 @@ t6667b.scala:16: error: ambiguous implicit values: match expected type Test.Box new Test() ^ -t6667b.scala:19: error: Search of in-scope implicits was ambiguous, and the implicit scope was searched. In Scala 2.11.0, this code will not compile. See SI-6667. -ambiguous implicit values: +t6667b.scala:19: error: ambiguous implicit values: both value a in object Test of type => Test.Box and value b of type Test.Box match expected type Test.Box diff --git a/test/files/neg/t6667b.flags b/test/files/neg/t6667b.flags deleted file mode 100644 index 6c1dd108ae..0000000000 --- a/test/files/neg/t6667b.flags +++ /dev/null @@ -1 +0,0 @@ --Xfatal-warnings -Xlint
\ No newline at end of file diff --git a/test/files/neg/t667.check b/test/files/neg/t667.check index d4367bc87b..e68c6dea00 100644 --- a/test/files/neg/t667.check +++ b/test/files/neg/t667.check @@ -1,4 +1,4 @@ -t667.scala:8: error: class Ni inherits itself +t667.scala:8: error: illegal cyclic reference involving class Ni class Ni extends super.Ni with Ni; - ^ + ^ one error found diff --git a/test/files/neg/t6675-old-patmat.check b/test/files/neg/t6675-old-patmat.check deleted file mode 100644 index bc3920da06..0000000000 --- a/test/files/neg/t6675-old-patmat.check +++ /dev/null @@ -1,4 +0,0 @@ -t6675-old-patmat.scala:10: error: extractor pattern binds a single value to a Product3 of type (Int, Int, Int) - "" match { case X(b) => b } // should warn under -Xlint. Not an error because of SI-6111 - ^ -one error found diff --git a/test/files/neg/t6675-old-patmat.flags b/test/files/neg/t6675-old-patmat.flags deleted file mode 100644 index 604de64a62..0000000000 --- a/test/files/neg/t6675-old-patmat.flags +++ /dev/null @@ -1 +0,0 @@ --Xlint -Xfatal-warnings -Xoldpatmat
\ No newline at end of file diff --git a/test/files/neg/t6675-old-patmat.scala b/test/files/neg/t6675-old-patmat.scala deleted file mode 100644 index 4d500b77ba..0000000000 --- a/test/files/neg/t6675-old-patmat.scala +++ /dev/null @@ -1,13 +0,0 @@ -object X { - def unapply(s: String): Option[(Int,Int,Int)] = Some((1,2,3)) -} - -object Y { - def unapplySeq(s: String): Option[Seq[(Int,Int,Int)]] = Some(Seq((1,2,3))) -} - -object Test { - "" match { case X(b) => b } // should warn under -Xlint. Not an error because of SI-6111 - - "" match { case Y(b) => b } // no warning -} diff --git a/test/files/neg/t6675.check b/test/files/neg/t6675.check index 7b271de213..aecf04cb68 100644 --- a/test/files/neg/t6675.check +++ b/test/files/neg/t6675.check @@ -1,4 +1,6 @@ -t6675.scala:10: error: extractor pattern binds a single value to a Product3 of type (Int, Int, Int) +t6675.scala:10: warning: object X expects 3 patterns to hold (Int, Int, Int) but crushing into 3-tuple to fit single pattern (SI-6675) "" match { case X(b) => b } // should warn under -Xlint. Not an error because of SI-6111 ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/t6815.check b/test/files/neg/t6815.check new file mode 100644 index 0000000000..fae3819be1 --- /dev/null +++ b/test/files/neg/t6815.check @@ -0,0 +1,5 @@ +t6815.scala:15: error: stable identifier required, but Test.this.u.emptyValDef found. + Note that value emptyValDef is not stable because its type, Test.u.ValDef, is volatile. + case _: u.emptyValDef.T => // and, unlike in pos/t6185.scala, we shouldn't allow this. + ^ +one error found diff --git a/test/files/neg/t6815.scala b/test/files/neg/t6815.scala new file mode 100644 index 0000000000..ff973a7437 --- /dev/null +++ b/test/files/neg/t6815.scala @@ -0,0 +1,17 @@ +trait U { + trait ValOrDefDefApi { + def name: Any + } + type ValOrDefDef <: ValOrDefDefApi + type ValDef <: ValOrDefDef with ValDefApi { type T } + trait ValDefApi extends ValOrDefDefApi { this: ValDef => } + val emptyValDef: ValDef // the result type is volatile +} + +object Test { + val u: U = ??? + + (null: Any) match { + case _: u.emptyValDef.T => // and, unlike in pos/t6185.scala, we shouldn't allow this. + } +} diff --git a/test/files/neg/t6889.check b/test/files/neg/t6889.check new file mode 100644 index 0000000000..a77e8a010c --- /dev/null +++ b/test/files/neg/t6889.check @@ -0,0 +1,7 @@ +t6889.scala:16: error: the result type of an implicit conversion must be more specific than AnyRef + def f(x: Dingo): AnyRef = x // fail - no conversion to AnyRef + ^ +t6889.scala:17: error: an expression of type Null is ineligible for implicit conversion + var x: Int = null // fail - no conversion from Null + ^ +two errors found diff --git a/test/files/neg/t6889.scala b/test/files/neg/t6889.scala new file mode 100644 index 0000000000..ef1963669c --- /dev/null +++ b/test/files/neg/t6889.scala @@ -0,0 +1,18 @@ +package bippy { + trait Bippy[A] extends Any +} +package foo { + package object unrelated { + implicit def bippyDingo[A](x: bippy.Bippy[A]): AnyRef = Nil + } + package unrelated { + trait Unrelated + } +} + +object Test { + trait Dingo extends Any with bippy.Bippy[foo.unrelated.Unrelated] + + def f(x: Dingo): AnyRef = x // fail - no conversion to AnyRef + var x: Int = null // fail - no conversion from Null +} diff --git a/test/files/neg/t6902.check b/test/files/neg/t6902.check index 8ad7fd37f9..ed0ed75303 100644 --- a/test/files/neg/t6902.check +++ b/test/files/neg/t6902.check @@ -1,10 +1,12 @@ -t6902.scala:4: error: unreachable code +t6902.scala:4: warning: unreachable code case Some(b) => 3 // no warning was emitted ^ -t6902.scala:9: error: unreachable code +t6902.scala:9: warning: unreachable code case Some(b) => 3 // no warning was emitted ^ -t6902.scala:21: error: unreachable code +t6902.scala:21: warning: unreachable code case 1 => 3 // crash ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/t692.check b/test/files/neg/t692.check index 4149366309..0ca99717d6 100644 --- a/test/files/neg/t692.check +++ b/test/files/neg/t692.check @@ -11,7 +11,7 @@ t692.scala:13: error: class Foo takes type parameters case class BarType[T3 <: Foo](tpeT : RefType[T3]) extends ClassType[Bar[T3],Foo](FooType); ^ t692.scala:14: error: class Foo takes type parameters - implicit def typeOfBar[T4 <: Foo](implicit elem : RefType[T4]) : RefType[Bar[T4]] = + implicit def typeOfBar[T4 <: Foo](implicit elem : RefType[T4]) : RefType[Bar[T4]] = ^ t692.scala:19: error: class Foo takes type parameters class Bar[A <: Foo](implicit tpeA : Type[A]) extends Foo; diff --git a/test/files/neg/t692.scala b/test/files/neg/t692.scala index f230a6bacf..24e1d2fea3 100644 --- a/test/files/neg/t692.scala +++ b/test/files/neg/t692.scala @@ -5,15 +5,15 @@ abstract class test3 { abstract class RefType[C <: AnyRef] extends Type[C]; case class ObjectType() extends RefType[AnyRef]; abstract class ClassType[C <: Z, Z <: AnyRef](zuper : RefType[Z]) extends RefType[C]; - + case class FooType() extends ClassType[Foo,AnyRef](ObjectType()); implicit def typeOfFoo = FooType(); case class BarType[T3 <: Foo](tpeT : RefType[T3]) extends ClassType[Bar[T3],Foo](FooType); - implicit def typeOfBar[T4 <: Foo](implicit elem : RefType[T4]) : RefType[Bar[T4]] = + implicit def typeOfBar[T4 <: Foo](implicit elem : RefType[T4]) : RefType[Bar[T4]] = BarType(elem); - + class Foo[A <: AnyRef]; class Bar[A <: Foo](implicit tpeA : Type[A]) extends Foo; diff --git a/test/files/neg/t693.check b/test/files/neg/t693.check index 62325b5c60..25bd141501 100644 --- a/test/files/neg/t693.check +++ b/test/files/neg/t693.check @@ -1,4 +1,4 @@ t693.scala:4: error: x is already defined as value x - val x : Int = 10; + val x : Int = 10; ^ one error found diff --git a/test/files/neg/t693.scala b/test/files/neg/t693.scala index d2074bee38..3a9e6247a8 100644 --- a/test/files/neg/t693.scala +++ b/test/files/neg/t693.scala @@ -1,5 +1,5 @@ abstract class test4 { trait Type; val x : Type = null; - val x : Int = 10; + val x : Int = 10; } diff --git a/test/files/neg/t696b.check b/test/files/neg/t696.check index fcdb5440d8..b7bc5cdf98 100644 --- a/test/files/neg/t696b.check +++ b/test/files/neg/t696.check @@ -1,8 +1,8 @@ -t696b.scala:5: error: diverging implicit expansion for type TypeUtil0.Type[Any] +t696.scala:5: error: diverging implicit expansion for type TypeUtil0.Type[Any] starting with method WithType in object TypeUtil0 as[Any](null) ^ -t696b.scala:6: error: diverging implicit expansion for type TypeUtil0.Type[X] +t696.scala:6: error: diverging implicit expansion for type TypeUtil0.Type[X] starting with method WithType in object TypeUtil0 def foo[X]() = as[X](null) ^ diff --git a/test/files/neg/t696b.scala b/test/files/neg/t696.scala index ca76f7ef6c..ca76f7ef6c 100644 --- a/test/files/neg/t696b.scala +++ b/test/files/neg/t696.scala diff --git a/test/files/neg/t6963a.check b/test/files/neg/t6963a.check index 159896fd10..5858e7740a 100644 --- a/test/files/neg/t6963a.check +++ b/test/files/neg/t6963a.check @@ -1,5 +1,7 @@ -t6963a.scala:4: error: method scanRight in trait TraversableLike has changed semantics in version 2.9.0: +t6963a.scala:4: warning: method scanRight in trait TraversableLike has changed semantics in version 2.9.0: The behavior of `scanRight` has changed. The previous behavior can be reproduced with scanRight.reverse. List(1,2,3,4,5).scanRight(0)(_+_) ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/t6963a.scala b/test/files/neg/t6963a.scala index b3366b2557..6808e541bb 100644 --- a/test/files/neg/t6963a.scala +++ b/test/files/neg/t6963a.scala @@ -1,5 +1,5 @@ object Test { import scala.collection.mutable._ - + List(1,2,3,4,5).scanRight(0)(_+_) } diff --git a/test/files/neg/t6963b.check b/test/files/neg/t6963b.check deleted file mode 100644 index 7e205a41d0..0000000000 --- a/test/files/neg/t6963b.check +++ /dev/null @@ -1,13 +0,0 @@ -t6963b.scala:2: error: An Array will no longer match as Seq[_]. - def f1(x: Any) = x.isInstanceOf[Seq[_]] - ^ -t6963b.scala:4: error: An Array will no longer match as Seq[_]. - case _: Seq[_] => true - ^ -t6963b.scala:16: error: An Array will no longer match as Seq[_]. - case (Some(_: Seq[_]), Nil, _) => 1 - ^ -t6963b.scala:17: error: An Array will no longer match as Seq[_]. - case (None, List(_: List[_], _), _) => 2 - ^ -four errors found diff --git a/test/files/neg/t6963b.flags b/test/files/neg/t6963b.flags deleted file mode 100644 index 83caa2b147..0000000000 --- a/test/files/neg/t6963b.flags +++ /dev/null @@ -1 +0,0 @@ --Xmigration:2.7 -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t6963b.scala b/test/files/neg/t6963b.scala deleted file mode 100644 index 3cfa8f0dca..0000000000 --- a/test/files/neg/t6963b.scala +++ /dev/null @@ -1,20 +0,0 @@ -object Test { - def f1(x: Any) = x.isInstanceOf[Seq[_]] - def f2(x: Any) = x match { - case _: Seq[_] => true - case _ => false - } - - def f3(x: Any) = x match { - case _: Array[_] => true - case _ => false - } - - def f4(x: Any) = x.isInstanceOf[Traversable[_]] - - def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match { - case (Some(_: Seq[_]), Nil, _) => 1 - case (None, List(_: List[_], _), _) => 2 - case _ => 3 - } -} diff --git a/test/files/neg/t696a.check b/test/files/neg/t696a.check deleted file mode 100644 index 490fc1a571..0000000000 --- a/test/files/neg/t696a.check +++ /dev/null @@ -1,5 +0,0 @@ -t696a.scala:4: error: diverging implicit expansion for type TypeUtil0.Type[Any] -starting with method WithType in object TypeUtil0 - as[Any](null); - ^ -one error found diff --git a/test/files/neg/t696a.scala b/test/files/neg/t696a.scala deleted file mode 100644 index a06a32141a..0000000000 --- a/test/files/neg/t696a.scala +++ /dev/null @@ -1,6 +0,0 @@ -object TypeUtil0 { - trait Type[+T]; - implicit def WithType[S,T](implicit tpeS : Type[S], tpeT : Type[T]) : Type[S with T] = null - as[Any](null); - def as[T](x : Any)(implicit tpe : Type[T]) = null; -} diff --git a/test/files/neg/t696b.flags b/test/files/neg/t696b.flags deleted file mode 100644 index d564f2b1f8..0000000000 --- a/test/files/neg/t696b.flags +++ /dev/null @@ -1 +0,0 @@ --Xdivergence211
\ No newline at end of file diff --git a/test/files/neg/t7007.check b/test/files/neg/t7007.check new file mode 100644 index 0000000000..e22ecb9e4e --- /dev/null +++ b/test/files/neg/t7007.check @@ -0,0 +1,7 @@ +t7007.scala:5: error: Implementation restriction: <$anon: A => B> requires premature access to class Crash. + def this(a: Seq[A]) = this(a.collect{ case b: B => b}, a.collect{ case b: B => b}) + ^ +t7007.scala:5: error: Implementation restriction: <$anon: A => B> requires premature access to class Crash. + def this(a: Seq[A]) = this(a.collect{ case b: B => b}, a.collect{ case b: B => b}) + ^ +two errors found diff --git a/test/files/neg/t7007.scala b/test/files/neg/t7007.scala new file mode 100644 index 0000000000..e41dccf550 --- /dev/null +++ b/test/files/neg/t7007.scala @@ -0,0 +1,14 @@ +class A +class B extends A + +class Crash(b1: Seq[B], b2: Seq[B]) { + def this(a: Seq[A]) = this(a.collect{ case b: B => b}, a.collect{ case b: B => b}) +} + +object Main extends App { + + // runtime exception with either constructor + val c1 = new Crash(Seq(new B, new B)) + val c2 = new Crash(Seq(new B), Seq(new B)) + +} diff --git a/test/files/neg/t7020.check b/test/files/neg/t7020.check index a869b12363..f9600ca7fc 100644 --- a/test/files/neg/t7020.check +++ b/test/files/neg/t7020.check @@ -1,17 +1,19 @@ -t7020.scala:3: error: match may not be exhaustive. -It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List(_, _) +t7020.scala:3: warning: match may not be exhaustive. +It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List((x: Int forSome x not in (1, 2, 4, 5, 6, 7)), _), List(1, _), List(2, _), List(4, _), List(5, _), List(6, _), List(7, _), List(??, _), List(_, _) List(5) match { ^ -t7020.scala:10: error: match may not be exhaustive. -It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List(_, _) +t7020.scala:10: warning: match may not be exhaustive. +It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List((x: Int forSome x not in (1, 2, 4, 5, 6, 7)), _), List(1, _), List(2, _), List(4, _), List(5, _), List(6, _), List(7, _), List(??, _), List(_, _) List(5) match { ^ -t7020.scala:17: error: match may not be exhaustive. -It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List(_, _) +t7020.scala:17: warning: match may not be exhaustive. +It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List((x: Int forSome x not in (1, 2, 4, 5, 6, 7)), _), List(1, _), List(2, _), List(4, _), List(5, _), List(6, _), List(7, _), List(??, _), List(_, _) List(5) match { ^ -t7020.scala:24: error: match may not be exhaustive. -It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List(_, _) +t7020.scala:24: warning: match may not be exhaustive. +It would fail on the following inputs: List((x: Int forSome x not in (1, 2, 4, 5, 6, 7))), List((x: Int forSome x not in (1, 2, 4, 5, 6, 7)), _), List(1, _), List(2, _), List(4, _), List(5, _), List(6, _), List(7, _), List(??, _), List(_, _) List(5) match { ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/t7110.check b/test/files/neg/t7110.check new file mode 100644 index 0000000000..e484dc4325 --- /dev/null +++ b/test/files/neg/t7110.check @@ -0,0 +1,6 @@ +t7110.scala:2: warning: A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled. + try { ??? } // warn + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7110.flags b/test/files/neg/t7110.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/t7110.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t7110.scala b/test/files/neg/t7110.scala new file mode 100644 index 0000000000..79ac325216 --- /dev/null +++ b/test/files/neg/t7110.scala @@ -0,0 +1,6 @@ +object Test { + try { ??? } // warn + + try { ??? } finally ??? // no warn + try { ??? } catch { case _: Throwable => } // no warn +} diff --git a/test/files/neg/t715.scala b/test/files/neg/t715.scala index a5ccd567f9..87b2525a63 100644 --- a/test/files/neg/t715.scala +++ b/test/files/neg/t715.scala @@ -1,4 +1,4 @@ -package test; +package test; trait B { type Node <: NodeImpl; trait NodeImpl { diff --git a/test/files/neg/t7157.check b/test/files/neg/t7157.check new file mode 100644 index 0000000000..c6a7af9a23 --- /dev/null +++ b/test/files/neg/t7157.check @@ -0,0 +1,73 @@ +Test_2.scala:5: error: too many arguments for macro method m1_0_0: ()Unit + m1_0_0(1) + ^ +Test_2.scala:6: error: too many arguments for macro method m1_0_0: ()Unit + m1_0_0(1, 2) + ^ +Test_2.scala:7: error: too many arguments for macro method m1_0_0: ()Unit + m1_0_0(1, 2, 3) + ^ +Test_2.scala:9: error: macro applications do not support named and/or default arguments + m1_1_1() + ^ +Test_2.scala:11: error: too many arguments for macro method m1_1_1: (x: Int)Unit + m1_1_1(1, 2) + ^ +Test_2.scala:12: error: too many arguments for macro method m1_1_1: (x: Int)Unit + m1_1_1(1, 2, 3) + ^ +Test_2.scala:14: error: macro applications do not support named and/or default arguments + m1_2_2() + ^ +Test_2.scala:15: error: macro applications do not support named and/or default arguments + m1_2_2(1) + ^ +Test_2.scala:17: error: too many arguments for macro method m1_2_2: (x: Int, y: Int)Unit + m1_2_2(1, 2, 3) + ^ +Test_2.scala:24: error: macro applications do not support named and/or default arguments + m1_1_inf() + ^ +Test_2.scala:29: error: macro applications do not support named and/or default arguments + m1_2_inf() + ^ +Test_2.scala:30: error: macro applications do not support named and/or default arguments + m1_2_inf(1) + ^ +Test_2.scala:35: error: too many arguments for macro method m2_0_0: ()Unit + m2_0_0()(1) + ^ +Test_2.scala:36: error: too many arguments for macro method m2_0_0: ()Unit + m2_0_0()(1, 2) + ^ +Test_2.scala:37: error: too many arguments for macro method m2_0_0: ()Unit + m2_0_0()(1, 2, 3) + ^ +Test_2.scala:39: error: macro applications do not support named and/or default arguments + m2_1_1()() + ^ +Test_2.scala:41: error: too many arguments for macro method m2_1_1: (x: Int)Unit + m2_1_1()(1, 2) + ^ +Test_2.scala:42: error: too many arguments for macro method m2_1_1: (x: Int)Unit + m2_1_1()(1, 2, 3) + ^ +Test_2.scala:44: error: macro applications do not support named and/or default arguments + m2_2_2()() + ^ +Test_2.scala:45: error: macro applications do not support named and/or default arguments + m2_2_2()(1) + ^ +Test_2.scala:47: error: too many arguments for macro method m2_2_2: (x: Int, y: Int)Unit + m2_2_2()(1, 2, 3) + ^ +Test_2.scala:54: error: macro applications do not support named and/or default arguments + m2_1_inf()() + ^ +Test_2.scala:59: error: macro applications do not support named and/or default arguments + m2_2_inf()() + ^ +Test_2.scala:60: error: macro applications do not support named and/or default arguments + m2_2_inf()(1) + ^ +24 errors found diff --git a/test/files/neg/t7157/Impls_Macros_1.scala b/test/files/neg/t7157/Impls_Macros_1.scala new file mode 100644 index 0000000000..09f423fbab --- /dev/null +++ b/test/files/neg/t7157/Impls_Macros_1.scala @@ -0,0 +1,32 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Macros { + def impl1_0_0(c: Context)() = c.literalUnit + def impl1_1_1(c: Context)(x: c.Expr[Int]) = c.literalUnit + def impl1_2_2(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = c.literalUnit + def m1_0_0() = macro impl1_0_0 + def m1_1_1(x: Int) = macro impl1_1_1 + def m1_2_2(x: Int, y: Int) = macro impl1_2_2 + + def impl1_0_inf(c: Context)(x: c.Expr[Int]*) = c.literalUnit + def impl1_1_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int]*) = c.literalUnit + def impl1_2_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = c.literalUnit + def m1_0_inf(x: Int*) = macro impl1_0_inf + def m1_1_inf(x: Int, y: Int*) = macro impl1_1_inf + def m1_2_inf(x: Int, y: Int, z: Int*) = macro impl1_2_inf + + def impl2_0_0(c: Context)()() = c.literalUnit + def impl2_1_1(c: Context)()(x: c.Expr[Int]) = c.literalUnit + def impl2_2_2(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]) = c.literalUnit + def m2_0_0()() = macro impl2_0_0 + def m2_1_1()(x: Int) = macro impl2_1_1 + def m2_2_2()(x: Int, y: Int) = macro impl2_2_2 + + def impl2_0_inf(c: Context)()(x: c.Expr[Int]*) = c.literalUnit + def impl2_1_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]*) = c.literalUnit + def impl2_2_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = c.literalUnit + def m2_0_inf()(x: Int*) = macro impl2_0_inf + def m2_1_inf()(x: Int, y: Int*) = macro impl2_1_inf + def m2_2_inf()(x: Int, y: Int, z: Int*) = macro impl2_2_inf +}
\ No newline at end of file diff --git a/test/files/neg/t7157/Test_2.scala b/test/files/neg/t7157/Test_2.scala new file mode 100644 index 0000000000..45a6026399 --- /dev/null +++ b/test/files/neg/t7157/Test_2.scala @@ -0,0 +1,63 @@ +import Macros._ + +object Test extends App { + m1_0_0() + m1_0_0(1) + m1_0_0(1, 2) + m1_0_0(1, 2, 3) + + m1_1_1() + m1_1_1(1) + m1_1_1(1, 2) + m1_1_1(1, 2, 3) + + m1_2_2() + m1_2_2(1) + m1_2_2(1, 2) + m1_2_2(1, 2, 3) + + m1_0_inf() + m1_0_inf(1) + m1_0_inf(1, 2) + m1_0_inf(1, 2, 3) + + m1_1_inf() + m1_1_inf(1) + m1_1_inf(1, 2) + m1_1_inf(1, 2, 3) + + m1_2_inf() + m1_2_inf(1) + m1_2_inf(1, 2) + m1_2_inf(1, 2, 3) + + m2_0_0()() + m2_0_0()(1) + m2_0_0()(1, 2) + m2_0_0()(1, 2, 3) + + m2_1_1()() + m2_1_1()(1) + m2_1_1()(1, 2) + m2_1_1()(1, 2, 3) + + m2_2_2()() + m2_2_2()(1) + m2_2_2()(1, 2) + m2_2_2()(1, 2, 3) + + m2_0_inf()() + m2_0_inf()(1) + m2_0_inf()(1, 2) + m2_0_inf()(1, 2, 3) + + m2_1_inf()() + m2_1_inf()(1) + m2_1_inf()(1, 2) + m2_1_inf()(1, 2, 3) + + m2_2_inf()() + m2_2_inf()(1) + m2_2_inf()(1, 2) + m2_2_inf()(1, 2, 3) +}
\ No newline at end of file diff --git a/test/files/neg/t7166.check b/test/files/neg/t7166.check deleted file mode 100644 index c87198cb27..0000000000 --- a/test/files/neg/t7166.check +++ /dev/null @@ -1,4 +0,0 @@ -Test_2.scala:2: error: silent = true does work! - println(implicitly[Complex[Foo]]) - ^ -one error found diff --git a/test/files/neg/t7166/Impls_Macros_1.scala b/test/files/neg/t7166/Impls_Macros_1.scala deleted file mode 100644 index 62a15657c3..0000000000 --- a/test/files/neg/t7166/Impls_Macros_1.scala +++ /dev/null @@ -1,26 +0,0 @@ -import scala.reflect.macros.Context -import language.experimental.macros - -trait Complex[T] - -class Foo - -object Complex { - def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { - import c.universe._ - def shout(msg: String) = { - val cannotShutMeUp = c.asInstanceOf[scala.reflect.macros.runtime.Context].universe.currentRun.currentUnit.error _ - cannotShutMeUp(c.enclosingPosition.asInstanceOf[scala.reflect.internal.util.Position], msg) - } - try { - val complexOfT = appliedType(typeOf[Complex[_]], List(weakTypeOf[T])) - val infiniteRecursion = c.inferImplicitValue(complexOfT, silent = true) - shout("silent = true does work!") - } catch { - case ex: Exception => shout(ex.toString) - } - c.literalNull - } - - implicit def genComplex[T]: Complex[T] = macro impl[T] -} diff --git a/test/files/neg/t7166/Test_2.scala b/test/files/neg/t7166/Test_2.scala deleted file mode 100644 index dcc4593335..0000000000 --- a/test/files/neg/t7166/Test_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends App { - println(implicitly[Complex[Foo]]) -}
\ No newline at end of file diff --git a/test/files/neg/t7171.check b/test/files/neg/t7171.check index 8bdf08129b..ecd768afda 100644 --- a/test/files/neg/t7171.check +++ b/test/files/neg/t7171.check @@ -1,7 +1,6 @@ -t7171.scala:2: error: The outer reference in this type test cannot be checked at run time. +t7171.scala:2: warning: The outer reference in this type test cannot be checked at run time. final case class A() ^ -t7171.scala:9: error: The outer reference in this type test cannot be checked at run time. - case _: A => true; case _ => false - ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7171b.check b/test/files/neg/t7171b.check index bd6b2bcfb4..bf695afea7 100644 --- a/test/files/neg/t7171b.check +++ b/test/files/neg/t7171b.check @@ -1,10 +1,6 @@ -t7171b.scala:2: error: The outer reference in this type test cannot be checked at run time. +t7171b.scala:2: warning: The outer reference in this type test cannot be checked at run time. final case class A() ^ -t7171b.scala:8: error: The outer reference in this type test cannot be checked at run time. - case _: A => true; case _ => false - ^ -t7171b.scala:13: error: The outer reference in this type test cannot be checked at run time. - case _: A => true; case _ => false - ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7185.check b/test/files/neg/t7185.check deleted file mode 100644 index 46f2cc797e..0000000000 --- a/test/files/neg/t7185.check +++ /dev/null @@ -1,7 +0,0 @@ -t7185.scala:2: error: overloaded method value apply with alternatives: - (f: scala.xml.Node => Boolean)scala.xml.NodeSeq <and> - (i: Int)scala.xml.Node - cannot be applied to () - <e></e>() - ^ -one error found diff --git a/test/files/neg/t7185.scala b/test/files/neg/t7185.scala deleted file mode 100644 index 2f9284bc5f..0000000000 --- a/test/files/neg/t7185.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - <e></e>() -} diff --git a/test/files/neg/t7214neg.check b/test/files/neg/t7214neg.check new file mode 100644 index 0000000000..0660cccd02 --- /dev/null +++ b/test/files/neg/t7214neg.check @@ -0,0 +1,7 @@ +t7214neg.scala:28: error: wrong number of patterns for object Extractor offering Any: expected 1, found 0 + case Extractor() => + ^ +t7214neg.scala:28: error: wrong number of patterns for object Extractor offering Any: expected 1, found 0 + case Extractor() => + ^ +two errors found diff --git a/test/files/neg/t7214neg.scala b/test/files/neg/t7214neg.scala new file mode 100644 index 0000000000..ff1ea8082d --- /dev/null +++ b/test/files/neg/t7214neg.scala @@ -0,0 +1,57 @@ +// pattern matcher crashes here trying to synthesize an uneeded outer test. +// no-symbol does not have an owner +// at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:49) +// at scala.tools.nsc.Global.abort(Global.scala:253) +// at scala.reflect.internal.Symbols$NoSymbol.owner(Symbols.scala:3248) +// at scala.reflect.internal.Symbols$Symbol.effectiveOwner(Symbols.scala:678) +// at scala.reflect.internal.Symbols$Symbol.isDefinedInPackage(Symbols.scala:664) +// at scala.reflect.internal.TreeGen.mkAttributedSelect(TreeGen.scala:188) +// at scala.reflect.internal.TreeGen.mkAttributedRef(TreeGen.scala:124) +// at scala.tools.nsc.ast.TreeDSL$CODE$.REF(TreeDSL.scala:308) +// at scala.tools.nsc.typechecker.PatternMatching$TreeMakers$TypeTestTreeMaker$treeCondStrategy$.outerTest(PatternMatching.scala:1209) +class Crash { + type Alias = C#T + + val c = new C + val t = new c.T + + // Crash via a Typed Pattern... + (t: Any) match { + case e: Alias => + } + + // ... or via a Typed Extractor Pattern. + object Extractor { + def unapply(a: Alias): Option[Any] = None + } + (t: Any) match { + case Extractor() => + case _ => + } + + // checking that correct outer tests are applied when + // aliases for path dependent types are involved. + val c2 = new C + type CdotT = c.T + type C2dotT = c2.T + + val outerField = t.getClass.getDeclaredFields.find(_.getName contains ("outer")).get + outerField.setAccessible(true) + + (t: Any) match { + case _: C2dotT => + println(s"!!! wrong match. t.outer=${outerField.get(t)} / c2 = $c2") // this matches on 2.10.0 + case _: CdotT => + case _ => + println(s"!!! wrong match. t.outer=${outerField.get(t)} / c = $c") + } +} + +class C { + class T +} + +object Test extends App { + new Crash +} + diff --git a/test/files/neg/t7285.check b/test/files/neg/t7285.check index 108f4292a8..a38772bead 100644 --- a/test/files/neg/t7285.check +++ b/test/files/neg/t7285.check @@ -1,13 +1,15 @@ -t7285.scala:15: error: match may not be exhaustive. +t7285.scala:15: warning: match may not be exhaustive. It would fail on the following input: (Up, Down) (d1, d2) match { ^ -t7285.scala:33: error: match may not be exhaustive. +t7285.scala:33: warning: match may not be exhaustive. It would fail on the following input: Down (d1) match { ^ -t7285.scala:51: error: match may not be exhaustive. +t7285.scala:51: warning: match may not be exhaustive. It would fail on the following input: (Up, Down) (d1, d2) match { ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/t7290.check b/test/files/neg/t7290.check index 85bedbac95..ad2d0e25b0 100644 --- a/test/files/neg/t7290.check +++ b/test/files/neg/t7290.check @@ -1,10 +1,12 @@ -t7290.scala:4: error: Pattern contains duplicate alternatives: 0 +t7290.scala:4: warning: Pattern contains duplicate alternatives: 0 case 0 | 0 => 0 ^ -t7290.scala:5: error: Pattern contains duplicate alternatives: 2, 3 +t7290.scala:5: warning: Pattern contains duplicate alternatives: 2, 3 case 2 | 2 | 2 | 3 | 2 | 3 => 0 ^ -t7290.scala:6: error: Pattern contains duplicate alternatives: 4 +t7290.scala:6: warning: Pattern contains duplicate alternatives: 4 case 4 | (_ @ 4) => 0 ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/t7292-deprecation.check b/test/files/neg/t7292-deprecation.check new file mode 100644 index 0000000000..17f010dfdf --- /dev/null +++ b/test/files/neg/t7292-deprecation.check @@ -0,0 +1,12 @@ +t7292-deprecation.scala:2: warning: Octal escape literals are deprecated, use \u0000 instead. + val chr1 = '\0' + ^ +t7292-deprecation.scala:3: warning: Octal escape literals are deprecated, use \u0053 instead. + val str1 = "abc\123456" + ^ +t7292-deprecation.scala:4: warning: Octal escape literals are deprecated, use \n instead. + val lf = '\012' + ^ +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/t7292-deprecation.flags b/test/files/neg/t7292-deprecation.flags new file mode 100644 index 0000000000..7de3c0f3ee --- /dev/null +++ b/test/files/neg/t7292-deprecation.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation diff --git a/test/files/neg/t7292-deprecation.scala b/test/files/neg/t7292-deprecation.scala new file mode 100644 index 0000000000..d857f0e1ec --- /dev/null +++ b/test/files/neg/t7292-deprecation.scala @@ -0,0 +1,5 @@ +object OctalEscapes { + val chr1 = '\0' + val str1 = "abc\123456" + val lf = '\012' +} diff --git a/test/files/neg/t7292-removal.check b/test/files/neg/t7292-removal.check new file mode 100644 index 0000000000..1cd59b0992 --- /dev/null +++ b/test/files/neg/t7292-removal.check @@ -0,0 +1,10 @@ +t7292-removal.scala:2: error: Octal escape literals are unsupported, use \u0000 instead. + val chr1 = '\0' + ^ +t7292-removal.scala:3: error: Octal escape literals are unsupported, use \u0053 instead. + val str1 = "abc\123456" + ^ +t7292-removal.scala:4: error: Octal escape literals are unsupported, use \n instead. + val lf = '\012' + ^ +three errors found diff --git a/test/files/neg/t7292-removal.flags b/test/files/neg/t7292-removal.flags new file mode 100644 index 0000000000..29f4ede37a --- /dev/null +++ b/test/files/neg/t7292-removal.flags @@ -0,0 +1 @@ +-Xfuture diff --git a/test/files/neg/t7292-removal.scala b/test/files/neg/t7292-removal.scala new file mode 100644 index 0000000000..d857f0e1ec --- /dev/null +++ b/test/files/neg/t7292-removal.scala @@ -0,0 +1,5 @@ +object OctalEscapes { + val chr1 = '\0' + val str1 = "abc\123456" + val lf = '\012' +} diff --git a/test/files/neg/t7294.check b/test/files/neg/t7294.check new file mode 100644 index 0000000000..f15289c1c0 --- /dev/null +++ b/test/files/neg/t7294.check @@ -0,0 +1,6 @@ +t7294.scala:4: warning: fruitless type test: a value of type (Int, Int) cannot also be a Seq[A] + (1, 2) match { case Seq() => 0; case _ => 1 } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7294.flags b/test/files/neg/t7294.flags new file mode 100644 index 0000000000..3f3381a45b --- /dev/null +++ b/test/files/neg/t7294.flags @@ -0,0 +1 @@ +-Xfuture -Xfatal-warnings diff --git a/test/files/neg/t7294.scala b/test/files/neg/t7294.scala new file mode 100644 index 0000000000..335d071124 --- /dev/null +++ b/test/files/neg/t7294.scala @@ -0,0 +1,5 @@ +object Test { + // Treat TupleN as final under -Xfuture for the for the purposes + // of the "fruitless type test" warning. + (1, 2) match { case Seq() => 0; case _ => 1 } +} diff --git a/test/files/neg/t7294b.check b/test/files/neg/t7294b.check new file mode 100644 index 0000000000..0033b72125 --- /dev/null +++ b/test/files/neg/t7294b.check @@ -0,0 +1,6 @@ +t7294b.scala:1: warning: inheritance from class Tuple2 in package scala is deprecated: Tuples will be made final in a future version. +class C extends Tuple2[Int, Int](0, 0) + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7294b.flags b/test/files/neg/t7294b.flags new file mode 100644 index 0000000000..d1b831ea87 --- /dev/null +++ b/test/files/neg/t7294b.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t7294b.scala b/test/files/neg/t7294b.scala new file mode 100644 index 0000000000..2ab86a8058 --- /dev/null +++ b/test/files/neg/t7294b.scala @@ -0,0 +1 @@ +class C extends Tuple2[Int, Int](0, 0)
\ No newline at end of file diff --git a/test/files/neg/t7324.check b/test/files/neg/t7324.check new file mode 100644 index 0000000000..586947d5e7 --- /dev/null +++ b/test/files/neg/t7324.check @@ -0,0 +1,4 @@ +t7324.scala:2: error: Platform restriction: a parameter list's length cannot exceed 254. +class Bar( + ^ +one error found diff --git a/test/files/neg/t7324.scala b/test/files/neg/t7324.scala new file mode 100644 index 0000000000..81d7674d68 --- /dev/null +++ b/test/files/neg/t7324.scala @@ -0,0 +1,57 @@ +object Bar extends App +class Bar( +_1: Int, _2: Int, _3: Int, _4: Int, _5: Int, _6: Int, _7: Int, _8: Int, _9: Int, _10: Int, +_11: Int, _12: Int, _13: Int, _14: Int, _15: Int, _16: Int, _17: Int, _18: Int, _19: Int, _20: Int, +_21: Int, _22: Int, _23: Int, _24: Int, _25: Int, _26: Int, _27: Int, _28: Int, _29: Int, _30: Int, +_31: Int, _32: Int, _33: Int, _34: Int, _35: Int, _36: Int, _37: Int, _38: Int, _39: Int, _40: Int, +_41: Int, _42: Int, _43: Int, _44: Int, _45: Int, _46: Int, _47: Int, _48: Int, _49: Int, _50: Int, +_51: Int, _52: Int, _53: Int, _54: Int, _55: Int, _56: Int, _57: Int, _58: Int, _59: Int, _60: Int, +_61: Int, _62: Int, _63: Int, _64: Int, _65: Int, _66: Int, _67: Int, _68: Int, _69: Int, _70: Int, +_71: Int, _72: Int, _73: Int, _74: Int, _75: Int, _76: Int, _77: Int, _78: Int, _79: Int, _80: Int, +_81: Int, _82: Int, _83: Int, _84: Int, _85: Int, _86: Int, _87: Int, _88: Int, _89: Int, _90: Int, +_91: Int, _92: Int, _93: Int, _94: Int, _95: Int, _96: Int, _97: Int, _98: Int, _99: Int, _100: Int, +_101: Int, _102: Int, _103: Int, _104: Int, _105: Int, _106: Int, _107: Int, _108: Int, _109: Int, _110: Int, +_111: Int, _112: Int, _113: Int, _114: Int, _115: Int, _116: Int, _117: Int, _118: Int, _119: Int, _120: Int, +_121: Int, _122: Int, _123: Int, _124: Int, _125: Int, _126: Int, _127: Int, _128: Int, _129: Int, _130: Int, +_131: Int, _132: Int, _133: Int, _134: Int, _135: Int, _136: Int, _137: Int, _138: Int, _139: Int, _140: Int, +_141: Int, _142: Int, _143: Int, _144: Int, _145: Int, _146: Int, _147: Int, _148: Int, _149: Int, _150: Int, +_151: Int, _152: Int, _153: Int, _154: Int, _155: Int, _156: Int, _157: Int, _158: Int, _159: Int, _160: Int, +_161: Int, _162: Int, _163: Int, _164: Int, _165: Int, _166: Int, _167: Int, _168: Int, _169: Int, _170: Int, +_171: Int, _172: Int, _173: Int, _174: Int, _175: Int, _176: Int, _177: Int, _178: Int, _179: Int, _180: Int, +_181: Int, _182: Int, _183: Int, _184: Int, _185: Int, _186: Int, _187: Int, _188: Int, _189: Int, _190: Int, +_191: Int, _192: Int, _193: Int, _194: Int, _195: Int, _196: Int, _197: Int, _198: Int, _199: Int, _200: Int, +_201: Int, _202: Int, _203: Int, _204: Int, _205: Int, _206: Int, _207: Int, _208: Int, _209: Int, _210: Int, +_211: Int, _212: Int, _213: Int, _214: Int, _215: Int, _216: Int, _217: Int, _218: Int, _219: Int, _220: Int, +_221: Int, _222: Int, _223: Int, _224: Int, _225: Int, _226: Int, _227: Int, _228: Int, _229: Int, _230: Int, +_231: Int, _232: Int, _233: Int, _234: Int, _235: Int, _236: Int, _237: Int, _238: Int, _239: Int, _240: Int, +_241: Int, _242: Int, _243: Int, _244: Int, _245: Int, _246: Int, _247: Int, _248: Int, _249: Int, _250: Int, +_251: Int, _252: Int, _253: Int, _254: Int, _255: Int +) + +class BarOK( +_1: Int, _2: Int, _3: Int, _4: Int, _5: Int, _6: Int, _7: Int, _8: Int, _9: Int, _10: Int, +_11: Int, _12: Int, _13: Int, _14: Int, _15: Int, _16: Int, _17: Int, _18: Int, _19: Int, _20: Int, +_21: Int, _22: Int, _23: Int, _24: Int, _25: Int, _26: Int, _27: Int, _28: Int, _29: Int, _30: Int, +_31: Int, _32: Int, _33: Int, _34: Int, _35: Int, _36: Int, _37: Int, _38: Int, _39: Int, _40: Int, +_41: Int, _42: Int, _43: Int, _44: Int, _45: Int, _46: Int, _47: Int, _48: Int, _49: Int, _50: Int, +_51: Int, _52: Int, _53: Int, _54: Int, _55: Int, _56: Int, _57: Int, _58: Int, _59: Int, _60: Int, +_61: Int, _62: Int, _63: Int, _64: Int, _65: Int, _66: Int, _67: Int, _68: Int, _69: Int, _70: Int, +_71: Int, _72: Int, _73: Int, _74: Int, _75: Int, _76: Int, _77: Int, _78: Int, _79: Int, _80: Int, +_81: Int, _82: Int, _83: Int, _84: Int, _85: Int, _86: Int, _87: Int, _88: Int, _89: Int, _90: Int, +_91: Int, _92: Int, _93: Int, _94: Int, _95: Int, _96: Int, _97: Int, _98: Int, _99: Int, _100: Int, +_101: Int, _102: Int, _103: Int, _104: Int, _105: Int, _106: Int, _107: Int, _108: Int, _109: Int, _110: Int, +_111: Int, _112: Int, _113: Int, _114: Int, _115: Int, _116: Int, _117: Int, _118: Int, _119: Int, _120: Int, +_121: Int, _122: Int, _123: Int, _124: Int, _125: Int, _126: Int, _127: Int, _128: Int, _129: Int, _130: Int, +_131: Int, _132: Int, _133: Int, _134: Int, _135: Int, _136: Int, _137: Int, _138: Int, _139: Int, _140: Int, +_141: Int, _142: Int, _143: Int, _144: Int, _145: Int, _146: Int, _147: Int, _148: Int, _149: Int, _150: Int, +_151: Int, _152: Int, _153: Int, _154: Int, _155: Int, _156: Int, _157: Int, _158: Int, _159: Int, _160: Int, +_161: Int, _162: Int, _163: Int, _164: Int, _165: Int, _166: Int, _167: Int, _168: Int, _169: Int, _170: Int, +_171: Int, _172: Int, _173: Int, _174: Int, _175: Int, _176: Int, _177: Int, _178: Int, _179: Int, _180: Int, +_181: Int, _182: Int, _183: Int, _184: Int, _185: Int, _186: Int, _187: Int, _188: Int, _189: Int, _190: Int, +_191: Int, _192: Int, _193: Int, _194: Int, _195: Int, _196: Int, _197: Int, _198: Int, _199: Int, _200: Int, +_201: Int, _202: Int, _203: Int, _204: Int, _205: Int, _206: Int, _207: Int, _208: Int, _209: Int, _210: Int, +_211: Int, _212: Int, _213: Int, _214: Int, _215: Int, _216: Int, _217: Int, _218: Int, _219: Int, _220: Int, +_221: Int, _222: Int, _223: Int, _224: Int, _225: Int, _226: Int, _227: Int, _228: Int, _229: Int, _230: Int, +_231: Int, _232: Int, _233: Int, _234: Int, _235: Int, _236: Int, _237: Int, _238: Int, _239: Int, _240: Int, +_241: Int, _242: Int, _243: Int, _244: Int, _245: Int, _246: Int, _247: Int, _248: Int, _249: Int, _250: Int, +_251: Int, _252: Int, _253: Int, _254: Int) diff --git a/test/files/neg/t7325.check b/test/files/neg/t7325.check index 709ab6db3e..d2c40f4df8 100644 --- a/test/files/neg/t7325.check +++ b/test/files/neg/t7325.check @@ -1,19 +1,19 @@ -t7325.scala:2: error: percent signs not directly following splicees must be escaped +t7325.scala:2: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%") ^ -t7325.scala:4: error: percent signs not directly following splicees must be escaped +t7325.scala:4: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%%%") ^ -t7325.scala:6: error: percent signs not directly following splicees must be escaped +t7325.scala:6: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%%%%%") ^ t7325.scala:16: error: wrong conversion string println(f"${0}%") ^ -t7325.scala:19: error: percent signs not directly following splicees must be escaped +t7325.scala:19: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"${0}%%%d") ^ -t7325.scala:21: error: percent signs not directly following splicees must be escaped +t7325.scala:21: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"${0}%%%%%d") ^ 6 errors found diff --git a/test/files/neg/t7369.check b/test/files/neg/t7369.check index 4f101e145a..a4e99f496e 100644 --- a/test/files/neg/t7369.check +++ b/test/files/neg/t7369.check @@ -1,13 +1,15 @@ -t7369.scala:6: error: unreachable code +t7369.scala:6: warning: unreachable code case Tuple1(X) => // unreachable ^ -t7369.scala:13: error: unreachable code +t7369.scala:13: warning: unreachable code case Tuple1(true) => // unreachable ^ -t7369.scala:31: error: unreachable code +t7369.scala:31: warning: unreachable code case Tuple1(X) => // unreachable ^ -t7369.scala:40: error: unreachable code +t7369.scala:40: warning: unreachable code case Tuple1(null) => // unreachable ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/pending/neg/plugin-after-terminal.check b/test/files/neg/t7494-after-terminal.check index 096efe09cd..096efe09cd 100644 --- a/test/pending/neg/plugin-after-terminal.check +++ b/test/files/neg/t7494-after-terminal.check diff --git a/test/pending/neg/plugin-after-terminal/src/ThePlugin.scala b/test/files/neg/t7494-after-terminal/ThePlugin.scala index 2a4607392f..f3c913086e 100644 --- a/test/pending/neg/plugin-after-terminal/src/ThePlugin.scala +++ b/test/files/neg/t7494-after-terminal/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { val name = "afterterminal" val description = "Declares one plugin that wants to be after the terminal phase" val components = List[PluginComponent](thePhase) - + private object thePhase extends PluginComponent { val global = ThePlugin.this.global @@ -20,9 +20,9 @@ class ThePlugin(val global: Global) extends Plugin { val phaseName = ThePlugin.this.name - def newPhase(prev: Phase) = new ThePhase(prev) + def newPhase(prev: Phase) = new ThePhase(prev) } - + private class ThePhase(prev: Phase) extends Phase(prev) { def name = ThePlugin.this.name def run {} diff --git a/test/files/neg/t7494-after-terminal/sample_2.flags b/test/files/neg/t7494-after-terminal/sample_2.flags new file mode 100644 index 0000000000..b8a476e361 --- /dev/null +++ b/test/files/neg/t7494-after-terminal/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:afterterminal diff --git a/test/files/neg/t7494-after-terminal/sample_2.scala b/test/files/neg/t7494-after-terminal/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-after-terminal/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/pending/neg/plugin-before-parser/misc/scalac-plugin.xml b/test/files/neg/t7494-after-terminal/scalac-plugin.xml index 90ff27dc2a..2558d6fd03 100644 --- a/test/pending/neg/plugin-before-parser/misc/scalac-plugin.xml +++ b/test/files/neg/t7494-after-terminal/scalac-plugin.xml @@ -1,5 +1,5 @@ <plugin> - <name>beforeparser</name> + <name>ignored</name> <classname>scala.test.plugins.ThePlugin</classname> </plugin> diff --git a/test/pending/neg/plugin-before-parser.check b/test/files/neg/t7494-before-parser.check index 9a407923b1..9a407923b1 100644 --- a/test/pending/neg/plugin-before-parser.check +++ b/test/files/neg/t7494-before-parser.check diff --git a/test/pending/neg/plugin-before-parser/src/ThePlugin.scala b/test/files/neg/t7494-before-parser/ThePlugin.scala index 7ca896650d..8714a55dc4 100644 --- a/test/pending/neg/plugin-before-parser/src/ThePlugin.scala +++ b/test/files/neg/t7494-before-parser/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { val name = "beforeparser" val description = "Declares one plugin that wants to be before the parser phase" val components = List[PluginComponent](thePhase) - + private object thePhase extends PluginComponent { val global = ThePlugin.this.global @@ -21,9 +21,9 @@ class ThePlugin(val global: Global) extends Plugin { val phaseName = ThePlugin.this.name - def newPhase(prev: Phase) = new ThePhase(prev) + def newPhase(prev: Phase) = new ThePhase(prev) } - + private class ThePhase(prev: Phase) extends Phase(prev) { def name = ThePlugin.this.name def run {} diff --git a/test/files/neg/t7494-before-parser/sample_2.flags b/test/files/neg/t7494-before-parser/sample_2.flags new file mode 100644 index 0000000000..0c92fc8a06 --- /dev/null +++ b/test/files/neg/t7494-before-parser/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:beforeparser diff --git a/test/files/neg/t7494-before-parser/sample_2.scala b/test/files/neg/t7494-before-parser/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-before-parser/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/pending/neg/plugin-after-terminal/misc/scalac-plugin.xml b/test/files/neg/t7494-before-parser/scalac-plugin.xml index 90ff27dc2a..90ff27dc2a 100644 --- a/test/pending/neg/plugin-after-terminal/misc/scalac-plugin.xml +++ b/test/files/neg/t7494-before-parser/scalac-plugin.xml diff --git a/test/files/neg/t7494-multi-right-after.check b/test/files/neg/t7494-multi-right-after.check new file mode 100644 index 0000000000..151d177414 --- /dev/null +++ b/test/files/neg/t7494-multi-right-after.check @@ -0,0 +1 @@ +error: Multiple phases want to run right after explicitouter; followers: erasure,multi-rafter; created phase-order.dot diff --git a/test/pending/neg/plugin-multiple-rafter/src/ThePlugin.scala b/test/files/neg/t7494-multi-right-after/ThePlugin.scala index 819176fa88..4c761517c1 100644 --- a/test/pending/neg/plugin-multiple-rafter/src/ThePlugin.scala +++ b/test/files/neg/t7494-multi-right-after/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { val name = "multi-rafter" val description = "" val components = List[PluginComponent](thePhase) - + private object thePhase extends PluginComponent { val global = ThePlugin.this.global @@ -20,9 +20,9 @@ class ThePlugin(val global: Global) extends Plugin { override val runsRightAfter = Some("explicitouter") val phaseName = ThePlugin.this.name - def newPhase(prev: Phase) = new ThePhase(prev) + def newPhase(prev: Phase) = new ThePhase(prev) } - + private class ThePhase(prev: Phase) extends Phase(prev) { def name = ThePlugin.this.name def run {} diff --git a/test/files/neg/t7494-multi-right-after/sample_2.flags b/test/files/neg/t7494-multi-right-after/sample_2.flags new file mode 100644 index 0000000000..9273fb98d7 --- /dev/null +++ b/test/files/neg/t7494-multi-right-after/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:multi-rafter diff --git a/test/files/neg/t7494-multi-right-after/sample_2.scala b/test/files/neg/t7494-multi-right-after/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-multi-right-after/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/pending/neg/plugin-cyclic-dependency/misc/scalac-plugin.xml b/test/files/neg/t7494-multi-right-after/scalac-plugin.xml index 90ff27dc2a..2558d6fd03 100644 --- a/test/pending/neg/plugin-cyclic-dependency/misc/scalac-plugin.xml +++ b/test/files/neg/t7494-multi-right-after/scalac-plugin.xml @@ -1,5 +1,5 @@ <plugin> - <name>beforeparser</name> + <name>ignored</name> <classname>scala.test.plugins.ThePlugin</classname> </plugin> diff --git a/test/files/neg/t7494-no-options.check b/test/files/neg/t7494-no-options.check new file mode 100644 index 0000000000..0bde84c96c --- /dev/null +++ b/test/files/neg/t7494-no-options.check @@ -0,0 +1,39 @@ +error: Error: ploogin takes no options + phase name id description + ---------- -- ----------- + parser 1 parse source into ASTs, perform simple desugaring + namer 2 resolve names, attach symbols to named trees +packageobjects 3 load package objects + typer 4 the meat and potatoes: type the trees + patmat 5 translate match expressions +superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code +#partest !-optimise + jvm 23 generate JVM bytecode + ploogin 24 A sample phase that does so many things it's kind of hard... + terminal 25 the last phase during a compilation run +#partest -optimise + inliner 23 optimization: do inlining +inlinehandlers 24 optimization: inline exception handlers + closelim 25 optimization: eliminate uncalled closures + constopt 26 optimization: optimize null and other constants + dce 27 optimization: eliminate dead code + jvm 28 generate JVM bytecode + ploogin 29 A sample phase that does so many things it's kind of hard... + terminal 30 the last phase during a compilation run +#partest diff --git a/test/files/neg/t7494-no-options/ploogin_1.scala b/test/files/neg/t7494-no-options/ploogin_1.scala new file mode 100644 index 0000000000..ed6adfc1cf --- /dev/null +++ b/test/files/neg/t7494-no-options/ploogin_1.scala @@ -0,0 +1,31 @@ + +package t6446 + +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) extends Plugin { + import global._ + + val name = "ploogin" + 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) { + // kewl kode + } + } + } +} diff --git a/test/files/neg/t7494-no-options/sample_2.flags b/test/files/neg/t7494-no-options/sample_2.flags new file mode 100644 index 0000000000..7f0f7afe48 --- /dev/null +++ b/test/files/neg/t7494-no-options/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xshow-phases -P:ploogin:inploog diff --git a/test/files/neg/t7494-no-options/sample_2.scala b/test/files/neg/t7494-no-options/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-no-options/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7494-no-options/scalac-plugin.xml b/test/files/neg/t7494-no-options/scalac-plugin.xml new file mode 100644 index 0000000000..e849bb5919 --- /dev/null +++ b/test/files/neg/t7494-no-options/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> +<name>sample-plugin</name> +<classname>t6446.Ploogin</classname> +</plugin> diff --git a/test/files/neg/t7494-right-after-before.check b/test/files/neg/t7494-right-after-before.check new file mode 100644 index 0000000000..7e83daab4a --- /dev/null +++ b/test/files/neg/t7494-right-after-before.check @@ -0,0 +1 @@ +error: Phase erasure can't follow explicitouter, created phase-order.dot diff --git a/test/pending/neg/plugin-rafter-before-1/src/ThePlugin.scala b/test/files/neg/t7494-right-after-before/ThePlugin.scala index 81ba85ae80..c42a914066 100644 --- a/test/pending/neg/plugin-rafter-before-1/src/ThePlugin.scala +++ b/test/files/neg/t7494-right-after-before/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { val name = "rafter-before-1" val description = "" val components = List[PluginComponent](thePhase1) - + private object thePhase1 extends PluginComponent { val global = ThePlugin.this.global @@ -20,9 +20,9 @@ class ThePlugin(val global: Global) extends Plugin { override val runsBefore = List[String]("erasure") val phaseName = ThePlugin.this.name - def newPhase(prev: Phase) = new ThePhase(prev) + def newPhase(prev: Phase) = new ThePhase(prev) } - + private class ThePhase(prev: Phase) extends Phase(prev) { def name = ThePlugin.this.name def run {} diff --git a/test/files/neg/t7494-right-after-before/sample_2.flags b/test/files/neg/t7494-right-after-before/sample_2.flags new file mode 100644 index 0000000000..97d0f5b5f6 --- /dev/null +++ b/test/files/neg/t7494-right-after-before/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:rafter-before-1 diff --git a/test/files/neg/t7494-right-after-before/sample_2.scala b/test/files/neg/t7494-right-after-before/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-right-after-before/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/pending/neg/plugin-multiple-rafter/misc/scalac-plugin.xml b/test/files/neg/t7494-right-after-before/scalac-plugin.xml index 90ff27dc2a..2558d6fd03 100644 --- a/test/pending/neg/plugin-multiple-rafter/misc/scalac-plugin.xml +++ b/test/files/neg/t7494-right-after-before/scalac-plugin.xml @@ -1,5 +1,5 @@ <plugin> - <name>beforeparser</name> + <name>ignored</name> <classname>scala.test.plugins.ThePlugin</classname> </plugin> diff --git a/test/pending/neg/plugin-rightafter-terminal.check b/test/files/neg/t7494-right-after-terminal.check index 6fe4f63c82..6fe4f63c82 100644 --- a/test/pending/neg/plugin-rightafter-terminal.check +++ b/test/files/neg/t7494-right-after-terminal.check diff --git a/test/pending/neg/plugin-rightafter-terminal/src/ThePlugin.scala b/test/files/neg/t7494-right-after-terminal/ThePlugin.scala index 9d6d30b327..47dd06ec8a 100644 --- a/test/pending/neg/plugin-rightafter-terminal/src/ThePlugin.scala +++ b/test/files/neg/t7494-right-after-terminal/ThePlugin.scala @@ -12,18 +12,18 @@ class ThePlugin(val global: Global) extends Plugin { val name = "rightafterterminal" val description = "Declares one plugin that wants to be right after the terminal phase" val components = List[PluginComponent](thePhase) - + private object thePhase extends PluginComponent { val global = ThePlugin.this.global val runsAfter = List[String]() override val runsRightAfter = Some("terminal") - + val phaseName = ThePlugin.this.name - def newPhase(prev: Phase) = new ThePhase(prev) + def newPhase(prev: Phase) = new ThePhase(prev) } - + private class ThePhase(prev: Phase) extends Phase(prev) { def name = ThePlugin.this.name def run {} diff --git a/test/files/neg/t7494-right-after-terminal/sample_2.flags b/test/files/neg/t7494-right-after-terminal/sample_2.flags new file mode 100644 index 0000000000..da046ba5f1 --- /dev/null +++ b/test/files/neg/t7494-right-after-terminal/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:rightafterterminal diff --git a/test/files/neg/t7494-right-after-terminal/sample_2.scala b/test/files/neg/t7494-right-after-terminal/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-right-after-terminal/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/pending/neg/plugin-rafter-before-1/misc/scalac-plugin.xml b/test/files/neg/t7494-right-after-terminal/scalac-plugin.xml index 90ff27dc2a..2558d6fd03 100644 --- a/test/pending/neg/plugin-rafter-before-1/misc/scalac-plugin.xml +++ b/test/files/neg/t7494-right-after-terminal/scalac-plugin.xml @@ -1,5 +1,5 @@ <plugin> - <name>beforeparser</name> + <name>ignored</name> <classname>scala.test.plugins.ThePlugin</classname> </plugin> diff --git a/test/files/neg/t7501.check b/test/files/neg/t7501.check new file mode 100644 index 0000000000..2ded07c7ed --- /dev/null +++ b/test/files/neg/t7501.check @@ -0,0 +1,7 @@ +t7501_2.scala:2: error: value name is not a member of A + def foo(a: A) = a.name + ^ +t7501_2.scala:4: error: not found: type X + type TP = X // already failed before this fix + ^ +two errors found diff --git a/test/files/neg/t7501/t7501_1.scala b/test/files/neg/t7501/t7501_1.scala new file mode 100644 index 0000000000..323c327623 --- /dev/null +++ b/test/files/neg/t7501/t7501_1.scala @@ -0,0 +1,12 @@ +object Test2 { + def test[X](name: String) = 12 +} +class strangeTest(x: Int) extends scala.annotation.StaticAnnotation + +trait A { + // When picking the type of `test`, the value parameter + // `x` was pickled with the owner `trait A`. On unpickling, + // it was taken to be a member! + @strangeTest(Test2.test("test")) + def test(x: String): Unit +} diff --git a/test/files/neg/t7501/t7501_2.scala b/test/files/neg/t7501/t7501_2.scala new file mode 100644 index 0000000000..044caea3c3 --- /dev/null +++ b/test/files/neg/t7501/t7501_2.scala @@ -0,0 +1,5 @@ +object Test { + def foo(a: A) = a.name + + type TP = X // already failed before this fix +} diff --git a/test/files/neg/t7519.check b/test/files/neg/t7519.check new file mode 100644 index 0000000000..164d67f595 --- /dev/null +++ b/test/files/neg/t7519.check @@ -0,0 +1,7 @@ +t7519.scala:5: error: could not find implicit value for parameter nada: Nothing + locally(0 : String) // was: "value conversion is not a member of C.this.C" + ^ +t7519.scala:15: error: could not find implicit value for parameter nada: Nothing + locally(0 : String) // was: "value conversion is not a member of U" + ^ +two errors found diff --git a/test/files/neg/t7519.scala b/test/files/neg/t7519.scala new file mode 100644 index 0000000000..aea0f35d8e --- /dev/null +++ b/test/files/neg/t7519.scala @@ -0,0 +1,18 @@ +class C { + implicit def conversion(m: Int)(implicit nada: Nothing): String = ??? + + class C { // rename class to get correct error, can't find implicit: Nothing. + locally(0 : String) // was: "value conversion is not a member of C.this.C" + } +} + +object Test2 { + trait T; trait U + new T { + implicit def conversion(m: Int)(implicit nada: Nothing): String = ??? + + new U { // nested anonymous classes also share a name. + locally(0 : String) // was: "value conversion is not a member of U" + } + } +} diff --git a/test/files/neg/t7622-cyclic-dependency.check b/test/files/neg/t7622-cyclic-dependency.check new file mode 100644 index 0000000000..3546964f5f --- /dev/null +++ b/test/files/neg/t7622-cyclic-dependency.check @@ -0,0 +1 @@ +error: Cycle in phase dependencies detected at cyclicdependency1, created phase-cycle.dot diff --git a/test/pending/neg/plugin-cyclic-dependency/src/ThePlugin.scala b/test/files/neg/t7622-cyclic-dependency/ThePlugin.scala index bd94ce60d7..35c0ff8f53 100644 --- a/test/pending/neg/plugin-cyclic-dependency/src/ThePlugin.scala +++ b/test/files/neg/t7622-cyclic-dependency/ThePlugin.scala @@ -12,7 +12,7 @@ class ThePlugin(val global: Global) extends Plugin { val name = "cyclicdependency" val description = "Declares two phases that have a cyclic dependency" val components = List[PluginComponent](thePhase1,thePhase2) - + private object thePhase1 extends PluginComponent { val global = ThePlugin.this.global @@ -20,9 +20,9 @@ class ThePlugin(val global: Global) extends Plugin { val phaseName = ThePlugin.this.name + "1" - def newPhase(prev: Phase) = new ThePhase(prev) + def newPhase(prev: Phase) = new ThePhase(prev, phaseName) } - + private object thePhase2 extends PluginComponent { val global = ThePlugin.this.global @@ -30,11 +30,10 @@ class ThePlugin(val global: Global) extends Plugin { val phaseName = ThePlugin.this.name + "2" - def newPhase(prev: Phase) = new ThePhase(prev) + def newPhase(prev: Phase) = new ThePhase(prev, phaseName) } - - private class ThePhase(prev: Phase) extends Phase(prev) { - def name = ThePlugin.this.name + + private class ThePhase(prev: Phase, val name: String) extends Phase(prev) { def run {} } } diff --git a/test/files/neg/t7622-cyclic-dependency/sample_2.flags b/test/files/neg/t7622-cyclic-dependency/sample_2.flags new file mode 100644 index 0000000000..db25b88a12 --- /dev/null +++ b/test/files/neg/t7622-cyclic-dependency/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:cyclicdependency diff --git a/test/files/neg/t7622-cyclic-dependency/sample_2.scala b/test/files/neg/t7622-cyclic-dependency/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7622-cyclic-dependency/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7622-cyclic-dependency/scalac-plugin.xml b/test/files/neg/t7622-cyclic-dependency/scalac-plugin.xml new file mode 100644 index 0000000000..2558d6fd03 --- /dev/null +++ b/test/files/neg/t7622-cyclic-dependency/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>ignored</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/files/neg/t7622-missing-dependency.check b/test/files/neg/t7622-missing-dependency.check new file mode 100644 index 0000000000..a0d0e30870 --- /dev/null +++ b/test/files/neg/t7622-missing-dependency.check @@ -0,0 +1,2 @@ +error: Phase 'myplugin' requires: List(missing) +one error found diff --git a/test/files/neg/t7622-missing-dependency/ThePlugin.scala b/test/files/neg/t7622-missing-dependency/ThePlugin.scala new file mode 100644 index 0000000000..fa634a64c1 --- /dev/null +++ b/test/files/neg/t7622-missing-dependency/ThePlugin.scala @@ -0,0 +1,33 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "myplugin" + val description = "Declares one plugin with a missing requirement" + val components = List[PluginComponent](thePhase) + + private object thePhase extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]("typer") + + val phaseName = ThePlugin.this.name + + override val requires = List("missing") + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = thePhase.phaseName + def run {} + } +} + diff --git a/test/files/neg/t7622-missing-dependency/sample_2.flags b/test/files/neg/t7622-missing-dependency/sample_2.flags new file mode 100644 index 0000000000..d69035100e --- /dev/null +++ b/test/files/neg/t7622-missing-dependency/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:myplugin diff --git a/test/files/neg/t7622-missing-dependency/sample_2.scala b/test/files/neg/t7622-missing-dependency/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7622-missing-dependency/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7622-missing-dependency/scalac-plugin.xml b/test/files/neg/t7622-missing-dependency/scalac-plugin.xml new file mode 100644 index 0000000000..3c14061dce --- /dev/null +++ b/test/files/neg/t7622-missing-dependency/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>myplugin</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/files/neg/t7622-missing-required.check b/test/files/neg/t7622-missing-required.check new file mode 100644 index 0000000000..5982178581 --- /dev/null +++ b/test/files/neg/t7622-missing-required.check @@ -0,0 +1,2 @@ +error: Missing required plugin: special-plugin +one error found diff --git a/test/files/neg/t7622-missing-required.flags b/test/files/neg/t7622-missing-required.flags new file mode 100644 index 0000000000..65deac6feb --- /dev/null +++ b/test/files/neg/t7622-missing-required.flags @@ -0,0 +1 @@ +-Xplugin-require:special-plugin diff --git a/test/files/neg/t7622-missing-required.scala b/test/files/neg/t7622-missing-required.scala new file mode 100644 index 0000000000..a0ba487b24 --- /dev/null +++ b/test/files/neg/t7622-missing-required.scala @@ -0,0 +1,4 @@ + +// the amazing features of this trait +// are unlocked by compiling with a special plugin. +trait Amazing diff --git a/test/files/neg/t7622-multi-followers.check b/test/files/neg/t7622-multi-followers.check new file mode 100644 index 0000000000..d123853a5b --- /dev/null +++ b/test/files/neg/t7622-multi-followers.check @@ -0,0 +1 @@ +error: Multiple phases want to run right after parser; followers: multi1,multi2; created phase-order.dot diff --git a/test/files/neg/t7622-multi-followers/ThePlugin.scala b/test/files/neg/t7622-multi-followers/ThePlugin.scala new file mode 100644 index 0000000000..cbd28d0c23 --- /dev/null +++ b/test/files/neg/t7622-multi-followers/ThePlugin.scala @@ -0,0 +1,44 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "multi" + val description = "Declares two phases that both follow parser" + val components = List[PluginComponent](thePhase1,thePhase2) + + private object thePhase1 extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]() + + override val runsRightAfter = Some("parser") + + val phaseName = ThePlugin.this.name + "1" + + def newPhase(prev: Phase) = new ThePhase(prev, phaseName) + } + + private object thePhase2 extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]() + + override val runsRightAfter = Some("parser") + + val phaseName = ThePlugin.this.name + "2" + + def newPhase(prev: Phase) = new ThePhase(prev, phaseName) + } + + private class ThePhase(prev: Phase, val name: String) extends Phase(prev) { + def run {} + } +} + diff --git a/test/files/neg/t7622-multi-followers/sample_2.flags b/test/files/neg/t7622-multi-followers/sample_2.flags new file mode 100644 index 0000000000..d2e83e9723 --- /dev/null +++ b/test/files/neg/t7622-multi-followers/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:multi diff --git a/test/files/neg/t7622-multi-followers/sample_2.scala b/test/files/neg/t7622-multi-followers/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7622-multi-followers/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7622-multi-followers/scalac-plugin.xml b/test/files/neg/t7622-multi-followers/scalac-plugin.xml new file mode 100644 index 0000000000..2558d6fd03 --- /dev/null +++ b/test/files/neg/t7622-multi-followers/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>ignored</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/files/neg/t7669.check b/test/files/neg/t7669.check new file mode 100644 index 0000000000..c090ed18ce --- /dev/null +++ b/test/files/neg/t7669.check @@ -0,0 +1,7 @@ +t7669.scala:9: warning: match may not be exhaustive. +It would fail on the following input: NotHandled(_) + def exhausto(expr: Expr): Unit = expr match { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7669.flags b/test/files/neg/t7669.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t7669.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t7669.scala b/test/files/neg/t7669.scala new file mode 100644 index 0000000000..12441ec056 --- /dev/null +++ b/test/files/neg/t7669.scala @@ -0,0 +1,13 @@ +object Test { + + sealed abstract class Expr + // Change type of `arg` to `Any` and the exhaustiveness warning + // is issued below + case class Op(arg: Expr) extends Expr + case class NotHandled(num: Double) extends Expr + + def exhausto(expr: Expr): Unit = expr match { + case Op(Op(_)) => + case Op(_) => + } +} diff --git a/test/files/neg/t7715.check b/test/files/neg/t7715.check new file mode 100644 index 0000000000..4ee6b6c95d --- /dev/null +++ b/test/files/neg/t7715.check @@ -0,0 +1,13 @@ +t7715.scala:8: error: error in interpolated string: identifier or block expected + days map s"On the $_th day of Christmas" foreach println + ^ +t7715.scala:10: error: error in interpolated string: identifier or block expected + val rf = (n: Int) => s"\\*{$_}"(n).r + ^ +t7715.scala:17: error: unbound placeholder parameter + days zip days map s"${_: Int} by ${_: Int}".tupled foreach println + ^ +t7715.scala:17: error: unbound placeholder parameter + days zip days map s"${_: Int} by ${_: Int}".tupled foreach println + ^ +four errors found diff --git a/test/files/neg/t7715.scala b/test/files/neg/t7715.scala new file mode 100644 index 0000000000..637ab8df6d --- /dev/null +++ b/test/files/neg/t7715.scala @@ -0,0 +1,18 @@ + +import PartialFunction.cond +import util._ + +object Test extends App { + val days = (1 to 12).toList + + days map s"On the $_th day of Christmas" foreach println + + val rf = (n: Int) => s"\\*{$_}"(n).r + def stars(n: Int)(s: String) = { + val r = rf(n) + cond(s) { case r(_*) => true } + } + Console println stars(5)("*****") + + days zip days map s"${_: Int} by ${_: Int}".tupled foreach println +} diff --git a/test/files/neg/t7721.check b/test/files/neg/t7721.check new file mode 100644 index 0000000000..e056b9a293 --- /dev/null +++ b/test/files/neg/t7721.check @@ -0,0 +1,21 @@ +t7721.scala:11: warning: abstract type pattern A.this.Foo is unchecked since it is eliminated by erasure + case x: Foo with Concrete => x.bippy + x.conco + ^ +t7721.scala:15: warning: abstract type pattern A.this.Foo is unchecked since it is eliminated by erasure + case x: Concrete with Foo => x.bippy + x.conco + ^ +t7721.scala:19: warning: abstract type pattern A.this.Foo is unchecked since it is eliminated by erasure + case x: Foo with Bar => x.bippy + x.barry + ^ +t7721.scala:39: warning: abstract type pattern B.this.Foo is unchecked since it is eliminated by erasure + case x: Foo with Concrete => x.bippy + x.dingo + x.conco + ^ +t7721.scala:43: warning: abstract type pattern B.this.Foo is unchecked since it is eliminated by erasure + case x: Concrete with Foo => x.bippy + x.dingo + x.conco + ^ +t7721.scala:47: warning: abstract type pattern B.this.Foo is unchecked since it is eliminated by erasure + case x: Foo with Bar with Concrete => x.bippy + x.barry + x.dingo + x.conco + x.bongo + ^ +error: No warnings can be incurred under -Xfatal-warnings. +6 warnings found +one error found diff --git a/test/files/neg/t7721.flags b/test/files/neg/t7721.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/t7721.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t7721.scala b/test/files/neg/t7721.scala new file mode 100644 index 0000000000..27884c9e35 --- /dev/null +++ b/test/files/neg/t7721.scala @@ -0,0 +1,140 @@ +import scala.language.reflectiveCalls + +trait A { + trait Concrete { def conco: Int = 1 } + type Foo <: { def bippy: Int } + type Bar <: { def barry: Int } + + implicit def barTag: scala.reflect.ClassTag[Bar] + + def f1(x: Any) = x match { + case x: Foo with Concrete => x.bippy + x.conco + case _ => -1 + } + def f2(x: Any) = x match { + case x: Concrete with Foo => x.bippy + x.conco + case _ => -1 + } + def f3(x: Any) = x match { + case x: Foo with Bar => x.bippy + x.barry + case _ => -1 + } + def f4(x: Any) = x match { + case x: (Foo @unchecked) => x.bippy // warns, suppressed + case _ => -1 + } + def f5(x: Any) = x match { + case x: (Bar @unchecked) => x.barry // warns (but about the "outer reference"), suppressed + case _ => -1 + } +} + +trait B extends A { + type Foo <: { def bippy: Int ; def dingo: Int } + type Bar <: { def barry: Int ; def bongo: Int } + + override implicit def barTag: scala.reflect.ClassTag[Bar] + + override def f1(x: Any) = x match { + case x: Foo with Concrete => x.bippy + x.dingo + x.conco + case _ => -1 + } + override def f2(x: Any) = x match { + case x: Concrete with Foo => x.bippy + x.dingo + x.conco + case _ => -1 + } + override def f3(x: Any) = x match { + case x: Foo with Bar with Concrete => x.bippy + x.barry + x.dingo + x.conco + x.bongo + case _ => -1 + } + override def f4(x: Any) = x match { + case x: (Foo @unchecked) => x.bippy + x.dingo // warns, suppressed + case _ => -1 + } + override def f5(x: Any) = x match { + case x: (Bar @unchecked) => x.barry + x.bongo // warns (but about the "outer reference"), suppressed + case _ => -1 + } +} + +object Test { + abstract class Base extends A { + trait Foo { + def bippy = 2 + def dingo = 3 + } + trait Bar { + def barry = 2 + def bongo = 3 + } + implicit def barTag: scala.reflect.ClassTag[Bar] = scala.reflect.ClassTag(classOf[Bar]) + + def run() { + println("f1") + wrap(f1(new Concrete {})) + wrap(f1(new Foo {})) + wrap(f1(new Bar {})) + wrap(f1(new Foo with Concrete {})) + wrap(f1(new Concrete with Foo {})) + + println("\nf2") + wrap(f2(new Concrete {})) + wrap(f2(new Foo {})) + wrap(f2(new Bar {})) + wrap(f2(new Foo with Concrete {})) + wrap(f2(new Concrete with Foo {})) + wrap(f2(new Bar with Concrete {})) + wrap(f2(new Concrete with Bar {})) + wrap(f2(new Concrete with Foo with Bar {})) + wrap(f2(new Foo with Bar with Concrete {})) + + println("\nf3") + wrap(f3(new Concrete {})) + wrap(f3(new Foo {})) + wrap(f3(new Bar {})) + wrap(f3(new Foo with Concrete {})) + wrap(f3(new Concrete with Foo {})) + wrap(f3(new Bar with Concrete {})) + wrap(f3(new Concrete with Bar {})) + wrap(f3(new Concrete with Foo with Bar {})) + wrap(f3(new Foo with Bar with Concrete {})) + + println("\nf4") + wrap(f4(new Concrete {})) + wrap(f4(new Foo {})) + wrap(f4(new Bar {})) + wrap(f4(new Foo with Concrete {})) + wrap(f4(new Concrete with Foo {})) + wrap(f4(new Bar with Concrete {})) + wrap(f4(new Concrete with Bar {})) + wrap(f4(new Concrete with Foo with Bar {})) + wrap(f4(new Foo with Bar with Concrete {})) + + println("\nf5") + wrap(f5(new Concrete {})) + wrap(f5(new Foo {})) + wrap(f5(new Bar {})) + wrap(f5(new Foo with Concrete {})) + wrap(f5(new Concrete with Foo {})) + wrap(f5(new Bar with Concrete {})) + wrap(f5(new Concrete with Bar {})) + wrap(f5(new Concrete with Foo with Bar {})) + wrap(f5(new Foo with Bar with Concrete {})) + } + } + + object ao extends Base + object bo extends Base with B + + private def wrap(body: => Any) { + try println(body) + catch { case ex: NoSuchMethodException => println(ex) } + } + + def main(args: Array[String]) { + ao.run() + bo.run() + } +} + +// java.lang.NoSuchMethodException: Test$$anon$1.bippy()
\ No newline at end of file diff --git a/test/files/neg/t7756a.check b/test/files/neg/t7756a.check new file mode 100644 index 0000000000..8d42717e47 --- /dev/null +++ b/test/files/neg/t7756a.check @@ -0,0 +1,7 @@ +t7756a.scala:7: error: type arguments [Object] do not conform to trait TA's type parameter bounds [X <: CharSequence] + locally(null: TA[Object]) + ^ +t7756a.scala:7: error: type arguments [Object] do not conform to trait TA's type parameter bounds [X <: CharSequence] + locally(null: TA[Object]) + ^ +two errors found diff --git a/test/files/neg/t7756a.scala b/test/files/neg/t7756a.scala new file mode 100644 index 0000000000..4453e84963 --- /dev/null +++ b/test/files/neg/t7756a.scala @@ -0,0 +1,11 @@ +object Test { + def test: Unit = { + trait TA[X <: CharSequence] + 0 match { + case _ => + // the bounds violation isn't reported. RefChecks seems to be too broadly disabled under virtpatmat: see 65340ed4ad2e + locally(null: TA[Object]) + () + } + } +} diff --git a/test/files/neg/t7756b.check b/test/files/neg/t7756b.check new file mode 100644 index 0000000000..2817a7e230 --- /dev/null +++ b/test/files/neg/t7756b.check @@ -0,0 +1,6 @@ +t7756b.scala:3: warning: comparing values of types Int and String using `==' will always yield false + case _ => 0 == "" + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7756b.flags b/test/files/neg/t7756b.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t7756b.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t7756b.scala b/test/files/neg/t7756b.scala new file mode 100644 index 0000000000..a2de29c8e7 --- /dev/null +++ b/test/files/neg/t7756b.scala @@ -0,0 +1,5 @@ +object Test { + 0 match { + case _ => 0 == "" + } +} diff --git a/test/files/neg/t7757a.check b/test/files/neg/t7757a.check new file mode 100644 index 0000000000..de24e23004 --- /dev/null +++ b/test/files/neg/t7757a.check @@ -0,0 +1,4 @@ +t7757a.scala:1: error: ';' expected but '@' found. +trait Foo @annot + ^ +one error found diff --git a/test/files/neg/t7757a.scala b/test/files/neg/t7757a.scala new file mode 100644 index 0000000000..24f6c16cb4 --- /dev/null +++ b/test/files/neg/t7757a.scala @@ -0,0 +1 @@ +trait Foo @annot
\ No newline at end of file diff --git a/test/files/neg/t7757b.check b/test/files/neg/t7757b.check new file mode 100644 index 0000000000..3e5a0f1fa6 --- /dev/null +++ b/test/files/neg/t7757b.check @@ -0,0 +1,4 @@ +t7757b.scala:2: error: expected start of definition +@annot2 + ^ +one error found diff --git a/test/files/neg/t7757b.scala b/test/files/neg/t7757b.scala new file mode 100644 index 0000000000..e9a537dba1 --- /dev/null +++ b/test/files/neg/t7757b.scala @@ -0,0 +1,2 @@ +trait Foo2 +@annot2
\ No newline at end of file diff --git a/test/files/neg/t783.scala b/test/files/neg/t783.scala index 5d20bc6d24..59f7c7f97d 100644 --- a/test/files/neg/t783.scala +++ b/test/files/neg/t783.scala @@ -18,7 +18,7 @@ object Main extends App { def globalInit : Global; final def globalInit0 = globalInit.asInstanceOf[global.type]; } - + object global0 extends Global { object analyzer extends Analyzer { type Global = global0.type; diff --git a/test/files/neg/t7834neg.check b/test/files/neg/t7834neg.check new file mode 100644 index 0000000000..569df4b8ce --- /dev/null +++ b/test/files/neg/t7834neg.check @@ -0,0 +1,41 @@ +t7834neg.scala:48: error: type mismatch; + found : C.super.q.type (with underlying type M2) + required: C.super.q.type + x1 = x2 // fail + ^ +t7834neg.scala:50: error: type mismatch; + found : C.super.q.type (with underlying type M1) + required: C.super.q.type + x2 = x1 // fail + ^ +t7834neg.scala:53: error: type mismatch; + found : C.super.q.type (with underlying type M1) + required: C.this.q.type + x3 = x1 // fail + ^ +t7834neg.scala:54: error: type mismatch; + found : C.super.q.type (with underlying type M2) + required: C.this.q.type + x3 = x2 // fail + ^ +t7834neg.scala:69: error: type mismatch; + found : C.super.q.type (with underlying type M2) + required: C.super.q.type + x1 = super[S2].q // fail + ^ +t7834neg.scala:71: error: type mismatch; + found : C.super.q.type (with underlying type M1) + required: C.super.q.type + x2 = super[S1].q // fail + ^ +t7834neg.scala:74: error: type mismatch; + found : C.super.q.type (with underlying type M1) + required: C.this.q.type + x3 = super[S1].q // fail + ^ +t7834neg.scala:75: error: type mismatch; + found : C.super.q.type (with underlying type M2) + required: C.this.q.type + x3 = super[S2].q // fail + ^ +8 errors found diff --git a/test/files/neg/t7834neg.scala b/test/files/neg/t7834neg.scala new file mode 100644 index 0000000000..d35a84eadd --- /dev/null +++ b/test/files/neg/t7834neg.scala @@ -0,0 +1,76 @@ +class M1 +class M2 extends M1 +class M3 extends M2 + +trait S1 { val q = new M1 ; val q1: q.type = q } +trait S2 { val q = new M2 ; val q2: q.type = q } + +class B extends S1 with S2 { + override val q = new M3 + val q3: q.type = q + + var x1: B.super[S1].q1.type = null + var x2: B.super[S2].q2.type = null + var x3: B.this.q3.type = null + + x1 = x1 + x1 = x2 + x1 = x3 + x2 = x1 + x2 = x2 + x2 = x3 + x3 = x1 + x3 = x2 + x3 = x3 + + x1 = q1 + x1 = q2 + x1 = q3 + x2 = q1 + x2 = q2 + x2 = q3 + x3 = q1 + x3 = q2 + x3 = x3 +} + +class C extends S1 with S2 { + override val q = new M3 + val q3: q.type = q + + // x1's type and x2's type are incompatible + // x3's is assignable to x1 or x2, but not vice versa + var x1: C.super[S1].q.type = null + var x2: C.super[S2].q.type = null + var x3: C.this.q.type = null + + x1 = x1 + x1 = x2 // fail + x1 = x3 + x2 = x1 // fail + x2 = x2 + x2 = x3 + x3 = x1 // fail + x3 = x2 // fail + x3 = x3 + + x1 = q1 + x1 = q2 + x1 = q3 + x2 = q1 + x2 = q2 + x2 = q3 + x3 = q1 + x3 = q2 + x3 = x3 + + x1 = q + x1 = super[S1].q + x1 = super[S2].q // fail + x2 = q + x2 = super[S1].q // fail + x2 = super[S2].q + x3 = q + x3 = super[S1].q // fail + x3 = super[S2].q // fail +} diff --git a/test/files/neg/t7848-interp-warn.check b/test/files/neg/t7848-interp-warn.check new file mode 100644 index 0000000000..cbdc9f4c27 --- /dev/null +++ b/test/files/neg/t7848-interp-warn.check @@ -0,0 +1,9 @@ +t7848-interp-warn.scala:7: warning: `$foo` looks like an interpolated identifier! Did you forget the interpolator? + "An important $foo message!" + ^ +t7848-interp-warn.scala:11: warning: That looks like an interpolated expression! Did you forget the interpolator? + "A doubly important ${foo * 2} message!" + ^ +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t7848-interp-warn.flags b/test/files/neg/t7848-interp-warn.flags new file mode 100644 index 0000000000..7949c2afa2 --- /dev/null +++ b/test/files/neg/t7848-interp-warn.flags @@ -0,0 +1 @@ +-Xlint -Xfatal-warnings diff --git a/test/files/neg/t7848-interp-warn.scala b/test/files/neg/t7848-interp-warn.scala new file mode 100644 index 0000000000..bb3eeff60c --- /dev/null +++ b/test/files/neg/t7848-interp-warn.scala @@ -0,0 +1,13 @@ + +package test + +object Test { + def f = { + val foo = "bar" + "An important $foo message!" + } + def g = { + val foo = "bar" + "A doubly important ${foo * 2} message!" + } +} diff --git a/test/files/neg/t7870.check b/test/files/neg/t7870.check new file mode 100644 index 0000000000..d9db911ac1 --- /dev/null +++ b/test/files/neg/t7870.check @@ -0,0 +1,4 @@ +t7870.scala:1: error: in class C, multiple overloaded alternatives of constructor C define default arguments. +class C(a: Int = 0, b: Any) { + ^ +one error found diff --git a/test/files/neg/t7870.scala b/test/files/neg/t7870.scala new file mode 100644 index 0000000000..5d48d43b3a --- /dev/null +++ b/test/files/neg/t7870.scala @@ -0,0 +1,3 @@ +class C(a: Int = 0, b: Any) { + def this(a: Int = 0) = this(???, ???) +} diff --git a/test/files/neg/t798.scala b/test/files/neg/t798.scala index b4a1939444..a2bf66d19b 100644 --- a/test/files/neg/t798.scala +++ b/test/files/neg/t798.scala @@ -4,5 +4,5 @@ trait Test[Bracks <: Bracks] { class C[T] val bracks : Bracks; val singletons = f(bracks); - + } diff --git a/test/files/neg/t836.scala b/test/files/neg/t836.scala index de23cf5387..3633b816c6 100644 --- a/test/files/neg/t836.scala +++ b/test/files/neg/t836.scala @@ -10,7 +10,7 @@ abstract class A { } class B extends A { - type MyObj = ObjImpl + type MyObj = ObjImpl val myString: S = "hello" val realString: String = myString // error: type missmatch } diff --git a/test/files/neg/t856.check b/test/files/neg/t856.check index 02978e1622..fb93f96d9f 100644 --- a/test/files/neg/t856.check +++ b/test/files/neg/t856.check @@ -5,7 +5,7 @@ it has 2 unimplemented members. */ // Members declared in scala.Equals def canEqual(that: Any): Boolean = ??? - + // Members declared in scala.Product2 def _2: Double = ??? diff --git a/test/files/neg/t856.scala b/test/files/neg/t856.scala index e50084b6bd..fea216bfad 100644 --- a/test/files/neg/t856.scala +++ b/test/files/neg/t856.scala @@ -1,4 +1,4 @@ -trait Complex extends Product2[Double,Double] +trait Complex extends Product2[Double,Double] class ComplexRect(val _1:Double, _2:Double) extends Complex { override def toString = "ComplexRect("+_1+","+_2+")" diff --git a/test/files/neg/t876.scala b/test/files/neg/t876.scala index fb1461a7d3..1f6a90dff3 100644 --- a/test/files/neg/t876.scala +++ b/test/files/neg/t876.scala @@ -11,11 +11,11 @@ object AssertionError extends AnyRef with App class Manager { final class B {} - + val map = new HashMap[A, B] } - - + + def test[T](f: => T) { f } test { diff --git a/test/files/neg/t877.check b/test/files/neg/t877.check index 5f25bd439c..c3d4ab6584 100644 --- a/test/files/neg/t877.check +++ b/test/files/neg/t877.check @@ -1,7 +1,7 @@ t877.scala:3: error: Invalid literal number trait Foo extends A(22A, Bug!) {} ^ -t877.scala:3: error: parents of traits may not have parameters +t877.scala:3: error: ')' expected but eof found. trait Foo extends A(22A, Bug!) {} - ^ + ^ two errors found diff --git a/test/files/neg/t877.scala b/test/files/neg/t877.scala index 8cb98279db..5e132a1dd4 100644 --- a/test/files/neg/t877.scala +++ b/test/files/neg/t877.scala @@ -1,3 +1,3 @@ -class A +class A trait Foo extends A(22A, Bug!) {} diff --git a/test/files/neg/t935.check b/test/files/neg/t935.check index 8b73700187..af634a2630 100644 --- a/test/files/neg/t935.check +++ b/test/files/neg/t935.check @@ -4,7 +4,4 @@ t935.scala:7: error: type arguments [Test3.B] do not conform to class E's type p t935.scala:13: error: type arguments [Test4.B] do not conform to class E's type parameter bounds [T <: String] val b: String @E[B](new B) = "hi" ^ -t935.scala:13: error: type arguments [Test4.B] do not conform to class E's type parameter bounds [T <: String] - val b: String @E[B](new B) = "hi" - ^ -three errors found +two errors found diff --git a/test/files/neg/t944.scala b/test/files/neg/t944.scala index 352269a80b..dc80e5f49f 100644 --- a/test/files/neg/t944.scala +++ b/test/files/neg/t944.scala @@ -1,6 +1,6 @@ object TooManyArgsFunction { - val f = (a1:Int, a2:Int, a3:Int, a4:Int, a5:Int, a6:Int, a7:Int, a8:Int, - a9:Int, a10:Int, a11:Int, a12:Int, a13:Int, a14:Int, a15:Int, - a16:Int, a17:Int, a18:Int, a19:Int, a20:Int, a21:Int, a22:Int, + val f = (a1:Int, a2:Int, a3:Int, a4:Int, a5:Int, a6:Int, a7:Int, a8:Int, + a9:Int, a10:Int, a11:Int, a12:Int, a13:Int, a14:Int, a15:Int, + a16:Int, a17:Int, a18:Int, a19:Int, a20:Int, a21:Int, a22:Int, a23:Int) => 1 } diff --git a/test/files/neg/t997.check b/test/files/neg/t997.check index 186095f44a..be1e92c369 100644 --- a/test/files/neg/t997.check +++ b/test/files/neg/t997.check @@ -1,7 +1,10 @@ -t997.scala:13: error: wrong number of arguments for object Foo +t997.scala:13: error: wrong number of patterns for object Foo offering (String, String): expected 2, found 3 +"x" match { case Foo(a, b, c) => Console.println((a,b,c)) } + ^ +t997.scala:13: error: wrong number of patterns for object Foo offering (String, String): expected 2, found 3 "x" match { case Foo(a, b, c) => Console.println((a,b,c)) } ^ t997.scala:13: error: not found: value a "x" match { case Foo(a, b, c) => Console.println((a,b,c)) } ^ -two errors found +three errors found diff --git a/test/files/neg/tailrec-2.check b/test/files/neg/tailrec-2.check index d3432a7e76..1daad6922e 100644 --- a/test/files/neg/tailrec-2.check +++ b/test/files/neg/tailrec-2.check @@ -1,4 +1,4 @@ -tailrec-2.scala:8: error: could not optimize @tailrec annotated method f: it contains a recursive call targeting supertype Super[A] +tailrec-2.scala:8: error: could not optimize @tailrec annotated method f: it contains a recursive call targeting a supertype @annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = (null: Super[A]).f(mem) ^ tailrec-2.scala:9: error: @tailrec annotated method contains no recursive calls diff --git a/test/files/neg/tailrec.scala b/test/files/neg/tailrec.scala index 5b9018ae89..e0ebde9863 100644 --- a/test/files/neg/tailrec.scala +++ b/test/files/neg/tailrec.scala @@ -9,21 +9,21 @@ object Winners { @tailrec def loopsucc1(x: Int): Int = loopsucc1(x - 1) @tailrec def loopsucc2[T](x: Int): Int = loopsucc2[T](x - 1) - + def ding() { object dong { @tailrec def loopsucc3(x: Int): Int = loopsucc3(x) } () } - + def inner(q: Int) = { @tailrec def loopsucc4(x: Int): Int = loopsucc4(x + 1) - + loopsucc4(q) } - + object innerBob { @tailrec def loopsucc5(x: Int): Int = loopsucc5(x) } @@ -45,19 +45,19 @@ object Failures { else n * facfail(n - 1) } -class Failures { +class Failures { // not private, not final @tailrec def fail1(x: Int): Int = fail1(x) - + // a typical between-chair-and-keyboard error @tailrec final def fail2[T](xs: List[T]): List[T] = xs match { case Nil => Nil case x :: xs => x :: fail2[T](xs) } - + // unsafe @tailrec final def fail3[T](x: Int): Int = fail3(x - 1) - + // unsafe class Tom[T](x: Int) { @tailrec final def fail4[U](other: Tom[U], x: Int): Int = other.fail4[U](other, x - 1) diff --git a/test/files/neg/tcpoly_infer_ticket1162.scala b/test/files/neg/tcpoly_infer_ticket1162.scala index b88bd358d9..0552b42a22 100644 --- a/test/files/neg/tcpoly_infer_ticket1162.scala +++ b/test/files/neg/tcpoly_infer_ticket1162.scala @@ -1,8 +1,8 @@ object Test { - trait Expression[A,B] + trait Expression[A,B] case class Lift[A,B,F[_]]() extends Expression[F[A],F[B]] - + def simplify[A,B]: Expression[A,B] = Lift[A,B]() } diff --git a/test/files/neg/tcpoly_ticket2101.scala b/test/files/neg/tcpoly_ticket2101.scala index 3af07acfac..68f061ce70 100644 --- a/test/files/neg/tcpoly_ticket2101.scala +++ b/test/files/neg/tcpoly_ticket2101.scala @@ -4,10 +4,10 @@ class T2[X] extends T[T2, X] // ill-typed // Forall Y. T2[Y] <: T[T2, X] // debugging before fix: -// def isSubType0 --> +// def isSubType0 --> // case (PolyType(tparams1, res1), PolyType(tparams2, res2)) => println("<:<PT: "+((tparams1, res1), (tparams2, res2))) //@MDEBUG // (tparams1.length == tparams2.length && -// List.forall2(tparams1, tparams2) +// List.forall2(tparams1, tparams2) // ((p1, p2) => p2.info.substSym(tparams2, tparams1) <:< p1.info) && // res1 <:< res2.substSym(tparams2, tparams1)) @@ -22,7 +22,7 @@ class T2[X] extends T[T2, X] // ill-typed // (tparams1.length == tparams2.length && // { // val tpsFresh = cloneSymbols(tparams1) // @M cloneSymbols(tparams2) should be equivalent -- TODO: check -// List.forall2(tparams1, tparams2) +// List.forall2(tparams1, tparams2) // ((p1, p2) => p2.info.substSym(tparams2, tpsFresh) <:< p1.info.substSym(tparams1, tpsFresh)) && -// res1.substSym(tparams1, tpsFresh) <:< res2.substSym(tparams2, tpsFresh) +// res1.substSym(tparams1, tpsFresh) <:< res2.substSym(tparams2, tpsFresh) // }) diff --git a/test/files/neg/tcpoly_typealias.scala b/test/files/neg/tcpoly_typealias.scala index 96e9349298..6c7f80cc0b 100644 --- a/test/files/neg/tcpoly_typealias.scala +++ b/test/files/neg/tcpoly_typealias.scala @@ -12,7 +12,7 @@ trait A3 { trait FooCov[+x] trait FooCon[-x] -trait FooBound[+x <: String] +trait FooBound[+x <: String] trait BOk1 extends A { type m[+x] = FooCov[x] @@ -30,8 +30,8 @@ trait BOk4 extends A3 { type m[+x] = FooCov[x] // weaker variance } -// there are two aspects to check: - // does type alias signature (not considering RHS) correspond to abstract type member in super class +// there are two aspects to check: + // does type alias signature (not considering RHS) correspond to abstract type member in super class // does RHS correspond to the type alias sig trait BInv extends A{ type m[x] = FooCov[x] // error: invariant x in alias def diff --git a/test/files/neg/tcpoly_variance_enforce.scala b/test/files/neg/tcpoly_variance_enforce.scala index 0db7b692f8..ddff0e9f94 100644 --- a/test/files/neg/tcpoly_variance_enforce.scala +++ b/test/files/neg/tcpoly_variance_enforce.scala @@ -6,7 +6,7 @@ trait coll3[m[x]] trait coll4[m[x <: y], y] -class FooInvar[x] +class FooInvar[x] class FooContra[-x] class FooCov[+x] class FooString[+x <: String] @@ -15,15 +15,15 @@ object fcollok extends coll[FooCov] object fcollinv extends coll[FooInvar] // error object fcollcon extends coll[FooContra] // error object fcollwb extends coll[FooString] // error - + object fcoll2ok extends coll2[FooCov] // error object fcoll2inv extends coll2[FooInvar] // error -object fcoll2con extends coll2[FooContra] +object fcoll2con extends coll2[FooContra] object fcoll2wb extends coll2[FooString] // error - -object fcoll3ok extends coll3[FooCov] -object fcoll3inv extends coll3[FooInvar] -object fcoll3con extends coll3[FooContra] + +object fcoll3ok extends coll3[FooCov] +object fcoll3inv extends coll3[FooInvar] +object fcoll3con extends coll3[FooContra] object fcoll3wb extends coll3[FooString] // error object fcoll4ok extends coll4[FooString, String] @@ -33,7 +33,7 @@ object fcoll4_2 extends coll4[FooString, Any] // error object test { var ok: coll[FooCov] = _ - + def x: coll[FooInvar] = sys.error("foo") // error def y: coll[FooContra] = sys.error("foo") // error } diff --git a/test/files/neg/type-diagnostics.scala b/test/files/neg/type-diagnostics.scala index de7e7adc3c..c4171328de 100644 --- a/test/files/neg/type-diagnostics.scala +++ b/test/files/neg/type-diagnostics.scala @@ -6,14 +6,14 @@ object SetVsSet { object TParamConfusion { def strings(xs: List[String]) = xs - + def f1[a <% Ordered[a]](x: List[a]) = { def f2[b >: List[a] <% Ordered[b]](x: List[a], y: b): Int = { def f3(xs: List[a], ys: List[a]) = -1 y match { case y1: List[a] => f3(x, y1) } } } - + def f2[String](s: String) = strings(List(s)) } diff --git a/test/files/neg/unchecked-abstract.check b/test/files/neg/unchecked-abstract.check index 6e811dc156..72019082ac 100644 --- a/test/files/neg/unchecked-abstract.check +++ b/test/files/neg/unchecked-abstract.check @@ -1,25 +1,27 @@ -unchecked-abstract.scala:16: error: abstract type H in type Contravariant[M.this.H] is unchecked since it is eliminated by erasure +unchecked-abstract.scala:16: warning: abstract type H in type Contravariant[M.this.H] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Contravariant[H]]) ^ -unchecked-abstract.scala:21: error: abstract type H in type Contravariant[M.this.H] is unchecked since it is eliminated by erasure +unchecked-abstract.scala:21: warning: abstract type H in type Contravariant[M.this.H] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Contravariant[H]]) ^ -unchecked-abstract.scala:27: error: abstract type T in type Invariant[M.this.T] is unchecked since it is eliminated by erasure +unchecked-abstract.scala:27: warning: abstract type T in type Invariant[M.this.T] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Invariant[T]]) ^ -unchecked-abstract.scala:28: error: abstract type L in type Invariant[M.this.L] is unchecked since it is eliminated by erasure +unchecked-abstract.scala:28: warning: abstract type L in type Invariant[M.this.L] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Invariant[L]]) ^ -unchecked-abstract.scala:31: error: abstract type H in type Invariant[M.this.H] is unchecked since it is eliminated by erasure +unchecked-abstract.scala:31: warning: abstract type H in type Invariant[M.this.H] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Invariant[H]]) ^ -unchecked-abstract.scala:33: error: abstract type L in type Invariant[M.this.L] is unchecked since it is eliminated by erasure +unchecked-abstract.scala:33: warning: abstract type L in type Invariant[M.this.L] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Invariant[L]]) ^ -unchecked-abstract.scala:36: error: abstract type H in type Invariant[M.this.H] is unchecked since it is eliminated by erasure +unchecked-abstract.scala:36: warning: abstract type H in type Invariant[M.this.H] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Invariant[H]]) ^ -unchecked-abstract.scala:37: error: abstract type T in type Invariant[M.this.T] is unchecked since it is eliminated by erasure +unchecked-abstract.scala:37: warning: abstract type T in type Invariant[M.this.T] is unchecked since it is eliminated by erasure /* warn */ println(x.isInstanceOf[Invariant[T]]) ^ -8 errors found +error: No warnings can be incurred under -Xfatal-warnings. +8 warnings found +one error found diff --git a/test/files/neg/unchecked-impossible.check b/test/files/neg/unchecked-impossible.check index 0ab371dbaa..d150a5a853 100644 --- a/test/files/neg/unchecked-impossible.check +++ b/test/files/neg/unchecked-impossible.check @@ -1,4 +1,10 @@ -unchecked-impossible.scala:5: error: fruitless type test: a value of type T2[Int,Int] cannot also be a Seq[A] +unchecked-impossible.scala:5: warning: fruitless type test: a value of type T2[Int,Int] cannot also be a Seq[A] case Seq(x) => ^ +unchecked-impossible.scala:5: error: pattern type is incompatible with expected type; + found : Seq[A] + required: T2[Int,Int] + case Seq(x) => + ^ +one warning found one error found diff --git a/test/files/neg/unchecked-knowable.check b/test/files/neg/unchecked-knowable.check index d279427327..327a5f202d 100644 --- a/test/files/neg/unchecked-knowable.check +++ b/test/files/neg/unchecked-knowable.check @@ -1,7 +1,9 @@ -unchecked-knowable.scala:18: error: fruitless type test: a value of type Bippy cannot also be a A1 +unchecked-knowable.scala:18: warning: fruitless type test: a value of type Bippy cannot also be a A1 /* warn */ (new Bippy).isInstanceOf[A1] ^ -unchecked-knowable.scala:19: error: fruitless type test: a value of type Bippy cannot also be a B1 +unchecked-knowable.scala:19: warning: fruitless type test: a value of type Bippy cannot also be a B1 /* warn */ (new Bippy).isInstanceOf[B1] ^ -two errors found +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/unchecked-refinement.check b/test/files/neg/unchecked-refinement.check index d81517464f..e85a51f44d 100644 --- a/test/files/neg/unchecked-refinement.check +++ b/test/files/neg/unchecked-refinement.check @@ -1,13 +1,15 @@ -unchecked-refinement.scala:17: error: abstract type U in type pattern Foo[U,U,V] is unchecked since it is eliminated by erasure +unchecked-refinement.scala:17: warning: abstract type U in type pattern Foo[U,U,V] is unchecked since it is eliminated by erasure /* warn */ case _: Foo[U, U, V] if b => () ^ -unchecked-refinement.scala:19: error: non-variable type argument Any in type pattern Foo[Any,U,V] is unchecked since it is eliminated by erasure +unchecked-refinement.scala:19: warning: non-variable type argument Any in type pattern Foo[Any,U,V] is unchecked since it is eliminated by erasure /* warn */ case _: Foo[Any, U, V] if b => () ^ -unchecked-refinement.scala:23: error: a pattern match on a refinement type is unchecked +unchecked-refinement.scala:23: warning: a pattern match on a refinement type is unchecked /* nowarn - todo */ case x: AnyRef { def bippy: Int } if b => x.bippy // this could/should do an instance check and not warn ^ -unchecked-refinement.scala:24: error: a pattern match on a refinement type is unchecked +unchecked-refinement.scala:24: warning: a pattern match on a refinement type is unchecked /* nowarn - todo */ case x: AnyRef { def size: Int } if b => x.size // this could/should do a static conformance test and not warn ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/unchecked-suppress.check b/test/files/neg/unchecked-suppress.check index 2e23d21386..038105918e 100644 --- a/test/files/neg/unchecked-suppress.check +++ b/test/files/neg/unchecked-suppress.check @@ -1,10 +1,12 @@ -unchecked-suppress.scala:4: error: non-variable type argument Int in type pattern Set[Int] is unchecked since it is eliminated by erasure +unchecked-suppress.scala:4: warning: non-variable type argument Int in type pattern Set[Int] is unchecked since it is eliminated by erasure case xs: Set[Int] => xs.head // unchecked ^ -unchecked-suppress.scala:5: error: non-variable type argument String in type pattern Map[String @unchecked,String] is unchecked since it is eliminated by erasure +unchecked-suppress.scala:5: warning: non-variable type argument String in type pattern Map[String @unchecked,String] is unchecked since it is eliminated by erasure case xs: Map[String @unchecked, String] => xs.head // one unchecked, one okay ^ -unchecked-suppress.scala:7: error: non-variable type argument Int in type pattern (Int, Int) => Int is unchecked since it is eliminated by erasure +unchecked-suppress.scala:7: warning: non-variable type argument Int in type pattern (Int, Int) => Int is unchecked since it is eliminated by erasure case f: ((Int, Int) => Int) => // unchecked ^ -three errors found +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/unchecked.check b/test/files/neg/unchecked.check index 2883b716c9..570f02f219 100644 --- a/test/files/neg/unchecked.check +++ b/test/files/neg/unchecked.check @@ -1,19 +1,21 @@ -unchecked.scala:18: error: non-variable type argument String in type pattern Iterable[String] is unchecked since it is eliminated by erasure +unchecked.scala:18: warning: non-variable type argument String in type pattern Iterable[String] is unchecked since it is eliminated by erasure case xs: Iterable[String] => xs.head // unchecked ^ -unchecked.scala:22: error: non-variable type argument Any in type pattern Set[Any] is unchecked since it is eliminated by erasure +unchecked.scala:22: warning: non-variable type argument Any in type pattern Set[Any] is unchecked since it is eliminated by erasure case xs: Set[Any] => xs.head // unchecked ^ -unchecked.scala:26: error: non-variable type argument Any in type pattern Map[Any,Any] is unchecked since it is eliminated by erasure +unchecked.scala:26: warning: non-variable type argument Any in type pattern Map[Any,Any] is unchecked since it is eliminated by erasure case xs: Map[Any, Any] => xs.head // unchecked ^ -unchecked.scala:35: error: non-variable type argument List[Nothing] in type pattern Test.Contra[List[Nothing]] is unchecked since it is eliminated by erasure +unchecked.scala:35: warning: non-variable type argument List[Nothing] in type pattern Test.Contra[List[Nothing]] is unchecked since it is eliminated by erasure case xs: Contra[List[Nothing]] => xs.head // unchecked ^ -unchecked.scala:50: error: non-variable type argument String in type pattern Test.Exp[String] is unchecked since it is eliminated by erasure +unchecked.scala:50: warning: non-variable type argument String in type pattern Test.Exp[String] is unchecked since it is eliminated by erasure case ArrayApply(x: Exp[Array[T]], _, j: Exp[String]) => x // unchecked ^ -unchecked.scala:55: error: non-variable type argument Array[T] in type pattern Test.Exp[Array[T]] is unchecked since it is eliminated by erasure +unchecked.scala:55: warning: non-variable type argument Array[T] in type pattern Test.Exp[Array[T]] is unchecked since it is eliminated by erasure case ArrayApply(x: Exp[Array[T]], _, _) => x // unchecked ^ -6 errors found +error: No warnings can be incurred under -Xfatal-warnings. +6 warnings found +one error found diff --git a/test/files/neg/unchecked2.check b/test/files/neg/unchecked2.check index 68fdfa82ac..a7b8391856 100644 --- a/test/files/neg/unchecked2.check +++ b/test/files/neg/unchecked2.check @@ -1,43 +1,45 @@ -unchecked2.scala:4: error: fruitless type test: a value of type Some[List[Int]] cannot also be a Option[List[String]] (but still might match its erasure) +unchecked2.scala:4: warning: fruitless type test: a value of type Some[List[Int]] cannot also be a Option[List[String]] (but still might match its erasure) /* warn */ Some(List(1)).isInstanceOf[Option[List[String]]] ^ -unchecked2.scala:5: error: non-variable type argument Option[_] in type Option[Option[_]] is unchecked since it is eliminated by erasure +unchecked2.scala:5: warning: non-variable type argument Option[_] in type Option[Option[_]] is unchecked since it is eliminated by erasure /* warn */ Some(123).isInstanceOf[Option[Option[_]]] ^ -unchecked2.scala:6: error: fruitless type test: a value of type Some[Int] cannot also be a Option[String] (but still might match its erasure) +unchecked2.scala:6: warning: fruitless type test: a value of type Some[Int] cannot also be a Option[String] (but still might match its erasure) /* warn */ Some(123).isInstanceOf[Option[String]] ^ -unchecked2.scala:7: error: fruitless type test: a value of type Some[Int] cannot also be a Option[List[String]] (but still might match its erasure) +unchecked2.scala:7: warning: fruitless type test: a value of type Some[Int] cannot also be a Option[List[String]] (but still might match its erasure) /* warn */ Some(123).isInstanceOf[Option[List[String]]] ^ -unchecked2.scala:8: error: fruitless type test: a value of type Some[Int] cannot also be a Option[List[Int => String]] (but still might match its erasure) +unchecked2.scala:8: warning: fruitless type test: a value of type Some[Int] cannot also be a Option[List[Int => String]] (but still might match its erasure) /* warn */ Some(123).isInstanceOf[Option[List[Int => String]]] ^ -unchecked2.scala:9: error: fruitless type test: a value of type Some[Int] cannot also be a Option[(String, Double)] (but still might match its erasure) +unchecked2.scala:9: warning: fruitless type test: a value of type Some[Int] cannot also be a Option[(String, Double)] (but still might match its erasure) /* warn */ Some(123).isInstanceOf[Option[(String, Double)]] ^ -unchecked2.scala:10: error: fruitless type test: a value of type Some[Int] cannot also be a Option[String => Double] (but still might match its erasure) +unchecked2.scala:10: warning: fruitless type test: a value of type Some[Int] cannot also be a Option[String => Double] (but still might match its erasure) /* warn */ Some(123).isInstanceOf[Option[String => Double]] ^ -unchecked2.scala:14: error: non-variable type argument List[String] in type Option[List[String]] is unchecked since it is eliminated by erasure +unchecked2.scala:14: warning: non-variable type argument List[String] in type Option[List[String]] is unchecked since it is eliminated by erasure /* warn */ (Some(List(1)): Any).isInstanceOf[Option[List[String]]] ^ -unchecked2.scala:15: error: non-variable type argument Int in type Option[Int] is unchecked since it is eliminated by erasure +unchecked2.scala:15: warning: non-variable type argument Int in type Option[Int] is unchecked since it is eliminated by erasure /* warn */ (Some(123): Any).isInstanceOf[Option[Int]] ^ -unchecked2.scala:16: error: non-variable type argument String in type Option[String] is unchecked since it is eliminated by erasure +unchecked2.scala:16: warning: non-variable type argument String in type Option[String] is unchecked since it is eliminated by erasure /* warn */ (Some(123): Any).isInstanceOf[Option[String]] ^ -unchecked2.scala:17: error: non-variable type argument List[String] in type Option[List[String]] is unchecked since it is eliminated by erasure +unchecked2.scala:17: warning: non-variable type argument List[String] in type Option[List[String]] is unchecked since it is eliminated by erasure /* warn */ (Some(123): Any).isInstanceOf[Option[List[String]]] ^ -unchecked2.scala:18: error: non-variable type argument List[Int => String] in type Option[List[Int => String]] is unchecked since it is eliminated by erasure +unchecked2.scala:18: warning: non-variable type argument List[Int => String] in type Option[List[Int => String]] is unchecked since it is eliminated by erasure /* warn */ (Some(123): Any).isInstanceOf[Option[List[Int => String]]] ^ -unchecked2.scala:19: error: non-variable type argument (String, Double) in type Option[(String, Double)] is unchecked since it is eliminated by erasure +unchecked2.scala:19: warning: non-variable type argument (String, Double) in type Option[(String, Double)] is unchecked since it is eliminated by erasure /* warn */ (Some(123): Any).isInstanceOf[Option[(String, Double)]] ^ -unchecked2.scala:20: error: non-variable type argument String => Double in type Option[String => Double] is unchecked since it is eliminated by erasure +unchecked2.scala:20: warning: non-variable type argument String => Double in type Option[String => Double] is unchecked since it is eliminated by erasure /* warn */ (Some(123): Any).isInstanceOf[Option[String => Double]] ^ -14 errors found +error: No warnings can be incurred under -Xfatal-warnings. +14 warnings found +one error found diff --git a/test/files/neg/unchecked3.check b/test/files/neg/unchecked3.check index f4f0c74257..a7582a8930 100644 --- a/test/files/neg/unchecked3.check +++ b/test/files/neg/unchecked3.check @@ -1,37 +1,42 @@ -unchecked3.scala:24: error: non-variable type argument Double in type pattern E1[Double] is unchecked since it is eliminated by erasure +unchecked3.scala:24: warning: non-variable type argument Double in type pattern E1[Double] is unchecked since it is eliminated by erasure /* warn */ def peerTypes2(x: B1[Int]) = x match { case _: E1[Double] => true } ^ -unchecked3.scala:25: error: non-variable type argument Double in type pattern F1[Double] is unchecked since it is eliminated by erasure +unchecked3.scala:25: warning: non-variable type argument Double in type pattern F1[Double] is unchecked since it is eliminated by erasure /* warn */ def peerTypes3(x: B1[_]) = x match { case _: F1[Double] => true } ^ -unchecked3.scala:28: error: non-variable type argument Int in type pattern A2[Int] is unchecked since it is eliminated by erasure +unchecked3.scala:28: warning: non-variable type argument Int in type pattern A2[Int] is unchecked since it is eliminated by erasure /* warn */ def twotypes1[T](x: B2[T, Int]) = x match { case _: A2[Int] => true } ^ -unchecked3.scala:32: error: non-variable type argument Int in type pattern B2[_,Int] is unchecked since it is eliminated by erasure +unchecked3.scala:32: warning: non-variable type argument Int in type pattern B2[_,Int] is unchecked since it is eliminated by erasure /* warn */ def twotypes5[T](x: A2[T]) = x match { case _: B2[_, Int] => true } ^ -unchecked3.scala:40: error: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure +unchecked3.scala:40: warning: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure /* warn */ case _: Array[List[String]] => () ^ -unchecked3.scala:43: error: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure +unchecked3.scala:43: warning: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure /* warn */ case _: Array[Array[List[String]]] => () ^ -unchecked3.scala:50: error: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure +unchecked3.scala:50: warning: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure /* warn */ case _: Array[List[String]] => () ^ -unchecked3.scala:53: error: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure +unchecked3.scala:53: warning: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure /* warn */ case _: Array[Array[List[String]]] => () ^ -unchecked3.scala:60: error: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure +unchecked3.scala:60: warning: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure /* warn */ case _: Array[List[String]] => () ^ -unchecked3.scala:62: error: non-variable type argument Array[String] in type pattern Array[List[Array[String]]] is unchecked since it is eliminated by erasure +unchecked3.scala:62: warning: non-variable type argument Array[String] in type pattern Array[List[Array[String]]] is unchecked since it is eliminated by erasure /* warn */ case _: Array[List[Array[String]]] => () ^ -unchecked3.scala:63: error: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure +unchecked3.scala:63: warning: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure /* warn */ case _: Array[Array[List[String]]] => () ^ -unchecked3.scala:75: error: abstract type A in type pattern Set[Q.this.A] is unchecked since it is eliminated by erasure +unchecked3.scala:75: warning: abstract type A in type pattern Set[Q.this.A] is unchecked since it is eliminated by erasure /* warn */ case xs: Set[A] => xs.head ^ -12 errors found +unchecked3.scala:62: warning: unreachable code + /* warn */ case _: Array[List[Array[String]]] => () + ^ +error: No warnings can be incurred under -Xfatal-warnings. +13 warnings found +one error found diff --git a/test/files/neg/unicode-unterminated-quote.check b/test/files/neg/unicode-unterminated-quote.check index 5085505fb4..166488710b 100644 --- a/test/files/neg/unicode-unterminated-quote.check +++ b/test/files/neg/unicode-unterminated-quote.check @@ -1,7 +1,7 @@ unicode-unterminated-quote.scala:2: error: unclosed string literal - val x = /u0022 + val x = \u0022 ^ unicode-unterminated-quote.scala:2: error: '}' expected but eof found. - val x = /u0022 + val x = \u0022 ^ two errors found diff --git a/test/files/neg/unit-returns-value.check b/test/files/neg/unit-returns-value.check index ab458a350b..f30a506ebe 100644 --- a/test/files/neg/unit-returns-value.check +++ b/test/files/neg/unit-returns-value.check @@ -1,7 +1,15 @@ -unit-returns-value.scala:4: error: a pure expression does nothing in statement position; you may be omitting necessary parentheses +unit-returns-value.scala:4: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses if (b) return 5 ^ -unit-returns-value.scala:4: error: enclosing method f has result type Unit: return value discarded +unit-returns-value.scala:4: warning: enclosing method f has result type Unit: return value discarded if (b) return 5 ^ -two errors found +unit-returns-value.scala:22: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + i1 // warn + ^ +unit-returns-value.scala:23: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + i2 // warn + ^ +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/unit-returns-value.scala b/test/files/neg/unit-returns-value.scala index ecc981f217..fc5a37069f 100644 --- a/test/files/neg/unit-returns-value.scala +++ b/test/files/neg/unit-returns-value.scala @@ -3,9 +3,30 @@ object Test { var b = false if (b) return 5 } - + // no warning def g { return println("hello") } } + +class UnusedValues { + var i1 = 2 + val i2 = 2 + lazy val i3 = 2 + object i4 { } + def i5 = 2 + final def i6 = 2 + + def x = { + i1 // warn + i2 // warn + i3 // no warn + i4 // no warn + i5 // no warn + i6 // could warn someday, if i6 returned 2.type instead of Int + + 5 + } +} + diff --git a/test/files/neg/unreachablechar.check b/test/files/neg/unreachablechar.check index 58ce1a7e91..121f12a0c7 100644 --- a/test/files/neg/unreachablechar.check +++ b/test/files/neg/unreachablechar.check @@ -1,4 +1,9 @@ -unreachablechar.scala:5: error: unreachable code +unreachablechar.scala:4: warning: patterns after a variable pattern cannot match (SLS 8.1.1) + case _ => println("stuff"); + ^ +unreachablechar.scala:5: warning: unreachable code due to variable pattern on line 4 case 'f' => println("not stuff?"); ^ +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found one error found diff --git a/test/files/neg/unreachablechar.flags b/test/files/neg/unreachablechar.flags index 809e9ff2f2..85d8eb2ba2 100644 --- a/test/files/neg/unreachablechar.flags +++ b/test/files/neg/unreachablechar.flags @@ -1 +1 @@ - -Xoldpatmat +-Xfatal-warnings diff --git a/test/files/neg/varargs.scala b/test/files/neg/varargs.scala index 657750ec8f..be75e9b0a7 100644 --- a/test/files/neg/varargs.scala +++ b/test/files/neg/varargs.scala @@ -7,21 +7,21 @@ import annotation.varargs // Failing varargs annotation object Test { - + trait A { def v1(a: Int, b: Array[String]) = a } - + trait B extends A { @varargs def v1(a: Int, b: String*) = a + b.length } - + @varargs def nov(a: Int) = 0 @varargs def v(a: Int, b: String*) = a + b.length @varargs def v2(a: Int, b: String*) = 0 def v2(a: Int, b: Array[String]) = 0 - - def main(args: Array[String]) { + + def main(args: Array[String]) { } - + } diff --git a/test/files/neg/variances-refinement.check b/test/files/neg/variances-refinement.check new file mode 100644 index 0000000000..2bed3ffa6b --- /dev/null +++ b/test/files/neg/variances-refinement.check @@ -0,0 +1,22 @@ +variances-refinement.scala:17: error: contravariant type A occurs in covariant position in type ()AnyRef{def f0(x: A): A} of method fail1 + def fail1() = { object O { def f0(x: A): A = ??? } ; O } // fail + ^ +variances-refinement.scala:18: error: covariant type B occurs in contravariant position in type ()AnyRef{def f0(x: B): A} of method fail2 + def fail2() = { object O { def f0(x: B): A = ??? } ; O } // fail + ^ +variances-refinement.scala:19: error: covariant type B occurs in contravariant position in type ()AnyRef{def f0(x: B): B} of method fail3 + def fail3() = { object O { def f0(x: B): B = ??? } ; O } // fail + ^ +variances-refinement.scala:20: error: covariant type B occurs in contravariant position in type ()AnyRef{def f0(x: B): C} of method fail4 + def fail4() = { object O { def f0(x: B): C = ??? } ; O } // fail + ^ +variances-refinement.scala:21: error: contravariant type A occurs in covariant position in type ()AnyRef{def f0(x: C): A} of method fail5 + def fail5() = { object O { def f0(x: C): A = ??? } ; O } // fail + ^ +variances-refinement.scala:23: error: contravariant type A occurs in covariant position in type ()O1.type forSome { val O1: AnyRef with O0; type O0 <: AnyRef{def f0(x: A): A; def f1(x: A): B; def f2(x: A): C} } of method fail6 + def fail6() = { // fail + ^ +variances-refinement.scala:32: error: contravariant type A occurs in covariant position in type ()AnyRef{def f0(x: A): A; def f1(x: A): B; def f2(x: A): C} of method fail7 + def fail7() = { // fail + ^ +7 errors found diff --git a/test/files/neg/variances-refinement.scala b/test/files/neg/variances-refinement.scala new file mode 100644 index 0000000000..6bfd336ce0 --- /dev/null +++ b/test/files/neg/variances-refinement.scala @@ -0,0 +1,40 @@ +trait Trait[-A, +B, C] { + def ok() = { // ok + object O { + private def f0(x: A): A = ??? + def f1(x: A): B = ??? + def f2(x: A): C = ??? + private def f3(x: B): A = ??? + private def f4(x: B): B = ??? + private def f5(x: B): C = ??? + private def f6(x: C): A = ??? + def f7(x: C): B = ??? + def f8(x: C): C = ??? + } + O + } + + def fail1() = { object O { def f0(x: A): A = ??? } ; O } // fail + def fail2() = { object O { def f0(x: B): A = ??? } ; O } // fail + def fail3() = { object O { def f0(x: B): B = ??? } ; O } // fail + def fail4() = { object O { def f0(x: B): C = ??? } ; O } // fail + def fail5() = { object O { def f0(x: C): A = ??? } ; O } // fail + + def fail6() = { // fail + trait O0 { + def f0(x: A): A = ??? + def f1(x: A): B = ??? + def f2(x: A): C = ??? + } + object O1 extends O0 + O1 + } + def fail7() = { // fail + trait O0 { + def f0(x: A): A = ??? + def f1(x: A): B = ??? + def f2(x: A): C = ??? + } + new O0 { } + } +} diff --git a/test/files/neg/variances.check b/test/files/neg/variances.check index 0643e533b7..7d965e94dc 100644 --- a/test/files/neg/variances.check +++ b/test/files/neg/variances.check @@ -13,7 +13,10 @@ variances.scala:21: error: covariant type A occurs in invariant position in supe variances.scala:74: error: covariant type A occurs in contravariant position in type => test.Covariant.T[A]{val m: A => A} of value x val x: T[A] { ^ +variances.scala:89: error: covariant type T occurs in invariant position in type T of type A + type A = T + ^ variances.scala:90: error: covariant type T occurs in contravariant position in type => test.TestAlias.B[C.this.A] of method foo def foo: B[A] ^ -6 errors found +7 errors found diff --git a/test/files/neg/variances2.check b/test/files/neg/variances2.check new file mode 100644 index 0000000000..433cc125ad --- /dev/null +++ b/test/files/neg/variances2.check @@ -0,0 +1,229 @@ +variances2.scala:9: error: covariant type B occurs in contravariant position in type B of value x + def f1(x: B): Unit = () + ^ +variances2.scala:12: error: covariant type E occurs in contravariant position in type E of value x + def f4(x: E): Unit = () + ^ +variances2.scala:15: error: contravariant type A occurs in covariant position in type ()A of method f6 + def f6(): A = ??? + ^ +variances2.scala:18: error: contravariant type D occurs in covariant position in type ()D of method f9 + def f9(): D = ??? + ^ +variances2.scala:22: error: contravariant type A occurs in covariant position in type A => A of value f + def f12(f: A => A): Unit = () + ^ +variances2.scala:23: error: contravariant type A occurs in covariant position in type A => B of value f + def f13(f: A => B): Unit = () + ^ +variances2.scala:24: error: contravariant type A occurs in covariant position in type A => C of value f + def f14(f: A => C): Unit = () + ^ +variances2.scala:25: error: contravariant type A occurs in covariant position in type A => D of value f + def f15(f: A => D): Unit = () + ^ +variances2.scala:26: error: contravariant type A occurs in covariant position in type A => E of value f + def f16(f: A => E): Unit = () + ^ +variances2.scala:27: error: contravariant type A occurs in covariant position in type A => F of value f + def f17(f: A => F): Unit = () + ^ +variances2.scala:29: error: covariant type B occurs in contravariant position in type B => B of value f + def f19(f: B => B): Unit = () + ^ +variances2.scala:32: error: covariant type E occurs in contravariant position in type B => E of value f + def f22(f: B => E): Unit = () + ^ +variances2.scala:35: error: covariant type B occurs in contravariant position in type C => B of value f + def f25(f: C => B): Unit = () + ^ +variances2.scala:38: error: covariant type E occurs in contravariant position in type C => E of value f + def f28(f: C => E): Unit = () + ^ +variances2.scala:40: error: contravariant type D occurs in covariant position in type D => A of value f + def f30(f: D => A): Unit = () + ^ +variances2.scala:41: error: contravariant type D occurs in covariant position in type D => B of value f + def f31(f: D => B): Unit = () + ^ +variances2.scala:42: error: contravariant type D occurs in covariant position in type D => C of value f + def f32(f: D => C): Unit = () + ^ +variances2.scala:43: error: contravariant type D occurs in covariant position in type D => D of value f + def f33(f: D => D): Unit = () + ^ +variances2.scala:44: error: contravariant type D occurs in covariant position in type D => E of value f + def f34(f: D => E): Unit = () + ^ +variances2.scala:45: error: contravariant type D occurs in covariant position in type D => F of value f + def f35(f: D => F): Unit = () + ^ +variances2.scala:47: error: covariant type B occurs in contravariant position in type E => B of value f + def f37(f: E => B): Unit = () + ^ +variances2.scala:50: error: covariant type E occurs in contravariant position in type E => E of value f + def f40(f: E => E): Unit = () + ^ +variances2.scala:53: error: covariant type B occurs in contravariant position in type F => B of value f + def f43(f: F => B): Unit = () + ^ +variances2.scala:56: error: covariant type E occurs in contravariant position in type F => E of value f + def f46(f: F => E): Unit = () + ^ +variances2.scala:59: error: contravariant type A occurs in covariant position in type ()A => A of method f48 + def f48(): A => A = null + ^ +variances2.scala:62: error: contravariant type D occurs in covariant position in type ()A => D of method f51 + def f51(): A => D = null + ^ +variances2.scala:65: error: covariant type B occurs in contravariant position in type ()B => A of method f54 + def f54(): B => A = null + ^ +variances2.scala:66: error: covariant type B occurs in contravariant position in type ()B => B of method f55 + def f55(): B => B = null + ^ +variances2.scala:67: error: covariant type B occurs in contravariant position in type ()B => C of method f56 + def f56(): B => C = null + ^ +variances2.scala:68: error: covariant type B occurs in contravariant position in type ()B => D of method f57 + def f57(): B => D = null + ^ +variances2.scala:69: error: covariant type B occurs in contravariant position in type ()B => E of method f58 + def f58(): B => E = null + ^ +variances2.scala:70: error: covariant type B occurs in contravariant position in type ()B => F of method f59 + def f59(): B => F = null + ^ +variances2.scala:71: error: contravariant type A occurs in covariant position in type ()C => A of method f60 + def f60(): C => A = null + ^ +variances2.scala:74: error: contravariant type D occurs in covariant position in type ()C => D of method f63 + def f63(): C => D = null + ^ +variances2.scala:77: error: contravariant type A occurs in covariant position in type ()D => A of method f66 + def f66(): D => A = null + ^ +variances2.scala:80: error: contravariant type D occurs in covariant position in type ()D => D of method f69 + def f69(): D => D = null + ^ +variances2.scala:83: error: covariant type E occurs in contravariant position in type ()E => A of method f72 + def f72(): E => A = null + ^ +variances2.scala:84: error: covariant type E occurs in contravariant position in type ()E => B of method f73 + def f73(): E => B = null + ^ +variances2.scala:85: error: covariant type E occurs in contravariant position in type ()E => C of method f74 + def f74(): E => C = null + ^ +variances2.scala:86: error: covariant type E occurs in contravariant position in type ()E => D of method f75 + def f75(): E => D = null + ^ +variances2.scala:87: error: covariant type E occurs in contravariant position in type ()E => E of method f76 + def f76(): E => E = null + ^ +variances2.scala:88: error: covariant type E occurs in contravariant position in type ()E => F of method f77 + def f77(): E => F = null + ^ +variances2.scala:89: error: contravariant type A occurs in covariant position in type ()F => A of method f78 + def f78(): F => A = null + ^ +variances2.scala:92: error: contravariant type D occurs in covariant position in type ()F => D of method f81 + def f81(): F => D = null + ^ +variances2.scala:96: error: contravariant type A occurs in covariant position in type (x: A)A of method f84 + def f84(x: A): A = ??? + ^ +variances2.scala:99: error: contravariant type D occurs in covariant position in type (x: A)D of method f87 + def f87(x: A): D = ??? + ^ +variances2.scala:102: error: contravariant type A occurs in covariant position in type (x: B)A of method f90 + def f90(x: B): A = ??? + ^ +variances2.scala:102: error: covariant type B occurs in contravariant position in type B of value x + def f90(x: B): A = ??? + ^ +variances2.scala:103: error: covariant type B occurs in contravariant position in type B of value x + def f91(x: B): B = ??? + ^ +variances2.scala:104: error: covariant type B occurs in contravariant position in type B of value x + def f92(x: B): C = ??? + ^ +variances2.scala:105: error: contravariant type D occurs in covariant position in type (x: B)D of method f93 + def f93(x: B): D = ??? + ^ +variances2.scala:105: error: covariant type B occurs in contravariant position in type B of value x + def f93(x: B): D = ??? + ^ +variances2.scala:106: error: covariant type B occurs in contravariant position in type B of value x + def f94(x: B): E = ??? + ^ +variances2.scala:107: error: covariant type B occurs in contravariant position in type B of value x + def f95(x: B): F = ??? + ^ +variances2.scala:108: error: contravariant type A occurs in covariant position in type (x: C)A of method f96 + def f96(x: C): A = ??? + ^ +variances2.scala:111: error: contravariant type D occurs in covariant position in type (x: C)D of method f99 + def f99(x: C): D = ??? + ^ +variances2.scala:114: error: contravariant type A occurs in covariant position in type (x: D)A of method f102 + def f102(x: D): A = ??? + ^ +variances2.scala:117: error: contravariant type D occurs in covariant position in type (x: D)D of method f105 + def f105(x: D): D = ??? + ^ +variances2.scala:120: error: contravariant type A occurs in covariant position in type (x: E)A of method f108 + def f108(x: E): A = ??? + ^ +variances2.scala:120: error: covariant type E occurs in contravariant position in type E of value x + def f108(x: E): A = ??? + ^ +variances2.scala:121: error: covariant type E occurs in contravariant position in type E of value x + def f109(x: E): B = ??? + ^ +variances2.scala:122: error: covariant type E occurs in contravariant position in type E of value x + def f110(x: E): C = ??? + ^ +variances2.scala:123: error: contravariant type D occurs in covariant position in type (x: E)D of method f111 + def f111(x: E): D = ??? + ^ +variances2.scala:123: error: covariant type E occurs in contravariant position in type E of value x + def f111(x: E): D = ??? + ^ +variances2.scala:124: error: covariant type E occurs in contravariant position in type E of value x + def f112(x: E): E = ??? + ^ +variances2.scala:125: error: covariant type E occurs in contravariant position in type E of value x + def f113(x: E): F = ??? + ^ +variances2.scala:126: error: contravariant type A occurs in covariant position in type (x: F)A of method f114 + def f114(x: F): A = ??? + ^ +variances2.scala:129: error: contravariant type D occurs in covariant position in type (x: F)D of method f117 + def f117(x: F): D = ??? + ^ +variances2.scala:133: error: contravariant type A occurs in covariant position in supertype Cov[A] of object O1 + object O1 extends Cov[A] + ^ +variances2.scala:136: error: contravariant type D occurs in covariant position in supertype Cov[D] of object O4 + object O4 extends Cov[D] + ^ +variances2.scala:140: error: covariant type B occurs in contravariant position in supertype Con[B] of object O8 + object O8 extends Con[B] + ^ +variances2.scala:143: error: covariant type E occurs in contravariant position in supertype Con[E] of object O11 + object O11 extends Con[E] + ^ +variances2.scala:145: error: contravariant type A occurs in invariant position in supertype Inv[A] of object O13 + object O13 extends Inv[A] + ^ +variances2.scala:146: error: covariant type B occurs in invariant position in supertype Inv[B] of object O14 + object O14 extends Inv[B] + ^ +variances2.scala:148: error: contravariant type D occurs in invariant position in supertype Inv[D] of object O16 + object O16 extends Inv[D] + ^ +variances2.scala:149: error: covariant type E occurs in invariant position in supertype Inv[E] of object O17 + object O17 extends Inv[E] + ^ +76 errors found diff --git a/test/files/neg/variances2.scala b/test/files/neg/variances2.scala new file mode 100644 index 0000000000..d30345dd83 --- /dev/null +++ b/test/files/neg/variances2.scala @@ -0,0 +1,303 @@ +trait Cov[+A] +trait Con[-A] +trait Inv[A] + +trait Trait[-A, +B, C] { + // trait Inner[-D <: C, +E >: C, F] { + trait Inner[-D <: C, +E >: C, F] { + def f0(x: A): Unit = () + def f1(x: B): Unit = () + def f2(x: C): Unit = () + def f3(x: D): Unit = () + def f4(x: E): Unit = () + def f5(x: F): Unit = () + + def f6(): A = ??? + def f7(): B = ??? + def f8(): C = ??? + def f9(): D = ??? + def f10(): E = ??? + def f11(): F = ??? + + def f12(f: A => A): Unit = () + def f13(f: A => B): Unit = () + def f14(f: A => C): Unit = () + def f15(f: A => D): Unit = () + def f16(f: A => E): Unit = () + def f17(f: A => F): Unit = () + def f18(f: B => A): Unit = () + def f19(f: B => B): Unit = () + def f20(f: B => C): Unit = () + def f21(f: B => D): Unit = () + def f22(f: B => E): Unit = () + def f23(f: B => F): Unit = () + def f24(f: C => A): Unit = () + def f25(f: C => B): Unit = () + def f26(f: C => C): Unit = () + def f27(f: C => D): Unit = () + def f28(f: C => E): Unit = () + def f29(f: C => F): Unit = () + def f30(f: D => A): Unit = () + def f31(f: D => B): Unit = () + def f32(f: D => C): Unit = () + def f33(f: D => D): Unit = () + def f34(f: D => E): Unit = () + def f35(f: D => F): Unit = () + def f36(f: E => A): Unit = () + def f37(f: E => B): Unit = () + def f38(f: E => C): Unit = () + def f39(f: E => D): Unit = () + def f40(f: E => E): Unit = () + def f41(f: E => F): Unit = () + def f42(f: F => A): Unit = () + def f43(f: F => B): Unit = () + def f44(f: F => C): Unit = () + def f45(f: F => D): Unit = () + def f46(f: F => E): Unit = () + def f47(f: F => F): Unit = () + + def f48(): A => A = null + def f49(): A => B = null + def f50(): A => C = null + def f51(): A => D = null + def f52(): A => E = null + def f53(): A => F = null + def f54(): B => A = null + def f55(): B => B = null + def f56(): B => C = null + def f57(): B => D = null + def f58(): B => E = null + def f59(): B => F = null + def f60(): C => A = null + def f61(): C => B = null + def f62(): C => C = null + def f63(): C => D = null + def f64(): C => E = null + def f65(): C => F = null + def f66(): D => A = null + def f67(): D => B = null + def f68(): D => C = null + def f69(): D => D = null + def f70(): D => E = null + def f71(): D => F = null + def f72(): E => A = null + def f73(): E => B = null + def f74(): E => C = null + def f75(): E => D = null + def f76(): E => E = null + def f77(): E => F = null + def f78(): F => A = null + def f79(): F => B = null + def f80(): F => C = null + def f81(): F => D = null + def f82(): F => E = null + def f83(): F => F = null + + def f84(x: A): A = ??? + def f85(x: A): B = ??? + def f86(x: A): C = ??? + def f87(x: A): D = ??? + def f88(x: A): E = ??? + def f89(x: A): F = ??? + def f90(x: B): A = ??? + def f91(x: B): B = ??? + def f92(x: B): C = ??? + def f93(x: B): D = ??? + def f94(x: B): E = ??? + def f95(x: B): F = ??? + def f96(x: C): A = ??? + def f97(x: C): B = ??? + def f98(x: C): C = ??? + def f99(x: C): D = ??? + def f100(x: C): E = ??? + def f101(x: C): F = ??? + def f102(x: D): A = ??? + def f103(x: D): B = ??? + def f104(x: D): C = ??? + def f105(x: D): D = ??? + def f106(x: D): E = ??? + def f107(x: D): F = ??? + def f108(x: E): A = ??? + def f109(x: E): B = ??? + def f110(x: E): C = ??? + def f111(x: E): D = ??? + def f112(x: E): E = ??? + def f113(x: E): F = ??? + def f114(x: F): A = ??? + def f115(x: F): B = ??? + def f116(x: F): C = ??? + def f117(x: F): D = ??? + def f118(x: F): E = ??? + def f119(x: F): F = ??? + + object O1 extends Cov[A] + object O2 extends Cov[B] + object O3 extends Cov[C] + object O4 extends Cov[D] + object O5 extends Cov[E] + object O6 extends Cov[F] + object O7 extends Con[A] + object O8 extends Con[B] + object O9 extends Con[C] + object O10 extends Con[D] + object O11 extends Con[E] + object O12 extends Con[F] + object O13 extends Inv[A] + object O14 extends Inv[B] + object O15 extends Inv[C] + object O16 extends Inv[D] + object O17 extends Inv[E] + object O18 extends Inv[F] + } +} + +trait Trait2[-A, +B, C] { + // trait Inner[-D <: C, +E >: C, F] { + def method[D <: A, E >: B, F]() { + def f0(x: A): Unit = () + def f1(x: B): Unit = () + def f2(x: C): Unit = () + def f3(x: D): Unit = () + def f4(x: E): Unit = () + def f5(x: F): Unit = () + + def f6(): A = ??? + def f7(): B = ??? + def f8(): C = ??? + def f9(): D = ??? + def f10(): E = ??? + def f11(): F = ??? + + def f12(f: A => A): Unit = () + def f13(f: A => B): Unit = () + def f14(f: A => C): Unit = () + def f15(f: A => D): Unit = () + def f16(f: A => E): Unit = () + def f17(f: A => F): Unit = () + def f18(f: B => A): Unit = () + def f19(f: B => B): Unit = () + def f20(f: B => C): Unit = () + def f21(f: B => D): Unit = () + def f22(f: B => E): Unit = () + def f23(f: B => F): Unit = () + def f24(f: C => A): Unit = () + def f25(f: C => B): Unit = () + def f26(f: C => C): Unit = () + def f27(f: C => D): Unit = () + def f28(f: C => E): Unit = () + def f29(f: C => F): Unit = () + def f30(f: D => A): Unit = () + def f31(f: D => B): Unit = () + def f32(f: D => C): Unit = () + def f33(f: D => D): Unit = () + def f34(f: D => E): Unit = () + def f35(f: D => F): Unit = () + def f36(f: E => A): Unit = () + def f37(f: E => B): Unit = () + def f38(f: E => C): Unit = () + def f39(f: E => D): Unit = () + def f40(f: E => E): Unit = () + def f41(f: E => F): Unit = () + def f42(f: F => A): Unit = () + def f43(f: F => B): Unit = () + def f44(f: F => C): Unit = () + def f45(f: F => D): Unit = () + def f46(f: F => E): Unit = () + def f47(f: F => F): Unit = () + + def f48(): A => A = null + def f49(): A => B = null + def f50(): A => C = null + def f51(): A => D = null + def f52(): A => E = null + def f53(): A => F = null + def f54(): B => A = null + def f55(): B => B = null + def f56(): B => C = null + def f57(): B => D = null + def f58(): B => E = null + def f59(): B => F = null + def f60(): C => A = null + def f61(): C => B = null + def f62(): C => C = null + def f63(): C => D = null + def f64(): C => E = null + def f65(): C => F = null + def f66(): D => A = null + def f67(): D => B = null + def f68(): D => C = null + def f69(): D => D = null + def f70(): D => E = null + def f71(): D => F = null + def f72(): E => A = null + def f73(): E => B = null + def f74(): E => C = null + def f75(): E => D = null + def f76(): E => E = null + def f77(): E => F = null + def f78(): F => A = null + def f79(): F => B = null + def f80(): F => C = null + def f81(): F => D = null + def f82(): F => E = null + def f83(): F => F = null + + def f84(x: A): A = ??? + def f85(x: A): B = ??? + def f86(x: A): C = ??? + def f87(x: A): D = ??? + def f88(x: A): E = ??? + def f89(x: A): F = ??? + def f90(x: B): A = ??? + def f91(x: B): B = ??? + def f92(x: B): C = ??? + def f93(x: B): D = ??? + def f94(x: B): E = ??? + def f95(x: B): F = ??? + def f96(x: C): A = ??? + def f97(x: C): B = ??? + def f98(x: C): C = ??? + def f99(x: C): D = ??? + def f100(x: C): E = ??? + def f101(x: C): F = ??? + def f102(x: D): A = ??? + def f103(x: D): B = ??? + def f104(x: D): C = ??? + def f105(x: D): D = ??? + def f106(x: D): E = ??? + def f107(x: D): F = ??? + def f108(x: E): A = ??? + def f109(x: E): B = ??? + def f110(x: E): C = ??? + def f111(x: E): D = ??? + def f112(x: E): E = ??? + def f113(x: E): F = ??? + def f114(x: F): A = ??? + def f115(x: F): B = ??? + def f116(x: F): C = ??? + def f117(x: F): D = ??? + def f118(x: F): E = ??? + def f119(x: F): F = ??? + + object O1 extends Cov[A] + object O2 extends Cov[B] + object O3 extends Cov[C] + object O4 extends Cov[D] + object O5 extends Cov[E] + object O6 extends Cov[F] + object O7 extends Con[A] + object O8 extends Con[B] + object O9 extends Con[C] + object O10 extends Con[D] + object O11 extends Con[E] + object O12 extends Con[F] + object O13 extends Inv[A] + object O14 extends Inv[B] + object O15 extends Inv[C] + object O16 extends Inv[D] + object O17 extends Inv[E] + object O18 extends Inv[F] + + () + } +} diff --git a/test/files/neg/viewtest.scala b/test/files/neg/viewtest.scala index ddb7fa4a3b..5e7d624d23 100644 --- a/test/files/neg/viewtest.scala +++ b/test/files/neg/viewtest.scala @@ -37,7 +37,7 @@ object O { } } - implicit def view3[a <% Ordered[a]](x: List[a]): Ordered[List[a]] = + implicit def view3[a <% Ordered[a]](x: List[a]): Ordered[List[a]] = new Ordered[List[a]] { def compareTo [b >: List[a] <% Ordered[b]](y: b): Int = y match { case y1: List[a] => compareLists(x, y1) @@ -72,7 +72,7 @@ class Node[a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] { if (x == elem) this else if (x < elem) new Node(elem, l insert x, r) else new Node(elem, l, r insert x) - def elements: List[a] = + def elements: List[a] = l.elements ::: List(elem) ::: r.elements } @@ -86,7 +86,7 @@ case class Str(elem: String) extends Ordered[Str] { object Test { import O._ - private def toCharList(s: String): List[Char] = + private def toCharList(s: String): List[Char] = if (s.length() == 0) List() else s.charAt(0) :: toCharList(s.substring(1)) diff --git a/test/files/neg/virtpatmat_reach_null.check b/test/files/neg/virtpatmat_reach_null.check index 595c8ec889..e0c36c8c5b 100644 --- a/test/files/neg/virtpatmat_reach_null.check +++ b/test/files/neg/virtpatmat_reach_null.check @@ -1,4 +1,6 @@ -virtpatmat_reach_null.scala:13: error: unreachable code +virtpatmat_reach_null.scala:13: warning: unreachable code case _ => // unreachable ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/virtpatmat_reach_sealed_unsealed.check b/test/files/neg/virtpatmat_reach_sealed_unsealed.check index 10638eff52..064a12bcaa 100644 --- a/test/files/neg/virtpatmat_reach_sealed_unsealed.check +++ b/test/files/neg/virtpatmat_reach_sealed_unsealed.check @@ -1,14 +1,16 @@ -virtpatmat_reach_sealed_unsealed.scala:16: error: match may not be exhaustive. +virtpatmat_reach_sealed_unsealed.scala:16: warning: match may not be exhaustive. It would fail on the following input: false (true: Boolean) match { case true => } // not exhaustive, but reachable ^ -virtpatmat_reach_sealed_unsealed.scala:18: error: unreachable code +virtpatmat_reach_sealed_unsealed.scala:18: warning: unreachable code (true: Boolean) match { case true => case false => case _ => } // exhaustive, last case is unreachable ^ -virtpatmat_reach_sealed_unsealed.scala:19: error: unreachable code +virtpatmat_reach_sealed_unsealed.scala:19: warning: unreachable code (true: Boolean) match { case true => case false => case _: Boolean => } // exhaustive, last case is unreachable ^ -virtpatmat_reach_sealed_unsealed.scala:20: error: unreachable code +virtpatmat_reach_sealed_unsealed.scala:20: warning: unreachable code (true: Boolean) match { case true => case false => case _: Any => } // exhaustive, last case is unreachable ^ -four errors found +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/virtpatmat_unreach_select.check b/test/files/neg/virtpatmat_unreach_select.check index 3771971020..4fc78cd412 100644 --- a/test/files/neg/virtpatmat_unreach_select.check +++ b/test/files/neg/virtpatmat_unreach_select.check @@ -1,4 +1,6 @@ -virtpatmat_unreach_select.scala:10: error: unreachable code +virtpatmat_unreach_select.scala:10: warning: unreachable code case WARNING.id => // unreachable ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found one error found diff --git a/test/files/neg/volatile_no_override.check b/test/files/neg/volatile_no_override.check new file mode 100644 index 0000000000..a9a60ab697 --- /dev/null +++ b/test/files/neg/volatile_no_override.check @@ -0,0 +1,5 @@ +volatile_no_override.scala:13: error: overriding value x in class A of type Volatile.this.D; + value x has a volatile type; cannot override a member with non-volatile type + val x: A with D = null + ^ +one error found diff --git a/test/files/neg/volatile_no_override.scala b/test/files/neg/volatile_no_override.scala new file mode 100644 index 0000000000..9fad082a90 --- /dev/null +++ b/test/files/neg/volatile_no_override.scala @@ -0,0 +1,14 @@ +class B +class C(x: String) extends B + +abstract class A { + class D { type T >: C <: B } + val x: D + var y: x.T = new C("abc") +} + +class Volatile extends A { + type A >: Null + // test (1.4), pt 2 in RefChecks + val x: A with D = null +} diff --git a/test/files/neg/warn-inferred-any.check b/test/files/neg/warn-inferred-any.check new file mode 100644 index 0000000000..4628033e55 --- /dev/null +++ b/test/files/neg/warn-inferred-any.check @@ -0,0 +1,12 @@ +warn-inferred-any.scala:8: warning: a type was inferred to be `Any`; this may indicate a programming error. + { List(1, 2, 3) contains "a" } // only this warns + ^ +warn-inferred-any.scala:16: warning: a type was inferred to be `AnyVal`; this may indicate a programming error. + { 1l to 5l contains 5 } + ^ +warn-inferred-any.scala:17: warning: a type was inferred to be `AnyVal`; this may indicate a programming error. + { 1l to 5l contains 5d } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/warn-inferred-any.flags b/test/files/neg/warn-inferred-any.flags new file mode 100644 index 0000000000..a3127d392a --- /dev/null +++ b/test/files/neg/warn-inferred-any.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Ywarn-infer-any diff --git a/test/files/neg/warn-inferred-any.scala b/test/files/neg/warn-inferred-any.scala new file mode 100644 index 0000000000..b853e6e5a8 --- /dev/null +++ b/test/files/neg/warn-inferred-any.scala @@ -0,0 +1,19 @@ +trait Foo[-A <: AnyRef, +B <: AnyRef] { + def run[U](x: A)(action: B => U): Boolean = ??? + + { run(_: A)(_: B => String) } +} + +trait Xs[+A] { + { List(1, 2, 3) contains "a" } // only this warns + { List(1, 2, 3) contains 1 } + { identity(List(1, 2, 3) contains 1) } + { List("a") foreach println } +} + +trait Ys[+A] { + { 1 to 5 contains 5l } + { 1l to 5l contains 5 } + { 1l to 5l contains 5d } + { 1l to 5l contains 5l } +} diff --git a/test/files/neg/warn-unused-imports.check b/test/files/neg/warn-unused-imports.check new file mode 100644 index 0000000000..1b938f4fd7 --- /dev/null +++ b/test/files/neg/warn-unused-imports.check @@ -0,0 +1,44 @@ +warn-unused-imports.scala:7: warning: it is not recommended to define classes/objects inside of package objects. +If possible, define class A in package p1 instead. + class A + ^ +warn-unused-imports.scala:13: warning: it is not recommended to define classes/objects inside of package objects. +If possible, define class A in package p2 instead. + class A + ^ +warn-unused-imports.scala:57: warning: Unused import + import p1.A // warn + ^ +warn-unused-imports.scala:62: warning: Unused import + import p1.{ A, B } // warn on A + ^ +warn-unused-imports.scala:67: warning: Unused import + import p1.{ A, B } // warn on both + ^ +warn-unused-imports.scala:67: warning: Unused import + import p1.{ A, B } // warn on both + ^ +warn-unused-imports.scala:73: warning: Unused import + import c._ // warn + ^ +warn-unused-imports.scala:78: warning: Unused import + import p1._ // warn + ^ +warn-unused-imports.scala:85: warning: Unused import + import c._ // warn + ^ +warn-unused-imports.scala:91: warning: Unused import + import p1.c._ // warn + ^ +warn-unused-imports.scala:98: warning: Unused import + import p1._ // warn + ^ +warn-unused-imports.scala:118: warning: Unused import + import p1.A // warn + ^ +warn-unused-imports.scala:99: warning: local trait Warn is never used + trait Warn { // warn about unused local trait for good measure + ^ +error: No warnings can be incurred under -Xfatal-warnings. +13 warnings found +one error found diff --git a/test/files/neg/warn-unused-imports.flags b/test/files/neg/warn-unused-imports.flags new file mode 100644 index 0000000000..954eaba352 --- /dev/null +++ b/test/files/neg/warn-unused-imports.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Xlint diff --git a/test/files/neg/warn-unused-imports.scala b/test/files/neg/warn-unused-imports.scala new file mode 100644 index 0000000000..b7a2f1c414 --- /dev/null +++ b/test/files/neg/warn-unused-imports.scala @@ -0,0 +1,125 @@ +class Bippo { + def length: Int = 123 + class Tree +} + +package object p1 { + class A + implicit class B(val s: String) { def bippy = s } + val c: Bippo = new Bippo + type D = String +} +package object p2 { + class A + implicit class B(val s: String) { def bippy = s } + val c: Bippo = new Bippo + type D = Int +} + +trait NoWarn { + { + import p1._ // no warn + println("abc".bippy) + } + + { + import p1._ // no warn + println(new A) + } + + { + import p1.B // no warn + println("abc".bippy) + } + + { + import p1._ // no warn + import c._ // no warn + println(length) + } + + { + import p1._ // no warn + import c._ // no warn + val x: Tree = null + println(x) + } + + { + import p1.D // no warn + val x: D = null + println(x) + } +} + +trait Warn { + { + import p1.A // warn + println(123) + } + + { + import p1.{ A, B } // warn on A + println("abc".bippy) + } + + { + import p1.{ A, B } // warn on both + println(123) + } + + { + import p1._ // no warn (technically this could warn, but not worth the effort to unroll unusedness transitively) + import c._ // warn + println(123) + } + + { + import p1._ // warn + println(123) + } + + { + class Tree + import p1._ // no warn + import c._ // warn + val x: Tree = null + println(x) + } + + { + import p1.c._ // warn + println(123) + } +} + +trait Nested { + { + import p1._ // warn + trait Warn { // warn about unused local trait for good measure + import p2._ + println(new A) + println("abc".bippy) + } + println("") + } + + { + import p1._ // no warn + trait NoWarn { + import p2.B // no warn + println("abc".bippy) + println(new A) + } + println(new NoWarn { }) + } + + { + import p1.A // warn + trait Warn { + import p2.A + println(new A) + } + println(new Warn { }) + } +} diff --git a/test/files/neg/warn-unused-privates.check b/test/files/neg/warn-unused-privates.check new file mode 100644 index 0000000000..9c41a33e8f --- /dev/null +++ b/test/files/neg/warn-unused-privates.check @@ -0,0 +1,63 @@ +warn-unused-privates.scala:2: warning: private constructor in class Bippy is never used + private def this(c: Int) = this(c, c) // warn + ^ +warn-unused-privates.scala:4: warning: private method in class Bippy is never used + private def boop(x: Int) = x+a+b // warn + ^ +warn-unused-privates.scala:6: warning: private val in class Bippy is never used + final private val MILLIS2: Int = 1000 // warn + ^ +warn-unused-privates.scala:13: warning: private val in object Bippy is never used + private val HEY_INSTANCE: Int = 1000 // warn + ^ +warn-unused-privates.scala:35: warning: private val in class Boppy is never used + private val hummer = "def" // warn + ^ +warn-unused-privates.scala:42: warning: private var in trait Accessors is never used + private var v1: Int = 0 // warn + ^ +warn-unused-privates.scala:43: warning: private setter in trait Accessors is never used + private var v2: Int = 0 // warn, never set + ^ +warn-unused-privates.scala:44: warning: private var in trait Accessors is never used + private var v3: Int = 0 // warn, never got + ^ +warn-unused-privates.scala:56: warning: private default argument in trait DefaultArgs is never used + private def bippy(x1: Int, x2: Int = 10, x3: Int = 15): Int = x1 + x2 + x3 + ^ +warn-unused-privates.scala:56: warning: private default argument in trait DefaultArgs is never used + private def bippy(x1: Int, x2: Int = 10, x3: Int = 15): Int = x1 + x2 + x3 + ^ +warn-unused-privates.scala:67: warning: local var in method f0 is never used + var x = 1 // warn + ^ +warn-unused-privates.scala:74: warning: local val in method f1 is never used + val b = new Outer // warn + ^ +warn-unused-privates.scala:84: warning: private object in object Types is never used + private object Dongo { def f = this } // warn + ^ +warn-unused-privates.scala:94: warning: local object in method l1 is never used + object HiObject { def f = this } // warn + ^ +warn-unused-privates.scala:78: warning: local var x in method f2 is never set - it could be a val + var x = 100 // warn about it being a var + ^ +warn-unused-privates.scala:85: warning: private class Bar1 in object Types is never used + private class Bar1 // warn + ^ +warn-unused-privates.scala:87: warning: private type Alias1 in object Types is never used + private type Alias1 = String // warn + ^ +warn-unused-privates.scala:95: warning: local class Hi is never used + class Hi { // warn + ^ +warn-unused-privates.scala:99: warning: local class DingDongDoobie is never used + class DingDongDoobie // warn + ^ +warn-unused-privates.scala:102: warning: local type OtherThing is never used + type OtherThing = String // warn + ^ +error: No warnings can be incurred under -Xfatal-warnings. +20 warnings found +one error found diff --git a/test/files/neg/warn-unused-privates.flags b/test/files/neg/warn-unused-privates.flags new file mode 100644 index 0000000000..7949c2afa2 --- /dev/null +++ b/test/files/neg/warn-unused-privates.flags @@ -0,0 +1 @@ +-Xlint -Xfatal-warnings diff --git a/test/files/neg/warn-unused-privates.scala b/test/files/neg/warn-unused-privates.scala new file mode 100644 index 0000000000..cb6e946a34 --- /dev/null +++ b/test/files/neg/warn-unused-privates.scala @@ -0,0 +1,105 @@ +class Bippy(a: Int, b: Int) { + private def this(c: Int) = this(c, c) // warn + private def bippy(x: Int): Int = bippy(x) // TODO: could warn + private def boop(x: Int) = x+a+b // warn + final private val MILLIS1 = 2000 // no warn, might have been inlined + final private val MILLIS2: Int = 1000 // warn + final private val HI_COMPANION: Int = 500 // no warn, accessed from companion + def hi() = Bippy.HI_INSTANCE +} +object Bippy { + def hi(x: Bippy) = x.HI_COMPANION + private val HI_INSTANCE: Int = 500 // no warn, accessed from instance + private val HEY_INSTANCE: Int = 1000 // warn +} + +class A(val msg: String) +class B1(msg: String) extends A(msg) +class B2(msg0: String) extends A(msg0) +class B3(msg0: String) extends A("msg") + +/*** Early defs warnings disabled primarily due to SI-6595. + * The test case is here to assure we aren't issuing false positives; + * the ones labeled "warn" don't warn. + ***/ +class Boppy extends { + private val hmm: String = "abc" // no warn, used in early defs + private val hom: String = "def" // no warn, used in body + private final val him = "ghi" // no warn, might have been (was) inlined + final val him2 = "ghi" // no warn, same + final val himinline = him + private val hum: String = "jkl" // warn + final val ding = hmm.length +} with Mutable { + val dinger = hom + private val hummer = "def" // warn + + private final val bum = "ghi" // no warn, might have been (was) inlined + final val bum2 = "ghi" // no warn, same +} + +trait Accessors { + private var v1: Int = 0 // warn + private var v2: Int = 0 // warn, never set + private var v3: Int = 0 // warn, never got + private var v4: Int = 0 // no warn + + def bippy(): Int = { + v3 = 5 + v4 = 6 + v2 + v4 + } +} + +trait DefaultArgs { + // warn about default getters for x2 and x3 + private def bippy(x1: Int, x2: Int = 10, x3: Int = 15): Int = x1 + x2 + x3 + + def boppy() = bippy(5, 100, 200) +} + +class Outer { + class Inner +} + +trait Locals { + def f0 = { + var x = 1 // warn + var y = 2 + y = 3 + y + y + } + def f1 = { + val a = new Outer // no warn + val b = new Outer // warn + new a.Inner + } + def f2 = { + var x = 100 // warn about it being a var + x + } +} + +object Types { + private object Dongo { def f = this } // warn + private class Bar1 // warn + private class Bar2 // no warn + private type Alias1 = String // warn + private type Alias2 = String // no warn + def bippo = (new Bar2).toString + + def f(x: Alias2) = x.length + + def l1() = { + object HiObject { def f = this } // warn + class Hi { // warn + def f1: Hi = new Hi + def f2(x: Hi) = x + } + class DingDongDoobie // warn + class Bippy // no warn + type Something = Bippy // no warn + type OtherThing = String // warn + (new Bippy): Something + } +} diff --git a/test/files/pos/CustomGlobal.scala b/test/files/pos/CustomGlobal.scala index 30bf227950..a5668bd7c0 100644 --- a/test/files/pos/CustomGlobal.scala +++ b/test/files/pos/CustomGlobal.scala @@ -22,7 +22,7 @@ class CustomGlobal(currentSettings: Settings, reporter: Reporter) extends Global override def newTyper(context: Context): Typer = new CustomTyper(context) class CustomTyper(context : Context) extends Typer(context) { - override def typed(tree: Tree, mode: Int, pt: Type): Tree = { + override def typed(tree: Tree, mode: Mode, pt: Type): Tree = { if (tree.summaryString contains "Bippy") println("I'm typing a Bippy! It's a " + tree.shortClass + ".") diff --git a/test/files/pos/List1.scala b/test/files/pos/List1.scala index 9d3a51f4e3..30ebf5e1e7 100644 --- a/test/files/pos/List1.scala +++ b/test/files/pos/List1.scala @@ -9,15 +9,15 @@ object lists { def Nil[b] = new List[b] { def isEmpty: Boolean = true; - def head = error("head of Nil"); - def tail = error("tail of Nil"); + def head = sys.error("head of Nil"); + def tail = sys.error("tail of Nil"); } def Cons[c](x: c, xs: List[c]): List[c] = new List[c] { def isEmpty = false; def head = x; def tail = xs; - } + } def foo = { val intnil = Nil[Int]; diff --git a/test/files/pos/MailBox.scala b/test/files/pos/MailBox.scala index 2a3f02df0b..8e27bd362d 100644 --- a/test/files/pos/MailBox.scala +++ b/test/files/pos/MailBox.scala @@ -24,7 +24,7 @@ class MailBox { private val sent = new LinkedList[Any]; private var lastSent = sent; private val receivers = new LinkedList[Receiver]; - private var lastReceiver = receivers; + private var lastReceiver = receivers; def send(msg: Any): Unit = synchronized { var r = receivers; @@ -59,7 +59,7 @@ class MailBox { } f(msg) } - + def receiveWithin[a](msec: Long)(f: PartialFunction[Any, a]): a = { val msg: Any = synchronized { var s = sent; diff --git a/test/files/pos/SI-7638.scala b/test/files/pos/SI-7638.scala index da16e0bd2c..831475d005 100644 --- a/test/files/pos/SI-7638.scala +++ b/test/files/pos/SI-7638.scala @@ -9,7 +9,7 @@ trait ArrayVectorOrder[@specialized(Int) A] extends Ordering[A] { } object vectorOrder { - implicit def arrayOrder[@specialized(Int) A]() = + implicit def arrayOrder[@specialized(Int) A]() = /* * Before applying patch: * @@ -17,8 +17,8 @@ object vectorOrder { * during phase: mixin * library version: version 2.10.3-20130625-164027-d22e8d282c * compiler version: version 2.10.3-20130627-153946-54cb6af7db - * reconstructed args: - * + * reconstructed args: + * * last tree to typer: TypeTree(class Array) * symbol: class Array in package scala (flags: final) * symbol definition: final class Array[T >: ? <: ?] extends Object @@ -27,12 +27,12 @@ object vectorOrder { * context owners: anonymous class anon$1 -> package compile * * == Expanded type of tree == - * + * * TypeRef( * TypeSymbol(final class Array[T >: ? <: ?] extends Object) * args = List(TypeRef(TypeSymbol(final abstract class Int extends ))) * ) - * + * * unhandled exception while transforming SI-7638.scala * error: uncaught exception during compilation: java.lang.UnsupportedOperationException * error: java.lang.UnsupportedOperationException: tail of empty list diff --git a/test/files/pos/Transactions.scala b/test/files/pos/Transactions.scala index 525eff7514..32889f8180 100644 --- a/test/files/pos/Transactions.scala +++ b/test/files/pos/Transactions.scala @@ -28,7 +28,7 @@ class Transaction { var next: Transaction = null def this(hd: Transaction, tl: Transaction) = { this(); this.head = head; this.next = next } - + def makeAbort() = synchronized { while (status != Transaction.Aborted && status != Transaction.Committed) { status = Transaction.Abortable @@ -48,7 +48,7 @@ class Transaction { case ex: AbortException => abort(); None case ex: Throwable => abort(); throw ex } - + } trait Transactional { @@ -58,7 +58,7 @@ trait Transactional { /** copy back snapshot */ def rollBack(): Unit - + var readers: Transaction var writer: Transaction @@ -66,11 +66,11 @@ trait Transactional { if (writer == null) null else if (writer.status == Transaction.Running) writer else { - if (writer.status != Transaction.Committed) rollBack(); - writer = null; - null + if (writer.status != Transaction.Committed) rollBack(); + writer = null; + null } - + def getter(thisTrans: Transaction) { if (writer == thisTrans) return var r = readers @@ -96,7 +96,7 @@ trait Transactional { synchronized { val w = currentWriter() if (w != null) - if (thisTrans.id < w.id) { w.makeAbort(); rollBack() } + if (thisTrans.id < w.id) { w.makeAbort(); rollBack() } else throw new AbortException var r = readers while (r != null && r.head.status != Transaction.Running) { r = r.next; readers = r } @@ -111,4 +111,3 @@ trait Transactional { } } } - diff --git a/test/files/pos/annotated-treecopy/Impls_Macros_1.scala b/test/files/pos/annotated-treecopy/Impls_Macros_1.scala index d92fbca380..ecf8916c46 100644 --- a/test/files/pos/annotated-treecopy/Impls_Macros_1.scala +++ b/test/files/pos/annotated-treecopy/Impls_Macros_1.scala @@ -21,8 +21,8 @@ object Macros { // normalize argument name var b1 = new Transformer { override def transform(tree: Tree): Tree = tree match { - case Ident(x) if (x==n) => Ident(newTermName("_arg")) - case tt @ TypeTree() if tt.original != null => TypeTree(tt.tpe) setOriginal transform(tt.original) + case Ident(x) if (x==n) => Ident(TermName("_arg")) + case tt: TypeTree if tt.original != null => TypeTree(tt.tpe) setOriginal transform(tt.original) // without the fix to LazyTreeCopier.Annotated, we would need to uncomment the line below to make the macro work // that's because the pattern match in the input expression gets expanded into Typed(<x>, TypeTree(<Int @unchecked>)) // with the original of the TypeTree being Annotated(<@unchecked>, Ident(<x>)) diff --git a/test/files/pos/annotations.scala b/test/files/pos/annotations.scala index 706a715bad..4832ce4ecd 100644 --- a/test/files/pos/annotations.scala +++ b/test/files/pos/annotations.scala @@ -2,7 +2,7 @@ class ann(i: Int) extends scala.annotation.Annotation class cfann(x: String) extends annotation.ClassfileAnnotation // annotations on abstract types -abstract class C1[@serializable @cloneable +T, U, V[_]] +abstract class C1[@annotation.elidable(0) +T, U, V[_]] abstract class C2[@deprecated @ann(1) T <: Number, V] diff --git a/test/files/pos/annotations2.scala b/test/files/pos/annotations2.scala new file mode 100644 index 0000000000..3bce7f8ac4 --- /dev/null +++ b/test/files/pos/annotations2.scala @@ -0,0 +1,31 @@ + +class B[T](x: (T, T)) { + def this(xx: (T, Any, Any)) = this((xx._1, xx._1)) +} +class BAnn[T](x: (T, T)) extends scala.annotation.StaticAnnotation { + def this(xx: (T, Any, Any)) = this((xx._1, xx._1)) +} +class CAnn[T](x: (T, T)) extends scala.annotation.StaticAnnotation { + def this(xx: Class[T]) = this((xx.newInstance(), xx.newInstance())) +} + +class A1 { + val b1 = new B((1, 2, 3)) + val b2 = new B((1, 2)) + val b3 = new B[Int]((1, 2, 3)) + val b4 = new B[Int]((1, 2)) +} + +class A2 { + @BAnn((1, 2, 3)) val b1 = null + @BAnn((1, 2)) val b2 = null + @BAnn[Int]((1, 2, 3)) val b3 = null + @BAnn[Int]((1, 2)) val b4 = null +} + +class A3 { + @CAnn(classOf[Int]) val b1 = null + @CAnn((1, 2)) val b2 = null + @CAnn[Int](classOf[Int]) val b3 = null + @CAnn[Int]((1, 2)) val b4 = null +} diff --git a/test/files/pos/array-interfaces.scala b/test/files/pos/array-interfaces.scala index 4955911078..70cafd2bb1 100644 --- a/test/files/pos/array-interfaces.scala +++ b/test/files/pos/array-interfaces.scala @@ -1,7 +1,7 @@ object s { def f(x: Cloneable) = () def g(x: java.io.Serializable) = () - + def main(args: Array[String]): Unit = { f(args) g(args) diff --git a/test/files/pos/arrays2.scala b/test/files/pos/arrays2.scala index 2d5409cbb8..795c486e37 100644 --- a/test/files/pos/arrays2.scala +++ b/test/files/pos/arrays2.scala @@ -11,8 +11,8 @@ object arrays2 { // #2422 object arrays4 { - val args = Array[String]("World") - "Hello %1$s".format(args: _*) + val args = Array[String]("World") + "Hello %1$s".format(args: _*) } // #2461 diff --git a/test/files/jvm/xml02.check b/test/files/pos/attachments-typed-another-ident.check index e69de29bb2..e69de29bb2 100644 --- a/test/files/jvm/xml02.check +++ b/test/files/pos/attachments-typed-another-ident.check diff --git a/test/files/neg/macro-invalidimpl-h.flags b/test/files/pos/attachments-typed-another-ident.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-h.flags +++ b/test/files/pos/attachments-typed-another-ident.flags diff --git a/test/files/pos/attachments-typed-another-ident/Impls_1.scala b/test/files/pos/attachments-typed-another-ident/Impls_1.scala new file mode 100644 index 0000000000..c3f541075e --- /dev/null +++ b/test/files/pos/attachments-typed-another-ident/Impls_1.scala @@ -0,0 +1,17 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object MyAttachment + +object Macros { + def impl(c: Context) = { + import c.universe._ + val ident = Ident(TermName("bar")) updateAttachment MyAttachment + assert(ident.attachments.get[MyAttachment.type].isDefined, ident.attachments) + val typed = c.typeCheck(ident) + assert(typed.attachments.get[MyAttachment.type].isDefined, typed.attachments) + c.Expr[Int](typed) + } + + def foo = macro impl +} diff --git a/test/files/pos/attachments-typed-another-ident/Macros_Test_2.scala b/test/files/pos/attachments-typed-another-ident/Macros_Test_2.scala new file mode 100644 index 0000000000..022639bfe9 --- /dev/null +++ b/test/files/pos/attachments-typed-another-ident/Macros_Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + def bar = 2 + Macros.foo +} + diff --git a/test/files/pos/attachments-typed-ident/Impls_1.scala b/test/files/pos/attachments-typed-ident/Impls_1.scala index cc40893a93..c382cabc59 100644 --- a/test/files/pos/attachments-typed-ident/Impls_1.scala +++ b/test/files/pos/attachments-typed-ident/Impls_1.scala @@ -6,7 +6,7 @@ object MyAttachment object Macros { def impl(c: Context) = { import c.universe._ - val ident = Ident(newTermName("bar")) updateAttachment MyAttachment + val ident = Ident(TermName("bar")) updateAttachment MyAttachment assert(ident.attachments.get[MyAttachment.type].isDefined, ident.attachments) val typed = c.typeCheck(ident) assert(typed.attachments.get[MyAttachment.type].isDefined, typed.attachments) diff --git a/test/files/pos/attributes.scala b/test/files/pos/attributes.scala index ec735d0aae..60e00bff7d 100644 --- a/test/files/pos/attributes.scala +++ b/test/files/pos/attributes.scala @@ -1,3 +1,5 @@ +class serializable extends annotation.StaticAnnotation + @serializable class C1; @serializable @volatile class C2; @serializable @volatile class C3; diff --git a/test/files/pos/builders.scala b/test/files/pos/builders.scala index 51d8af88f8..0b620769c0 100644 --- a/test/files/pos/builders.scala +++ b/test/files/pos/builders.scala @@ -18,16 +18,16 @@ object builders { def += (elem: B) { buf += elem } def result: List[B] = buf.toList } -/* +/* def fill[A, Dim1, Dim2, Coll](n1: Int, n2: Int, elem: A)(implicit b1: Builder[Coll, Dim1, A], b2: Builder[Coll, Dim2, Dim1]) = { for (i <- 0 until n1) { for (j <- 0 until n2) { b1 += elem - } + } b2 += b1.result } b2.result - } + } */ /* implicit def arrayBuilder[A, B] = new Builder[Array[A], Array[B], B] { @@ -35,7 +35,7 @@ object builders { private val buf = new scala.collection.mutable.ListBuffer[B] def += (elem: B) { buf += elem } def result: Array[B] = buf.toArray - } + } */ class Iter[A, C](elems: List[A]) { def ++ [B >: A, D](xs: Iterable[B])(implicit b: Builder[C, D, B]): D = { @@ -48,7 +48,7 @@ object builders { b.result } } - + def main(args : Array[String]) : Unit = { val x1 = new Iter[Int, List[Int]](List(1, 2, 3)) // val x2 = new Iter[Int, Array[Int]](List(1, 2, 3)) diff --git a/test/files/pos/chang/Test.scala b/test/files/pos/chang/Test.scala index 9bb745e377..f74c6355b5 100644 --- a/test/files/pos/chang/Test.scala +++ b/test/files/pos/chang/Test.scala @@ -1,3 +1,3 @@ -object Test extends Application { +object Test extends App { new com.netgents.hello.Outer[String] } diff --git a/test/files/pos/channels.scala b/test/files/pos/channels.scala index 0a2274c47a..b2f0cdc321 100644 --- a/test/files/pos/channels.scala +++ b/test/files/pos/channels.scala @@ -6,7 +6,7 @@ case class ![a](chan: Channel[a], data: a) /* object Bang { - def unapply[a](x: ![a]): Option[{Channel[a], a}] = + def unapply[a](x: ![a]): Option[{Channel[a], a}] = Some(x.chan, x.data) } @@ -14,7 +14,7 @@ object Bang { object Test extends App { object IC extends Channel[Int] def f[b](x: ![b]): Int = x match { - case send: ![c] => + case send: ![c] => send.chan match { case IC => send.data } @@ -27,4 +27,3 @@ object Test2 extends App { case IC ! x => x } } - diff --git a/test/files/pos/clsrefine.scala b/test/files/pos/clsrefine.scala index b29c01db8b..0a016dec07 100644 --- a/test/files/pos/clsrefine.scala +++ b/test/files/pos/clsrefine.scala @@ -25,9 +25,9 @@ object test { val y1, y2 = 1; } val a: A { type X1 = Int; type X2 = Int } = b; - val a1 = new A { + val a1 = new A { type X1 = Int; - type X2 = String; + type X2 = String; val x1 = 1; val x2 = "hello" } diff --git a/test/files/pos/collectGenericCC.scala b/test/files/pos/collectGenericCC.scala index 8201c6a271..5c51a50d71 100644 --- a/test/files/pos/collectGenericCC.scala +++ b/test/files/pos/collectGenericCC.scala @@ -7,8 +7,8 @@ object Test { r foreach ((a: A) => b += a) b.result } - - collect[Int, Vector[Int]](List(1,2,3,4)) + + collect[Int, Vector[Int]](List(1,2,3,4)) collect[Char, String](List('1','2','3','4')) - collect[Char, Array[Char]](List('1','2','3','4')) + collect[Char, Array[Char]](List('1','2','3','4')) }
\ No newline at end of file diff --git a/test/files/pos/context.scala b/test/files/pos/context.scala index 13f6bb43c5..4e11d07eb4 100644 --- a/test/files/pos/context.scala +++ b/test/files/pos/context.scala @@ -12,10 +12,10 @@ class Context { abstract class SymbolWrapper { val context: Context; import context._; - + class Symbols { self: context.symbols.type => - + abstract class Symbol { def typ: types.Type; def sym: Symbol = typ.sym; @@ -29,7 +29,7 @@ abstract class TypeWrapper { class Types { self: context.types.type => - + abstract class Type { def sym: symbols.Symbol; def typ: Type = sym.typ; diff --git a/test/files/pos/cycle-jsoup.flags b/test/files/pos/cycle-jsoup.flags new file mode 100644 index 0000000000..ca20f55172 --- /dev/null +++ b/test/files/pos/cycle-jsoup.flags @@ -0,0 +1 @@ +-Ybreak-cycles diff --git a/test/files/pos/cycle-jsoup.scala b/test/files/pos/cycle-jsoup.scala new file mode 100644 index 0000000000..879e693537 --- /dev/null +++ b/test/files/pos/cycle-jsoup.scala @@ -0,0 +1,5 @@ +object Test { + def main(args : Array[String]) { + org.jsoup.Jsoup.parse(null: java.net.URL, 3000) + } +} diff --git a/test/files/pos/cycle.flags b/test/files/pos/cycle.flags new file mode 100644 index 0000000000..ca20f55172 --- /dev/null +++ b/test/files/pos/cycle.flags @@ -0,0 +1 @@ +-Ybreak-cycles diff --git a/test/files/pos/cycle/J_1.java b/test/files/pos/cycle/J_1.java new file mode 100644 index 0000000000..0cc218eebe --- /dev/null +++ b/test/files/pos/cycle/J_1.java @@ -0,0 +1,16 @@ +package bar; + +public class J_1 { + public void f(C.D arg) { + } +} + +class B extends J_1 { + public void g(C.D arg) { + } +} + +class C extends B { + public class D { + } +} diff --git a/test/files/pos/cycle/X_2.scala b/test/files/pos/cycle/X_2.scala new file mode 100644 index 0000000000..c1840f3b99 --- /dev/null +++ b/test/files/pos/cycle/X_2.scala @@ -0,0 +1,3 @@ +import bar.J_1._ //<--- illegal cyclic reference involving + +class X diff --git a/test/files/pos/cyclics-pos.scala b/test/files/pos/cyclics-pos.scala index 051bdd6ed8..395e88815a 100644 --- a/test/files/pos/cyclics-pos.scala +++ b/test/files/pos/cyclics-pos.scala @@ -1,26 +1,26 @@ trait Param[T] trait Abs { type T } trait Cyclic1[A <: Param[A]] // works -trait Cyclic2[A <: Abs { type T <: A }] -trait Cyclic3 { type A <: Abs { type T = A } } +trait Cyclic2[A <: Abs { type T <: A }] +trait Cyclic3 { type A <: Abs { type T = A } } trait Cyclic4 { type A <: Param[A] } // works -trait Cyclic5 { type AA <: Abs; type A <: AA { type T = A } } +trait Cyclic5 { type AA <: Abs; type A <: AA { type T = A } } trait IterableTemplate { type Elem type Constr <: IterableTemplate type ConstrOf[A] = Constr { type Elem = A } - + def iterator: Iterator[Elem] - + def map [B] (f: Elem => B): ConstrOf[B] - + def foreach(f: Elem => Unit) = iterator.foreach(f) } trait Iterable[A] extends IterableTemplate { self => - type Elem + type Elem type Constr <: Iterable[A] { type Constr <: Iterable.this.Constr } } diff --git a/test/files/pos/depmet_implicit_chaining_zw.scala b/test/files/pos/depmet_implicit_chaining_zw.scala index 93da3b0f8e..ce5ea476d8 100644 --- a/test/files/pos/depmet_implicit_chaining_zw.scala +++ b/test/files/pos/depmet_implicit_chaining_zw.scala @@ -3,7 +3,7 @@ trait Succ[N] trait ZipWith[N, S] { type T - val x: T = error("") + val x: T = sys.error("") } object ZipWith { @@ -15,7 +15,7 @@ object ZipWith { type T = Stream[S] => zWith.T // dependent types replace the associated types functionality } - // can't use implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]], + // can't use implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]], // since that will chop of the {type T = ... } refinement in adapt (pt = ZipWith[Succ[Succ[Zero]], Int => String => Boolean]) // this works // def zipWith(implicit zw: ZipWith[Succ[Succ[Zero]], Int => String => Boolean]): zw.T = zw.x @@ -25,4 +25,4 @@ object ZipWith { type _2 = Succ[Succ[Zero]] val zw = ?[ZipWith[_2, Int => String => Boolean]].x // : Stream[Int] => Stream[String] => Stream[Boolean] // val zw = implicitly[ZipWith[Succ[Succ[Zero]], Int => String => Boolean]{type T = Stream[Int] => Stream[String] => Stream[Boolean]}].x -}
\ No newline at end of file +} diff --git a/test/files/pos/depmet_implicit_norm_ret.scala b/test/files/pos/depmet_implicit_norm_ret.scala index bafd2f7c51..0c587cf164 100644 --- a/test/files/pos/depmet_implicit_norm_ret.scala +++ b/test/files/pos/depmet_implicit_norm_ret.scala @@ -1,29 +1,29 @@ object Test{ def ?[S <: AnyRef](implicit w : S) : w.type = w - + // fallback, lower priority (overloading rules apply: pick alternative in subclass lowest in subtyping lattice) class ZipWithDefault { implicit def ZeroZipWith[S] = new ZipWith[S] { type T = Stream[S] - } + } } - + object ZipWith extends ZipWithDefault { // def apply[S: ZipWith](s : S) = ?[ZipWith[S]].zipWith(s) // TODO: bug return type should be inferred def apply[S](s : S)(implicit zw: ZipWith[S]): zw.T = zw.zipWith(s) implicit def SuccZipWith[S,R](implicit zWith : ZipWith[R]) = new ZipWith[S => R] { type T = Stream[S] => zWith.T // dependent types replace the associated types functionality - } + } } - + trait ZipWith[S] { type T - def zipWith : S => T = error("") + def zipWith : S => T = sys.error("") } - + // bug: inferred return type = (Stream[A]) => java.lang.Object with Test.ZipWith[B]{type T = Stream[B]}#T // this seems incompatible with vvvvvvvvvvvvvvvvvvvvvv -- #3731 - def map[A,B](f : A => B) /* : Stream[A] => Stream[B]*/ = ZipWith(f) - val tst: Stream[Int] = map{x: String => x.length}(Stream("a")) -}
\ No newline at end of file + def map[A,B](f : A => B) /* : Stream[A] => Stream[B]*/ = ZipWith(f) + val tst: Stream[Int] = map{x: String => x.length}(Stream("a")) +} diff --git a/test/files/pos/depmet_implicit_oopsla_session.scala b/test/files/pos/depmet_implicit_oopsla_session.scala index e2c67d7c32..21588a56ad 100644 --- a/test/files/pos/depmet_implicit_oopsla_session.scala +++ b/test/files/pos/depmet_implicit_oopsla_session.scala @@ -11,19 +11,19 @@ object Sessions { def run(p: Stop, dp: Stop): Unit = {} } - implicit def InDual[A, B](implicit sessionDIn: Session[B]) = + implicit def InDual[A, B](implicit sessionDIn: Session[B]) = new Session[In[A, B]] { type Dual = Out[A, sessionDIn.Dual] - def run(p: In[A, B], dp: Dual): Unit = + def run(p: In[A, B], dp: Dual): Unit = sessionDIn.run(p.func(dp.x), dp.y) } - implicit def OutDual[A, B](implicit sessionDOut: Session[B]) = + implicit def OutDual[A, B](implicit sessionDOut: Session[B]) = new Session[Out[A, B]] { type Dual = In[A, sessionDOut.Dual] - def run(p: Out[A, B], dp: Dual): Unit = + def run(p: Out[A, B], dp: Dual): Unit = sessionDOut.run(p.y, dp.func(p.x)) } @@ -32,7 +32,7 @@ object Sessions { sealed case class Out[+A, +B](x: A, y: B) def addServer = - In{x: Int => + In{x: Int => In{y: Int => System.out.println("Thinking") Out(x+y, Stop())}} @@ -48,7 +48,7 @@ object Sessions { // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]#HasDual[D]) = // s.run(p, dp) - // + // // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]{type Dual=D}) = // s.run(p, dp) diff --git a/test/files/pos/depmet_implicit_oopsla_session_2.scala b/test/files/pos/depmet_implicit_oopsla_session_2.scala index 8d7daa6dc6..5c3b78e3f5 100644 --- a/test/files/pos/depmet_implicit_oopsla_session_2.scala +++ b/test/files/pos/depmet_implicit_oopsla_session_2.scala @@ -36,7 +36,7 @@ object Sessions { implicit def InDual[Data, Cont](implicit cont: Session[Cont]) = new Session[In[Data, Cont]] { type Dual = Out[Data, cont.Dual] - def run(self: Self, dual: Dual): Unit = + def run(self: Self, dual: Dual): Unit = cont.run(self.recv(dual.data), dual.cont) } @@ -46,13 +46,13 @@ object Sessions { implicit def OutDual[Data, Cont](implicit cont: Session[Cont]) = new Session[Out[Data, Cont]] { type Dual = In[Data, cont.Dual] - def run(self: Self, dual: Dual): Unit = + def run(self: Self, dual: Dual): Unit = cont.run(self.cont, dual.recv(self.data)) } // a concrete session def addServer = - In{x: Int => + In{x: Int => In{y: Int => System.out.println("Thinking") Out(x+y, Stop())}} @@ -71,7 +71,7 @@ object Sessions { // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]#HasDual[D]) = // s.run(p, dp) - // + // // def runSession[S, D](p: S, dp: D)(implicit s: Session[S]{type Dual=D}) = // s.run(p, dp) diff --git a/test/files/pos/depmet_implicit_oopsla_session_simpler.scala b/test/files/pos/depmet_implicit_oopsla_session_simpler.scala index d2986ef56f..04b8f94e64 100644 --- a/test/files/pos/depmet_implicit_oopsla_session_simpler.scala +++ b/test/files/pos/depmet_implicit_oopsla_session_simpler.scala @@ -5,7 +5,7 @@ object Sessions { def run(dp: Dual): Unit } - sealed case class Stop extends Session { + sealed case class Stop() extends Session { type Dual = Stop def run(dp: Dual): Unit = {} @@ -14,7 +14,7 @@ object Sessions { // can't write B <: Session{type Dual = BDual} due to limitations in type inference algorithm // (type variables cannot occur on both sides of <:) // using B#Dual instead of BDual is too imprecise, since it is disconnected from the actual argument that is passed for B - // would be nice if we could introduce a universal quantification over BDual that is not part of the + // would be nice if we could introduce a universal quantification over BDual that is not part of the // type parameter list sealed case class In[A, B <: Session, BDual <: Session](recv: A => B)(implicit dual: B <:< Session{type Dual=BDual}) extends Session { type Dual = Out[A, BDual] @@ -29,7 +29,7 @@ object Sessions { } def addServer = - In{x: Int => + In{x: Int => In{y: Int => System.out.println("Thinking") Out(x+y, Stop())}} diff --git a/test/files/pos/depmet_implicit_oopsla_zipwith.scala b/test/files/pos/depmet_implicit_oopsla_zipwith.scala index fe69802d26..c76d02c1ae 100644 --- a/test/files/pos/depmet_implicit_oopsla_zipwith.scala +++ b/test/files/pos/depmet_implicit_oopsla_zipwith.scala @@ -15,7 +15,7 @@ object ZipWith { def manyApp = n => xs => xs } - implicit def SuccZipWith[N, S, R](implicit zw: ZipWith[N, R]) = + implicit def SuccZipWith[N, S, R](implicit zw: ZipWith[N, R]) = new ZipWith[Succ[N],S => R] { type T = Stream[S] => zw.T @@ -33,12 +33,12 @@ object ZipWith { object Test { def zWith[N, S](n: N, s: S)(implicit zw: ZipWith[N, S]): zw.T = zw.zipWith(n)(s) - def zipWith0: Stream[Int] = zWith(Zero(),0) + def zipWith0: Stream[Int] = zWith(Zero(),0) // (Stream[A]) => java.lang.Object with ZipWith[Zero,B]{type T = Stream[B]}#T // should normalise to: Stream[A] => Stream[B] def map[A, B](f: A => B) = zWith(Succ(Zero()),f) - + def zipWith3[A, B, C, D](f: A => B => C => D) = //: Stream[A] => Stream[B] => Stream[C] => Stream[D] = // BUG why do we need a return type? zWith(Succ(Succ(Succ(Zero()))),f) }
\ No newline at end of file diff --git a/test/files/pos/depmet_implicit_tpbetareduce.scala b/test/files/pos/depmet_implicit_tpbetareduce.scala index c0b9b4e8e4..35d260683b 100644 --- a/test/files/pos/depmet_implicit_tpbetareduce.scala +++ b/test/files/pos/depmet_implicit_tpbetareduce.scala @@ -1,10 +1,10 @@ trait HOSeq { trait Accumulator[+coll[x], elT] trait Iterable[+t] { - type m[+x] + type m[+x] def accumulator[t]: Accumulator[m, t] } - implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] {} + implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] {} trait List[+t] extends Iterable[t] { type m[+x] = List[x] def accumulator[t]: Accumulator[List, t] = listAccumulator[t] diff --git a/test/files/pos/elidable-tparams.scala b/test/files/pos/elidable-tparams.scala index e47951f61d..23b1cba615 100644 --- a/test/files/pos/elidable-tparams.scala +++ b/test/files/pos/elidable-tparams.scala @@ -3,7 +3,7 @@ import elidable._ class ElidableCrashTest { trait My - + @elidable(MINIMUM) def foo[a >: My <: My]: scala.Unit = () foo[My] // crash diff --git a/test/files/pos/erasure-nsquared.scala b/test/files/pos/erasure-nsquared.scala new file mode 100644 index 0000000000..b0e30ade58 --- /dev/null +++ b/test/files/pos/erasure-nsquared.scala @@ -0,0 +1,35 @@ +trait BigCast { + def bar(x: Int): AnyRef = ( + null + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + ) +} diff --git a/test/pending/pos/exhaust_2.scala b/test/files/pos/exhaust_2.scala index 4f4e47c43b..4f4e47c43b 100644 --- a/test/pending/pos/exhaust_2.scala +++ b/test/files/pos/exhaust_2.scala diff --git a/test/files/pos/existentials.scala b/test/files/pos/existentials.scala index 0adbc701a6..9ca86d13d8 100644 --- a/test/files/pos/existentials.scala +++ b/test/files/pos/existentials.scala @@ -11,7 +11,7 @@ class A { // lazy val quux3a = f() // quux3a // } - + val bippy0 = f _ def bippy1 = f _ // lazy val bippy2 = f _ diff --git a/test/files/pos/exponential-spec.scala b/test/files/pos/exponential-spec.scala index 83aef58f7e..54515c1d21 100644 --- a/test/files/pos/exponential-spec.scala +++ b/test/files/pos/exponential-spec.scala @@ -5,7 +5,7 @@ trait Exp[T] object Test { def f[T](exp: Exp[T]): Exp[T] = ( - f[T] _ + f[T] _ compose f[T] compose f[T] compose f[T] @@ -42,6 +42,6 @@ object Test { compose f[T] compose f[T] compose f[T] - compose f[T] + compose f[T] )(exp) } diff --git a/test/files/pos/extractor-types.scala b/test/files/pos/extractor-types.scala new file mode 100644 index 0000000000..bb9659a13c --- /dev/null +++ b/test/files/pos/extractor-types.scala @@ -0,0 +1,30 @@ +package p1 { + object Ex { def unapply(p: Any): Option[_ <: Int] = null } + object Foo { val Ex(_) = null } +} +// a.scala:2: error: error during expansion of this match (this is a scalac bug). +// The underlying error was: type mismatch; +// found : Some[_$1(in value x$1)] where type _$1(in value x$1) +// required: Some[_$1(in method unapply)] +// object Foo { val Ex(_) = null } +// ^ +// one error found + +package p2 { + trait Other { + class Quux + object Baz { def unapply(x: Any): Option[Quux] = None } + } + trait Reifiers { + def f() { + val u2: Other = null + (null: Any) match { case u2.Baz(x) => println(x) } //: u2.Quux) } + // The underlying error was: type mismatch; + // found : Other#Quux + // required: u2.Quux + // x match { case u2.Baz(x) => println(x: u2.Quux) } + // ^ + // one error found + } + } +} diff --git a/test/files/pos/gadt-gilles.scala b/test/files/pos/gadt-gilles.scala index 309168c1e0..662be9017d 100644 --- a/test/files/pos/gadt-gilles.scala +++ b/test/files/pos/gadt-gilles.scala @@ -6,7 +6,7 @@ object Test { val x: A[C with D] = new B[C, D] {} val y: A[C with D] = x match { case b: B[u, v] => (new B[u, v] {}): A[u with v] } // OK - + def f[T, U](p: A[T with U]): A[T with U] = p match { case b: B[u, v] => new A[u with v] {} } // Not OK } diff --git a/test/files/pos/gadts2.scala b/test/files/pos/gadts2.scala index 2263cf13a6..fc2a7e4333 100644 --- a/test/files/pos/gadts2.scala +++ b/test/files/pos/gadts2.scala @@ -9,8 +9,8 @@ object Test { final case class NumTerm(val n: Number) extends Term[Number] def f[a](t: Term[a], c: Cell[a]) { - t match { - case NumTerm(n) => c.x = MyDouble(1.0) + t match { + case NumTerm(n) => c.x = MyDouble(1.0) } } diff --git a/test/files/pos/gen-traversable-methods.scala b/test/files/pos/gen-traversable-methods.scala index 2604a09f11..bc720742cf 100644 --- a/test/files/pos/gen-traversable-methods.scala +++ b/test/files/pos/gen-traversable-methods.scala @@ -6,7 +6,7 @@ import collection._ object Test { - + def main(args: Array[String]) { val gen: GenTraversable[Int] = List(1, 2, 3) gen.head @@ -16,5 +16,5 @@ object Test { gen.lastOption gen.init } - + } diff --git a/test/files/pos/generic-sigs.scala b/test/files/pos/generic-sigs.scala index b112766056..98c50b8e82 100644 --- a/test/files/pos/generic-sigs.scala +++ b/test/files/pos/generic-sigs.scala @@ -6,7 +6,7 @@ object A { def f3(x: Class[_ <: Int]) = x def f4(x: Class[_ <: String with Int]) = x def f5(x: Class[_ <: Int with String]) = x - + class Bippy[T] def f6(x: Int) = new Bippy[t forSome { type t <: Int }] def f7(x: T forSome { type T <: Float }) = x @@ -14,7 +14,7 @@ object A { def f9(x: T forSome { type T <: runtime.BoxedUnit }) = x def f10(x: Int) = new Bippy[t forSome { type t <: Unit }] def f11(x: Int) = new Bippy[t forSome { type t >: Null }] - + class Boppy[+T1,-T2] def g1 = new Boppy[t forSome { type t <: Int }, u forSome { type u <: String }] } diff --git a/test/files/pos/gosh.scala b/test/files/pos/gosh.scala index 427df4d33c..98fae8a31e 100644 --- a/test/files/pos/gosh.scala +++ b/test/files/pos/gosh.scala @@ -7,35 +7,35 @@ object ShapeTest extends App { abstract class Shape { def draw(): Unit } - + class Line(s: Point, e: Point) extends Shape { def draw() { Console.println("draw line " + s + "," + e) } } - + abstract class Foo { type T <: Object - + def show(o: T): Unit def print() { Console.println("in Foo") } } - + abstract class ShapeFoo extends Foo { type T <: Shape def show(o: T) { o.draw() } override def print() { Console.println("in ShapeFoo") } } - + class LineFoo extends ShapeFoo { type T = Line override def print() { Console.println("in LineFoo") } } - + val p1 = new Point(1,4) val p2 = new Point(12, 28) - + val l1 = new Line(p1, p2) - + val l = new ShapeFoo { // ** // type T = Line // ** // override def print() { Console.println("in LineFoo") } // ** // diff --git a/test/files/pos/gui.scala b/test/files/pos/gui.scala index 322e0a6e22..3b4f49cf55 100644 --- a/test/files/pos/gui.scala +++ b/test/files/pos/gui.scala @@ -2,7 +2,7 @@ object Geom { trait Shape case class Point(x: Int, y: Int) extends Shape case class Rectangle(ll: Point, ur: Point) extends Shape { - def inset(delta: Int) = + def inset(delta: Int) = Rectangle(Point(ll.x - delta, ll.y - delta), Point(ur.x + delta, ur.y + delta)); } } @@ -20,7 +20,7 @@ trait Screen { } object DummyScreen extends Screen { - def drawRect(r: Geom.Rectangle, c: Color) { + def drawRect(r: Geom.Rectangle, c: Color) { Console.println("draw " + r + " with " + c) } def fillRect(r: Geom.Rectangle, c: Color) { @@ -55,7 +55,7 @@ object GUI { def mouseDown(p: Geom.Point): Unit } - abstract class Button(scr: Screen, p: Geom.Point, name: String) + abstract class Button(scr: Screen, p: Geom.Point, name: String) extends Glyph with MouseCtl { var enabled: Boolean = false val label = new Label(scr, p, name) @@ -86,7 +86,7 @@ object GUIClient { def quit() { Console.println("application exited") } } - class QuitButton (scr: Screen, p: Geom.Point, name: String, a: App) + class QuitButton (scr: Screen, p: Geom.Point, name: String, a: App) extends GUI.Button(scr, p, name) { def doit() { a.quit() } } diff --git a/test/files/pos/hk-infer.scala b/test/files/pos/hk-infer.scala index 7834282bf2..30e3476404 100644 --- a/test/files/pos/hk-infer.scala +++ b/test/files/pos/hk-infer.scala @@ -31,7 +31,7 @@ object DoesWorkHK { def BOOP(ys: Seq[M[_]]) = new Booper[M](xs ++ ys) } implicit def mkBoop[M[_]](xs: Seq[M[_]]) = new Booper[M](xs) - + def f1 = x BOOP y BOOP x1 BOOP x2 } diff --git a/test/files/pos/hkarray.scala b/test/files/pos/hkarray.scala index 3faae180f4..af1160300a 100644 --- a/test/files/pos/hkarray.scala +++ b/test/files/pos/hkarray.scala @@ -1,5 +1,5 @@ trait Foo[CC[_]] { } class Bip { - val x = new Foo[Array] { } + val x = new Foo[Array] { } }
\ No newline at end of file diff --git a/test/files/pos/hkrange.scala b/test/files/pos/hkrange.scala index 8d61167ad8..a6803230ed 100644 --- a/test/files/pos/hkrange.scala +++ b/test/files/pos/hkrange.scala @@ -1,5 +1,5 @@ class A { def f[CC[X] <: Traversable[X]](x: CC[Int]) = () - + f(1 to 5) } diff --git a/test/files/pos/imp2-pos.scala b/test/files/pos/imp2-pos.scala index 407b07f3fd..5460c60015 100644 --- a/test/files/pos/imp2-pos.scala +++ b/test/files/pos/imp2-pos.scala @@ -1,5 +1,5 @@ object Test { - import collection.mutable._ + import collection.mutable._ import collection.mutable._ val x = new HashMap } diff --git a/test/files/pos/implicit-infix-ops.scala b/test/files/pos/implicit-infix-ops.scala index d7519e6340..66f3718e86 100644 --- a/test/files/pos/implicit-infix-ops.scala +++ b/test/files/pos/implicit-infix-ops.scala @@ -1,7 +1,7 @@ object Test { import Ordering.Implicits._ import Numeric.Implicits._ - + def f1[T: Numeric](x: T, y: T, z: T) = x + y + z def f2[T: Ordering](x: T, y: T, z: T) = if (x < y) (z > y) else (x < z) } @@ -9,7 +9,7 @@ object Test { object Int { import Ordering.Implicits._ import math.Integral.Implicits._ - + def f1[T: Integral](x: T, y: T, z: T) = (x + y + z) / z def f2[T: Ordering](x: T, y: T, z: T) = if (x < y) (z > y) else (x < z) } @@ -17,7 +17,7 @@ object Int { object Frac { import Ordering.Implicits._ import math.Fractional.Implicits._ - + def f1[T: Fractional](x: T, y: T, z: T) = (x + y + z) / z def f2[T: Ordering](x: T, y: T, z: T) = if (x < y) (z > y) else (x < z) }
\ No newline at end of file diff --git a/test/files/pos/implicits-new.scala b/test/files/pos/implicits-new.scala index ffc387132a..7b4f20c6c9 100644 --- a/test/files/pos/implicits-new.scala +++ b/test/files/pos/implicits-new.scala @@ -3,9 +3,9 @@ import scala.reflect.{ClassTag, classTag} // #1435 object t1435 { - implicit def a(s:String):String = error("") - implicit def a(i:Int):String = error("") - implicit def b(i:Int):String = error("") + implicit def a(s:String):String = sys.error("") + implicit def a(i:Int):String = sys.error("") + implicit def b(i:Int):String = sys.error("") } class C1435 { @@ -89,4 +89,4 @@ package foo2709 { // Problem with specs object specsProblem { println(implicitly[TypeTag[Class[_]]]) -}
\ No newline at end of file +} diff --git a/test/files/pos/implicits-old.scala b/test/files/pos/implicits-old.scala index 2c01dd0ba8..62ae6b835c 100644 --- a/test/files/pos/implicits-old.scala +++ b/test/files/pos/implicits-old.scala @@ -1,8 +1,8 @@ // #1435 object t1435 { - implicit def a(s:String):String = error("") - implicit def a(i:Int):String = error("") - implicit def b(i:Int):String = error("") + implicit def a(s:String):String = sys.error("") + implicit def a(i:Int):String = sys.error("") + implicit def b(i:Int):String = sys.error("") } class C1435 { @@ -45,7 +45,7 @@ object Test1625 { implicit def byName[A](x: =>A) = new Wrapped(x) implicit def byVal[A](x: A) = x - + def main(args: Array[String]) = { // val res:Wrapped = 7 // works @@ -57,7 +57,7 @@ object Test1625 { } object Test2188 { - implicit def toJavaList[A: ClassManifest](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*) + implicit def toJavaList[A: ClassManifest](t:collection.Seq[A]):java.util.List[A] = java.util.Arrays.asList(t.toArray:_*) val x: java.util.List[String] = List("foo") } @@ -67,21 +67,21 @@ object TestNumericWidening { val x: java.lang.Long = y } -// #2709 -package foo2709 { - class A - class B - - package object bar { - implicit def a2b(a: A): B = new B - } - - package bar { - object test { - new A: B - } - } -} +// #2709 +package foo2709 { + class A + class B + + package object bar { + implicit def a2b(a: A): B = new B + } + + package bar { + object test { + new A: B + } + } +} // Problem with specs object specsProblem { diff --git a/test/files/pos/imports-pos.scala b/test/files/pos/imports-pos.scala index 5f70a5d2da..f6a55e5e07 100644 --- a/test/files/pos/imports-pos.scala +++ b/test/files/pos/imports-pos.scala @@ -7,10 +7,10 @@ object test { val foo = 1; - p("hello"); print("world"); S.out.println("!"); + p("hello"); print("world"); S.out.println("!"); S.out.flush(); } object test1 { import test._; foo -} +} diff --git a/test/files/pos/infer2-pos.scala b/test/files/pos/infer2-pos.scala index 06d0f5814f..2ce88be544 100644 --- a/test/files/pos/infer2-pos.scala +++ b/test/files/pos/infer2-pos.scala @@ -1,8 +1,7 @@ package test class Lst[T] case class cons[T](x: T, xs: Lst[T]) extends Lst[T] -case class nil[T] extends Lst[T] +case class nil[T]() extends Lst[T] object test { Console.println(cons(1, nil())) } - diff --git a/test/files/pos/inferbroadtype.scala b/test/files/pos/inferbroadtype.scala index 467bd0f186..de8f7aa184 100644 --- a/test/files/pos/inferbroadtype.scala +++ b/test/files/pos/inferbroadtype.scala @@ -2,7 +2,7 @@ object Test { abstract class Base { val changesBaseClasses: Boolean } class Concrete extends Base { val changesBaseClasses = true } def getBase : Base = new Concrete - + var c = new Base { val changesBaseClasses = true } c = getBase } diff --git a/test/files/pos/infersingle.scala b/test/files/pos/infersingle.scala index 6830fcd799..60f4ff07e6 100644 --- a/test/files/pos/infersingle.scala +++ b/test/files/pos/infersingle.scala @@ -1,5 +1,52 @@ -object Test { +object Test1 { def one[T](x: T): Option[T] = Some(x) val x = "one" val y: Option[x.type] = one(x) -}
\ No newline at end of file +} + +object Test2 { + // Has never worked, but seems desirable given the recent changes to + // pattern type inference. + val a = "" + object Id { + def unapply(xxxx: Any): Some[a.type] = Some[a.type](a) + } + val b: a.type = (a: a.type) match { + case Id(x) => x + } +} + +object Test3 { + val a = "" + object Id { + def unapply(xxxx: Any): Some[Test3.type] = Some[Test3.type](Test3) + } + val b: Test3.type = a match { + case Id(x) => x + } +} + +class Test4 { + val a = "" + object Id { + def unapply(xxxx: Any): Some[Test4.this.type] = Some[Test4.this.type](Test4.this) + } + val b: Test4.this.type = a match { + case Id(x) => x + } +} + +class Super5 { + final val q = "" + def q1: q.type = q +} + +class Test5 extends Super5 { + val a = "" + object Id { + def unapply(xxxx: Any): Some[Test5.super.q.type] = Some[Test5.super.q.type](q1) + } + val b: Test5.super.q.type = a match { + case Id(x) => x + } +} diff --git a/test/files/pos/inliner2.scala b/test/files/pos/inliner2.scala index fe231ec3c4..bc83e04312 100644 --- a/test/files/pos/inliner2.scala +++ b/test/files/pos/inliner2.scala @@ -10,7 +10,7 @@ class A { final def bob2() = if (debug) 1 else 2 } // Cool: -// +// // % ls -1 /tmp/2901/ // A$$anonfun$bob1$1.class // A$$anonfun$bob1$2.class @@ -20,7 +20,7 @@ class A { // A.class // // Observations: -// +// // (1) The inlined version accesses the field: the explicit one calls the accessor. // (2) The inlined version fails to eliminate boxing. With reference types it emits // an unneeded checkcast. @@ -30,7 +30,7 @@ class A { // inlined at all sites. // // Generated bytecode for the above: -// +// // public final int bob1(); // Code: // Stack=1, Locals=1, Args_size=1 @@ -44,7 +44,7 @@ class A { // 15: invokestatic #41; //Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer; // 18: invokestatic #45; //Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I // 21: ireturn -// +// // public final int bob2(); // Code: // Stack=1, Locals=1, Args_size=1 diff --git a/test/files/pos/java-access-pos/J.java b/test/files/pos/java-access-pos/J.java index 4f2024673c..b6bc3363a1 100644 --- a/test/files/pos/java-access-pos/J.java +++ b/test/files/pos/java-access-pos/J.java @@ -4,11 +4,11 @@ public abstract class J { public J() { } J(int x1) { } protected J(int x1, int x2) { } - + abstract void packageAbstract(); protected abstract void protectedAbstract(); public abstract void publicAbstract(); - + void packageConcrete() { return; } protected void protectedConcrete() { return; } public void publicConcrete() { return; } diff --git a/test/files/pos/java-access-pos/S1.scala b/test/files/pos/java-access-pos/S1.scala index cc739d9555..10730e3a70 100644 --- a/test/files/pos/java-access-pos/S1.scala +++ b/test/files/pos/java-access-pos/S1.scala @@ -6,7 +6,7 @@ class S1 extends J { override private[b] def packageAbstract() = () override protected[b] def protectedAbstract() = () override def publicAbstract() = () - + override private[b] def packageConcrete() = () override protected[b] def protectedConcrete() = () override def publicConcrete() = () @@ -26,7 +26,7 @@ class S3 extends J { protected[b] def packageAbstract() = () protected[b] def protectedAbstract() = () def publicAbstract() = () - + override protected[b] def packageConcrete() = () override protected[b] def protectedConcrete() = () override def publicConcrete() = () @@ -37,7 +37,7 @@ class S4 extends J { private[a] def packageAbstract() = () protected[a] def protectedAbstract() = () def publicAbstract() = () - + override private[a] def packageConcrete() = () override protected[a] def protectedConcrete() = () override def publicConcrete() = () @@ -48,14 +48,14 @@ class S5 extends J { def packageAbstract() = () def protectedAbstract() = () def publicAbstract() = () - + override def packageConcrete() = () override def protectedConcrete() = () override def publicConcrete() = () } /** Constructors. */ -class S6 extends J(1) { +class S6 extends J(1) { def packageAbstract() = () def protectedAbstract() = () def publicAbstract() = () diff --git a/test/files/neg/javaConversions-2.10-ambiguity.scala b/test/files/pos/javaConversions-2.10-ambiguity.scala index e856846a29..c4aad6cbfc 100644 --- a/test/files/neg/javaConversions-2.10-ambiguity.scala +++ b/test/files/pos/javaConversions-2.10-ambiguity.scala @@ -5,6 +5,6 @@ import java.util.concurrent.{ConcurrentHashMap => CHM} object Bar { def assertType[T](t: T) = t val a = new CHM[String, String]() += (("", "")) - assertType[mutable.ConcurrentMap[String, String]](a) + assertType[concurrent.Map[String, String]](a) } // vim: set et: diff --git a/test/files/pos/javaConversions-2.10-regression.scala b/test/files/pos/javaConversions-2.10-regression.scala index e1b81015ba..7c7ff03b55 100644 --- a/test/files/pos/javaConversions-2.10-regression.scala +++ b/test/files/pos/javaConversions-2.10-regression.scala @@ -3,10 +3,10 @@ import JavaConversions._ import java.util.concurrent.{ConcurrentHashMap => CHM} object Foo { - def buildCache2_9_simple[K <: AnyRef, V <: AnyRef]: mutable.ConcurrentMap[K, V] = - asScalaConcurrentMap(new CHM()) + def buildCache2_9_simple[K <: AnyRef, V <: AnyRef]: concurrent.Map[K, V] = + mapAsScalaConcurrentMap(new CHM()) - def buildCache2_9_implicit[K <: AnyRef, V <: AnyRef]: mutable.ConcurrentMap[K, V] = + def buildCache2_9_implicit[K <: AnyRef, V <: AnyRef]: concurrent.Map[K, V] = new CHM[K, V]() } diff --git a/test/files/pos/javaReadsSigs/fromjava.java b/test/files/pos/javaReadsSigs/fromjava.java index eca63961d5..92441b0c6b 100644 --- a/test/files/pos/javaReadsSigs/fromjava.java +++ b/test/files/pos/javaReadsSigs/fromjava.java @@ -22,11 +22,11 @@ class B { }; class Contra { // Not an Ordering<Character>. static Ordering<Object> charOrd = scala.math.Ordering.Char$.MODULE$; - + public boolean useCharOrd() { return charOrd.compare(new Object(), new Object()) == 0; } - + static Numeric<?> intNum = scala.math.Numeric.IntIsIntegral$.MODULE$; } @@ -36,13 +36,13 @@ public class fromjava { return null; } }; - + public static Function1<Tuple2<? extends Object, B>, B> f2 = new scala.runtime.AbstractFunction1<Tuple2<? extends Object, B>, B>() { public B apply(Tuple2<? extends Object, B> tup) { return tup._2(); } }; - + public static String vector(Vector<String> x) { Vector<String> y = x.take(2); return y.head(); diff --git a/test/files/pos/kinds.scala b/test/files/pos/kinds.scala new file mode 100644 index 0000000000..6d6da0c8b6 --- /dev/null +++ b/test/files/pos/kinds.scala @@ -0,0 +1,13 @@ +trait IllKind1 { + def g(s: String): String = s + def f: String = ??? + def f[C](c: C): String = g(f) +} + +trait IllKind2 { + def b1: Char = ??? + def b2: Byte = ??? + + def f1 = "abc" contains b1 + def f2 = "abc" contains b2 +} diff --git a/test/files/pos/lambdalift.scala b/test/files/pos/lambdalift.scala index 10bbf3ac12..bc997d6f81 100644 --- a/test/files/pos/lambdalift.scala +++ b/test/files/pos/lambdalift.scala @@ -11,5 +11,5 @@ object test { def h() = x; } g() + new inner().g(); - } + } } diff --git a/test/files/pos/liftcode_polymorphic.scala b/test/files/pos/liftcode_polymorphic.scala index 8f537d278a..249f5a0569 100644 --- a/test/files/pos/liftcode_polymorphic.scala +++ b/test/files/pos/liftcode_polymorphic.scala @@ -1,6 +1,6 @@ import scala.reflect.runtime.universe._ -object Append extends Application { +object Append extends App { def append[A](l1: List[A], l2: List[A]):List[A] = l1 match { diff --git a/test/files/pos/listpattern.scala b/test/files/pos/listpattern.scala index b64068474c..47145bf037 100644 --- a/test/files/pos/listpattern.scala +++ b/test/files/pos/listpattern.scala @@ -1,7 +1,7 @@ trait Value {} case class FloatValue(x: Double) extends Value object Test { - def applyNumeric(op: (Double, Double) => Double): + def applyNumeric(op: (Double, Double) => Double): PartialFunction[List[Value], Value] = { case List(FloatValue(x), FloatValue(y)) => FloatValue(op(x, y)) } diff --git a/test/files/pos/lookupswitch.scala b/test/files/pos/lookupswitch.scala index 33594c0ea6..5d48251240 100644 --- a/test/files/pos/lookupswitch.scala +++ b/test/files/pos/lookupswitch.scala @@ -34,4 +34,3 @@ class A { case 20 => "20" } } -
\ No newline at end of file diff --git a/test/files/pos/looping-jsig.scala b/test/files/pos/looping-jsig.scala index e2d9e76229..6e3313c463 100644 --- a/test/files/pos/looping-jsig.scala +++ b/test/files/pos/looping-jsig.scala @@ -1,15 +1,15 @@ import scala.collection.mutable._ trait BugTrack { - trait B[+T] + trait B[+T] val cache : HashMap[A[_], B[_]] = HashMap.empty - def A[T](f: Int => B[T]): A[T] + def A[T](f: Int => B[T]): A[T] = new A[T]{def apply(in: Int) = f(in)} - + abstract class A[+T] extends (Int => B[T]) { def giveMeSame = this - } + } def amethod[T](p: =>A[T]): A[T] = A(in => cache.get(p) match { case Some(res) => res diff --git a/test/files/pos/lub-dealias-widen.scala b/test/files/pos/lub-dealias-widen.scala index 38854fbc5c..8d26708d65 100644 --- a/test/files/pos/lub-dealias-widen.scala +++ b/test/files/pos/lub-dealias-widen.scala @@ -27,7 +27,7 @@ object Test { = p2 >> { (xs: List[String]) => 0 } // This works after https://github.com/scala/scala/commit/a06d31f6a - // Before: error: inferred type arguments [List[String] => String,List[String] => String] + // Before: error: inferred type arguments [List[String] => String,List[String] => String] // do not conform to method &'s type parameter bounds // [G <: H,H >: Int => (Int => String)] val s = r & r2 diff --git a/test/files/pos/matchStarlift.scala b/test/files/pos/matchStarlift.scala deleted file mode 100644 index dab46eada2..0000000000 --- a/test/files/pos/matchStarlift.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Tet { - import scala.xml._; - def fooz(x: Node=>String) = {} - def foo( m:Node ):Unit = fooz { - case Elem(_,_,_,_,n,_*) if (n == m) => "gaga" - } -} diff --git a/test/files/pos/michel6.scala b/test/files/pos/michel6.scala index f312bf1796..b32e8bed75 100644 --- a/test/files/pos/michel6.scala +++ b/test/files/pos/michel6.scala @@ -1,6 +1,6 @@ object M { def f(x: Int): Unit = {} - + def g(): Int => Unit = if (0 == 0) f else g() } diff --git a/test/files/pos/needstypeearly.scala b/test/files/pos/needstypeearly.scala index bd93b5c45d..a90c2575f2 100644 --- a/test/files/pos/needstypeearly.scala +++ b/test/files/pos/needstypeearly.scala @@ -1,4 +1,4 @@ -abstract class NeedsXEarly { - val x: Int +abstract class NeedsXEarly { + val x: Int } class Foo extends { val x = 1 } with NeedsXEarly diff --git a/test/files/pos/nothing_manifest_disambig-old.scala b/test/files/pos/nothing_manifest_disambig-old.scala index 076742033f..9a3db0c6d4 100644 --- a/test/files/pos/nothing_manifest_disambig-old.scala +++ b/test/files/pos/nothing_manifest_disambig-old.scala @@ -1,10 +1,10 @@ object Test { def mani[T: Manifest](xs: T) = xs mani(List()) - + def listElMani[T: Manifest](xs: List[T]) = xs listElMani(List()) - + def foo[A, C](m : C)(implicit ev: C <:< Traversable[A], mani: Manifest[A]): (C, A, Manifest[A]) = (m, m.head, mani) - foo(List(1,2,3)) + foo(List(1,2,3)) }
\ No newline at end of file diff --git a/test/files/pos/nullary.scala b/test/files/pos/nullary.scala index 8e5a834012..614fcdf480 100644 --- a/test/files/pos/nullary.scala +++ b/test/files/pos/nullary.scala @@ -2,7 +2,7 @@ abstract class NullaryTest[T, m[s]] { def nullary: String = "a" val x = nullary - def nullary2: T + def nullary2: T val x2 = nullary2 def nullary3: m[T] @@ -16,5 +16,5 @@ class Concrete extends NullaryTest[Int, List] { object test { (new Concrete).nullary2 - (new Concrete).nullary3 + (new Concrete).nullary3 } diff --git a/test/files/pos/nullary_poly.scala b/test/files/pos/nullary_poly.scala index 4de7235a1c..d2e1e127a1 100644 --- a/test/files/pos/nullary_poly.scala +++ b/test/files/pos/nullary_poly.scala @@ -2,9 +2,9 @@ class A { // built-in synchronized {} - + val x: String = "a".asInstanceOf[String] - + // user-defined: def polyNullary[T]: List[T] = Nil } diff --git a/test/files/pos/optmatch.scala b/test/files/pos/optmatch.scala new file mode 100644 index 0000000000..354be65da7 --- /dev/null +++ b/test/files/pos/optmatch.scala @@ -0,0 +1,33 @@ +// final case class NonZeroLong(value: Long) extends AnyVal { +// def get: Long = value +// def isEmpty: Boolean = get == 0l +// } + +class NonZeroLong(val value: Long) extends AnyVal { + def get: Long = value + def isEmpty: Boolean = get == 0l +} +object NonZeroLong { + def unapply(value: Long): NonZeroLong = new NonZeroLong(value) +} + + +object Foo { + def unapply(x: Int): NonZeroLong = new NonZeroLong(1L << x) + // public long unapply(int); + // 0: lconst_1 + // 1: iload_1 + // 2: lshl + // 3: lreturn +} + +object Test { + def f(x: Int): Int = x match { + case Foo(1024l) => 1 + case _ => 2 + } + def main(args: Array[String]): Unit = { + println(f(10)) + println(f(11)) + } +} diff --git a/test/files/pos/overloaded-unapply.scala b/test/files/pos/overloaded-unapply.scala new file mode 100644 index 0000000000..4105a25f10 --- /dev/null +++ b/test/files/pos/overloaded-unapply.scala @@ -0,0 +1,8 @@ +trait Baz { + type Type >: Null + + case class HoleType(a: String, b: String, c: String) + object HoleType { def unapply(tpe: Type): Option[HoleType] = ??? } + + (null: Type) match { case HoleType(holeTpe) => holeTpe } +} diff --git a/test/files/pos/override-object-yes.scala b/test/files/pos/override-object-yes.scala index b0563df0a3..858f9b21fc 100644 --- a/test/files/pos/override-object-yes.scala +++ b/test/files/pos/override-object-yes.scala @@ -14,8 +14,8 @@ package case1 { override def f = 3 } } - - trait Foo3 { + + trait Foo3 { object Bar { def g: Traversable[Int] = Nil } diff --git a/test/files/pos/partialfun.scala b/test/files/pos/partialfun.scala index d8971e56fb..9f32a22023 100644 --- a/test/files/pos/partialfun.scala +++ b/test/files/pos/partialfun.scala @@ -1,6 +1,6 @@ object partialfun { - def applyPartial[b](f: PartialFunction[Option[String], b])(x: Option[String]) = + def applyPartial[b](f: PartialFunction[Option[String], b])(x: Option[String]) = if (f.isDefinedAt(x)) f(x) else "<undefined>"; applyPartial { diff --git a/test/files/pos/pat_gilles.scala b/test/files/pos/pat_gilles.scala index 567d700eba..704d5b9c00 100644 --- a/test/files/pos/pat_gilles.scala +++ b/test/files/pos/pat_gilles.scala @@ -1,7 +1,7 @@ abstract class Table2 { - val x: Any => Unit = { zz:Any => + val x: Any => Unit = { zz:Any => zz match { case Table2.CellUpdated(row, column) => val foo = Table2.CellUpdated(2,2) diff --git a/test/files/pos/patmat-extract-tparam.scala b/test/files/pos/patmat-extract-tparam.scala new file mode 100644 index 0000000000..6417b49c2b --- /dev/null +++ b/test/files/pos/patmat-extract-tparam.scala @@ -0,0 +1,13 @@ +trait Bip[T] { def h: T } +trait BoolBip extends Bip[Boolean] + +class A { + def g(x: Boolean): Unit = () + def f(xs: List[Bip[_]]) = xs foreach { case x: BoolBip => g(x.h) } +} + +class B { + def g(x: Boolean): Unit = () + def g(x: Int): Unit = () + def f(xs: List[Bip[_]]) = xs foreach { case x: BoolBip => g(x.h) } +} diff --git a/test/files/pos/private-types-after-typer.scala b/test/files/pos/private-types-after-typer.scala new file mode 100644 index 0000000000..79ef934063 --- /dev/null +++ b/test/files/pos/private-types-after-typer.scala @@ -0,0 +1,9 @@ +// Testing that the type of the outer accessor in O2 +// doesn't crash the compiler over private type escaping scope. +trait T { + class C { + private object O1 { + object O2 + } + } +}
\ No newline at end of file diff --git a/test/files/pos/propagate.scala b/test/files/pos/propagate.scala index a7f9d6ce6d..5881920798 100644 --- a/test/files/pos/propagate.scala +++ b/test/files/pos/propagate.scala @@ -14,4 +14,3 @@ class C { - diff --git a/test/files/pos/relax_implicit_divergence.scala b/test/files/pos/relax_implicit_divergence.scala index 8525c84bab..f17d0239d8 100644 --- a/test/files/pos/relax_implicit_divergence.scala +++ b/test/files/pos/relax_implicit_divergence.scala @@ -1,7 +1,7 @@ class A(val options: Seq[String]) object Test { - implicit def ss: Equiv[Seq[String]] = error("dummy") - implicit def equivA(implicit seqEq: Equiv[Seq[String]]): Equiv[A] = error("dummy") + implicit def ss: Equiv[Seq[String]] = sys.error("dummy") + implicit def equivA(implicit seqEq: Equiv[Seq[String]]): Equiv[A] = sys.error("dummy") implicitly[Equiv[A]] -}
\ No newline at end of file +} diff --git a/test/files/pos/return_thistype.scala b/test/files/pos/return_thistype.scala index f164e06cc0..c0736c0ad9 100644 --- a/test/files/pos/return_thistype.scala +++ b/test/files/pos/return_thistype.scala @@ -1,8 +1,8 @@ // tests transformation of return type in typedTypeApply (see also tcpoly_gm.scala) -class As { - class A { +class As { + class A { def foo: A.this.type = bar.asInstanceOf[A.this.type] def foo2: this.type = bar.asInstanceOf[this.type] - def bar: A = null + def bar: A = null } } diff --git a/test/files/pos/scala-singleton.scala b/test/files/pos/scala-singleton.scala index 5e0baa0cb2..08038db93b 100644 --- a/test/files/pos/scala-singleton.scala +++ b/test/files/pos/scala-singleton.scala @@ -3,12 +3,12 @@ object Test { def f1(x: AnyRef with Singleton): AnyRef with Singleton = x def f2[T <: AnyRef with Singleton](x: T): T = x - + val x1: AnyRef with Singleton = "abc" val x2 = "def" final val x3 = "ghi" val x4: String = "jkl" - + // compiles... def narrow1(x: AnyRef): AnyRef with Singleton = x @@ -17,26 +17,26 @@ object Test { // fails, wait, what? This fails and narrow1 compiles? def narrow3(x: AnyRef): AnyRef with Singleton = x.asInstanceOf[AnyRef with Singleton] - + // ok def narrow4[T <: AnyRef](x: T): AnyRef with Singleton = x - + object imp { implicit def narrow4[T <: AnyRef](x: T): AnyRef with Singleton = x val x5: String = "mno" def imp1 = f1(x5) - + // f2(x5) // doesn't work but I think it should def imp2 = f2(narrow4(x5)) } - + def main(args: Array[String]): Unit = { // compiles f1(x1) f1(x2) f1(x3) f1(x4) - + f2(x1) // f2(x2) // f2(x3) // maybe this one should work diff --git a/test/files/pos/scoping1.scala b/test/files/pos/scoping1.scala index 548f154b6b..9fe1b5f3e5 100644 --- a/test/files/pos/scoping1.scala +++ b/test/files/pos/scoping1.scala @@ -9,4 +9,4 @@ object This extends App { def foo() = () } val c: C = new D -} +} diff --git a/test/files/pos/sealed-final.flags b/test/files/pos/sealed-final.flags new file mode 100644 index 0000000000..cfabf7a5b4 --- /dev/null +++ b/test/files/pos/sealed-final.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Yinline-warnings -optimise
\ No newline at end of file diff --git a/test/files/pos/sealed-final.scala b/test/files/pos/sealed-final.scala new file mode 100644 index 0000000000..bdedb5c1f6 --- /dev/null +++ b/test/files/pos/sealed-final.scala @@ -0,0 +1,14 @@ +sealed abstract class Foo { + @inline def bar(x: Int) = x + 1 +} +object Foo { + def mkFoo(): Foo = new Baz2 +} + +object Baz1 extends Foo +final class Baz2 extends Foo + +object Test { + // bar should be inlined now + def f = Foo.mkFoo() bar 10 +} diff --git a/test/files/pos/selftails.scala b/test/files/pos/selftails.scala index 7c58543747..a4253b80c7 100644 --- a/test/files/pos/selftails.scala +++ b/test/files/pos/selftails.scala @@ -1,10 +1,10 @@ package net.liftweb.util - + /** * This trait adds functionality to Scala standard types */ trait BasicTypesHelpers { self: StringHelpers with ControlHelpers => - + /** * Compare two arrays of Byte for byte equality. * @return true if two Byte arrays contain the same bytes @@ -19,5 +19,5 @@ trait BasicTypesHelpers { self: StringHelpers with ControlHelpers => } } -trait StringHelpers +trait StringHelpers trait ControlHelpers diff --git a/test/files/pos/seq-ordering.scala b/test/files/pos/seq-ordering.scala index 8f1d293c40..517d8ae8aa 100644 --- a/test/files/pos/seq-ordering.scala +++ b/test/files/pos/seq-ordering.scala @@ -2,7 +2,7 @@ import Ordering.Implicits._ class A { import Predef.{ implicitly => ? } - + ?[Ordering[List[Int]]] ?[Ordering[IndexedSeq[(Int, String)]]] ?[Ordering[Seq[Seq[Int]]]] diff --git a/test/files/pos/signatures/Test.java b/test/files/pos/signatures/Test.java index 78c196526b..3d1e3756a7 100644 --- a/test/files/pos/signatures/Test.java +++ b/test/files/pos/signatures/Test.java @@ -3,7 +3,7 @@ import test.Outer; /* Test correct generation of java signatures. The Outer class should not * have a Java signature attribute for the inner method definition. Trait - * Mutable should have one, even though it is also a nested definition. + * Mutable should have one, even though it is also a nested definition. * (but for classes there is a way to tell about nesting to the JVM). */ class Test { diff --git a/test/files/pos/signatures/sig.scala b/test/files/pos/signatures/sig.scala index 3feb9c456a..4236f27bed 100644 --- a/test/files/pos/signatures/sig.scala +++ b/test/files/pos/signatures/sig.scala @@ -1,7 +1,7 @@ package test /* Tests correct generation of Java signatures. The local method 'bar' should - * not get a generic signature, as it may refer to type parameters of the enclosing + * not get a generic signature, as it may refer to type parameters of the enclosing * method, and the JVM does not know about nested methods. */ class Outer { diff --git a/test/files/pos/simple-exceptions.scala b/test/files/pos/simple-exceptions.scala index 38f2fc8500..a9f16bf90b 100644 --- a/test/files/pos/simple-exceptions.scala +++ b/test/files/pos/simple-exceptions.scala @@ -8,7 +8,7 @@ object Test { try { try { Console.println("hi!") - error("xx") + sys.error("xx") } finally Console.println("ho!") } diff --git a/test/files/pos/spec-Function1.scala b/test/files/pos/spec-Function1.scala index 5b6af67a74..5a115501d8 100644 --- a/test/files/pos/spec-Function1.scala +++ b/test/files/pos/spec-Function1.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -35,11 +35,11 @@ package scalabip trait Function1[@specialized -T1, @specialized +R] extends AnyRef { self => def apply(v1:T1): R override def toString() = "<function>" - + /** (f compose g)(x) == f(g(x)) */ def compose[A](g: A => T1): A => R = { x => apply(g(x)) } - + /** (f andThen g)(x) == g(f(x)) */ def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) } diff --git a/test/files/pos/spec-annotations.scala b/test/files/pos/spec-annotations.scala index 48281e5df5..b23abf48e8 100644 --- a/test/files/pos/spec-annotations.scala +++ b/test/files/pos/spec-annotations.scala @@ -1,7 +1,7 @@ class ann(i: Int) extends scala.annotation.Annotation // annotations on abstract types -abstract class C1[@serializable @cloneable +T, U, V[_]] +abstract class C1[@annotation.elidable(0) +T, U, V[_]] abstract class C2[@deprecated @ann(1) T <: Number, V] diff --git a/test/files/pos/spec-arrays.scala b/test/files/pos/spec-arrays.scala index 84f6eef071..883bc2fe62 100644 --- a/test/files/pos/spec-arrays.scala +++ b/test/files/pos/spec-arrays.scala @@ -20,7 +20,7 @@ abstract class AbsArray[T] { def updateBoolean(idx: Int, elem: Boolean) = update(idx, elem.asInstanceOf[T]) def applyObject(idx: Int): Object = apply(idx).asInstanceOf[Object] def updateObject(idx: Int, elem: Object) = update(idx, elem.asInstanceOf[T]) -} +} final class IntArray(arr: Array[Int]) extends AbsArray[Int] { def apply(idx: Int): Int = applyInt(idx) @@ -64,7 +64,7 @@ class ScalaSpecTest extends Test { while (i < arr.length) { acc = acc + arr.applyInt(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -74,7 +74,7 @@ class ScalaSpecTest extends Test { } } } - + class ScalaSpec2Test extends Test { val arr: AbsArray[Int] = new IntArray(new Array[Int](1000)) @@ -84,7 +84,7 @@ class ScalaSpec2Test extends Test { while (i < arr.length) { acc = acc + arr.applyInt(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -94,7 +94,7 @@ class ScalaSpec2Test extends Test { } } } - + class ScalaWrapTest extends Test { val arr: AbsArray[Int] = new ArraySeq(new Array[Int](1000)) @@ -104,7 +104,7 @@ class ScalaWrapTest extends Test { while (i < arr.length) { acc = acc + arr.applyInt(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -114,7 +114,7 @@ class ScalaWrapTest extends Test { } } } - + class ScalaGenTest extends Test { val arr: AbsArray[Integer] = new ArraySeq(new Array[Integer](1000)) for (i <- 0 until arr.length) arr(i) = new Integer(0) @@ -125,7 +125,7 @@ class ScalaGenTest extends Test { while (i < arr.length) { acc = acc + arr.apply(i).intValue; i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -135,7 +135,7 @@ class ScalaGenTest extends Test { } } } - + class JavaTest extends Test { val arr = new Array[Int](1000) @@ -145,7 +145,7 @@ class JavaTest extends Test { while (i < arr.length) { acc = acc + arr(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -166,7 +166,7 @@ class ScalaSpec3Test extends Test { while (i < arr.length) { acc = acc + arr(i); i += 1 } acc } - + def modify(j: Int) = { val base = j * 100 % 1000 var i = 0 @@ -177,38 +177,11 @@ class ScalaSpec3Test extends Test { } } -object TestJava extends scala.testing.Benchmark { - def run() { - (new JavaTest).run() - } -} - -object TestSpec extends scala.testing.Benchmark { - def run() { - (new ScalaSpecTest).run() - } -} - -object TestSpec2 extends scala.testing.Benchmark { - def run() { - (new ScalaSpec2Test).run() - } -} - -object TestGen extends scala.testing.Benchmark { - def run() { - (new ScalaGenTest).run() - } -} - -object TestWrap extends scala.testing.Benchmark { - def run() { - (new ScalaWrapTest).run() - } -} - -object TestSpec3 extends scala.testing.Benchmark { - def run() { - (new ScalaSpec3Test).run() - } +object TestRunner { + (new JavaTest).run() + (new ScalaSpecTest).run() + (new ScalaSpec2Test).run() + (new ScalaGenTest).run() + (new ScalaWrapTest).run() + (new ScalaSpec3Test).run() } diff --git a/test/files/pos/spec-asseenfrom.scala b/test/files/pos/spec-asseenfrom.scala index cf20fc5ffa..ede5791709 100644 --- a/test/files/pos/spec-asseenfrom.scala +++ b/test/files/pos/spec-asseenfrom.scala @@ -1,8 +1,8 @@ -class Automaton[@specialized(Double) W,State] { +class Automaton[@specialized(Double) W,State] { - def finalWeight(s: State): W = error("todo"); + def finalWeight(s: State): W = sys.error("todo"); - def allStates: Set[State] = error("toodo"); + def allStates: Set[State] = sys.error("toodo"); /** * Returns a map from states to its final weight. may expand all nodes. diff --git a/test/files/pos/spec-cyclic.scala b/test/files/pos/spec-cyclic.scala index b983caa6db..6cd7685370 100644 --- a/test/files/pos/spec-cyclic.scala +++ b/test/files/pos/spec-cyclic.scala @@ -6,25 +6,25 @@ trait MyPartialFunction[-A, +B] extends AnyRef with AbsFun[A, B] trait ColMap[A, +B] extends MyPartialFunction[A, B] /*with Collection[(A, B)] */ -trait ColSorted[K,+A] extends ColRanged[K,A] +trait ColSorted[K,+A] extends ColRanged[K,A] -trait ColSortedMap[K,+E] extends ColMap[K,E] with ColSorted[K,Tuple2[K,E]] +trait ColSortedMap[K,+E] extends ColMap[K,E] with ColSorted[K,Tuple2[K,E]] trait MutMap[A, B] extends AnyRef with ColMap[A, B] -trait ColRanged[K, +A] //extends Iterable[A] +trait ColRanged[K, +A] //extends Iterable[A] trait JclRanged[K,A] extends ColRanged[K,A] //with MutableIterable[A] { -trait JclMap[K,E] extends /*collection.jcl.MutableIterable[Tuple2[K,E]] with*/ MutMap[K,E] +trait JclMap[K,E] extends /*collection.jcl.MutableIterable[Tuple2[K,E]] with*/ MutMap[K,E] trait JclSorted[K,A] extends ColSorted[K,A] with JclRanged[K,A] trait JclSortedMap[K,E] extends ColSortedMap[K,E] with JclMap[K,E] with JclSorted[K,Tuple2[K,E]] class Foo[A, B] extends JclSortedMap[A, B] { - def apply(x: A): B = error("NYI") + def apply(x: A): B = sys.error("NYI") } class Bar { diff --git a/test/files/pos/spec-funs.scala b/test/files/pos/spec-funs.scala index 611ec0ef62..f92ae9899d 100644 --- a/test/files/pos/spec-funs.scala +++ b/test/files/pos/spec-funs.scala @@ -19,7 +19,7 @@ final class IntTest { val xs = new Array[Int](10000) val f = new AbsFunction1[Int, Int] { def apply(x: Int): Int = x * x - } + } for (j <- 0 until niters) { transF(xs, f) } @@ -54,10 +54,7 @@ final class ClosureTest { } } -object TestInt extends scala.testing.Benchmark { - def run() = (new IntTest).run() -} - -object TestClosure extends scala.testing.Benchmark { - def run() = (new ClosureTest).run() +object TestRunner { + (new IntTest).run() + (new ClosureTest).run() } diff --git a/test/files/pos/spec-params-old.scala b/test/files/pos/spec-params-old.scala index f522512846..33a252120c 100644 --- a/test/files/pos/spec-params-old.scala +++ b/test/files/pos/spec-params-old.scala @@ -10,7 +10,7 @@ class Foo[@specialized A: ClassManifest] { def m2[@specialized B <: String](x: B) = x.concat("a") // conflicting in bounds, no mention of other spec members - // expect an overload here plus implementation in + // expect an overload here plus implementation in // compatible specialized subclasses def m3[@specialized B >: A](x: B) = () @@ -19,10 +19,10 @@ class Foo[@specialized A: ClassManifest] { // non-conflicting, expect a normalized overload implementation here def m5[@specialized B](x: B) = x - + // non-conflicting, expect a normalized implementation here // and specialized implementations for all expansions in specialized subclasses - def m6[@specialized B](x: B, y: A) = + def m6[@specialized B](x: B, y: A) = goal(y) def goal(x: A) = { diff --git a/test/files/pos/spec-sealed.scala b/test/files/pos/spec-sealed.scala index 5782930899..d7ecfaaabd 100644 --- a/test/files/pos/spec-sealed.scala +++ b/test/files/pos/spec-sealed.scala @@ -2,13 +2,13 @@ sealed abstract class MyList[@specialized +A] { def head: A def tail: MyList[A] - def ::[@specialized B >: A](x: B): MyList[B] = + def ::[@specialized B >: A](x: B): MyList[B] = new Cons[B](x, this) } case object MyNil extends MyList[Nothing] { - def head = error("nil") - def tail = error("nil") + def head = sys.error("nil") + def tail = sys.error("nil") } case class Cons[@specialized a](private val hd: a, tl: MyList[a]) extends MyList[a] { @@ -19,7 +19,7 @@ case class Cons[@specialized a](private val hd: a, tl: MyList[a]) extends MyList abstract class IntList extends MyList[Int] object Main extends App { - val xs = 1 :: 2 :: 3 :: MyNil + val xs = 1 :: 2 :: 3 :: MyNil println(xs) } diff --git a/test/files/pos/spec-short.scala b/test/files/pos/spec-short.scala index 94a8007c6e..71e56a485a 100644 --- a/test/files/pos/spec-short.scala +++ b/test/files/pos/spec-short.scala @@ -5,7 +5,7 @@ abstract class AbsFun[@specialized T, @specialized U] { // abstract function, specialized def sum(xs: List[T]): Int - def prod(xs: List[T], mul: (Int, T) => Int): Int = + def prod(xs: List[T], mul: (Int, T) => Int): Int = (1 /: xs)(mul) // concrete function, not specialized @@ -18,9 +18,9 @@ abstract class AbsFun[@specialized T, @specialized U] { class Square extends AbsFun[Int, Int] { def apply(x: Int): Int = x * x - def sum(xs: List[Int]): Int = + def sum(xs: List[Int]): Int = (0 /: xs) (_ + _) - def abs(m: Int): Int = + def abs(m: Int): Int = sum(List(1, 2, 3)) } diff --git a/test/files/pos/spec-sparsearray-new.scala b/test/files/pos/spec-sparsearray-new.scala index 7b3934c476..df31089fe2 100644 --- a/test/files/pos/spec-sparsearray-new.scala +++ b/test/files/pos/spec-sparsearray-new.scala @@ -4,7 +4,7 @@ import scala.collection.mutable.MapLike class SparseArray[@specialized(Int) T:ClassTag] extends collection.mutable.Map[Int,T] with collection.mutable.MapLike[Int,T,SparseArray[T]] { override def get(x: Int) = { val ind = findOffset(x) - if(ind < 0) None else Some(error("ignore")) + if(ind < 0) None else Some(sys.error("ignore")) } /** @@ -13,13 +13,13 @@ class SparseArray[@specialized(Int) T:ClassTag] extends collection.mutable.Map[I * negative and can be converted into an insertion point with -(rv+1). */ private def findOffset(i : Int) : Int = { - error("impl doesn't matter") + sys.error("impl doesn't matter") } - override def apply(i : Int) : T = { error("ignore") } - override def update(i : Int, value : T) = error("ignore") + override def apply(i : Int) : T = { sys.error("ignore") } + override def update(i : Int, value : T) = sys.error("ignore") override def empty = new SparseArray[T] - def -=(ind: Int) = error("ignore") - def +=(kv: (Int,T)) = error("ignore") - override final def iterator = error("ignore") -}
\ No newline at end of file + def -=(ind: Int) = sys.error("ignore") + def +=(kv: (Int,T)) = sys.error("ignore") + override final def iterator = sys.error("ignore") +} diff --git a/test/files/pos/spec-sparsearray-old.scala b/test/files/pos/spec-sparsearray-old.scala index ea7710a785..e10dabd542 100644 --- a/test/files/pos/spec-sparsearray-old.scala +++ b/test/files/pos/spec-sparsearray-old.scala @@ -3,7 +3,7 @@ import scala.collection.mutable.MapLike class SparseArray[@specialized(Int) T:ClassManifest] extends collection.mutable.Map[Int,T] with collection.mutable.MapLike[Int,T,SparseArray[T]] { override def get(x: Int) = { val ind = findOffset(x) - if(ind < 0) None else Some(error("ignore")) + if(ind < 0) None else Some(sys.error("ignore")) } /** @@ -12,13 +12,13 @@ class SparseArray[@specialized(Int) T:ClassManifest] extends collection.mutable. * negative and can be converted into an insertion point with -(rv+1). */ private def findOffset(i : Int) : Int = { - error("impl doesn't matter") + sys.error("impl doesn't matter") } - override def apply(i : Int) : T = { error("ignore") } - override def update(i : Int, value : T) = error("ignore") + override def apply(i : Int) : T = { sys.error("ignore") } + override def update(i : Int, value : T) = sys.error("ignore") override def empty = new SparseArray[T] - def -=(ind: Int) = error("ignore") - def +=(kv: (Int,T)) = error("ignore") - override final def iterator = error("ignore") + def -=(ind: Int) = sys.error("ignore") + def +=(kv: (Int,T)) = sys.error("ignore") + override final def iterator = sys.error("ignore") } diff --git a/test/files/pos/spec-t3497.scala b/test/files/pos/spec-t3497.scala index 6cc0e24f89..ff054aa7de 100644 --- a/test/files/pos/spec-t3497.scala +++ b/test/files/pos/spec-t3497.scala @@ -10,7 +10,7 @@ object B extends A[ Array[Byte], Int ] { return -1 } } - + return 0 } } diff --git a/test/files/pos/spec-tailcall.scala b/test/files/pos/spec-tailcall.scala index d91e2f59ce..703ec011ad 100644 --- a/test/files/pos/spec-tailcall.scala +++ b/test/files/pos/spec-tailcall.scala @@ -1,5 +1,5 @@ class TailCall[@specialized T] { - final def dropLeft(n: Int, xs: List[T]): List[T] = + final def dropLeft(n: Int, xs: List[T]): List[T] = if (n == 0) xs else dropLeft(n - 1, xs.tail) /* @@ -7,7 +7,7 @@ class TailCall[@specialized T] { def crash(o: Option[String]) = filter { case None if { - def dropLeft[T](n: Int, xs: List[T]): List[T] = + def dropLeft[T](n: Int, xs: List[T]): List[T] = if (n == 0) xs else dropLeft(n - 1, xs.tail) dropLeft(2, List(1, 2, 3)).isEmpty diff --git a/test/files/pos/spec-traits.scala b/test/files/pos/spec-traits.scala index c6cc2921b7..074f6c3d3c 100644 --- a/test/files/pos/spec-traits.scala +++ b/test/files/pos/spec-traits.scala @@ -11,19 +11,19 @@ class Lazy { // issue 3307 class Bug3307 { - def f[Z](block: String => Z) { - block("abc") + def f[Z](block: String => Z) { + block("abc") } - - ({ () => - f { implicit x => println(x) } })() + + ({ () => + f { implicit x => println(x) } })() } // issue 3301 trait T[X] class Bug3301 { - def t[A]: T[A] = error("stub") + def t[A]: T[A] = sys.error("stub") () => { type X = Int diff --git a/test/files/pos/spec-vector.scala b/test/files/pos/spec-vector.scala index 06e49b521f..392949c669 100644 --- a/test/files/pos/spec-vector.scala +++ b/test/files/pos/spec-vector.scala @@ -1,4 +1,4 @@ // ticket #3379, abstract overrides trait Vector extends (Int=>Double) { - override def apply(i: Int): Double + override def apply(i: Int): Double } diff --git a/test/files/pos/spec.scala b/test/files/pos/spec.scala index 093d3cded4..cc060ffe84 100644 --- a/test/files/pos/spec.scala +++ b/test/files/pos/spec.scala @@ -7,7 +7,7 @@ class Bar[@specialized(Int, AnyRef) A](a: A) { } -class WithInner[@specialized(Int, AnyRef) A](a: A) { +class WithInner[@specialized(Int, AnyRef) A](a: A) { class Inner { def meth = a } @@ -42,7 +42,7 @@ class Qux[@specialized(AnyRef) A] { class Foo[@specialized(Int, AnyRef) A](val a: Array[A]) { a(0) - + def id(elem: A) = a(0) = elem } @@ -52,13 +52,13 @@ object Test { def main(arg: Array[String]) { val f = new Foo(new Array[String](5)) f.id("") - + val z = new Baz[Int, Double] z.ab(1, 1.0) - + testspec(new Array[String](5)) testspec(new Array[Int](5)) } - + def testspec[@specialized(Int, AnyRef) T](arr: Array[T]) = arr(0) } diff --git a/test/files/pos/strings.scala b/test/files/pos/strings.scala index 83b8179706..9fe8cfd94b 100644 --- a/test/files/pos/strings.scala +++ b/test/files/pos/strings.scala @@ -6,5 +6,5 @@ object test { } // #1000 object A { - println("""This a "raw" string ending with a "double quote"""") + println("""This a "raw" string ending with a "double quote"""") } diff --git a/test/files/pos/sudoku.scala b/test/files/pos/sudoku.scala index 336dc756a9..9435f504d6 100644 --- a/test/files/pos/sudoku.scala +++ b/test/files/pos/sudoku.scala @@ -3,22 +3,22 @@ object SudokuSolver extends App { // held in a global variable m. The program begins by reading 9 lines // of input to fill the board var m: Array[Array[Char]] = Array.tabulate(9)((x: Int) => readLine.toArray) - + // For printing m, a method print is defined def print = { println(""); m map (carr => println(new String(carr))) } - + // The test for validity is performed by looping over i=0..8 and // testing the row, column and 3x3 square containing the given // coordinate def invalid(i: Int, x: Int, y: Int, n: Char): Boolean = i<9 && (m(y)(i) == n || m(i)(x) == n || m(y/3*3 + i/3)(x/3*3 + i % 3) == n || invalid(i+1, x, y, n)) - + // Looping over a half-closed range of consecutive integers [l..u) // is factored out into a higher-order function def fold(f: (Int, Int) => Int, accu: Int, l: Int, u: Int): Int = if(l==u) accu else fold(f, f(accu, l), l+1, u) - + // The search function examines each position on the board in turn, // trying the numbers 1..9 in each unfilled position // The function is itself a higher-order fold, accumulating the value @@ -34,7 +34,7 @@ object SudokuSolver extends App { val newaccu = search(x+1, y, f, accu); m(y)(x) = '0'; newaccu}, accu, 1, 10)} - + // The main part of the program uses the search function to accumulate // the total number of solutions println("\n"+search(0,0,i => {print; i+1},0)+" solution(s)") diff --git a/test/files/pos/super.cmds b/test/files/pos/super.cmds deleted file mode 100644 index 8f3f8a4172..0000000000 --- a/test/files/pos/super.cmds +++ /dev/null @@ -1,2 +0,0 @@ -javac Super_1.java -scalac Super_2.scala diff --git a/test/files/pos/super/Super_1.java b/test/files/pos/super/Super_1.java index 418ae96bc0..9acbba0ec4 100644 --- a/test/files/pos/super/Super_1.java +++ b/test/files/pos/super/Super_1.java @@ -1,6 +1,6 @@ // A.java interface Inter<T> { } -class Super implements Inter<Super.Inner> { +class Super implements Inter<Super.Inner> { public class Inner { }; } diff --git a/test/files/pos/switch-small.flags b/test/files/pos/switch-small.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/switch-small.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t0031.scala b/test/files/pos/t0031.scala index ec6eae9282..d4050c8184 100644 --- a/test/files/pos/t0031.scala +++ b/test/files/pos/t0031.scala @@ -4,17 +4,17 @@ object Main { def ensure(postcondition: a => Boolean): a } - def require[a](precondition: => Boolean)(command: => a): Ensure[a] = + def require[a](precondition: => Boolean)(command: => a): Ensure[a] = if (precondition) new Ensure[a] { def ensure(postcondition: a => Boolean): a = { val result = command; if (postcondition(result)) result - else error("Assertion error") + else sys.error("Assertion error") } } else - error("Assertion error"); + sys.error("Assertion error"); def arb[a](s: List[a]) = require (! s.isEmpty) { diff --git a/test/files/pos/t0066.scala b/test/files/pos/t0066.scala index 9317da7165..2153264e7a 100644 --- a/test/files/pos/t0066.scala +++ b/test/files/pos/t0066.scala @@ -3,5 +3,5 @@ class GBTree[A, B] /*with Map[A, B, GBTree[A,B]]*/ { case class Node[A,B](key:A,value:B,smaller:Node[A,B],bigger:Node[A,B]) extends Tree[A,B]; case class Nil[A,B]() extends Tree[A,B]; - + } diff --git a/test/files/pos/t0069.scala b/test/files/pos/t0069.scala index 5a8c15cd5a..e4c242c0ee 100644 --- a/test/files/pos/t0069.scala +++ b/test/files/pos/t0069.scala @@ -8,4 +8,3 @@ object testCQ { */ } - diff --git a/test/files/pos/t0227.scala b/test/files/pos/t0227.scala index 8650350c4a..806b20d409 100644 --- a/test/files/pos/t0227.scala +++ b/test/files/pos/t0227.scala @@ -5,7 +5,7 @@ final class Settings { abstract class Factory { type libraryType <: Base - final def apply(settings: Settings): libraryType = error("bla") + final def apply(settings: Settings): libraryType = sys.error("bla") } abstract class Base { @@ -19,7 +19,7 @@ class SA(val settings: Settings) extends Base { SD ) ::: settings.f( SC - ) + ) } object SC extends Factory { diff --git a/test/files/pos/t0288/Foo.scala b/test/files/pos/t0288/Foo.scala index 1f7d81327d..778ba65f58 100644 --- a/test/files/pos/t0288/Foo.scala +++ b/test/files/pos/t0288/Foo.scala @@ -6,4 +6,4 @@ class Foo extends Outer{ val bar = new Inner(); // Shouldn't this work? -} +} diff --git a/test/files/pos/t0288/Outer.java b/test/files/pos/t0288/Outer.java index 7a3754fb5d..bea3e3f8d0 100644 --- a/test/files/pos/t0288/Outer.java +++ b/test/files/pos/t0288/Outer.java @@ -6,4 +6,4 @@ public class Outer{ } -} +} diff --git a/test/files/pos/t0301.scala b/test/files/pos/t0301.scala index cb68f38062..24b4776010 100644 --- a/test/files/pos/t0301.scala +++ b/test/files/pos/t0301.scala @@ -1,7 +1,7 @@ package fos abstract class Expr -case class Var extends Expr +case class Var() extends Expr object Analyzer { def substitution(expr: Expr, cls: (Var,Var)): Expr = diff --git a/test/files/pos/t0305.scala b/test/files/pos/t0305.scala index 4d37a02eb3..4838b1fcf8 100644 --- a/test/files/pos/t0305.scala +++ b/test/files/pos/t0305.scala @@ -1,5 +1,5 @@ object Test extends App { - + def foo(is:Int*) = 1; def foo(i:Int) = 2; diff --git a/test/files/pos/t0422.scala b/test/files/pos/t0422.scala deleted file mode 100644 index cb3ba279d4..0000000000 --- a/test/files/pos/t0422.scala +++ /dev/null @@ -1,17 +0,0 @@ -import scala.util.regexp.WordExp; -import scala.util.automata.WordBerrySethi; - -object BoolWordExp extends WordExp { - type _labelT = MyLabels; - type _regexpT = RegExp; - abstract class MyLabels extends Label ; - case class MyLabel(c:Char) extends MyLabels; -} - -object MyTranslator extends WordBerrySethi { - override val lang = BoolWordExp; - import lang._; - override protected def seenLabel( r:RegExp, i:Int, label: _labelT ): Unit = { - super.seenLabel(r,i,label) - } -} diff --git a/test/files/pos/t0438.scala b/test/files/pos/t0438.scala index 33b7efeaac..fa5b7711ff 100644 --- a/test/files/pos/t0438.scala +++ b/test/files/pos/t0438.scala @@ -1,9 +1,9 @@ class Foo { - implicit def pair2fun2[A, B, C](f: (A, B) => C) = + implicit def pair2fun2[A, B, C](f: (A, B) => C) = {p: (A, B) => f(p._1, p._2) } def foo(f: ((Int, Int)) => Int) = f - def bar(x: Int, y: Int) = x + y + def bar(x: Int, y: Int) = x + y foo({ (x: Int, y: Int) => x + y }) // works foo(pair2fun2(bar _)) // works diff --git a/test/files/pos/t0453.scala b/test/files/pos/t0453.scala index d59a3d22f2..dfacc5eed7 100644 --- a/test/files/pos/t0453.scala +++ b/test/files/pos/t0453.scala @@ -1,5 +1,5 @@ object Test { - val foo = new { + val foo = new { trait Bar def l () : Bar = { new Bar {} } } diff --git a/test/files/pos/t0599.scala b/test/files/pos/t0599.scala index 6125b99ce2..885159af66 100644 --- a/test/files/pos/t0599.scala +++ b/test/files/pos/t0599.scala @@ -15,4 +15,4 @@ abstract class FooA { a.xxx; doB.xxx; } - } + } diff --git a/test/files/pos/t0625.scala b/test/files/pos/t0625.scala index bda463d6a6..5614542599 100644 --- a/test/files/pos/t0625.scala +++ b/test/files/pos/t0625.scala @@ -1,6 +1,6 @@ object Test { def idMap[C[_],T](m: { def map[U](f: T => U): C[U] }): C[T] = m.map(t => t) - + def main(args: Array[String]): Unit = { idMap(Some(5)) idMap(Responder.constant(5)) diff --git a/test/files/pos/t0646.scala b/test/files/pos/t0646.scala deleted file mode 100644 index 6146e60020..0000000000 --- a/test/files/pos/t0646.scala +++ /dev/null @@ -1,21 +0,0 @@ -object xfor { - - import scala.xml.NodeSeq - - val books = - <bks> - <title>Blabla</title> - <title>Blubabla</title> - <title>Baaaaaaalabla</title> - </bks>; - - new NodeSeq { val theSeq = books.child } match { - case t @ Seq(<title>Blabla</title>) => t - } - - //val n: NodeSeq = new NodeSeq { val theSeq = books.child } - //n match { - // case t @ <title>Blabla</title> => t - //} - -} diff --git a/test/files/pos/t0770.scala b/test/files/pos/t0770.scala index bb438f1918..7a0a2bf9bb 100644 --- a/test/files/pos/t0770.scala +++ b/test/files/pos/t0770.scala @@ -1,7 +1,7 @@ trait A { private[this] val p = 5 - + def f = (b: Byte) => p } diff --git a/test/files/pos/t0774/unrelated.scala b/test/files/pos/t0774/unrelated.scala index 483f836d0c..1efdb2505e 100644 --- a/test/files/pos/t0774/unrelated.scala +++ b/test/files/pos/t0774/unrelated.scala @@ -1,8 +1,8 @@ object Outer { import Inner._ - + deathname - + object Inner { def deathname: Int = 1 } diff --git a/test/files/pos/t0786.scala b/test/files/pos/t0786.scala index 4d9f1d0dc9..f40cf7d2e1 100644 --- a/test/files/pos/t0786.scala +++ b/test/files/pos/t0786.scala @@ -2,15 +2,15 @@ object ImplicitProblem { class M[T] def nullval[T] = null.asInstanceOf[T]; - + trait Rep[T] { def eval: Int } - + implicit def toRep0(n: Int) = new Rep[Int] { def eval = 0 } - + implicit def toRepN[T](n: M[T])(implicit f: T => Rep[T]) = new Rep[M[T]] { def eval = f(nullval[T]).eval + 1 } @@ -18,11 +18,11 @@ object ImplicitProblem { def depth[T <% Rep[T]](n: T) = n.eval def main(args: Array[String]) { - println(depth(nullval[M[Int]])) // (1) this works + println(depth(nullval[M[Int]])) // (1) this works println(nullval[M[Int]].eval) // (2) this works - + type m = M[Int] - println(depth(nullval[m])) // (3) this doesn't compile on 2.7.RC1 + println(depth(nullval[m])) // (3) this doesn't compile on 2.7.RC1 println(nullval[m].eval) // (4) this works } diff --git a/test/files/pos/t0851.scala b/test/files/pos/t0851.scala new file mode 100644 index 0000000000..fc7109dcd4 --- /dev/null +++ b/test/files/pos/t0851.scala @@ -0,0 +1,14 @@ +package test + +object test1 { + case class Foo[T,T2](f : (T,T2) => String) extends (((T,T2)) => String){ + def apply(t : T) = (s:T2) => f(t,s) + def apply(p : (T,T2)) = f(p._1,p._2) + } + implicit def g[T](f : (T,String) => String) = Foo(f) + def main(args : Array[String]) : Unit = { + val f = (x:Int,s:String) => s + x + println(f(1)) + () + } +} diff --git a/test/files/pos/t0872.scala b/test/files/pos/t0872.scala new file mode 100644 index 0000000000..8f4c1c4436 --- /dev/null +++ b/test/files/pos/t0872.scala @@ -0,0 +1,8 @@ +object Main { + def main(args : Array[String]) { + val fn = (a : Int, str : String) => "a: " + a + ", str: " + str + implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null) + println(fn(1)) + () + } +} diff --git a/test/files/pos/t1000.scala b/test/files/pos/t1000.scala index fabef94fff..613af76b94 100644 --- a/test/files/pos/t1000.scala +++ b/test/files/pos/t1000.scala @@ -1,5 +1,5 @@ object A { - println("""This a "raw" string ending with a "double quote"""") + println("""This a "raw" string ending with a "double quote"""") } object Test extends App { diff --git a/test/files/pos/t1014.scala b/test/files/pos/t1014.scala deleted file mode 100644 index 3fc10d10dc..0000000000 --- a/test/files/pos/t1014.scala +++ /dev/null @@ -1,15 +0,0 @@ -import scala.xml.{NodeSeq, Elem} - -class EO extends App with Moo { - // return type is Flog, inherited from overridden method. - // implicit conversions are applied because expected type `pt` is `Flog` when `computeType(rhs, pt)`. - def cat = <cat>dog</cat> - - implicit def nodeSeqToFlog(in: Elem): Flog = new Flog(in) -} - -trait Moo { - def cat: Flog -} - -class Flog(val in: NodeSeq) diff --git a/test/files/pos/t1029.cmds b/test/files/pos/t1029.cmds deleted file mode 100644 index 06b863dc03..0000000000 --- a/test/files/pos/t1029.cmds +++ /dev/null @@ -1,2 +0,0 @@ -scalac Test_1.scala -scalac Test_2.scala diff --git a/test/files/pos/t1035.scala b/test/files/pos/t1035.scala index bd693d9e68..e0a9379c7e 100644 --- a/test/files/pos/t1035.scala +++ b/test/files/pos/t1035.scala @@ -7,7 +7,7 @@ class A { var name:String = _ def getName() = name def this(name:String, age:Int){this();this.name=name} - + } class B(name:String) extends A(name,0){ @@ -18,15 +18,15 @@ class D { object A { def unapply(p:A) = Some(p.getName) } - + object B { def unapply(p:B) = Some(p.getName) } def foo(p:Any) = p match { - case B(n) => println("B") - case A(n) => println("A") - - + case B(n) => println("B") + case A(n) => println("A") + + } } diff --git a/test/files/pos/t1048.scala b/test/files/pos/t1048.scala index ce57e72391..cd16db5b60 100644 --- a/test/files/pos/t1048.scala +++ b/test/files/pos/t1048.scala @@ -1,7 +1,7 @@ trait T[U] { def x: T[V] forSome { type V <: U } } - + object T { def unapply[U](t: T[U]): Option[T[V] forSome { type V <: U }] = Some(t.x) } @@ -12,4 +12,3 @@ object Test { } } - diff --git a/test/files/pos/t1059.scala b/test/files/pos/t1059.scala deleted file mode 100644 index bcd8f0374f..0000000000 --- a/test/files/pos/t1059.scala +++ /dev/null @@ -1,28 +0,0 @@ -package com; - -import scala.xml._ - -object Main { - - def main(args : Array[String]) : Unit = { - - var m : PartialFunction[Any, Any] = { - - case SafeNodeSeq(s @ _*) => println(s) } - - println(m(<a/> ++ <b/>)) - println(m.isDefinedAt(<a/> ++ <b/>)) - - } - -} - -object SafeNodeSeq { - - def unapplySeq(any: Any) : Option[Seq[Node]] = any match { case s: Seq[_] => Some(s flatMap ( _ match { - - case n: Node => n case _ => NodeSeq.Empty - - })) case _ => None } - -} diff --git a/test/files/pos/t1071.scala b/test/files/pos/t1071.scala index 7fb802f8b0..59149a021b 100644 --- a/test/files/pos/t1071.scala +++ b/test/files/pos/t1071.scala @@ -12,6 +12,6 @@ object Test { val c = new C (c: D).a // works - c.a // error + c.a // error } diff --git a/test/files/pos/t1090.scala b/test/files/pos/t1090.scala index dca762af4f..a9bce90b00 100644 --- a/test/files/pos/t1090.scala +++ b/test/files/pos/t1090.scala @@ -10,7 +10,7 @@ object Test { type Node = Core.this.Node } def f(manager : Manager) = manager.iterator.foreach{ - case node : NodeImpl => + case node : NodeImpl => } } } diff --git a/test/files/pos/t1107.scala b/test/files/pos/t1107a.scala index 0bf40bb4cc..0bf40bb4cc 100644 --- a/test/files/pos/t1107.scala +++ b/test/files/pos/t1107a.scala diff --git a/test/files/pos/t1107b/O.scala b/test/files/pos/t1107b/O.scala index aa605a6d09..0198867704 100644 --- a/test/files/pos/t1107b/O.scala +++ b/test/files/pos/t1107b/O.scala @@ -4,10 +4,10 @@ object O case s: Sub => true case _ => false } - + def main(args: Array[String]): Unit = { val c = new AnyRef with C c.bob.toString + c.bob2.toString - } + } } diff --git a/test/files/pos/t1107b/T.scala b/test/files/pos/t1107b/T.scala index 1f3712d529..0dff0b94fd 100644 --- a/test/files/pos/t1107b/T.scala +++ b/test/files/pos/t1107b/T.scala @@ -1,6 +1,6 @@ sealed trait Top sealed trait Sub extends Top -trait C { +trait C { private object P extends Sub def bob() = P.getClass def bob2() = O.d(P) diff --git a/test/files/pos/t1123.scala b/test/files/pos/t1123.scala index a7b009cbbe..3812fa3eb3 100644 --- a/test/files/pos/t1123.scala +++ b/test/files/pos/t1123.scala @@ -7,5 +7,5 @@ object Test { } def f = extraListener.h } - def main(args : Array[String]) : Unit = (new Editor).f + def main(args : Array[String]) : Unit = (new Editor).f } diff --git a/test/files/pos/t1133.scala b/test/files/pos/t1133.scala index 4538de5f5f..562b528ea3 100644 --- a/test/files/pos/t1133.scala +++ b/test/files/pos/t1133.scala @@ -8,21 +8,21 @@ object Match case _ => println("fail") } } - + object Extractor1 { def unapply(x: Any) = x match { case x: String => Some(x, x+x, x+x+x, x+x, x) case _ => None } } - + object Extractor2 { def unapply(x: Any) = x match { case x: String => Some(x, x+x, x+x+x) case _ => None } } - + object Extractor3 { def unapply(x: Any) = x match { case x: String => Some(x, x, x) diff --git a/test/files/pos/t1164.scala b/test/files/pos/t1164.scala index 307ca92c85..ab58c1d6b4 100644 --- a/test/files/pos/t1164.scala +++ b/test/files/pos/t1164.scala @@ -1,29 +1,29 @@ -object test { +object test { - class Foo[a](val arg : a) + class Foo[a](val arg : a) + + object Foo { + def apply [a](arg : a, right :a) = new Foo[a](arg) + def unapply [a](m : Foo[a]) = Some (m.arg) + } - object Foo { - def apply [a](arg : a, right :a) = new Foo[a](arg) - def unapply [a](m : Foo[a]) = Some (m.arg) - } - def matchAndGetArgFromFoo[a]( e:Foo[a]):a = {e match { case Foo(x) => x }} - - + + // Try the same thing as above but use function as argument to Bar // constructor - + type FunIntToA [a] = (Int) => a - class Bar[a] (var f: FunIntToA[a]) - + class Bar[a] (var f: FunIntToA[a]) + object Bar { def apply[a](f: FunIntToA[a]) = new Bar[a](f) def unapply[a](m: Bar[a]) = Some (m.f) } - + def matchAndGetFunFromBar[a](b:Bar[a]) : FunIntToA[a] = { b match { case Bar(x) => x}} - + } diff --git a/test/files/pos/t1168.scala b/test/files/pos/t1168.scala index d9f38714b8..75638e792f 100644 --- a/test/files/pos/t1168.scala +++ b/test/files/pos/t1168.scala @@ -1,5 +1,5 @@ object Test extends App { - + trait SpecialException {} try { diff --git a/test/files/pos/t1203.scala b/test/files/pos/t1203.scala deleted file mode 100644 index 062ef93fc6..0000000000 --- a/test/files/pos/t1203.scala +++ /dev/null @@ -1,7 +0,0 @@ -case class ant(t: String) extends scala.annotation.Annotation -object Test { - def main(args: Array[String]): Unit = { - val a: scala.xml.NodeSeq @ant("12") = Nil - println(a) - } -} diff --git a/test/files/pos/t1210a.scala b/test/files/pos/t1210a.scala index fbb0a611d6..b3492f96e4 100644 --- a/test/files/pos/t1210a.scala +++ b/test/files/pos/t1210a.scala @@ -1,9 +1,9 @@ // both styles of abstraction should behave the same // related to 1210 because that bug broke the OO version below -trait OO { +trait OO { abstract class Test { self => type T - + val v: Test {type T = self.T} = self.v.v } } diff --git a/test/files/pos/t122.scala b/test/files/pos/t122.scala index e3daeef73e..630e24ce4a 100644 --- a/test/files/pos/t122.scala +++ b/test/files/pos/t122.scala @@ -1,4 +1,4 @@ class L { - val List(v:Int, 2) = List(2, v:Int) + val List(v:Int, 2) = List(2, v:Int) val (a:Int, b:Int) = (1, a) } diff --git a/test/files/pos/t1230/S.scala b/test/files/pos/t1230/S.scala index f8a691b6de..530dd4b853 100644 --- a/test/files/pos/t1230/S.scala +++ b/test/files/pos/t1230/S.scala @@ -1 +1 @@ -object S extends Application { (new J).foo = 5 } +object S extends App { (new J).foo = 5 } diff --git a/test/files/pos/t1231/S.scala b/test/files/pos/t1231/S.scala index ee08866e04..f14aa2561b 100644 --- a/test/files/pos/t1231/S.scala +++ b/test/files/pos/t1231/S.scala @@ -1 +1 @@ -object S extends Application { println(J.j1) } +object S extends App { println(J.j1) } diff --git a/test/files/pos/t1236.scala b/test/files/pos/t1236.scala index 7028162ee0..5e221ce411 100644 --- a/test/files/pos/t1236.scala +++ b/test/files/pos/t1236.scala @@ -1,5 +1,5 @@ trait Empty[E[_]] { - def e[A]: E[A] + def e[A]: E[A] } object T { diff --git a/test/files/pos/t1237.scala b/test/files/pos/t1237.scala index 0d1dd05d50..7777372138 100644 --- a/test/files/pos/t1237.scala +++ b/test/files/pos/t1237.scala @@ -1,11 +1,11 @@ -class HelloWorld { - def main(args: Array[String]) { +class HelloWorld { + def main(args: Array[String]) { object TypeBool; trait Fct { def g(x : Int) = TypeBool // breaks. - + // def g(x : Int) = 3 // fine. } diff --git a/test/files/pos/t1254/t1254.java b/test/files/pos/t1254/t1254.java index 17dc391672..17e1c60bf5 100644 --- a/test/files/pos/t1254/t1254.java +++ b/test/files/pos/t1254/t1254.java @@ -11,7 +11,7 @@ class NothingBug3 { scala.Option<?> o = scala.None$.MODULE$; test(o); - None.toLeft(new scala.runtime.AbstractFunction0<Integer>() { + None.toLeft(new scala.runtime.AbstractFunction0<Integer>() { public Integer apply() { return 0; } }); } diff --git a/test/files/pos/t1263/test.scala b/test/files/pos/t1263/test.scala index 7ced59083a..92d8c1cdfa 100644 --- a/test/files/pos/t1263/test.scala +++ b/test/files/pos/t1263/test.scala @@ -2,7 +2,7 @@ package test trait Map[A, +B] { def plus(key: A): MapTo = new MapTo(key) - + class MapTo(key: A) { def arrow [B1 >: B](value: B1) = null } diff --git a/test/files/pos/t1272.scala b/test/files/pos/t1272.scala index aab1a886c7..d86a909ae5 100644 --- a/test/files/pos/t1272.scala +++ b/test/files/pos/t1272.scala @@ -2,8 +2,8 @@ object ImplicitTest { implicit val i : Int = 10 implicit def a(implicit i : Int) : Array[Byte] = null implicit def b[T](implicit i : Int) : Array[T] = null - + def fn[T](implicit x : T) = 0 - + val x = fn[Array[Byte]] }
\ No newline at end of file diff --git a/test/files/pos/t1292.scala b/test/files/pos/t1292.scala index 3ed153abf2..83a996d530 100644 --- a/test/files/pos/t1292.scala +++ b/test/files/pos/t1292.scala @@ -1,5 +1,5 @@ trait Foo[T <: Foo[T, Enum], Enum <: Enumeration] { - type StV = Enum#Value + type StV = Enum#Value type Meta = MegaFoo[T, Enum] type Slog <: Enumeration diff --git a/test/files/pos/t1318.scala b/test/files/pos/t1318.scala index 3fc6e3060f..f3d2f7ab5a 100644 --- a/test/files/pos/t1318.scala +++ b/test/files/pos/t1318.scala @@ -19,7 +19,7 @@ object A extends A0 {} abstract class B0 extends M { type mType = B0 - def fs: List[fType] = Nil + def fs: List[fType] = Nil } object B extends B0 {} diff --git a/test/files/pos/t1357.scala b/test/files/pos/t1357.scala index 7bc6d45034..fcdecb3ad3 100644 --- a/test/files/pos/t1357.scala +++ b/test/files/pos/t1357.scala @@ -6,7 +6,7 @@ object NonEmptyCons { object Main { type BT[+H, +T <: Tuple2[Tuple2[H, T], Tuple2[H, T]]] = Tuple2[H, T] - + // type T = Tuple2[String,String] type BinaryTree[+E] = BT[E, T forSome { type T <: Tuple2[BT[E, T], BT[E, T]] }] diff --git a/test/files/pos/t1385.scala b/test/files/pos/t1385.scala index 59953bcc39..aefd9c35b3 100644 --- a/test/files/pos/t1385.scala +++ b/test/files/pos/t1385.scala @@ -1,3 +1,3 @@ -@serializable object Test { - private def readResolve:AnyRef = this +object Test extends Serializable { + private def readResolve: AnyRef = this } diff --git a/test/files/pos/t1439.flags b/test/files/pos/t1439.flags index 1e70f5c5c7..bca57e4785 100644 --- a/test/files/pos/t1439.flags +++ b/test/files/pos/t1439.flags @@ -1 +1 @@ --unchecked -Xfatal-warnings -Xoldpatmat -language:higherKinds +-unchecked -Xfatal-warnings -language:higherKinds diff --git a/test/files/pos/t1480.scala b/test/files/pos/t1480.scala index 3dc3062ca0..1d9f94d2e9 100644 --- a/test/files/pos/t1480.scala +++ b/test/files/pos/t1480.scala @@ -1,6 +1,6 @@ class Foo{ def compare(newP : Any, oldP : Any) : Boolean = (newP,oldP) match { - case (newP : AnyRef, oldP : AnyRef) if newP == oldP => newP == oldP - case (newS : Symbol, oldS: Symbol) if newS == oldS => newS == oldS + case (newP : AnyRef, oldP : AnyRef) if newP == oldP => newP == oldP + case (newS : Symbol, oldS: Symbol) if newS == oldS => newS == oldS } } diff --git a/test/files/pos/t1560.scala b/test/files/pos/t1560.scala index fb5592016a..2af299af86 100644 --- a/test/files/pos/t1560.scala +++ b/test/files/pos/t1560.scala @@ -1,13 +1,13 @@ object Test extends App { - + trait C[T] { def t: T } - + def b: Option[C[x] forSome { type x }] = null - + def c = b match { case Some(b) => b.t } - + } diff --git a/test/files/pos/t1565.scala b/test/files/pos/t1565.scala index 030086c541..df333151d5 100644 --- a/test/files/pos/t1565.scala +++ b/test/files/pos/t1565.scala @@ -3,7 +3,7 @@ object Bug1565 { def x() = { 0; (a : Int, b : Int) => println(List(a, b)) ; 0 } (a : Int, b : Int) => println(List(a, b)) - + // various function syntaxes to exercise the parser val xs = List(1,2,3) xs.filter(x => x < 2) diff --git a/test/files/pos/t1591b.scala b/test/files/pos/t1591b.scala index 84372bb084..c671ad6472 100644 --- a/test/files/pos/t1591b.scala +++ b/test/files/pos/t1591b.scala @@ -1,10 +1,10 @@ import scala.tools.nsc._ -class SemanticTokens(val compiler: Global) { - import compiler._ +class SemanticTokens(val compiler: Global) { + import compiler._ def build() = ErrorType - + class Process { def f() = analyzer // or to crash the compiler instead of a nice message, diff --git a/test/files/pos/t1626.scala b/test/files/pos/t1626.scala deleted file mode 100644 index 200be47430..0000000000 --- a/test/files/pos/t1626.scala +++ /dev/null @@ -1,4 +0,0 @@ -object o { - val n = <a xmlns=""/> - n.namespace == null -} diff --git a/test/files/pos/t1648.scala b/test/files/pos/t1648.scala deleted file mode 100644 index 6d53ce11ee..0000000000 --- a/test/files/pos/t1648.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test { - class MyClass extends scala.util.logging.Logged { } - val x = new MyClass with scala.util.logging.ConsoleLogger -} diff --git a/test/files/pos/t1711/Seq.scala b/test/files/pos/t1711/Seq.scala index 5f426ea0f7..c18f05cd73 100644 --- a/test/files/pos/t1711/Seq.scala +++ b/test/files/pos/t1711/Seq.scala @@ -3,7 +3,7 @@ package com object Sequence { def filteringFunction[V](filter: V => Boolean): List[V] => List[V] = { - def include(v: V) = + def include(v: V) = filter(v) (l: List[V]) => l.filter(include) } diff --git a/test/files/pos/t1722-A.scala b/test/files/pos/t1722-A.scala index 9e522a5059..d059bf22f8 100644 --- a/test/files/pos/t1722-A.scala +++ b/test/files/pos/t1722-A.scala @@ -1,8 +1,8 @@ sealed trait Top trait C { private object P extends Top -} -/* +} +/* $ scala -e 'new AnyRef with C' error: error while loading Top, class file '/private/tmp/bobobo/./Top.class' is broken (error reading Scala signature of /private/tmp/bobobo/./Top.class: malformed Scala signature of Top at 185; reference value P of trait C refers to nonexisting symbol.) diff --git a/test/files/pos/t1722/Test.scala b/test/files/pos/t1722/Test.scala index 5685d8f40a..f236d3fdc4 100755 --- a/test/files/pos/t1722/Test.scala +++ b/test/files/pos/t1722/Test.scala @@ -1,5 +1,5 @@ package t1722 object Test { - val x = new AnyRef with C + val x = new AnyRef with C } diff --git a/test/files/pos/t1722/Top.scala b/test/files/pos/t1722/Top.scala index cec4c531f9..4ac52412aa 100755 --- a/test/files/pos/t1722/Top.scala +++ b/test/files/pos/t1722/Top.scala @@ -3,8 +3,8 @@ package t1722 sealed trait Top trait C { private object P extends Top -} -/* +} +/* $ scala -e 'new AnyRef with C' error: error while loading Top, class file '/private/tmp/bobobo/./Top.class' is broken (error reading Scala signature of /private/tmp/bobobo/./Top.class: malformed Scala signature of Top at 185; reference value P of trait C refers to nonexisting symbol.) diff --git a/test/files/pos/t1745/J.java b/test/files/pos/t1745/J.java index d95efe8e6f..8444eabb24 100644 --- a/test/files/pos/t1745/J.java +++ b/test/files/pos/t1745/J.java @@ -1,9 +1,9 @@ -class J { +class J { S1 s1; S2 s2; - + String s = bar(S3.foo(), S3.bar("def")); - + private String bar(String s1, String s2) { return s1 + s2; } diff --git a/test/pending/pos/t1751/A1_2.scala b/test/files/pos/t1751/A1_2.scala index 354d5eecd0..354d5eecd0 100644 --- a/test/pending/pos/t1751/A1_2.scala +++ b/test/files/pos/t1751/A1_2.scala diff --git a/test/pending/pos/t1751/A2_1.scala b/test/files/pos/t1751/A2_1.scala index c768062e43..c768062e43 100644 --- a/test/pending/pos/t1751/A2_1.scala +++ b/test/files/pos/t1751/A2_1.scala diff --git a/test/pending/pos/t1751/SuiteClasses.java b/test/files/pos/t1751/SuiteClasses.java index a415e4f572..a415e4f572 100644 --- a/test/pending/pos/t1751/SuiteClasses.java +++ b/test/files/pos/t1751/SuiteClasses.java diff --git a/test/files/pos/t1756.scala b/test/files/pos/t1756.scala index 2e09c8a94a..1d067c3b04 100755 --- a/test/files/pos/t1756.scala +++ b/test/files/pos/t1756.scala @@ -1,5 +1,5 @@ -/** +/** This is a tricky issue which has to do with the fact that too much conflicting type information is propagated into a single implicit search, where the intended solution applies two implicit searches. @@ -35,20 +35,20 @@ class Poly[C <: Ring[C]](val c: C) extends Ring[Poly[C]] { } object Test extends App { - + implicit def coef2poly[C <: Ring[C]](c: C): Poly[C] = new Poly(c) val a = new A val x = new Poly(new A) - + println(x+a) // works println(a+x) // works - + val y = new Poly(new Poly(new A)) - + println(x+y*x) // works println(x*y+x) // works println(y*x+x) // works - + println(x+x*y) // failed before } diff --git a/test/files/pos/t1761.scala b/test/files/pos/t1761.scala deleted file mode 100644 index 2af7280734..0000000000 --- a/test/files/pos/t1761.scala +++ /dev/null @@ -1,10 +0,0 @@ -import scala.xml._ - -class Foo { - val elements: Seq[Node] = Nil - val innerTransform: PartialFunction[Elem, String] = { - case Elem(_, l: String, _, _, _ @ _*) if elements.exists(_.label == l) => - l - } -} - diff --git a/test/pending/pos/t1782/Ann.java b/test/files/pos/t1782/Ann.java index 0dcfbd2ed7..0dcfbd2ed7 100644 --- a/test/pending/pos/t1782/Ann.java +++ b/test/files/pos/t1782/Ann.java diff --git a/test/pending/pos/t1782/Days.java b/test/files/pos/t1782/Days.java index 203a87b1c2..203a87b1c2 100644 --- a/test/pending/pos/t1782/Days.java +++ b/test/files/pos/t1782/Days.java diff --git a/test/pending/pos/t1782/ImplementedBy.java b/test/files/pos/t1782/ImplementedBy.java index 6aa8b4fa9e..6aa8b4fa9e 100644 --- a/test/pending/pos/t1782/ImplementedBy.java +++ b/test/files/pos/t1782/ImplementedBy.java diff --git a/test/pending/pos/t1782/Test_1.scala b/test/files/pos/t1782/Test_1.scala index 6467a74c29..6467a74c29 100644 --- a/test/pending/pos/t1782/Test_1.scala +++ b/test/files/pos/t1782/Test_1.scala diff --git a/test/files/pos/t1786.scala b/test/files/pos/t1786.scala new file mode 100644 index 0000000000..32d6c06f6e --- /dev/null +++ b/test/files/pos/t1786.scala @@ -0,0 +1,19 @@ +class SomeClass(val intValue:Int) +class MyClass[T <: SomeClass](val myValue:T) +class Flooz[A >: Null <: SomeClass, T >: Null <: A](var value: T) + +class A { + def f1(i:MyClass[_]) = i.myValue.intValue + def f2(i:MyClass[_ <: SomeClass]) = i.myValue.intValue + // def f3[T](i: MyClass[T]) = i.myValue.intValue + def f4[T <: SomeClass](i: MyClass[T]) = i.myValue.intValue + // def f5[T >: Null](i: MyClass[T]) = i.myValue.intValue + // def f6[T >: Null <: String](i: MyClass[T]) = i.myValue.intValue + i.myValue.charAt(0) + + // def g1[A, T](x: Flooz[A, T]) = { x.value = null ; x.value.intValue } + def g2(x: Flooz[_, _]) = { x.value = null ; x.value.intValue } + + class MyClass2(x: MyClass[_]) { val p = x.myValue.intValue } + // class MyClass3[T <: String](x: MyClass[T]) { val p = x.myValue.intValue + x.myValue.length } + // class MyClass4[T >: Null](x: MyClass[T]) { val p = x.myValue.intValue } +} diff --git a/test/files/pos/t1798.scala b/test/files/pos/t1798.scala index 93df61e844..1624e3025e 100644 --- a/test/files/pos/t1798.scala +++ b/test/files/pos/t1798.scala @@ -2,7 +2,7 @@ object Foo { private def bar(): Int = 55 } class Foo(x: Int) { def this() = this(Foo.bar()) } /* - * scalac28 a.scala + * scalac28 a.scala a.scala:2: error: method bar cannot be accessed in object Foo class Foo(x: Int) { def this() = this(Foo.bar()) } ^ diff --git a/test/files/pos/t1832.scala b/test/files/pos/t1832.scala index c7b1ffb838..f3bb556e32 100644 --- a/test/files/pos/t1832.scala +++ b/test/files/pos/t1832.scala @@ -1,7 +1,7 @@ trait Cloning { trait Foo def fn(g: Any => Unit): Foo - + implicit def mkStar(i: Int) = new { def *(a: Foo): Foo = null } val pool = 4 * fn { case ghostSYMBOL: Int => ghostSYMBOL * 2 } diff --git a/test/files/pos/t1840/J.java b/test/files/pos/t1840/J.java index a697596fdd..fd98b6c4a5 100644 --- a/test/files/pos/t1840/J.java +++ b/test/files/pos/t1840/J.java @@ -1,4 +1,4 @@ package p; -class J { - J() {} +class J { + J() {} } diff --git a/test/files/pos/t1942.cmds b/test/files/pos/t1942.cmds deleted file mode 100644 index c14311042a..0000000000 --- a/test/files/pos/t1942.cmds +++ /dev/null @@ -1,2 +0,0 @@ -scalac A_1.scala -scalac Test_2.scala diff --git a/test/files/pos/t1974.scala b/test/files/pos/t1974.scala index 3d28478177..a0daa13c21 100644 --- a/test/files/pos/t1974.scala +++ b/test/files/pos/t1974.scala @@ -1,20 +1,20 @@ object Broken { private var map = Map[Class[_], String]() - + def addToMap(c : Class[_], s : String) = map += (c -> s) def fetch(c : Class[_]) = map(c) } object Works { private var map = Map[Class[_], String]() - + def addToMap(c : Class[_], s : String) = map += ((c, s)) def fetch(c : Class[_]) = map(c) } object Works2 { private var map = Map[Class[_], String]() - + def addToMap(c : Class[_], s : String) = map += ((c : Class[_]) -> s) def fetch(c : Class[_]) = map(c) }
\ No newline at end of file diff --git a/test/files/pos/t2023.scala b/test/files/pos/t2023.scala index de3e848fbd..21c6fc96a6 100644 --- a/test/files/pos/t2023.scala +++ b/test/files/pos/t2023.scala @@ -3,11 +3,11 @@ trait C[A] object C { implicit def ipl[A](implicit from: A => Ordered[A]): C[A] = null } - + object P { def foo[A](i: A, j: A)(implicit c: C[A]): Unit = () } - + class ImplicitChainTest { def testTrivial: Unit = { P.foo('0', '9') diff --git a/test/files/pos/t2060.scala b/test/files/pos/t2060.scala index cf7250f545..2c701150e4 100755 --- a/test/files/pos/t2060.scala +++ b/test/files/pos/t2060.scala @@ -4,7 +4,7 @@ * line': * * val failure = 1.0 + new Op[Int] - * + * * we reduce the problem to finding a function from Double to * {+: _ >: Op[Int] <: Any}, that is, a method which takes * an argument which is an Op[Int] or a supertype thereof. diff --git a/test/files/pos/t2081.scala b/test/files/pos/t2081.scala index d772c02dc2..395134f71c 100644 --- a/test/files/pos/t2081.scala +++ b/test/files/pos/t2081.scala @@ -7,5 +7,5 @@ object ScalaForRubyists { val x = 10.days // a couple parser corner cases I wanted not to break - val y = 5.e0 + 5e7 + val y = 5.0e0 + 5e7 } diff --git a/test/files/pos/t2082.scala b/test/files/pos/t2082.scala index 38937d78fb..3a160612fe 100755 --- a/test/files/pos/t2082.scala +++ b/test/files/pos/t2082.scala @@ -1,10 +1,10 @@ trait Mapper[T <: Mapper[T]] -trait KeyedMapper[KeyType, T <: KeyedMapper[KeyType, T]] extends Mapper[T] +trait KeyedMapper[KeyType, T <: KeyedMapper[KeyType, T]] extends Mapper[T] -trait KeyedMetaMapper[KeyType, T <: KeyedMapper[KeyType, T]] +trait KeyedMetaMapper[KeyType, T <: KeyedMapper[KeyType, T]] trait MappedForeignKey[KeyType, Owner <: Mapper[Owner], Other <: KeyedMapper[KeyType, Other]] @@ -19,19 +19,19 @@ class TestRun extends KeyedMapper[Long, TestRun] with IdPK { object TestRun extends TestRun with KeyedMetaMapper[Long, TestRun] class MetaTestSubject extends TestSubject with KeyedMetaMapper[Long, TestSubject] -object TestSubject extends MetaTestSubject +object TestSubject extends MetaTestSubject object Main { - + def oneToOneJoin[PType <: KeyedMapper[Long, PType] with IdPK, CType <: KeyedMapper[Long, CType] with IdPK, - CMetaType <: CType with KeyedMetaMapper[Long, CType], + CMetaType <: CType with KeyedMetaMapper[Long, CType], FKType <: MappedForeignKey[Long, PType, CType]] - (parents: List[PType], metaMapper: CMetaType, keyGetter: (PType) => FKType ): + (parents: List[PType], metaMapper: CMetaType, keyGetter: (PType) => FKType ): Map[Long, CType] = Map.empty - + def callIt { - oneToOneJoin[TestRun, TestSubject, MetaTestSubject, + oneToOneJoin[TestRun, TestSubject, MetaTestSubject, MappedForeignKey[Long, TestRun, TestSubject]]( List(), TestSubject, (tr: TestRun) => tr.testSubject) } diff --git a/test/files/pos/t2130-2.scala b/test/files/pos/t2130-2.scala index 464f5e0d8e..1d0b33c3e5 100644 --- a/test/files/pos/t2130-2.scala +++ b/test/files/pos/t2130-2.scala @@ -10,7 +10,7 @@ package object bar { class Dingus object Dingus case class Dongus(x: Float) - + def apply(xs: Int*) = new Bippy(xs.sum) def apply() = new Bippy(5) } diff --git a/test/files/pos/t2133.scala b/test/files/pos/t2133.scala index 99bac5c38b..c74d0a4bbf 100644 --- a/test/files/pos/t2133.scala +++ b/test/files/pos/t2133.scala @@ -13,6 +13,6 @@ trait Foo2 { class Bob extends AnyRef with Foo with Foo2 { import bip._ import bar._ - + def go() = fn() } diff --git a/test/files/pos/t2168.scala b/test/files/pos/t2168.scala index 845c5b7361..21afb239a0 100644 --- a/test/files/pos/t2168.scala +++ b/test/files/pos/t2168.scala @@ -2,5 +2,3 @@ object Test extends App { def foo1(x: AnyRef) = x match { case x: Function0[_] => x() } def foo2(x: AnyRef) = x match { case x: Function0[Any] => x() } } - - diff --git a/test/files/pos/t2171.scala b/test/files/pos/t2171.scala index a5663c96cd..6c754c76a6 100644 --- a/test/files/pos/t2171.scala +++ b/test/files/pos/t2171.scala @@ -3,5 +3,5 @@ final object test { try 0 catch { case ex => println(msg) } def main (args: Array[String]): Unit = - while (true) logIgnoredException ("...") + while (true) logIgnoredException ("...") } diff --git a/test/files/pos/t2261.scala b/test/files/pos/t2261.scala index af24234235..aac5c9e0fd 100644 --- a/test/files/pos/t2261.scala +++ b/test/files/pos/t2261.scala @@ -5,5 +5,5 @@ object Test { x = List(1,2,3) // the problem here was that somehow the type variable that was used to infer the type argument for List.apply // would accumulate several conflicting constraints - // can't reproduce with + // can't reproduce with }
\ No newline at end of file diff --git a/test/files/pos/t2281.scala b/test/files/pos/t2281.scala deleted file mode 100644 index 3515d2e2e6..0000000000 --- a/test/files/pos/t2281.scala +++ /dev/null @@ -1,41 +0,0 @@ -import scala.collection.mutable.ArrayBuffer - -class A { - def f(x: Boolean) = if (x) <br/><br/> else <br/> -} - -class B { - def splitSentences(text : String) : ArrayBuffer[String] = { - val outarr = new ArrayBuffer[String] - var outstr = new StringBuffer - var prevspace = false - val ctext = text.replaceAll("\n+","\n") - ctext foreach {c => - outstr append c - if(c == '.' || c == '!' || c == '?' || c == '\n' || c == ':' || c == ';' || (prevspace && c == '-') ){ - outarr += outstr.toString - outstr = new StringBuffer - } - if(c == '\n'){ - outarr += "\n\n" - } - prevspace = c == ' ' - } - if(outstr.length > 0){ - outarr += outstr.toString - } - outarr - } - - def spanForSentence(x : String,picktext : String) = - if(x == "\n\n"){ - <br/><br/> - }else{ - <span class='clicksentence' style={if(x == picktext) "background-color: yellow" else ""}>{x}</span> - } - - def selectableSentences(text : String, picktext : String) = { - val sentences = splitSentences(text) - sentences.map(x => spanForSentence(x,picktext)) - } -}
\ No newline at end of file diff --git a/test/files/pos/t2305.scala b/test/files/pos/t2305.scala index d0b103fdba..6b66c5db13 100644 --- a/test/files/pos/t2305.scala +++ b/test/files/pos/t2305.scala @@ -1,6 +1,6 @@ import java.util.ArrayList -trait Bind[Z[_]] +trait Bind[Z[_]] class MySerializable[X] extends java.io.Serializable @@ -17,7 +17,7 @@ object works { object breaks { def runbind(implicit bind: Bind[ArrayList]) {} - runbind + runbind /*java.lang.AssertionError: assertion failed: java.io.Serializable at scala.Predef$.assert(Predef.scala:107) at scala.tools.nsc.symtab.Types$TypeRef.transform(Types.scala:1417) diff --git a/test/files/pos/t2310.scala b/test/files/pos/t2310.scala index e08411a3df..68912b4961 100644 --- a/test/files/pos/t2310.scala +++ b/test/files/pos/t2310.scala @@ -1,15 +1,15 @@ import scala.Stream._ object consistencyError { - /* this gives an error: + /* this gives an error: Consistency problem compiling (virtual file)! Trying to call method body%1(List(scala.collection.immutable.Stream[A])) with arguments (List(tp2, temp6, temp5)) case (l #:: ls, rs) => None ^ scala.tools.nsc.symtab.Types$TypeError: too many arguments for method body%1: (val rs: scala.collection.immutable.Stream[A])None.type - + two errors found - vss(0) = + vss(0) = args = List(tp2, temp6, temp5) vss(1) = value rs, value ls, value l args = List(tp2, temp6, temp5) @@ -18,19 +18,19 @@ object consistencyError { labels(1) = method body%1 labels(0) = method body%0 bx = 1 - label.tpe = (val rs: scala.collection.immutable.Stream[A])None.type + label.tpe = (val rs: scala.collection.immutable.Stream[A])None.type */ def crash[A](lefts: Stream[A], rights: Stream[A]) = (lefts, rights) match { case (Stream.Empty, Stream.Empty) => None case (l #:: ls, rs) => None } - + // These work // def works1[A](lefts: Stream[A]) = lefts match { // case Stream.Empty => None // case l #:: ls => None // } - // + // // def works2[A](lefts: Stream[A], rights: Stream[A]) = (lefts, rights) match { // case (Stream.Empty, Stream.Empty) => None // case (ls, rs) => None diff --git a/test/files/pos/t2331.scala b/test/files/pos/t2331.scala index 9a15b5c2a9..a7f80ac98e 100644 --- a/test/files/pos/t2331.scala +++ b/test/files/pos/t2331.scala @@ -4,8 +4,8 @@ trait C { object Test { val o /*: C --> no crash*/ = new C { - def m[T]: Nothing /*: T --> no crash*/ = error("omitted") + def m[T]: Nothing /*: T --> no crash*/ = sys.error("omitted") } o.m[Nothing] -}
\ No newline at end of file +} diff --git a/test/files/pos/t2399.scala b/test/files/pos/t2399.scala index b009f7856b..07882dd549 100644 --- a/test/files/pos/t2399.scala +++ b/test/files/pos/t2399.scala @@ -3,12 +3,12 @@ trait That2[A, R <: That2[A, R]] trait T[A, This >: Null <: That1[A] with T[A, This]] extends That2[A, This] { self: This => - + private var next: This = _ def isEmpty = next eq null - + def length: Int = { def loop(x: This, cnt: Int): Int = if (x.isEmpty) cnt else loop(x.next, cnt + 1) loop(self, 0) - } + } }
\ No newline at end of file diff --git a/test/files/pos/t2413/TestScalac.scala b/test/files/pos/t2413/TestScalac.scala index 6992a30f2c..098e852dd7 100644 --- a/test/files/pos/t2413/TestScalac.scala +++ b/test/files/pos/t2413/TestScalac.scala @@ -4,7 +4,7 @@ class Foo extends TestJava { // THIS METHOD YIELDS TO CRASH /* def foomethod : Option[String] => Unit = { - case None => + case None => val path = repeatParam("s","a","b","c") () case Some(error) => diff --git a/test/files/pos/t2421.scala b/test/files/pos/t2421.scala index 26e485c160..2544a1cb36 100644 --- a/test/files/pos/t2421.scala +++ b/test/files/pos/t2421.scala @@ -1,14 +1,14 @@ object Test { abstract class <~<[-From, +To] extends (From => To) - implicit def trivial[A]: A <~< A = error("") + implicit def trivial[A]: A <~< A = sys.error("") trait Forcible[T] - implicit val forcibleInt: (Int <~< Forcible[Int]) = error("") + implicit val forcibleInt: (Int <~< Forcible[Int]) = sys.error("") - def headProxy[P <: Forcible[Int]](implicit w: Int <~< P): P = error("") - - headProxy - // trivial[Int] should not be considered a valid implicit, since w would have type Int <~< Int, + def headProxy[P <: Forcible[Int]](implicit w: Int <~< P): P = sys.error("") + + headProxy + // trivial[Int] should not be considered a valid implicit, since w would have type Int <~< Int, // and headProxy's type parameter P cannot be instantiated to Int -}
\ No newline at end of file +} diff --git a/test/files/pos/t2421_delitedsl.scala b/test/files/pos/t2421_delitedsl.scala index ad6afa7bd8..a05887023a 100644 --- a/test/files/pos/t2421_delitedsl.scala +++ b/test/files/pos/t2421_delitedsl.scala @@ -1,10 +1,10 @@ trait DeliteDSL { abstract class <~<[-From, +To] extends (From => To) - implicit def trivial[A]: A <~< A = new (A <~< A) {def apply(x: A) = x} + implicit def trivial[A]: A <~< A = new (A <~< A) {def apply(x: A) = x} trait Forcible[T] object Forcible { - def factory[T](f: T => Forcible[T]) = new (T <~< Forcible[T]){def apply(x: T) = f(x)} + def factory[T](f: T => Forcible[T]) = new (T <~< Forcible[T]){def apply(x: T) = f(x)} } case class DeliteInt(x: Int) extends Forcible[Int] @@ -22,16 +22,16 @@ trait DeliteDSL { // If T is already a proxy (it is forcible), the compiler should use // forcibleIdentity to deduce that P=T. If T is Int, the compiler // should use intToForcible to deduce that P=DeliteInt. - // + // // Without this feature, the user must write 'xs.proxyOfFirst[DeliteInt]', // with the feature they can write 'xs.proxyOfFirst', which is shorter and // avoids exposing internal DELITE types to the world. object Test { - val x = new DeliteCollection(List(1,2,3)).headProxy + val x = new DeliteCollection(List(1,2,3)).headProxy // inferred: val x: Forcible[Int] = new DeliteCollection[Int](List.apply[Int](1, 2, 3)).headProxy[Forcible[Int]](forcibleInt); - val xAlready = new DeliteCollection(List(DeliteInt(1),DeliteInt(2),DeliteInt(3))).headProxy + val xAlready = new DeliteCollection(List(DeliteInt(1),DeliteInt(2),DeliteInt(3))).headProxy // inferred: val xAlready: DeliteInt = new DeliteCollection[DeliteInt](List.apply[DeliteInt](DeliteInt(1), DeliteInt(2), DeliteInt(3))).headProxy[DeliteInt](trivial[DeliteInt]); } }
\ No newline at end of file diff --git a/test/files/pos/t2421b_pos.scala b/test/files/pos/t2421b_pos.scala index 8b848abb75..0df3461662 100644 --- a/test/files/pos/t2421b_pos.scala +++ b/test/files/pos/t2421b_pos.scala @@ -11,7 +11,7 @@ object Test { f } -/* bug: +/* bug: error: ambiguous implicit values: both method b in object Test1 of type [X <: Test1.B]Test1.F[X] and method a in object Test1 of type => Test1.F[Test1.A] diff --git a/test/files/pos/t2429.scala b/test/files/pos/t2429.scala index 3ea3f9e2a5..550681b6a2 100755 --- a/test/files/pos/t2429.scala +++ b/test/files/pos/t2429.scala @@ -1,10 +1,10 @@ object Msg { trait T - + trait TSeq - + object TSeq { - implicit def fromSeq(s: Seq[T]): TSeq = error("stub") + implicit def fromSeq(s: Seq[T]): TSeq = sys.error("stub") } def render { @@ -12,7 +12,7 @@ object Msg { case (a, b) => { a match { case _ => b match { - case _ => error("stub") + case _ => sys.error("stub") } } } @@ -20,6 +20,6 @@ object Msg { } } object Oops { - implicit def someImplicit(s: Seq[_]): String = error("stub") + implicit def someImplicit(s: Seq[_]): String = sys.error("stub") def item: String = Nil map { case e: Any => e } } diff --git a/test/files/pos/t2435.scala b/test/files/pos/t2435.scala index 2db931b99f..697e9e1f2d 100644 --- a/test/files/pos/t2435.scala +++ b/test/files/pos/t2435.scala @@ -9,7 +9,7 @@ object Bug { case class FConstant[E <: FChain](constant:String, tail:E) extends FChain { type T = tail.T } - + object FNil extends FChain { type T = Unit } diff --git a/test/files/pos/t2444.scala b/test/files/pos/t2444.scala index a052270196..fac1e95d0f 100644 --- a/test/files/pos/t2444.scala +++ b/test/files/pos/t2444.scala @@ -2,14 +2,14 @@ object Test { trait Foo - class Bar { + class Bar { object baz extends Foo } - def frob[P1, P2<:Foo](f:P1 => P2) = () + def frob[P1, P2<:Foo](f:P1 => P2) = () def main(args:Array[String]) : Unit = { - frob((p:Bar) => p.baz) + frob((p:Bar) => p.baz) } } diff --git a/test/files/pos/t2464.cmds b/test/files/pos/t2464.cmds deleted file mode 100644 index ca733ef23d..0000000000 --- a/test/files/pos/t2464.cmds +++ /dev/null @@ -1,3 +0,0 @@ -javac JavaOne.java -scalac ScalaOne_1.scala -scalac t2464_2.scala diff --git a/test/files/pos/t2464/ScalaOne_1.scala b/test/files/pos/t2464/ScalaOne_1.scala index 0271b9ce72..1caf8ecae4 100644 --- a/test/files/pos/t2464/ScalaOne_1.scala +++ b/test/files/pos/t2464/ScalaOne_1.scala @@ -1,6 +1,6 @@ class ScalaClassOne extends ClassTwo.Child { def func4() = { func2 - } + } } diff --git a/test/files/pos/t247.scala b/test/files/pos/t247.scala index 983b7998a9..e976404e61 100644 --- a/test/files/pos/t247.scala +++ b/test/files/pos/t247.scala @@ -12,7 +12,7 @@ class TreeMapFactory[KEY](newOrder:Order[KEY]) extends MapFactory[KEY] { def Empty[V] = new TreeMap[KEY,V](new TreeMapFactory[KEY](order)); } -class Tree[KEY,Entry](order:Order[KEY]) { +class Tree[KEY,Entry](order:Order[KEY]) { def size =0; } diff --git a/test/files/pos/t2484.scala b/test/files/pos/t2484.scala index 7d1b7cb03c..29f798edf9 100755 --- a/test/files/pos/t2484.scala +++ b/test/files/pos/t2484.scala @@ -1,7 +1,9 @@ +import concurrent.ExecutionContext.Implicits.global + class Admin extends javax.swing.JApplet { val jScrollPane = new javax.swing.JScrollPane (null, 0, 0) def t2484: Unit = { - scala.concurrent.ops.spawn {jScrollPane.synchronized { + scala.concurrent.future {jScrollPane.synchronized { def someFunction () = {} //scala.concurrent.ops.spawn {someFunction ()} jScrollPane.addComponentListener (new java.awt.event.ComponentAdapter {override def componentShown (e: java.awt.event.ComponentEvent) = { diff --git a/test/files/pos/t2504.scala b/test/files/pos/t2504.scala index 0abe7dd13e..67f8226852 100755 --- a/test/files/pos/t2504.scala +++ b/test/files/pos/t2504.scala @@ -1,5 +1,5 @@ object Test { val ys: Iterable[_] = Array("abc") - val xs = Array("abc") + val xs = Array("abc") xs sameElements Array("abc") } diff --git a/test/files/pos/t2545.scala b/test/files/pos/t2545.scala index b4238fb718..6ad994223c 100755 --- a/test/files/pos/t2545.scala +++ b/test/files/pos/t2545.scala @@ -1,6 +1,6 @@ trait Frog[T] { - def hello: T - def size: Int + def hello: T + def size: Int } trait OnlyWithFrogs { diff --git a/test/files/pos/t2569/Child.scala b/test/files/pos/t2569/Child.scala index 3d7f4248b5..64f4dc172f 100644 --- a/test/files/pos/t2569/Child.scala +++ b/test/files/pos/t2569/Child.scala @@ -1,9 +1,9 @@ package varargs - + class Child extends Parent { - + override def concatenate(strings: String*): String = strings map("\"" + _ + "\"") mkString("(", ", ", ")") - + } diff --git a/test/files/pos/t2569/Parent.java b/test/files/pos/t2569/Parent.java index 133f2ee567..89421becbd 100644 --- a/test/files/pos/t2569/Parent.java +++ b/test/files/pos/t2569/Parent.java @@ -1,7 +1,7 @@ package varargs; - + public class Parent { - + public String concatenate(String... strings) { StringBuilder builder = new StringBuilder(); for (String s : strings) { @@ -9,5 +9,5 @@ package varargs; } return builder.toString(); } - + } diff --git a/test/files/pos/t2613.scala b/test/files/pos/t2613.scala new file mode 100644 index 0000000000..3a64dbc282 --- /dev/null +++ b/test/files/pos/t2613.scala @@ -0,0 +1,11 @@ +import language.existentials + +object Test { + class Row + + abstract class MyRelation [R <: Row, +Relation <: MyRelation[R, Relation]] + + type M = MyRelation[R, Relation] forSome {type R <: Row; type Relation <: MyRelation[R, Relation]} + + var (x,y): (String, M) = null +} diff --git a/test/files/pos/t262.scala b/test/files/pos/t262.scala index b81490977c..ec6187b36b 100644 --- a/test/files/pos/t262.scala +++ b/test/files/pos/t262.scala @@ -1,11 +1,11 @@ object O { abstract class A { - def f:A; + def f:A; } class B extends A { def f = if(1 == 2) new C else new D; } - class C extends A { + class C extends A { def f = this; } class D extends A { diff --git a/test/files/pos/t2665.scala b/test/files/pos/t2665.scala index 108daf509a..3163e31326 100644 --- a/test/files/pos/t2665.scala +++ b/test/files/pos/t2665.scala @@ -1,3 +1,3 @@ object Test { - val x: Unit = Array("") + val x: Unit = Array("") }
\ No newline at end of file diff --git a/test/files/pos/t2669.scala b/test/files/pos/t2669.scala index e34f08f0f5..72e931178c 100644 --- a/test/files/pos/t2669.scala +++ b/test/files/pos/t2669.scala @@ -23,6 +23,6 @@ import java.util.Vector // scalac cannot detect lack of type params, but then throws AssertionError later: class TVector2639 { - val b = new Vector // this line passed without error detected + val b = new Vector // this line passed without error detected val a = new Vector(1) // this line caused throwing AssertionError when scalac } diff --git a/test/files/pos/t2691.scala b/test/files/pos/t2691.scala index 94012a8177..5f0ddd122f 100644 --- a/test/files/pos/t2691.scala +++ b/test/files/pos/t2691.scala @@ -1,5 +1,5 @@ object Breakdown { - def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there")) + def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there")) } object Test { 42 match { diff --git a/test/files/pos/t2698.scala b/test/files/pos/t2698.scala deleted file mode 100644 index 0e2662de61..0000000000 --- a/test/files/pos/t2698.scala +++ /dev/null @@ -1,10 +0,0 @@ -import scala.collection._ -import scala.util.regexp._ - -abstract class S2 { - val lang: WordExp - type __labelT = lang._labelT - - var deltaq: Array[__labelT] = _ - def delta1 = immutable.Map(deltaq.zipWithIndex: _*) -} diff --git a/test/files/pos/t2726.cmds b/test/files/pos/t2726.cmds deleted file mode 100644 index 5fcb18bfbb..0000000000 --- a/test/files/pos/t2726.cmds +++ /dev/null @@ -1,2 +0,0 @@ -scalac SQLBuilder_1.scala -scalac test_2.scala diff --git a/test/files/pos/t2726/SQLBuilder_1.scala b/test/files/pos/t2726/SQLBuilder_1.scala index 7b3e3d8322..8d07a88265 100644 --- a/test/files/pos/t2726/SQLBuilder_1.scala +++ b/test/files/pos/t2726/SQLBuilder_1.scala @@ -1,7 +1,7 @@ class SQLBuilder extends SQLBuilder.Segment -object SQLBuilder { - trait Segment +object SQLBuilder { + trait Segment } diff --git a/test/files/pos/t2797.scala b/test/files/pos/t2797.scala index 4323664e91..cf579d8de4 100644 --- a/test/files/pos/t2797.scala +++ b/test/files/pos/t2797.scala @@ -1,9 +1,9 @@ class MyVector[A] { - def map[B](f: A => B): MyVector[B] = error("") + def map[B](f: A => B): MyVector[B] = sys.error("") } object Test { def unzip[B, C](_this: MyVector[(B, C)]): (MyVector[B], MyVector[C]) = { (_this.map{ bc => bc._1 }, _this.map{ bc => bc._2 }) } -}
\ No newline at end of file +} diff --git a/test/files/pos/t2910.scala b/test/files/pos/t2910.scala index 17a6a64809..d4d92fa765 100644 --- a/test/files/pos/t2910.scala +++ b/test/files/pos/t2910.scala @@ -9,9 +9,9 @@ object Test { lazy val s = "abc" } - def test3 { + def test3 { lazy val lazyBar = bar - object bar { + object bar { val foo = 12 } lazy val lazyBar2 = bar @@ -29,5 +29,5 @@ object Test { lazy val f: Int = g Console.println("foo") lazy val g: Int = f - } + } }
\ No newline at end of file diff --git a/test/files/pos/t2913.scala b/test/files/pos/t2913.scala index ee86b9e402..11d8b92053 100755 --- a/test/files/pos/t2913.scala +++ b/test/files/pos/t2913.scala @@ -11,13 +11,13 @@ class RichA { object Test { implicit def AToRichA(a: A) = new RichA - + val a = new A a.foo() a.foo(1) a.foo("") // Without implicits, a type error regarding invalid argument types is generated at `""`. This is - // the same position as an argument, so the 'second try' typing with an Implicit View is tried, + // the same position as an argument, so the 'second try' typing with an Implicit View is tried, // and AToRichA(a).foo("") is found. // // My reading of the spec "7.3 Views" is that `a.foo` denotes a member of `a`, so the view should @@ -48,6 +48,6 @@ object Main { val fn = (a : Int, str : String) => "a: " + a + ", str: " + str implicit def fx[T](f : (T,String) => String) = (x:T) => f(x,null) println(fn(1)) - () + () } } diff --git a/test/files/pos/t2939.scala b/test/files/pos/t2939.scala index 67677f2f18..3be4d4d561 100644 --- a/test/files/pos/t2939.scala +++ b/test/files/pos/t2939.scala @@ -4,10 +4,10 @@ object Proxies { class C1 extends MapProxy[Int,Int] { def self = Map[Int,Int]() } class C2 extends mutable.MapProxy[Int,Int] { def self = mutable.Map[Int,Int]() } class C3 extends immutable.MapProxy[Int,Int] { def self = immutable.Map[Int,Int]() } - + class C4 extends SetProxy[Int] { def self = Set[Int]() } class C5 extends mutable.SetProxy[Int] { def self = mutable.Set[Int]() } class C6 extends immutable.SetProxy[Int] { def self = immutable.Set[Int]() } - + class C7 extends SeqProxy[Int] { def self = Seq[Int]() } }
\ No newline at end of file diff --git a/test/pending/pos/t294/Ann.java b/test/files/pos/t294/Ann.java index 934ca46297..934ca46297 100644 --- a/test/pending/pos/t294/Ann.java +++ b/test/files/pos/t294/Ann.java diff --git a/test/pending/pos/t294/Ann2.java b/test/files/pos/t294/Ann2.java index 025b79e794..025b79e794 100644 --- a/test/pending/pos/t294/Ann2.java +++ b/test/files/pos/t294/Ann2.java diff --git a/test/pending/pos/t294/Test_1.scala b/test/files/pos/t294/Test_1.scala index ff1f34b10e..ff1f34b10e 100644 --- a/test/pending/pos/t294/Test_1.scala +++ b/test/files/pos/t294/Test_1.scala diff --git a/test/pending/pos/t294/Test_2.scala b/test/files/pos/t294/Test_2.scala index 9fb1c6e175..9fb1c6e175 100644 --- a/test/pending/pos/t294/Test_2.scala +++ b/test/files/pos/t294/Test_2.scala diff --git a/test/files/pos/t2940/Error.scala b/test/files/pos/t2940/Error.scala index 7c600667f3..bf5a6bd0df 100644 --- a/test/files/pos/t2940/Error.scala +++ b/test/files/pos/t2940/Error.scala @@ -5,8 +5,8 @@ abstract class Error { object Test { trait Quux[T] extends Cycle[Quux[T]] val x = new Quux[Int] { def doStuff() { } } - + def main(args: Array[String]): Unit = { - + } } diff --git a/test/files/pos/t2994a.scala b/test/files/pos/t2994a.scala index f2d57c34ca..cb4a389e2f 100644 --- a/test/files/pos/t2994a.scala +++ b/test/files/pos/t2994a.scala @@ -17,8 +17,8 @@ object Naturals { type _5 = SUCC[_4] type _6 = SUCC[_5] - - // crashes scala-2.8.0 beta1 + + // crashes scala-2.8.0 beta1 trait MUL[n <: NAT, m <: NAT] extends NAT { trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] diff --git a/test/files/pos/t3020.scala b/test/files/pos/t3020.scala index cb429cd94f..016563e27f 100644 --- a/test/files/pos/t3020.scala +++ b/test/files/pos/t3020.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { var x = true - + ( { if (x) new scala.util.Random() } .asInstanceOf[Runnable] ) } } diff --git a/test/files/pos/t3079.scala b/test/files/pos/t3079.scala index 4bead34ff3..fa732ea516 100644 --- a/test/files/pos/t3079.scala +++ b/test/files/pos/t3079.scala @@ -10,8 +10,8 @@ object Coerce { def IdentityCoerce[B] = new Coerce[Identity[B], B] { // java.lang.Error: A in trait Identity cannot be instantiated from ?x$1.type def unwrap = _.value - + // Providing the type of _ works around the problem. - //def unwrap = (_: Identity[B]).value + //def unwrap = (_: Identity[B]).value } }
\ No newline at end of file diff --git a/test/files/pos/t3106.scala b/test/files/pos/t3106.scala index cf7b507126..162e93366f 100644 --- a/test/files/pos/t3106.scala +++ b/test/files/pos/t3106.scala @@ -3,5 +3,5 @@ class Sample[A] (val d0: ((A,A)) => A) {} object Sample { implicit def apply[A] (x:A): Sample[A] = { new Sample(p => p._1) - } + } }
\ No newline at end of file diff --git a/test/files/pos/t3108.scala b/test/files/pos/t3108.scala deleted file mode 100644 index 6a1da73220..0000000000 --- a/test/files/pos/t3108.scala +++ /dev/null @@ -1,5 +0,0 @@ -object A { - val a: NotNull = "" - val b: NotNull = 41 -} - diff --git a/test/files/pos/t3136.scala b/test/files/pos/t3136.scala index 6a5850aeb0..33d42c2f3c 100644 --- a/test/files/pos/t3136.scala +++ b/test/files/pos/t3136.scala @@ -11,7 +11,7 @@ object NullaryMethodType { } object Test { - def TEST(tp: Type): String = + def TEST(tp: Type): String = tp match { case PolyType(ps1, PolyType(ps2, res @ PolyType(a, b))) => "1"+tp // couldn't find a simpler version that still crashes case NullaryMethodType(meh) => "2"+meh diff --git a/test/files/pos/t3152.scala b/test/files/pos/t3152.scala index a20428dbee..3d1dcbd6f0 100644 --- a/test/files/pos/t3152.scala +++ b/test/files/pos/t3152.scala @@ -1,13 +1,13 @@ trait Applicative[M[_]] sealed trait MA[M[_], A] { - def sequence[N[_], B](implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = error("stub") - // def sequence3[N[_], B]()(implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = error("stub") + def sequence[N[_], B](implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = sys.error("stub") + // def sequence3[N[_], B]()(implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = sys.error("stub") } object test { - implicit def ListMA[A](l: List[A]): MA[List, A] = error("stub") - implicit val ao: Applicative[Option] = error("stub") + implicit def ListMA[A](l: List[A]): MA[List, A] = sys.error("stub") + implicit val ao: Applicative[Option] = sys.error("stub") /* This compiles OK: (Nil: List[Option[Int]]).sequence3(): Option[List[Int]] @@ -17,4 +17,4 @@ object test { // !!! No line number is reported with the error (Nil: List[Option[Int]]).sequence: Option[List[Int]] (List[Option[Int]]()).sequence: Option[List[Int]] -}
\ No newline at end of file +} diff --git a/test/files/pos/t3174b.scala b/test/files/pos/t3174b.scala index 002c4f090f..4df1bfe837 100755 --- a/test/files/pos/t3174b.scala +++ b/test/files/pos/t3174b.scala @@ -2,9 +2,9 @@ trait Foo[X] { def foo : Map[String,Foo[X]] } object Test { def f[T]() : Foo[T] = { - class Anon extends Foo[T] { - var foo: Map[String, Foo[T]] = Map[String,Foo[T]]() - //def foo = Map[String,Foo[T]]() + class Anon extends Foo[T] { + var foo: Map[String, Foo[T]] = Map[String,Foo[T]]() + //def foo = Map[String,Foo[T]]() //def foo_=(x: Map[String,Foo[T]]) {} } new Anon diff --git a/test/files/pos/t3175-pos.scala b/test/files/pos/t3175-pos.scala index 497ff8255c..89bbf8b5fc 100644 --- a/test/files/pos/t3175-pos.scala +++ b/test/files/pos/t3175-pos.scala @@ -1,7 +1,7 @@ object Test { - def f(g:{val update:Unit}) = g.update - + def f(g:{val update:Unit}) = g.update + def main(args: Array[String]): Unit = { - + } } diff --git a/test/files/pos/t3177.scala b/test/files/pos/t3177.scala index 21893c9422..9f9528faec 100644 --- a/test/files/pos/t3177.scala +++ b/test/files/pos/t3177.scala @@ -1,17 +1,17 @@ trait InvariantFunctor[F[_]] { def xmap[A, B](ma: F[A], f: A => B, g: B => A): F[B] } - + object InvariantFunctor { import Endo._ - + implicit val EndoInvariantFunctor = new InvariantFunctor[Endo] { - def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) } - + // The definition about fails with: // anon-type.scala:9: error: not found: value b - // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) // ^ // anon-type.scala:8: error: not found: type $anon // implicit val EndoInvariantFunctor = new InvariantFunctor[Endo] { @@ -20,9 +20,9 @@ object InvariantFunctor { // These both work: // implicit val EndoInvariantFunctorAscribed: InvariantFunctor[Endo] = new InvariantFunctor[Endo] { - // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) // } - // + // // implicit val EndoInvariantFunctorStubbed = new InvariantFunctor[Endo] { // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = error("stub") // } diff --git a/test/files/pos/t3252.scala b/test/files/pos/t3252.scala index 4b8e862714..3ecc1e7cef 100644 --- a/test/files/pos/t3252.scala +++ b/test/files/pos/t3252.scala @@ -8,8 +8,8 @@ class A { } } - private def g[T](block : => T) = error("") + private def g[T](block : => T) = sys.error("") } object B { - def h(block : => Unit) : Nothing = error("") -}
\ No newline at end of file + def h(block : => Unit) : Nothing = sys.error("") +} diff --git a/test/files/pos/t3274.scala b/test/files/pos/t3274.scala index dfa6a4ec01..15723184bb 100644 --- a/test/files/pos/t3274.scala +++ b/test/files/pos/t3274.scala @@ -1,7 +1,7 @@ -trait A { this: B => - trait X { +trait A { this: B => + trait X { class Y1 extends Y - } + } } trait B extends A { diff --git a/test/files/pos/t3312.scala b/test/files/pos/t3312.scala index 9bf3e23ed3..aef965d2e7 100644 --- a/test/files/pos/t3312.scala +++ b/test/files/pos/t3312.scala @@ -12,6 +12,6 @@ trait B extends Root { object Foo extends A with B { override def say: String = foo(super[A].say) - + def foo(p: => String): String = p } diff --git a/test/files/pos/t3349/AbstractTupleSet.java b/test/files/pos/t3349/AbstractTupleSet.java index 47b440a589..38e4743ef4 100644 --- a/test/files/pos/t3349/AbstractTupleSet.java +++ b/test/files/pos/t3349/AbstractTupleSet.java @@ -5,5 +5,5 @@ public abstract class AbstractTupleSet implements TupleSet { public void addColumn(String name, String expr) { throw new UnsupportedOperationException(); - } + } } diff --git a/test/files/pos/t3349/Test.scala b/test/files/pos/t3349/Test.scala index 8174e4c4f8..595beadc20 100644 --- a/test/files/pos/t3349/Test.scala +++ b/test/files/pos/t3349/Test.scala @@ -1,5 +1,5 @@ object Test { val label = "name" - val table: Table = error("") + val table: Table = sys.error("") table.addColumn( label, label.getClass ) -}
\ No newline at end of file +} diff --git a/test/files/pos/t3363-new.scala b/test/files/pos/t3363-new.scala index e609f4d55f..fef2bf8a72 100644 --- a/test/files/pos/t3363-new.scala +++ b/test/files/pos/t3363-new.scala @@ -9,7 +9,7 @@ object TestCase { //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine implicit def map2ops[T,F](fs: Map[T,F]) = new MapOps[F] { //if you remove this line, then code compiles - lazy val m: TypeTag[T] = error("just something to make it compile") + lazy val m: TypeTag[T] = sys.error("just something to make it compile") def is(xs: List[T]) = List(xs) } @@ -17,4 +17,4 @@ object TestCase { println(Map(1 -> "2") is List(2)) } - }
\ No newline at end of file + } diff --git a/test/files/pos/t3363-old.scala b/test/files/pos/t3363-old.scala index bae54084ea..c08cf2a6b6 100644 --- a/test/files/pos/t3363-old.scala +++ b/test/files/pos/t3363-old.scala @@ -7,7 +7,7 @@ object TestCase { //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine implicit def map2ops[T,F](fs: Map[T,F]) = new MapOps[F] { //if you remove this line, then code compiles - lazy val m: Manifest[T] = error("just something to make it compile") + lazy val m: Manifest[T] = sys.error("just something to make it compile") def is(xs: List[T]) = List(xs) } diff --git a/test/files/pos/t3411.scala b/test/files/pos/t3411.scala index b76fec66a6..b58e52db8d 100644 --- a/test/files/pos/t3411.scala +++ b/test/files/pos/t3411.scala @@ -1,6 +1,6 @@ object A { def g(c: PartialFunction[Any,Unit]) {} - + def f { lazy val x = 0 g { case `x` => } diff --git a/test/files/pos/t3417.scala b/test/files/pos/t3417.scala deleted file mode 100644 index d2de1608aa..0000000000 --- a/test/files/pos/t3417.scala +++ /dev/null @@ -1,11 +0,0 @@ -trait X extends NotNull { - def foo = 1 -} - -trait Y extends Object with NotNull { - def bar = 1 -} - -class Z extends NotNull - -class W extends Object with NotNull diff --git a/test/files/pos/t342.scala b/test/files/pos/t342.scala deleted file mode 100644 index 752b24d2ba..0000000000 --- a/test/files/pos/t342.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Main extends App { - - object Foo extends Enumeration(0, "Bar") { // 2 - val Bar = Value - } - import Foo._; - Console.println(Bar) -} diff --git a/test/files/pos/t3429/A.scala b/test/files/pos/t3429/A.scala index 4b705808c1..80785db51d 100644 --- a/test/files/pos/t3429/A.scala +++ b/test/files/pos/t3429/A.scala @@ -2,8 +2,8 @@ class A { @Test(exc = classOf[Exception]) def myTestMethod = 0 } -// rytz@chara:~/scala/trunk/sandbox$ javac Test.java -// rytz@chara:~/scala/trunk/sandbox$ ../build/pack/bin/scalac A.scala +// rytz@chara:~/scala/trunk/sandbox$ javac Test.java +// rytz@chara:~/scala/trunk/sandbox$ ../build/pack/bin/scalac A.scala // A.scala:2: error: type mismatch; // found : java.lang.Class[Exception](classOf[java.lang.Exception]) // required: java.lang.Class diff --git a/test/files/pos/t3430.scala b/test/files/pos/t3430.scala index 4990abb2a1..3129c6276a 100644 --- a/test/files/pos/t3430.scala +++ b/test/files/pos/t3430.scala @@ -1,6 +1,6 @@ // package com.example -object A { +object A { def f1(f: String => Boolean) = f("a") def f2(): Boolean = diff --git a/test/files/pos/t344.scala b/test/files/pos/t344.scala index 8a6ad9120d..449a763af7 100644 --- a/test/files/pos/t344.scala +++ b/test/files/pos/t344.scala @@ -1,7 +1,7 @@ object Bug { class A; - case class A1 extends A; - case class A2 extends A; + case class A1() extends A; + case class A2() extends A; def f: A = if (true) A1() diff --git a/test/files/pos/t3440.scala b/test/files/pos/t3440.scala index 46bba1b207..0e7ca6b70f 100644 --- a/test/files/pos/t3440.scala +++ b/test/files/pos/t3440.scala @@ -4,15 +4,15 @@ object test { } case object Int8 extends SampleFormat1 { - def readerFactory = error("") + def readerFactory = sys.error("") } case object Int16 extends SampleFormat1 { - def readerFactory = error("") + def readerFactory = sys.error("") } - + (new {}: Any) match { case 8 => Int8 case 16 => Int16 - case _ => error("") + case _ => sys.error("") } -}
\ No newline at end of file +} diff --git a/test/files/pos/t3477.scala b/test/files/pos/t3477.scala index 660aa55736..6a94baa6c8 100644 --- a/test/files/pos/t3477.scala +++ b/test/files/pos/t3477.scala @@ -1,7 +1,7 @@ class J3 { - def f[K, K1 >: K, V](x: Map[K1, V]): Map[K, V] = error("") + def f[K, K1 >: K, V](x: Map[K1, V]): Map[K, V] = sys.error("") } object Test { (new J3).f(Map[Int, Int]()) -}
\ No newline at end of file +} diff --git a/test/files/pos/t3521/DoubleValue.java b/test/files/pos/t3521/DoubleValue.java index 28f05cd972..e8c093890b 100644 --- a/test/files/pos/t3521/DoubleValue.java +++ b/test/files/pos/t3521/DoubleValue.java @@ -4,4 +4,4 @@ import java.lang.annotation.*; @Target(ElementType.FIELD) public @interface DoubleValue { double value(); -}
\ No newline at end of file +}
\ No newline at end of file diff --git a/test/files/pos/t3528.scala b/test/files/pos/t3528.scala index b1c4344731..ff49b3e929 100644 --- a/test/files/pos/t3528.scala +++ b/test/files/pos/t3528.scala @@ -4,5 +4,5 @@ class A { // 3528 comments def f2 = List(Set(1,2,3), List(1,2,3)) // 2322 - def f3 = List(null: Range, null: List[Int]) + def f3 = List(null: Range, null: List[Int]) } diff --git a/test/files/pos/t3568.scala b/test/files/pos/t3568.scala index 0f26e2fad3..c8e3fcc4be 100755 --- a/test/files/pos/t3568.scala +++ b/test/files/pos/t3568.scala @@ -14,7 +14,7 @@ package buffer { // ArrayVec2 can be compiled, instantiated and used. def main(args: Array[String]) { println(works) } } - + trait ElemType { type Element; type Component <: ElemType } trait Float1 extends ElemType { type Element = Float; type Component = Float1} class Vec2 extends ElemType { type Element = Vec2; type Component = Float1 } diff --git a/test/files/pos/t3578.scala b/test/files/pos/t3578.scala index 306cde811b..d984118208 100644 --- a/test/files/pos/t3578.scala +++ b/test/files/pos/t3578.scala @@ -24,7 +24,7 @@ object Test { case class JInt(num: BigInt) extends JValue case class JBool(value: Boolean) extends JValue case class JField(name: String, value: JValue) extends JValue - case class JObject(obj: List[JField]) extends JValue + case class JObject(obj: List[JField]) extends JValue case class JArray(arr: List[JValue]) extends JValue } diff --git a/test/files/pos/t3582.scala b/test/files/pos/t3582.scala index e20af5e61d..0ac112efbf 100644 --- a/test/files/pos/t3582.scala +++ b/test/files/pos/t3582.scala @@ -6,7 +6,7 @@ object Test { // [[syntax trees at end of typer]] // abstract trait C#5[A#9116 >: Nothing#5832 <: Any#52] extends scala#33.AnyRef#2780; // final object Test#15 extends java.lang.Object#2485 with ScalaObject#1913 { -// def ImplicitParamCA#9123[CC#9124[A#10858 >: Nothing#5832 <: Any#52] >: [A#10858]Nothing#5832 <: [A#10858]Any#52, +// def ImplicitParamCA#9123[CC#9124[A#10858 >: Nothing#5832 <: Any#52] >: [A#10858]Nothing#5832 <: [A#10858]Any#52, // A#9125 >: Nothing#5832 <: Any#52](implicit ev#10856: C#5[A#9127]): Unit#3818 // = scala#34.this.Predef#1683.implicitly#8816[C#5[A#10858]]() // } diff --git a/test/files/neg/t3631.scala b/test/files/pos/t3631.scala index bcf91619ee..bcf91619ee 100644 --- a/test/files/neg/t3631.scala +++ b/test/files/pos/t3631.scala diff --git a/test/files/pos/t3636.scala b/test/files/pos/t3636.scala index dbfc7a2c94..24d18c653d 100644 --- a/test/files/pos/t3636.scala +++ b/test/files/pos/t3636.scala @@ -5,11 +5,11 @@ class CTxnLocal[ T ] { } trait Txn - + trait ProcTxn { def ccstm: Txn } - + trait TxnLocal[ @specialized T ] { def apply()( implicit tx: ProcTxn ) : T def set( v: T )( implicit tx: ProcTxn ) : Unit diff --git a/test/files/pos/t3670.scala b/test/files/pos/t3670.scala index 19959f910f..ec4fbe5b4f 100644 --- a/test/files/pos/t3670.scala +++ b/test/files/pos/t3670.scala @@ -1,4 +1,4 @@ -class A { +class A { val n = { val z = { lazy val bb = 1 diff --git a/test/files/pos/t3671.scala b/test/files/pos/t3671.scala index 75559f84e2..1ca9327bb7 100644 --- a/test/files/pos/t3671.scala +++ b/test/files/pos/t3671.scala @@ -2,6 +2,6 @@ object Crash { def crash(value: Int): Unit = value match { case java.lang.Integer.MAX_VALUE => println("MAX_VALUE") - case java.lang.Integer.MIN_VALUE => println("MIN_VALUE") + case java.lang.Integer.MIN_VALUE => println("MIN_VALUE") } }
\ No newline at end of file diff --git a/test/files/pos/t3688-redux.scala b/test/files/pos/t3688-redux.scala deleted file mode 100644 index e601cf240c..0000000000 --- a/test/files/pos/t3688-redux.scala +++ /dev/null @@ -1,8 +0,0 @@ -import collection.JavaConverters._ -import java.{ util => ju } -import scala.collection.{ mutable, immutable } - -object Test { - def m[P <% AsJava[ju.List[Int]]](l: P) = 1 - m(List(1)) -}
\ No newline at end of file diff --git a/test/files/pos/t3731.scala b/test/files/pos/t3731.scala index 75938540c0..7a3cbec0f4 100644 --- a/test/files/pos/t3731.scala +++ b/test/files/pos/t3731.scala @@ -1,8 +1,8 @@ object Test{ trait ZW[S]{type T} - def ZipWith[S, M <: ZW[S]]: M#T = error("ZW") + def ZipWith[S, M <: ZW[S]]: M#T = sys.error("ZW") - // meh must be parameterised to force an asSeenFrom that + // meh must be parameterised to force an asSeenFrom that // duplicates the refinement in the TR's pre without updating its sym def meh[A] = ZipWith[A, ZW[A]{type T=Stream[A]}] diff --git a/test/files/pos/t3837.scala b/test/files/pos/t3837.scala index e1797dba77..bcaf63cc8d 100644 --- a/test/files/pos/t3837.scala +++ b/test/files/pos/t3837.scala @@ -1,8 +1,8 @@ class BipClass { } trait BipTrait { self: BipClass => - - private[this] def foo() = 5 + + private[this] def foo() = 5 def bar() = this.foo() } // error: value foo is not a member of BipTrait with BipClass diff --git a/test/files/pos/t3856.scala b/test/files/pos/t3856.scala index 5ea4b84e2c..132c95c5e6 100644 --- a/test/files/pos/t3856.scala +++ b/test/files/pos/t3856.scala @@ -1,4 +1,4 @@ -case class C[T](x: T) +case class C[T](x: T) case class CS(xs: C[_]*) diff --git a/test/files/pos/t3864/tuples_1.scala b/test/files/pos/t3864/tuples_1.scala index 1d19af6e41..5e97f8452b 100644 --- a/test/files/pos/t3864/tuples_1.scala +++ b/test/files/pos/t3864/tuples_1.scala @@ -1,11 +1,11 @@ -trait PimpedType[X] { +trait EnrichedType[X] { val value: X } trait Tuples { - -trait Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends PimpedType[Tuple15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]] { + +trait Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends EnrichedType[Tuple15[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple15[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15)) @@ -13,8 +13,8 @@ trait Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] extends PimpedType[T implicit def ToTuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)): Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] = new { val value = t } with Tuple15W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O] - -trait Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends PimpedType[Tuple16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]] { + +trait Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends EnrichedType[Tuple16[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple16[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16)) @@ -22,8 +22,8 @@ trait Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] extends PimpedTyp implicit def ToTuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)): Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] = new { val value = t } with Tuple16W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P] - -trait Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends PimpedType[Tuple17[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]] { + +trait Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends EnrichedType[Tuple17[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple17[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17)) @@ -31,8 +31,8 @@ trait Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] extends Pimped implicit def ToTuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)): Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] = new { val value = t } with Tuple17W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q] - -trait Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends PimpedType[Tuple18[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R]] { + +trait Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends EnrichedType[Tuple18[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple18[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18)) @@ -40,8 +40,8 @@ trait Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] extends Pim implicit def ToTuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)): Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] = new { val value = t } with Tuple18W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R] - -trait Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends PimpedType[Tuple19[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S]] { + +trait Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends EnrichedType[Tuple19[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple19[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _, _19: (S => SS) = identity[S] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18), _19(value._19)) @@ -49,8 +49,8 @@ trait Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] extends implicit def ToTuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)): Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] = new { val value = t } with Tuple19W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S] - -trait Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] extends PimpedType[Tuple20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T]] { + +trait Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] extends EnrichedType[Tuple20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple20[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _, _19: (S => SS) = identity[S] _, _20: (T => TT) = identity[T] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18), _19(value._19), _20(value._20)) @@ -58,8 +58,8 @@ trait Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] exten implicit def ToTuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)): Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] = new { val value = t } with Tuple20W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T] - -trait Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] extends PimpedType[Tuple21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U]] { + +trait Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] extends EnrichedType[Tuple21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple21[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT, UU](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _, _19: (S => SS) = identity[S] _, _20: (T => TT) = identity[T] _, _21: (U => UU) = identity[U] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT, UU) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18), _19(value._19), _20(value._20), _21(value._21)) @@ -67,12 +67,12 @@ trait Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] ex implicit def ToTuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)): Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] = new { val value = t } with Tuple21W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U] - -trait Tuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] extends PimpedType[Tuple22[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V]] { + +trait Tuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] extends EnrichedType[Tuple22[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V]] { def fold[Z](f: => (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V) => Z): Z = {import value._; f(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22)} def toIndexedSeq[Z](implicit ev: value.type <:< Tuple22[Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]): IndexedSeq[Z] = {val zs = ev(value); import zs._; IndexedSeq(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22)} def mapElements[AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT, UU, VV](_1: (A => AA) = identity[A] _, _2: (B => BB) = identity[B] _, _3: (C => CC) = identity[C] _, _4: (D => DD) = identity[D] _, _5: (E => EE) = identity[E] _, _6: (F => FF) = identity[F] _, _7: (G => GG) = identity[G] _, _8: (H => HH) = identity[H] _, _9: (I => II) = identity[I] _, _10: (J => JJ) = identity[J] _, _11: (K => KK) = identity[K] _, _12: (L => LL) = identity[L] _, _13: (M => MM) = identity[M] _, _14: (N => NN) = identity[N] _, _15: (O => OO) = identity[O] _, _16: (P => PP) = identity[P] _, _17: (Q => QQ) = identity[Q] _, _18: (R => RR) = identity[R] _, _19: (S => SS) = identity[S] _, _20: (T => TT) = identity[T] _, _21: (U => UU) = identity[U] _, _22: (V => VV) = identity[V] _): (AA, BB, CC, DD, EE, FF, GG, HH, II, JJ, KK, LL, MM, NN, OO, PP, QQ, RR, SS, TT, UU, VV) = (_1(value._1), _2(value._2), _3(value._3), _4(value._4), _5(value._5), _6(value._6), _7(value._7), _8(value._8), _9(value._9), _10(value._10), _11(value._11), _12(value._12), _13(value._13), _14(value._14), _15(value._15), _16(value._16), _17(value._17), _18(value._18), _19(value._19), _20(value._20), _21(value._21), _22(value._22)) } implicit def ToTuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V](t: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)): Tuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] = new { val value = t } with Tuple22W[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V] -}
\ No newline at end of file +} diff --git a/test/files/pos/t3866.scala b/test/files/pos/t3866.scala index 5fe7e3f50e..5d366ccf13 100644 --- a/test/files/pos/t3866.scala +++ b/test/files/pos/t3866.scala @@ -13,5 +13,5 @@ abstract class ImplicitRepeated { f("A", 1, 2) // should be implicitly resolved to alternative b) f( 1, 2 ) // should be implicitly resolved to alternative a) // ImplicitRepeated.this.f[Int, Nothing]("A", ImplicitRepeated.this.anyToN[Int](1), ImplicitRepeated.this.anyToN[Int](2)); - // ImplicitRepeated.this.f[Int, Nothing](ImplicitRepeated.this.anyToN[Int](1), ImplicitRepeated.this.anyToN[Int](2)) + // ImplicitRepeated.this.f[Int, Nothing](ImplicitRepeated.this.anyToN[Int](1), ImplicitRepeated.this.anyToN[Int](2)) }
\ No newline at end of file diff --git a/test/files/pos/t3880.scala b/test/files/pos/t3880.scala index b6f06c43a3..cd5f3c0125 100644 --- a/test/files/pos/t3880.scala +++ b/test/files/pos/t3880.scala @@ -1,6 +1,6 @@ abstract class Bar[+B] { } -abstract class C1[+B] extends Bar[B] { +abstract class C1[+B] extends Bar[B] { private[this] def g(x: C1[B]): Unit = () // this method is fine: notice that it allows the call to g, diff --git a/test/files/pos/t3883.scala b/test/files/pos/t3883.scala index adde0526b2..1b62c0c6d6 100644 --- a/test/files/pos/t3883.scala +++ b/test/files/pos/t3883.scala @@ -1,14 +1,14 @@ // need to test both orders object A1 { - implicit def i: Equiv[Boolean] = error("") - implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = error("") + implicit def i: Equiv[Boolean] = sys.error("") + implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = sys.error("") implicitly[Equiv[Boolean]] } object A2 { - implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = error("") - implicit def i: Equiv[Boolean] = error("") + implicit def div[T, A](implicit f: T => A, eq: Equiv[A]): Equiv[T] = sys.error("") + implicit def i: Equiv[Boolean] = sys.error("") implicitly[Equiv[Boolean]] } diff --git a/test/files/pos/t3898.scala b/test/files/pos/t3898.scala index 075692e5a8..ab47bbd877 100644 --- a/test/files/pos/t3898.scala +++ b/test/files/pos/t3898.scala @@ -2,5 +2,5 @@ trait Atomic[@specialized(Boolean) T] { def x: T def f(fn: T => T): Boolean = f(fn(x), true) - def f[R](a: T, b: R): R = b + def f[R](a: T, b: R): R = b } diff --git a/test/files/pos/t3927.scala b/test/files/pos/t3927.scala index eb4c4b3be5..f5869c55d5 100644 --- a/test/files/pos/t3927.scala +++ b/test/files/pos/t3927.scala @@ -1,6 +1,6 @@ object A { def x { - implicit lazy val e: Equiv[Int] = error("") + implicit lazy val e: Equiv[Int] = sys.error("") implicitly[Equiv[Int]] } -} +} diff --git a/test/files/pos/t3936/BlockingQueue.java b/test/files/pos/t3936/BlockingQueue.java new file mode 100644 index 0000000000..b902d4528d --- /dev/null +++ b/test/files/pos/t3936/BlockingQueue.java @@ -0,0 +1,3 @@ +package pack; +import java.util.Queue; +public interface BlockingQueue<E> extends Queue<E> { } diff --git a/test/files/pos/t3936/Queue.java b/test/files/pos/t3936/Queue.java new file mode 100644 index 0000000000..25c9087601 --- /dev/null +++ b/test/files/pos/t3936/Queue.java @@ -0,0 +1,2 @@ +package pack; +public interface Queue { } diff --git a/test/files/pos/t3936/Test.scala b/test/files/pos/t3936/Test.scala new file mode 100644 index 0000000000..c867a05ec9 --- /dev/null +++ b/test/files/pos/t3936/Test.scala @@ -0,0 +1,4 @@ +package pack +trait Test { + val b: BlockingQueue[Nothing] +} diff --git a/test/files/pos/t3938/Parent.java b/test/files/pos/t3938/Parent.java index a35f435030..08fae330bb 100644 --- a/test/files/pos/t3938/Parent.java +++ b/test/files/pos/t3938/Parent.java @@ -1,7 +1,7 @@ public class Parent<A>{ class I1 {} class I2 extends Parent.I1 {} - + // OKAY: class I3 extends I1 {} static class I4 {} diff --git a/test/files/pos/t3938/UseParent.scala b/test/files/pos/t3938/UseParent.scala index 3f4c2298d5..685d1a03a8 100644 --- a/test/files/pos/t3938/UseParent.scala +++ b/test/files/pos/t3938/UseParent.scala @@ -1,6 +1,6 @@ object UseParent { classOf[Parent[AnyRef]#I2] - + // OKAY classOf[Parent[AnyRef]#I3] classOf[Parent.I5] diff --git a/test/files/pos/t3943/Client_2.scala b/test/files/pos/t3943/Client_2.scala new file mode 100644 index 0000000000..650ac9b7a9 --- /dev/null +++ b/test/files/pos/t3943/Client_2.scala @@ -0,0 +1,7 @@ +object Test { + val x: Child = new Child + x.getInner.foo("meh") +// error: type mismatch; +// found : java.lang.String("meh") +// required: E +} diff --git a/test/files/pos/t3943/Outer_1.java b/test/files/pos/t3943/Outer_1.java new file mode 100644 index 0000000000..1d38c5e76b --- /dev/null +++ b/test/files/pos/t3943/Outer_1.java @@ -0,0 +1,14 @@ +class Outer<E> { + abstract class Inner { + abstract public void foo(E e); + } +} + +class Child extends Outer<String> { + // the implicit prefix for Inner is Outer<E> instead of Outer<String> + public Inner getInner() { + return new Inner() { + public void foo(String e) { System.out.println("meh "+e); } + }; + } +} diff --git a/test/files/pos/t3972.scala b/test/files/pos/t3972.scala index d6cbb3dfb7..5dfc10fcef 100644 --- a/test/files/pos/t3972.scala +++ b/test/files/pos/t3972.scala @@ -2,7 +2,7 @@ object CompilerCrash { def main(args: Array[String]) { args match { case Array("a", a @ _*) => { } // The code compiles fine if this line is commented out or "@ _*" is deleted or this line is swapped for the next line - case Array("b") => { } // The code compiles fine if this line is commented out + case Array("b") => { } // The code compiles fine if this line is commented out case Array("c", c) => { 0 // The code compiles fine if this line is commented out } diff --git a/test/files/pos/t4020.scala b/test/files/pos/t4020.scala index 8a758d53f7..f976460191 100644 --- a/test/files/pos/t4020.scala +++ b/test/files/pos/t4020.scala @@ -14,11 +14,11 @@ class B { def mthd(foo: a2.Foo) = { foo match { case a2.Foo2(i) => i - - // Note: This case is impossible. In fact, scalac + + // Note: This case is impossible. In fact, scalac // will (correctly) report an error if it is uncommented, // but a warning if it is commented. - + // case a1.Foo1(i) => i } } diff --git a/test/files/pos/t4070.scala b/test/files/pos/t4070.scala index 29c8d16e30..a9777f02ed 100644 --- a/test/files/pos/t4070.scala +++ b/test/files/pos/t4070.scala @@ -21,14 +21,14 @@ package b { /* // With crash below the clasess: -% scalac -Dscalac.debug.tvar ./a.scala +% scalac -Dscalac.debug.tvar ./a.scala [ create] ?_$1 ( In Foo#crash ) [ setInst] tv[Int] ( In Foo#crash, _$1=tv[Int] ) [ create] tv[Int] ( In Foo#crash ) [ clone] tv[Int] ( Foo#crash ) // With crash above the classes: -% scalac -Dscalac.debug.tvar ./a.scala +% scalac -Dscalac.debug.tvar ./a.scala [ create] ?tv ( In Foo#crash ) ./a.scala:2: error: Invalid type application in TypeVar: List(), List(Int) def crash(x: Dingus[_]): Unit = x match { case m: Bippy[tv] => () } diff --git a/test/files/pos/t4202.scala b/test/files/pos/t4202.scala index aca7d503ee..b2a0c0120a 100644 --- a/test/files/pos/t4202.scala +++ b/test/files/pos/t4202.scala @@ -2,7 +2,7 @@ object t4202_1 { () => { trait T { def t = () - } + } } } diff --git a/test/files/pos/t422.scala b/test/files/pos/t422.scala deleted file mode 100644 index cb3ba279d4..0000000000 --- a/test/files/pos/t422.scala +++ /dev/null @@ -1,17 +0,0 @@ -import scala.util.regexp.WordExp; -import scala.util.automata.WordBerrySethi; - -object BoolWordExp extends WordExp { - type _labelT = MyLabels; - type _regexpT = RegExp; - abstract class MyLabels extends Label ; - case class MyLabel(c:Char) extends MyLabels; -} - -object MyTranslator extends WordBerrySethi { - override val lang = BoolWordExp; - import lang._; - override protected def seenLabel( r:RegExp, i:Int, label: _labelT ): Unit = { - super.seenLabel(r,i,label) - } -} diff --git a/test/files/pos/t4220.scala b/test/files/pos/t4220.scala index 8fb999e345..98f2649767 100644 --- a/test/files/pos/t4220.scala +++ b/test/files/pos/t4220.scala @@ -1,4 +1,4 @@ -// don't know if our half-working sbt build is meaningfully +// don't know if our half-working sbt build is meaningfully // tested for #4220 with this, but it can't hurt. class Boo(a: Int = 0) diff --git a/test/files/pos/t4243.scala b/test/files/pos/t4243.scala index 5fa8665918..e6c66faff0 100644 --- a/test/files/pos/t4243.scala +++ b/test/files/pos/t4243.scala @@ -3,16 +3,16 @@ object wrap { - + trait DomainLike[@specialized(Int) A, +This <: Domain[A]] - + trait Domain[@specialized(Int) B] extends DomainLike[B, Domain[B]] - + trait IterableDomainLike[@specialized(Int) C, +This <: IterableDomain[C]] extends DomainLike[C, This] - + trait IterableDomain[@specialized(Int) D] extends Domain[D] with IterableDomainLike[D, IterableDomain[D]] - + } diff --git a/test/files/pos/t4266.scala b/test/files/pos/t4266.scala index 301cc264bc..222f65e970 100644 --- a/test/files/pos/t4266.scala +++ b/test/files/pos/t4266.scala @@ -1,21 +1,21 @@ object Test { - + trait Tensor2Like[ - @specialized(Int) A1, - +D1 <: DomainLike[A1], + @specialized(Int) A1, + +D1 <: DomainLike[A1], +D <: Product2DomainLike[D1] ] { def domain: D; - + def checkKey(k1: A1) { domain._1.contains(k1) } } - + trait DomainLike[A] { def contains(key: A): Boolean; } - + // trait DomainLike[@specialized(Int) A] { // def contains(key: A): Boolean; // } diff --git a/test/files/pos/t4269.scala b/test/files/pos/t4269.scala index 70f0471a9a..99a30785b4 100644 --- a/test/files/pos/t4269.scala +++ b/test/files/pos/t4269.scala @@ -1,5 +1,5 @@ -class A { - PartialFunction.condOpt(Nil) { - case items@List(_*) if true => +class A { + PartialFunction.condOpt(Nil) { + case items@List(_*) if true => } } diff --git a/test/files/pos/t4273.scala b/test/files/pos/t4273.scala index 9a942e8325..a4d37174ad 100644 --- a/test/files/pos/t4273.scala +++ b/test/files/pos/t4273.scala @@ -1,8 +1,8 @@ class A { implicit def compareComparables[T](x: T)(implicit ord: Ordering[T]) = new ord.Ops(x) - + class Bippy implicit val bippyOrdering = new Ordering[Bippy] { def compare(x: Bippy, y: Bippy) = util.Random.nextInt } - + (new Bippy) < (new Bippy) }
\ No newline at end of file diff --git a/test/files/pos/t4275.scala b/test/files/pos/t4275.scala index 183cb5155e..1938aceadc 100644 --- a/test/files/pos/t4275.scala +++ b/test/files/pos/t4275.scala @@ -1,6 +1,6 @@ object Test { def f = "abc".count(_ > 'a') - + class A { private val count: Int = 0 } diff --git a/test/files/pos/t430-feb09.scala b/test/files/pos/t430-feb09.scala index bba8996e4e..1499f32b7a 100644 --- a/test/files/pos/t430-feb09.scala +++ b/test/files/pos/t430-feb09.scala @@ -13,12 +13,12 @@ package c.scala { case class C[T]() } -// Doesn't compile: type Nothing is not a member of d.scala +// Doesn't compile: type Nothing is not a member of d.scala package d.scala.d { case class D[T]() } -// Doesn't compile: type Any is not a member of e.scala +// Doesn't compile: type Any is not a member of e.scala package e.scala { case class E[T >: Nothing]() } diff --git a/test/files/pos/t4365/a_1.scala b/test/files/pos/t4365/a_1.scala new file mode 100644 index 0000000000..6f3405b1ff --- /dev/null +++ b/test/files/pos/t4365/a_1.scala @@ -0,0 +1,18 @@ +import scala.collection._ + +trait SeqViewLike[+A, + +Coll, + +This <: SeqView[A, Coll] with SeqViewLike[A, Coll, This]] + extends Seq[A] with GenSeqViewLike[A, Coll, This] +{ + + trait Transformed[+B] extends super[GenSeqViewLike].Transformed[B] + + abstract class AbstractTransformed[+B] extends Seq[B] with Transformed[B] { + def underlying: Coll = error("") + } + + trait Reversed extends Transformed[A] with super[GenSeqViewLike].Reversed + + protected def newReversed: Transformed[A] = new AbstractTransformed[A] with Reversed +} diff --git a/test/files/pos/t4365/b_1.scala b/test/files/pos/t4365/b_1.scala new file mode 100644 index 0000000000..e5b5687185 --- /dev/null +++ b/test/files/pos/t4365/b_1.scala @@ -0,0 +1,22 @@ +import scala.collection._ + +trait GenSeqViewLike[+A, + +Coll, + +This <: GenSeqView[A, Coll] with GenSeqViewLike[A, Coll, This]] +extends GenSeq[A] { +self => + + trait Transformed[+B] { + def length: Int = 0 + def apply(idx: Int): B = error("") + } + + trait Reversed extends Transformed[A] { + def iterator: Iterator[A] = createReversedIterator + + private def createReversedIterator: Iterator[A] = { + self.foreach(_ => ()) + null + } + } +} diff --git a/test/files/pos/t4432.scala b/test/files/pos/t4432.scala index 09f4c2ab34..106312311a 100644 --- a/test/files/pos/t4432.scala +++ b/test/files/pos/t4432.scala @@ -9,7 +9,7 @@ object Main { } new A } - + def foo2 = { class B { val x = { @@ -38,5 +38,5 @@ object Main { } new D } - + } diff --git a/test/files/pos/t4457_1.scala b/test/files/pos/t4457_1.scala index 4442f28e4a..32edd6cfdc 100644 --- a/test/files/pos/t4457_1.scala +++ b/test/files/pos/t4457_1.scala @@ -15,7 +15,7 @@ object ImplicitConvAmbiguity2 { def aFunc[A](a: NN[A]) = new BB[A] def bFunc[T](e1: N[T]) = {} - + def typeMe1 { val x = aFunc(4F) bFunc(x) diff --git a/test/files/pos/t4501.scala b/test/files/pos/t4501.scala index dac2524024..40628f1a4b 100644 --- a/test/files/pos/t4501.scala +++ b/test/files/pos/t4501.scala @@ -6,7 +6,7 @@ class A { def f1 = foo(ListBuffer(), List()) def f2 = foo(ListBuffer(), ListBuffer()) def f3 = foo(List(), List()) - + // scalap // def f1 : scala.collection.Seq[scala.Nothing] = { /* compiled code */ } // def f2 : scala.collection.mutable.ListBuffer[scala.Nothing] = { /* compiled code */ } diff --git a/test/files/pos/t460.scala b/test/files/pos/t460.scala index 466d06c2ad..3fc13e4dd0 100644 --- a/test/files/pos/t460.scala +++ b/test/files/pos/t460.scala @@ -1,8 +1,8 @@ object Bug460 { def testFun(x : Int, y : Int) = x + y - val fn = testFun _ - - fn(1, 2) // Ok + val fn = testFun _ + + fn(1, 2) // Ok (testFun(_, _))(1, 2) // Ok (testFun _).apply(1, 2) (testFun _)(1, 2) // Error! (but no longer) diff --git a/test/files/pos/t4603/S.scala b/test/files/pos/t4603/S.scala index 9e228195a4..c7d809d9f7 100644 --- a/test/files/pos/t4603/S.scala +++ b/test/files/pos/t4603/S.scala @@ -1,7 +1,7 @@ // S.scala class S extends J[AnyRef] -object Test { +object Test { def main(args:Array[String]) { J.f(classOf[S]) } diff --git a/test/files/pos/t4649.flags b/test/files/pos/t4649.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t4649.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/pending/pos/t4649.scala b/test/files/pos/t4649.scala index 0d6caa8d7a..0d6caa8d7a 100644 --- a/test/pending/pos/t4649.scala +++ b/test/files/pos/t4649.scala diff --git a/test/files/pos/t4716.scala b/test/files/pos/t4716.scala index d4bd55c55b..ec29e8d2cb 100644 --- a/test/files/pos/t4716.scala +++ b/test/files/pos/t4716.scala @@ -2,7 +2,7 @@ -trait Bug2[@specialized(Int) +A] extends TraversableOnce[A] { +trait Bug2[@specialized(Int) +A] extends TraversableOnce[A] { def ++[B >: A](that: TraversableOnce[B]) = { lazy val it = that.toIterator it diff --git a/test/files/pos/t4717.scala b/test/files/pos/t4717.scala index 4acfe489cc..ed35a8ad87 100644 --- a/test/files/pos/t4717.scala +++ b/test/files/pos/t4717.scala @@ -6,13 +6,13 @@ trait Bug1[@specialized(Boolean) A] extends TraversableOnce[A] { - + def ++[B >: A](that: TraversableOnce[B]): Iterator[B] = new Iterator[B] { lazy val it = that.toIterator def hasNext = it.hasNext def next = it.next } - + } diff --git a/test/files/pos/t4744.flags b/test/files/pos/t4744.flags new file mode 100644 index 0000000000..ca20f55172 --- /dev/null +++ b/test/files/pos/t4744.flags @@ -0,0 +1 @@ +-Ybreak-cycles diff --git a/test/files/pos/t4744/Bar.scala b/test/files/pos/t4744/Bar.scala new file mode 100644 index 0000000000..1fb6d78973 --- /dev/null +++ b/test/files/pos/t4744/Bar.scala @@ -0,0 +1 @@ +class Bar { val quux = new Foo[java.lang.Integer]() } diff --git a/test/files/pos/t4744/Foo.java b/test/files/pos/t4744/Foo.java new file mode 100644 index 0000000000..6c764d0470 --- /dev/null +++ b/test/files/pos/t4744/Foo.java @@ -0,0 +1 @@ +public class Foo<T extends Comparable<? super T>> {} diff --git a/test/files/pos/t4760.scala b/test/files/pos/t4760.scala index 767e3847f4..d4407a86b4 100644 --- a/test/files/pos/t4760.scala +++ b/test/files/pos/t4760.scala @@ -19,7 +19,7 @@ class Test { import scala.util.Properties.lineSeparator } } - + // parses def f3 = { import scala._ diff --git a/test/pending/pos/t4786.scala b/test/files/pos/t4786.scala index f0579142b8..f0579142b8 100644 --- a/test/pending/pos/t4786.scala +++ b/test/files/pos/t4786.scala diff --git a/test/files/pos/t4840.scala b/test/files/pos/t4840.scala index eefa3b2dee..bf44f71d7a 100644 --- a/test/files/pos/t4840.scala +++ b/test/files/pos/t4840.scala @@ -1,6 +1,6 @@ class Crashy { def g(): Option[Any] = None - + def crashy() = { for (_ <- g()) { (null: Any) match { diff --git a/test/files/pos/t4853.scala b/test/files/pos/t4853.scala index ed9b320434..c91f2d6b05 100644 --- a/test/files/pos/t4853.scala +++ b/test/files/pos/t4853.scala @@ -3,7 +3,7 @@ object Animal { } class Animal[A <: AwakeOrAsleep] { - def goToSleep[B >: A <: Awake]: Animal[Asleep] = new Animal[Asleep] + def goToSleep[B >: A <: Awake]: Animal[Asleep] = new Animal[Asleep] def wakeUp[B >: A <: Asleep]: Animal[Awake] = new Animal[Awake] } diff --git a/test/pending/pos/t4859.scala b/test/files/pos/t4859.scala index ec5abd966d..284a39b7ab 100644 --- a/test/pending/pos/t4859.scala +++ b/test/files/pos/t4859.scala @@ -1,5 +1,7 @@ object O { + // error: C is not a legal prefix for a constructor C().CC() + // but this works. D().DD() } diff --git a/test/files/pos/t4970b.scala b/test/files/pos/t4970b.scala new file mode 100644 index 0000000000..cf9a6a6ae9 --- /dev/null +++ b/test/files/pos/t4970b.scala @@ -0,0 +1,32 @@ +object Traits { + trait OuterClass[V <: OuterClass[V]#InnerClass] { + trait InnerClass {self: V => + def method = () + } + } + + trait SubOuterClass[T <: SubOuterClass[T]#SubInnerClass] extends OuterClass[T] { + trait SubInnerClass extends super.InnerClass {self: T => } + } + + trait SubOuterClass2[T <: SubOuterClass2[T]#SubInnerClass2] extends OuterClass[T] { + trait SubInnerClass2 extends super.InnerClass {self: InnerClass with T => } + } + +} + +// object Classes { +// class OuterClass[V <: OuterClass[V]#InnerClass] { +// class InnerClass {self: V => +// def method = () +// } +// } + +// class SubOuterClass[T <: SubOuterClass[T]#SubInnerClass] extends OuterClass[T] { +// class SubInnerClass extends super.InnerClass {self: T => } +// } + +// class SubOuterClass2[T <: SubOuterClass2[T]#SubInnerClass2] extends OuterClass[T] { +// class SubInnerClass2 extends super.InnerClass {self: InnerClass with T => } +// } +// } diff --git a/test/files/pos/t5022.scala b/test/files/pos/t5022.scala new file mode 100644 index 0000000000..b9a085fb35 --- /dev/null +++ b/test/files/pos/t5022.scala @@ -0,0 +1,22 @@ +class ForSomeVsUnapply { + def test { + def makeWrap: Wrap = ??? + def useRep[e](rep: (e, X[e])) = () + + val repUnapply = Wrap.unapply(makeWrap).get + useRep(repUnapply) // okay + + val Wrap(rep0) = makeWrap + useRep(rep0) // error + + val rep = makeWrap match { + case Wrap(r) => r + }; + + useRep(rep) // error + } +} + +class X[e] + +case class Wrap(rep: (e, X[e]) forSome { type e }) diff --git a/test/files/pos/t5031_2.scala b/test/files/pos/t5031_2.scala index ded3e82301..e51215db84 100644 --- a/test/files/pos/t5031_2.scala +++ b/test/files/pos/t5031_2.scala @@ -1,4 +1,4 @@ -package object t5031 { +package object t5031 { class ID } diff --git a/test/files/pos/t5120.scala b/test/files/pos/t5120.scala index 2c193d129d..6731af14e4 100644 --- a/test/files/pos/t5120.scala +++ b/test/files/pos/t5120.scala @@ -1,12 +1,12 @@ -// An example extracted from SBT by Iulian -// that showed that the previous fix to t5120 +// An example extracted from SBT by Iulian +// that showed that the previous fix to t5120 // was too strict. class Test { class ScopedKey[T] class Value[T] class Compiled[T](val settings: Seq[Pair[T]]) - + case class Pair[T](k: ScopedKey[T], v: ScopedKey[T]) def transform[T](x: T) = x diff --git a/test/files/pos/t5127.scala b/test/files/pos/t5127.scala index e90b8d00a0..c562025302 100644 --- a/test/files/pos/t5127.scala +++ b/test/files/pos/t5127.scala @@ -4,5 +4,5 @@ package foo { class Parametrized1[T] extends Abstract1[Parametrized2[T]] { def bar(a: AnyRef) { a match { case d: Parametrized1[_] => println("ok") } } } - class Parametrized2[T] extends Parametrized1[T] with Abstract2[Parametrized2[T]] + class Parametrized2[T] extends Parametrized1[T] with Abstract2[Parametrized2[T]] } diff --git a/test/files/pos/t5156.scala b/test/files/pos/t5156.scala index e7912ef35c..52412ad4c1 100644 --- a/test/files/pos/t5156.scala +++ b/test/files/pos/t5156.scala @@ -1,6 +1,6 @@ sealed trait HList -final case class HCons[H, T <: HList](head : H, tail : T) extends HList -case object HNil extends HList +final case class HCons[H, T <: HList](head : H, tail : T) extends HList +case object HNil extends HList object HList { type ::[H, T <: HList] = HCons[H, T] diff --git a/test/files/pos/t516.scala b/test/files/pos/t516.scala index 735b259436..5561b7610c 100644 --- a/test/files/pos/t516.scala +++ b/test/files/pos/t516.scala @@ -4,7 +4,7 @@ import scala.collection.script._; class Members; object subscriber extends Subscriber[Message[String] with Undoable, Members] { - def notify(pub: Members, event: Message[String] with Undoable): Unit = + def notify(pub: Members, event: Message[String] with Undoable): Unit = (event: Message[String]) match { case Include(l, elem) => Console.println("ADD: " + elem); case Remove(l, elem) => Console.println("REM: " + elem); @@ -12,4 +12,3 @@ object subscriber extends Subscriber[Message[String] with Undoable, Members] { //case r : Remove [HasTree] with Undoable => } } - diff --git a/test/files/pos/t5178.scala b/test/files/pos/t5178.scala index 26c008d66f..ed0f814ec5 100644 --- a/test/files/pos/t5178.scala +++ b/test/files/pos/t5178.scala @@ -4,7 +4,7 @@ abstract class FileOps { trait DefaultFileOps { self: DefaultPath => - + override def withLock[R](start: Long = 5): Option[R] = None } diff --git a/test/files/pos/t5223.scala b/test/files/pos/t5223.scala index 0b2528e367..d81daa9907 100644 --- a/test/files/pos/t5223.scala +++ b/test/files/pos/t5223.scala @@ -2,5 +2,5 @@ import scala.reflect.runtime.universe._ object Foo extends App { reify{def printf(format: String, args: Any*): String = null } - reify{def printf(format: String, args: Any*): String = ("abc": @cloneable)} + reify{def printf(format: String, args: Any*): String = ("abc": @deprecated)} }
\ No newline at end of file diff --git a/test/files/pos/t5240.scala b/test/files/pos/t5240.scala index 2db689c27d..065d175f2f 100644 --- a/test/files/pos/t5240.scala +++ b/test/files/pos/t5240.scala @@ -5,7 +5,7 @@ package object foo { - + var labels: Array[_ <: String] = null - + } diff --git a/test/files/pos/t5317.scala b/test/files/pos/t5317.scala index 8c9c9d8222..052e84438c 100644 --- a/test/files/pos/t5317.scala +++ b/test/files/pos/t5317.scala @@ -2,11 +2,11 @@ object Test { trait S { type T; val x: AnyRef } trait A extends S { type T <: A; val x: A = null } trait B extends S { type T <: B; val x: B = null } - + val a = new A{} val b = new B{} val y = if (true) a else b - + // lub of y should allow for this println(y.x.x) } diff --git a/test/pending/pos/t5399a.scala b/test/files/pos/t5399a.scala index 4ebd85ad03..4ebd85ad03 100644 --- a/test/pending/pos/t5399a.scala +++ b/test/files/pos/t5399a.scala diff --git a/test/files/pos/t5459.scala b/test/files/pos/t5459.scala new file mode 100644 index 0000000000..971e6f896d --- /dev/null +++ b/test/files/pos/t5459.scala @@ -0,0 +1,48 @@ +trait A1 +trait A2 +trait A3 +trait L1 extends A1 with A2 with A3 + +object Test { + trait T1[-A <: A1] + trait T2[-A >: L1] + trait T3[ A <: A1] + trait T4[ A >: L1] + trait T5[+A <: A1] + trait T6[+A >: L1] + + def f1(x: T1[_]) = x + def f2(x: T2[_]) = x + def f3(x: T3[_]) = x + def f4(x: T4[_]) = x + def f5(x: T5[_]) = x + def f6(x: T6[_]) = x + // a.scala:22: error: type arguments [Any] do not conform to trait T5's type parameter bounds [+A <: A1] + // def f5(x: T5[_]) = x + // ^ + + def g1(x: T1[_ <: A1]) = x + def g2(x: T2[_ >: L1]) = x + def g3(x: T3[_ <: A1]) = x + def g4(x: T4[_ >: L1]) = x + def g5(x: T5[_ <: A1]) = x + def g6(x: T6[_ >: L1]) = x + + def q1(x: T1[_ >: L1]) = x + def q2(x: T2[_ <: A1]) = x + def q3(x: T3[_ >: L1]) = x + def q4(x: T4[_ <: A1]) = x + def q5(x: T5[_ >: L1]) = x + def q6(x: T6[_ <: A1]) = x + // a.scala:41: error: type arguments [Any] do not conform to trait T5's type parameter bounds [+A <: A1] + // def q5(x: T5[_ >: L1]) = x + // ^ + // two errors found + + def h1(x: T1[_ >: L1 <: A1]) = x + def h2(x: T2[_ >: L1 <: A1]) = x + def h3(x: T3[_ >: L1 <: A1]) = x + def h4(x: T4[_ >: L1 <: A1]) = x + def h5(x: T5[_ >: L1 <: A1]) = x + def h6(x: T6[_ >: L1 <: A1]) = x +} diff --git a/test/files/pos/t5541.scala b/test/files/pos/t5541.scala index 39682a2fff..90e5e4130b 100644 --- a/test/files/pos/t5541.scala +++ b/test/files/pos/t5541.scala @@ -27,7 +27,7 @@ object HASkipList { def asBranch : Branch[ S, A ] = this } } -sealed trait HASkipList[ S <: Sys[ S ], @specialized( Int ) A ] +sealed trait HASkipList[ S <: Sys[ S ], @specialized( Int ) A ] class HASkipListView[ S <: Sys[ S ], A ]( private val l: HASkipList[ S, A ])( implicit system: S ) { import HASkipList.Node diff --git a/test/pending/pos/t5606.scala b/test/files/pos/t5606.scala index 2545271e32..2545271e32 100644 --- a/test/pending/pos/t5606.scala +++ b/test/files/pos/t5606.scala diff --git a/test/pending/pos/t5639/Bar.scala b/test/files/pos/t5639/Bar.scala index f577500acd..f577500acd 100644 --- a/test/pending/pos/t5639/Bar.scala +++ b/test/files/pos/t5639/Bar.scala diff --git a/test/pending/pos/t5639/Foo.scala b/test/files/pos/t5639/Foo.scala index 6602150661..1a07734a8e 100644 --- a/test/pending/pos/t5639/Foo.scala +++ b/test/files/pos/t5639/Foo.scala @@ -1,6 +1,6 @@ package pack.age -class Baz +class Baz object Implicits { implicit def Baz(n: Int): Baz = new Baz diff --git a/test/files/pos/t5644/BoxesRunTime.java b/test/files/pos/t5644/BoxesRunTime.java index 241bf79ac8..74c4c6b4b9 100644 --- a/test/files/pos/t5644/BoxesRunTime.java +++ b/test/files/pos/t5644/BoxesRunTime.java @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2006-2011, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2006-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** diff --git a/test/files/pos/t573.scala b/test/files/pos/t573.scala index 7b9d377cd1..694d001e3c 100644 --- a/test/files/pos/t573.scala +++ b/test/files/pos/t573.scala @@ -16,15 +16,15 @@ import DirX._; abstract class Linked { type Node <: Node0; - + abstract class Node0 { self: Node => - + var next : Node = _; var prev : Node = _; - + def get(dir : Dir) = if (dir == BEFORE) prev; else next; - private def set(dir : Dir, node : Node) = + private def set(dir : Dir, node : Node) = if (dir == BEFORE) prev = node; else next = node; def link(dir : Dir, node : Node) = { @@ -34,7 +34,7 @@ abstract class Linked { node.set(dir.reverse, self); } - + def end(dir : Dir) : Node = { if (get(dir) == null) this; else get(dir).end(dir); diff --git a/test/files/pos/t577.scala b/test/files/pos/t577.scala index 236c1395e2..ede45399a0 100644 --- a/test/files/pos/t577.scala +++ b/test/files/pos/t577.scala @@ -1,15 +1,15 @@ trait PriorityTree { type Node <: BasicTreeNode; - + val top = initTree; top.next = (initTree); top.next.prev = (top); - + def initTree : Node; - - - + + + trait BasicTreeNode { private[PriorityTree] var next : Node = _; private[PriorityTree] var prev : Node = _; diff --git a/test/files/pos/t5809.scala b/test/files/pos/t5809.scala index 133e13c4ed..6101f546b3 100644 --- a/test/files/pos/t5809.scala +++ b/test/files/pos/t5809.scala @@ -1,5 +1,6 @@ package object foo { - implicit class PimpedInt(foo: Int) { + implicit class EnrichedInt(foo: Int) { def bar = ??? + def bippy = foo } -}
\ No newline at end of file +} diff --git a/test/files/pos/t5846.scala b/test/files/pos/t5846.scala index b06f5ac39c..05cabed6a0 100644 --- a/test/files/pos/t5846.scala +++ b/test/files/pos/t5846.scala @@ -4,7 +4,7 @@ /** Return the most general sorted map type. */ object Test extends App { - + val empty: collection.SortedMap[String, String] = collection.SortedMap.empty[String, String] - + } diff --git a/test/files/pos/t5853.scala b/test/files/pos/t5853.scala index 21d80206ab..2ebb6667dc 100644 --- a/test/files/pos/t5853.scala +++ b/test/files/pos/t5853.scala @@ -41,7 +41,7 @@ object Arrow { implicit final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { @inline def ->>[B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) } - + def foo = 1 ->> 2 } @@ -50,6 +50,6 @@ object SpecArrow { implicit final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { @inline def ->> [@specialized(Int) B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) } - + def foo = 1 ->> 2 } diff --git a/test/files/pos/t5877.scala b/test/files/pos/t5877.scala index c7827df99f..939013cd01 100644 --- a/test/files/pos/t5877.scala +++ b/test/files/pos/t5877.scala @@ -7,8 +7,8 @@ package foo { } package object foo { - // Crasher: No synthetics for method PimpedFoo2: synthetics contains - implicit class PimpedFoo2(value: Foo) { + // Crasher: No synthetics for method EnrichedFoo2: synthetics contains + implicit class EnrichedFoo2(value: Foo) { def huzzah = "" } } diff --git a/test/files/pos/t5877b.scala b/test/files/pos/t5877b.scala index 6b8cbd473e..43a2ea2f06 100644 --- a/test/files/pos/t5877b.scala +++ b/test/files/pos/t5877b.scala @@ -7,7 +7,7 @@ object Test { } object `package` { - implicit class PimpedFoo2(value: Foo) { + implicit class EnrichedFoo2(value: Foo) { def huzzah = "" } } diff --git a/test/files/pos/t599.scala b/test/files/pos/t599.scala index 53f205a26b..968e2deaee 100644 --- a/test/files/pos/t599.scala +++ b/test/files/pos/t599.scala @@ -16,4 +16,4 @@ abstract class FooA { val aaa: InnerB.this.B = doB aaa.xxx; } - } + } diff --git a/test/files/pos/t602.scala b/test/files/pos/t602.scala index 6062b976b6..18dd405645 100644 --- a/test/files/pos/t602.scala +++ b/test/files/pos/t602.scala @@ -10,5 +10,5 @@ case class Span[K <: Ordered[K]](low: Option[K], high: Option[K]) extends Functi case Span(Some(low), None) => (k >= low) case Span(None, Some(high)) => (k <= high) case _ => false - } + } } diff --git a/test/files/pos/t6123-explaintypes-implicits.flags b/test/files/pos/t6123-explaintypes-implicits.flags new file mode 100644 index 0000000000..b36707c7cf --- /dev/null +++ b/test/files/pos/t6123-explaintypes-implicits.flags @@ -0,0 +1 @@ +-explaintypes diff --git a/test/files/pos/t6123-explaintypes-implicits.scala b/test/files/pos/t6123-explaintypes-implicits.scala new file mode 100644 index 0000000000..5242b443d5 --- /dev/null +++ b/test/files/pos/t6123-explaintypes-implicits.scala @@ -0,0 +1,13 @@ +object ImplicitBugReport { + trait Exp[+T] + trait CanBuildExp[-Elem, +To] extends (Exp[Elem] => To) + trait TraversableExp[T, ExpT <: Exp[T]] extends Exp[Traversable[T]] + + implicit def canBuildExp[T]: CanBuildExp[T, Exp[T]] = ??? + implicit def canBuildExpTrav[T, ExpT <: Exp[T]](implicit c: CanBuildExp[T, ExpT]): CanBuildExp[Traversable[T], TraversableExp[T, ExpT]] = ??? + def toExpTempl[T, That](t: T)(implicit c: CanBuildExp[T, That]): That = ??? + + def testBug() { + val a1 = toExpTempl(Seq(1, 2, 3, 5)) + } +} diff --git a/test/files/pos/t613.scala b/test/files/pos/t613.scala index 6e3841dada..e140833106 100644 --- a/test/files/pos/t613.scala +++ b/test/files/pos/t613.scala @@ -3,9 +3,9 @@ class Outer extends App { abstract class C { val x: Int } - val foo = new C { + val foo = new C { class I { - val z = y + val z = y } val x = (new I).z } diff --git a/test/files/pos/t616.scala b/test/files/pos/t616.scala index 074ad190da..bb91c732a6 100644 --- a/test/files/pos/t616.scala +++ b/test/files/pos/t616.scala @@ -1,7 +1,7 @@ object testImplicit { implicit def foo2bar(foo: Foo): Bar = foo.bar class Foo(val bar: Bar) { - def testCoercion = {val a = this; a.baz} // here, foo2bar is inferred by the compiler, as expected + def testCoercion = {val a = this; a.baz} // here, foo2bar is inferred by the compiler, as expected //def testCoercionThisImplicit = baz // --> error: not found: value baz def testCoercionThisExplicit: Any = this.baz // --> error: value baz is not a member of Foo } diff --git a/test/files/pos/t6162-inheritance.flags b/test/files/pos/t6162-inheritance.flags new file mode 100644 index 0000000000..c6bfaf1f64 --- /dev/null +++ b/test/files/pos/t6162-inheritance.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings diff --git a/test/files/neg/t6162-inheritance.scala b/test/files/pos/t6162-inheritance.scala index 7b47b9285a..fca751edab 100644 --- a/test/files/neg/t6162-inheritance.scala +++ b/test/files/pos/t6162-inheritance.scala @@ -1,5 +1,8 @@ package scala.t6126 +// Don't warn about inheritance in the same file. +// We might use that as a prelude to sealing a class. + @deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") class Foo diff --git a/test/files/pos/t6201.scala b/test/files/pos/t6201.scala deleted file mode 100644 index 366c1f26eb..0000000000 --- a/test/files/pos/t6201.scala +++ /dev/null @@ -1,13 +0,0 @@ -class Test { - class Foo1 { - def must(x: scala.xml.Elem) = () - } - - class Foo2 { - def must(x: Int) = () - } - implicit def toFoo1(s: scala.xml.Elem) = new Foo1() - implicit def toFoo2(s: scala.xml.Elem) = new Foo2() - - def is: Unit = { (<a>{"a"}</a>).must(<a>{"b"}</a>) } -}
\ No newline at end of file diff --git a/test/files/pos/t6210.scala b/test/files/pos/t6210.scala index 1ce8493872..855c621b8e 100644 --- a/test/files/pos/t6210.scala +++ b/test/files/pos/t6210.scala @@ -10,9 +10,9 @@ case class TBool() extends Ty object Foo { def checkExpr(ast: AExpr): Ty = { var astTy:Ty = ast match { - case AAssign(nm: String, v:AExpr) => TBool() + case AAssign(nm: String, v:AExpr) => TBool() - case AConstBool(v: Boolean) => TBool() + case AConstBool(v: Boolean) => TBool() case _ => throw new Exception(s"Unhandled case check(ast: ${ast.getClass})") } diff --git a/test/files/pos/t6221.scala b/test/files/pos/t6221.scala new file mode 100644 index 0000000000..dd7776f596 --- /dev/null +++ b/test/files/pos/t6221.scala @@ -0,0 +1,29 @@ +class MyFunc[-A, +B] extends (A => B) { def apply(x: A): B = ??? } + +class MyCollection[A] { + def map[B](f: MyFunc[A, B]): MyCollection[B] = new MyCollection[B] +} + +class OtherFunc[-A, +B] {} + +object Test { + implicit def functionToMyFunc[A, B](f: A => B): MyFunc[A, B] = new MyFunc + + implicit def otherFuncToMyFunc[A, B](f: OtherFunc[A, B]): MyFunc[A, B] = new MyFunc + + def main(args: Array[String]) { + val col = new MyCollection[Int] + + // Doesn't compile: error: missing parameter type for expanded function ((x$1) => x$1.toString) + println(col.map(_.toString)) + + // Doesn't compile: error: missing parameter type + println(col.map(x => x.toString)) + + // Does compile + println(col.map((x: Int) => x.toString)) + + // Does compile (even though type params of OtherFunc not given) + println(col.map(new OtherFunc)) + } +}
\ No newline at end of file diff --git a/test/files/pos/t6301.scala b/test/files/pos/t6301.scala new file mode 100644 index 0000000000..fa81bbfa77 --- /dev/null +++ b/test/files/pos/t6301.scala @@ -0,0 +1,9 @@ +trait LoadedOver[@specialized(Int) A] { + def foo(x: Any): A + def foo(xs: String): A +} + +object Test { + def loaded: AnyRef with LoadedOver[Int] = sys.error("") + loaded.foo("") +} diff --git a/test/files/pos/t6355pos.scala b/test/files/pos/t6355pos.scala new file mode 100644 index 0000000000..c0e740dd68 --- /dev/null +++ b/test/files/pos/t6355pos.scala @@ -0,0 +1,16 @@ +import scala.language.dynamics + +class A extends Dynamic { + def applyDynamic[T1](method: String)(x1: T1): Any = 1 + def applyDynamic[T1, T2](method: String)(x: T1, y: T2): Any = 2 + def applyDynamic[T1, T2, T3](method: String)(x: T1, y: T2, z: T3): Any = 3 +} + +object Test { + def main(args: Array[String]): Unit = { + val x = new A + println(x[Int](5)) + println(x[Int, String](5, "a")) + println(x[Int, String, Int](5, "a", 5)) + } +} diff --git a/test/files/pos/t640.scala b/test/files/pos/t640.scala index 55f61df8af..45608bc3d4 100644 --- a/test/files/pos/t640.scala +++ b/test/files/pos/t640.scala @@ -1,2 +1,2 @@ -@serializable class A -@serializable class B extends A +class A extends Serializable +class B extends A with Serializable diff --git a/test/files/pos/t6447.scala b/test/files/pos/t6447.scala new file mode 100644 index 0000000000..1c0c0f2a31 --- /dev/null +++ b/test/files/pos/t6447.scala @@ -0,0 +1,18 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context + +class X { type T } + +object X { + // this works + def foo(x: X): x.T = macro fooImpl + def fooImpl(c: Context)(x: c.Expr[X]): c.Expr[x.value.T] = ??? + + // this doesn't + def bar(x: X, y: X): (x.T, y.T) = macro barImpl + def barImpl(c: Context)(x: c.Expr[X], y: c.Expr[X]): c.Expr[(x.value.T, y.value.T)] = ??? + + // neither does this + def baz(x: X)(xs: List[x.T]): Unit = macro bazImpl + def bazImpl(c: Context)(x: c.Expr[X])(xs: c.Expr[List[x.value.T]]): c.Expr[Unit] = ??? +} diff --git a/test/files/pos/t651.scala b/test/files/pos/t651.scala index 44d20ad580..c146446af9 100644 --- a/test/files/pos/t651.scala +++ b/test/files/pos/t651.scala @@ -4,12 +4,12 @@ trait Test3 { trait MatchableImpl { trait MatchImpl; } - + trait BracePairImpl { trait BraceImpl extends MatchableImpl { private object MyMatch1 extends MatchImpl; protected def match0 : MatchImpl = MyMatch1; - + } } } diff --git a/test/files/pos/t6574.scala b/test/files/pos/t6574.scala new file mode 100644 index 0000000000..59c1701eb4 --- /dev/null +++ b/test/files/pos/t6574.scala @@ -0,0 +1,19 @@ +class Bad[X, Y](val v: Int) extends AnyVal { + def vv = v + @annotation.tailrec final def foo[Z](a: Int)(b: String) { + this.foo[Z](a)(b) + } + + @annotation.tailrec final def differentReceiver { + {(); new Bad[X, Y](0)}.differentReceiver + } + + @annotation.tailrec final def dependent[Z](a: Int)(b: String): b.type = { + this.dependent[Z](a)(b) + } +} + +class HK[M[_]](val v: Int) extends AnyVal { + def hk[N[_]]: Unit = if (false) hk[M] else () +} + diff --git a/test/files/pos/t6624.scala b/test/files/pos/t6624.scala index 1a92b92d53..44554c59c7 100644 --- a/test/files/pos/t6624.scala +++ b/test/files/pos/t6624.scala @@ -10,7 +10,7 @@ object Test { val klist: KCons[Option, KCons[Option, KCons[Option, KNil[Nothing]]]] = ??? // crashes with - // "Exception in thread "main" scala.reflect.internal.Types$TypeError: value _1 is not a member + // "Exception in thread "main" scala.reflect.internal.Types$TypeError: value _1 is not a member // of KCons[Option,KCons[Option,KNil[Nothing]]]" klist match { case KCons(KCons(KCons(_))) => diff --git a/test/files/pos/t6664.scala b/test/files/pos/t6664.scala new file mode 100644 index 0000000000..7eb85f619d --- /dev/null +++ b/test/files/pos/t6664.scala @@ -0,0 +1,4 @@ +final case class A(i: Int, s: String) { + protected def copy(s2: String): A = A(i, s2) + protected def copy(i2: Int): A = A(i2, s) +} diff --git a/test/files/pos/t6664b.scala b/test/files/pos/t6664b.scala new file mode 100644 index 0000000000..a622866838 --- /dev/null +++ b/test/files/pos/t6664b.scala @@ -0,0 +1,5 @@ +object T { + def A(s: String): A = new A(3, s) + def A(i: Int): A = A(i, "abc") + case class A(i: Int, s: String) +} diff --git a/test/files/pos/t6745.scala b/test/files/pos/t6745.scala new file mode 100644 index 0000000000..2ab8e6d39a --- /dev/null +++ b/test/files/pos/t6745.scala @@ -0,0 +1,4 @@ +class Bar(val i: Int) { + self: Any with AnyRef => + def this() = this(0) +} diff --git a/test/files/pos/t675.scala b/test/files/pos/t675.scala index c284c0e202..905d29d44a 100644 --- a/test/files/pos/t675.scala +++ b/test/files/pos/t675.scala @@ -7,7 +7,7 @@ trait T { } trait X { def foo : Foo = FOO_0; - } + } } object Test extends App { @@ -15,5 +15,3 @@ object Test extends App { val x = new t.X{} Console.println(x.foo) } - - diff --git a/test/files/pos/t6797.scala b/test/files/pos/t6797.scala new file mode 100644 index 0000000000..ef1afa1eb3 --- /dev/null +++ b/test/files/pos/t6797.scala @@ -0,0 +1,4 @@ +object Test extends App /* workaround: don't extend App */ { + private class Matcher(aParam: Option[String] = None) + private val stringMatcher = new Matcher +} diff --git a/test/files/pos/t6815.scala b/test/files/pos/t6815.scala new file mode 100644 index 0000000000..9244b3d353 --- /dev/null +++ b/test/files/pos/t6815.scala @@ -0,0 +1,17 @@ +trait U { + trait ValOrDefDefApi { + def name: Any + } + type ValOrDefDef <: ValOrDefDefApi + type ValDef <: ValOrDefDef with ValDefApi + trait ValDefApi extends ValOrDefDefApi { this: ValDef => } + val emptyValDef: ValDef // the result type is volatile +} + +object Test { + val u: U = ??? + + u.emptyValDef match { + case u.emptyValDef => // but we shouldn't let that stop us from treating it as a stable identifier pattern. + } +} diff --git a/test/files/pos/t6815_import.scala b/test/files/pos/t6815_import.scala new file mode 100644 index 0000000000..56f4358d59 --- /dev/null +++ b/test/files/pos/t6815_import.scala @@ -0,0 +1,16 @@ +trait U { + trait ValOrDefDefApi { + def name: Any + } + type ValOrDefDef <: ValOrDefDefApi + type ValDef <: ValOrDefDef with ValDefApi + trait ValDefApi extends ValOrDefDefApi { this: ValDef => } + val emptyValDef: ValDef // the result type is volatile +} + +object Test { + val u: U = ??? + + // but we shouldn't let that stop us from treating it as a stable identifier for import + import u.emptyValDef.name +} diff --git a/test/files/pos/t6897.scala b/test/files/pos/t6897.scala deleted file mode 100644 index a7a03a1d3a..0000000000 --- a/test/files/pos/t6897.scala +++ /dev/null @@ -1,6 +0,0 @@ -class A { - val html = (null: Any) match { - case 1 => <xml:group></xml:group> - case 2 => <p></p> - } -} diff --git a/test/files/pos/t690.scala b/test/files/pos/t690.scala index 3fcdca785d..a93c54f007 100644 --- a/test/files/pos/t690.scala +++ b/test/files/pos/t690.scala @@ -10,5 +10,5 @@ trait test { override def foo(t : T) = super.foo(t); } def t : T; - M0.foo(t); + M0.foo(t); } diff --git a/test/files/pos/t6963c.scala b/test/files/pos/t6963c.scala index 0b6b5c757f..d3c3616eb2 100644 --- a/test/files/pos/t6963c.scala +++ b/test/files/pos/t6963c.scala @@ -9,9 +9,9 @@ object Test { case _: Array[_] => true case _ => false } - + def f4(x: Any) = x.isInstanceOf[Traversable[_]] - + def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match { case (Some(_: Seq[_]), Nil, _) => 1 case (None, List(_: List[_], _), _) => 2 diff --git a/test/files/pos/t6966.scala b/test/files/pos/t6966.scala new file mode 100644 index 0000000000..23adc6d0d2 --- /dev/null +++ b/test/files/pos/t6966.scala @@ -0,0 +1,17 @@ +import Ordering.{Byte, comparatorToOrdering} +trait Format[T] +trait InputCache[T] +object CacheIvy { + implicit def basicInputCache[I](implicit fmt: Format[I], eqv: Equiv[I]): InputCache[I] = null + implicit def arrEquiv[T](implicit t: Equiv[T]): Equiv[Array[T]] = null + implicit def hNilCache: InputCache[HNil] = null + implicit def ByteArrayFormat: Format[Array[Byte]] = null + type :+:[H, T <: HList] = HCons[H,T] + implicit def hConsCache[H, T <: HList](implicit head: InputCache[H], tail: InputCache[T]): InputCache[H :+: T] = null + hConsCache[Array[Byte], HNil] +} + +sealed trait HList +sealed trait HNil extends HList +object HNil extends HNil +final class HCons[H, T <: HList](head : H, tail : T) extends HList
\ No newline at end of file diff --git a/test/files/pos/t6976/ImplicitBug_1.scala b/test/files/pos/t6976/ImplicitBug_1.scala index c9031bab2e..50bc247acc 100644 --- a/test/files/pos/t6976/ImplicitBug_1.scala +++ b/test/files/pos/t6976/ImplicitBug_1.scala @@ -1,4 +1,4 @@ -// This one is weird and nasty. Not sure if this is scalac or sbt +// This one is weird and nasty. Not sure if this is scalac or sbt // (tried with 0.12 & 0.12.2-RC2) bug. // // A level of indirection is required to trigger this bug. @@ -11,12 +11,12 @@ // 4. sbt run (it fails) // 5. Switch it back & sbt run. It still fails. // -// In this project sbt clean helps. However in a large project where this +// In this project sbt clean helps. However in a large project where this // bug was found compiler crashed even after doing sbt clean. The only -// way to work around this was to reference Exts object explicitly (C) in +// way to work around this was to reference Exts object explicitly (C) in // the source file using its implicit classes. -// Lets suppose this is a mega-trait combining all sorts of helper +// Lets suppose this is a mega-trait combining all sorts of helper // functionality. trait Support extends Exts diff --git a/test/files/pos/t7014/t7014.scala b/test/files/pos/t7014/t7014.scala index faec4c7740..7c73f700be 100644 --- a/test/files/pos/t7014/t7014.scala +++ b/test/files/pos/t7014/t7014.scala @@ -1,4 +1,3 @@ package t7014 import ThreadSafetyLevel.COMPLETELY_THREADSAFE // refer to annotation so it gets parsed -
\ No newline at end of file diff --git a/test/files/pos/t711.scala b/test/files/pos/t711.scala index 10b410e54e..4dd6040969 100644 --- a/test/files/pos/t711.scala +++ b/test/files/pos/t711.scala @@ -2,7 +2,7 @@ abstract class Component class Button extends Component { def sayHey: Unit = Console.println("Hey, I'm a button") } - + abstract class Origin { val delegate: Component } diff --git a/test/files/pos/t715.cmds b/test/files/pos/t715.cmds deleted file mode 100644 index 2836967fca..0000000000 --- a/test/files/pos/t715.cmds +++ /dev/null @@ -1,2 +0,0 @@ -scalac meredith_1.scala -scalac runner_2.scala diff --git a/test/files/pos/t715/meredith_1.scala b/test/files/pos/t715/meredith_1.scala deleted file mode 100644 index 8261b9881a..0000000000 --- a/test/files/pos/t715/meredith_1.scala +++ /dev/null @@ -1,98 +0,0 @@ -package com.sap.dspace.model.othello; - -import scala.xml._ - -trait XMLRenderer { - type T <: Any {def getClass() : java.lang.Class[_]} - val valueTypes = - List( - classOf[java.lang.Boolean], - classOf[java.lang.Integer], - classOf[java.lang.Float], - classOf[java.lang.String] - // more to come - ) - - def value2XML( - value : Object, - field : java.lang.reflect.Field, - pojo : T - ) : Node = { - value match { - case null => Text( "null" ) - case vUnmatched => - if (value.isInstanceOf[java.lang.Boolean]) - Text( value.asInstanceOf[java.lang.Boolean].toString ) - else if (value.isInstanceOf[java.lang.Integer]) - Text( value.asInstanceOf[java.lang.Integer].toString ) - else if (value.isInstanceOf[java.lang.Float]) - Text( value.asInstanceOf[java.lang.Float].toString ) - // else if (value.isInstanceOf[T]) - // pojo2XML( value.asInstanceOf[T] ) - else - <unmatchedType> - <theType> - {vUnmatched.getClass.toString} - </theType> - <theValue> - {vUnmatched.toString} - </theValue> - </unmatchedType> - } - } - - def field2XML( - field : java.lang.reflect.Field, - pojo : T - ) : Elem = { - - val accessible = field.isAccessible; - field.setAccessible( true ); - // BUGBUG lgm need to disambiguate on type and possibly make - // recursive call to pojo2XML - val fldValXML = value2XML( field.get( pojo ), field, pojo ); - field.setAccessible( accessible ); - - Elem( - null, - field.getName, - null, - TopScope, - fldValXML - ) - } - - def pojo2XML( pojo : T ) : Elem = { - val progeny = - for (field <- pojo.getClass.getDeclaredFields) - yield field2XML( field, pojo ); - - Elem( - null, - pojo.getClass.getName, - null, - TopScope, - progeny.asInstanceOf[Array[scala.xml.Node]] : _* - ) - } -} - -case class POJO2XMLRenderer( recurse : Boolean ) - extends XMLRenderer { - type T = java.io.Serializable - override def value2XML( - value : Object, - field : java.lang.reflect.Field, - pojo : java.io.Serializable - ) : Node = { - if (recurse) super.value2XML( value, field, pojo ) - else Text( value + "" ) - } -} - -object thePOJO2XMLRenderer extends POJO2XMLRenderer( true ) { -} - -object Test extends Application { - println(com.sap.dspace.model.othello.thePOJO2XMLRenderer) -} diff --git a/test/files/pos/t715/runner_2.scala b/test/files/pos/t715/runner_2.scala deleted file mode 100644 index 1e4f40d654..0000000000 --- a/test/files/pos/t715/runner_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends Application { - println(com.sap.dspace.model.othello.thePOJO2XMLRenderer) -} diff --git a/test/files/pos/t7228.scala b/test/files/pos/t7228.scala new file mode 100644 index 0000000000..5d936f6529 --- /dev/null +++ b/test/files/pos/t7228.scala @@ -0,0 +1,75 @@ +object AdaptWithWeaklyConformantType { + implicit class D(d: Double) { def double = d*2 } + + val x1: Int = 1 + var x2: Int = 2 + val x3 = 3 + var x4 = 4 + final val x5 = 5 + final var x6 = 6 + + def f1 = x1.double + def f2 = x2.double + def f3 = x3.double + def f4 = x4.double + def f5 = x5.double + def f6 = x6.double +} + +object AdaptAliasWithWeaklyConformantType { + implicit class D(d: Double) { def double = d*2 } + type T = Int + + val x1: T = 1 + var x2: T = 2 + val x3 = (3: T) + var x4 = (4: T) + final val x5 = (5: T) + final var x6 = (6: T) + + def f1 = x1.double + def f2 = x2.double + def f3 = x3.double + def f4 = x4.double + def f5 = x5.double + def f6 = x6.double +} + +object AdaptToAliasWithWeaklyConformantType { + type U = Double + implicit class D(d: U) { def double = d*2 } + + val x1: Int = 1 + var x2: Int = 2 + val x3 = (3: Int) + var x4 = (4: Int) + final val x5 = (5: Int) + final var x6 = (6: Int) + + def f1 = x1.double + def f2 = x2.double + def f3 = x3.double + def f4 = x4.double + def f5 = x5.double + def f6 = x6.double +} + +object AdaptAliasToAliasWithWeaklyConformantType { + type U = Double + type T = Int + implicit class D(d: U) { def double = d*2 } + + val x1: T = 1 + var x2: T = 2 + val x3 = (3: T) + var x4 = (4: T) + final val x5 = (5: T) + final var x6 = (6: T) + + def f1 = x1.double + def f2 = x2.double + def f3 = x3.double + def f4 = x4.double + def f5 = x5.double + def f6 = x6.double +} diff --git a/test/files/pos/t7264/A_1.scala b/test/files/pos/t7264/A_1.scala new file mode 100644 index 0000000000..044d0110a2 --- /dev/null +++ b/test/files/pos/t7264/A_1.scala @@ -0,0 +1,11 @@ +object Foo { + object Values { + implicit def fromInt(x: Int): Values = ??? + } + trait Values +} +final class Foo(name: String) { + def bar(values: Foo.Values): Bar = ??? +} + +trait Bar diff --git a/test/files/pos/t7264/B_2.scala b/test/files/pos/t7264/B_2.scala new file mode 100644 index 0000000000..a8af2e727e --- /dev/null +++ b/test/files/pos/t7264/B_2.scala @@ -0,0 +1,7 @@ +object Test { + // if the following line is uncommented, things compile + // type X = Foo.Values + + + def foo(f: Foo) = f.bar(0 /* : Foo.Values */) +} diff --git a/test/files/pos/t7294.scala b/test/files/pos/t7294.scala new file mode 100644 index 0000000000..ccac2b1400 --- /dev/null +++ b/test/files/pos/t7294.scala @@ -0,0 +1,6 @@ +object Test { + // no fruitless warning as Tuple2 isn't (yet) final. + // The corresponding `neg` test will treat it as final + // for the purposes of these tests under -Xfuture. + (1, 2) match { case Seq() => 0; case _ => 1 } +} diff --git a/test/files/pos/t7296.scala b/test/files/pos/t7296.scala new file mode 100644 index 0000000000..0c078d3657 --- /dev/null +++ b/test/files/pos/t7296.scala @@ -0,0 +1,6 @@ +object Test { + type A = Int + // Emits the implementation restriction but then proceeds to crash + // when creating the Foo.unapply. + case class Foo(a: A, b: A, c: A, d: A, e: A, f: A, g: A, h: A, i: A, j: A, k: A, l: A, m: A, n: A, o: A, p: A, q: A, r: A, s: A, t: A, u: A, v: A, w: A, x: A, y: A, Z: A) +} diff --git a/test/files/pos/t7315.flags b/test/files/pos/t7315.flags new file mode 100644 index 0000000000..d1b831ea87 --- /dev/null +++ b/test/files/pos/t7315.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t7315.scala b/test/files/pos/t7315.scala new file mode 100644 index 0000000000..0abcea2451 --- /dev/null +++ b/test/files/pos/t7315.scala @@ -0,0 +1,4 @@ +package scala.pack + +@deprecatedInheritance +class C[@specialized A]
\ No newline at end of file diff --git a/test/files/pos/t7364/BadList.java b/test/files/pos/t7364/BadList.java new file mode 100644 index 0000000000..2692fa085f --- /dev/null +++ b/test/files/pos/t7364/BadList.java @@ -0,0 +1,3 @@ +public class BadList extends java.util.ArrayList { + public java.util.ArrayList foo() { return null; } +} diff --git a/test/files/pos/t7364/UseIt.scala b/test/files/pos/t7364/UseIt.scala new file mode 100644 index 0000000000..3847165323 --- /dev/null +++ b/test/files/pos/t7364/UseIt.scala @@ -0,0 +1,4 @@ +class UseIt { + val list = new BadList + list.foo() +} diff --git a/test/files/pos/t7364b/BadList_1.java b/test/files/pos/t7364b/BadList_1.java new file mode 100644 index 0000000000..fbb428adba --- /dev/null +++ b/test/files/pos/t7364b/BadList_1.java @@ -0,0 +1,3 @@ +public class BadList_1 extends java.util.ArrayList { + public java.util.ArrayList foo() { return null; } +} diff --git a/test/files/pos/t7364b/UseIt_2.scala b/test/files/pos/t7364b/UseIt_2.scala new file mode 100644 index 0000000000..06b50f6766 --- /dev/null +++ b/test/files/pos/t7364b/UseIt_2.scala @@ -0,0 +1,5 @@ +class UseIt { + val list = new BadList_1 + list.foo() + list.set(0, list.get(0)) +} diff --git a/test/files/pos/t7377b.flags b/test/files/pos/t7377b.flags deleted file mode 100644 index cb8324a345..0000000000 --- a/test/files/pos/t7377b.flags +++ /dev/null @@ -1 +0,0 @@ --Xoldpatmat
\ No newline at end of file diff --git a/test/files/pos/t7427.flags b/test/files/pos/t7427.flags new file mode 100644 index 0000000000..9c7d6400fc --- /dev/null +++ b/test/files/pos/t7427.flags @@ -0,0 +1 @@ +-Ydebug diff --git a/test/files/pos/t7427.scala b/test/files/pos/t7427.scala new file mode 100644 index 0000000000..cca52950d1 --- /dev/null +++ b/test/files/pos/t7427.scala @@ -0,0 +1,4 @@ +// Compiles with no options +// Compiles with -Ydebug -Ydisable-unreachable-prevention +// Crashes with -Ydebug +trait Bippy { 3 match { case 3 => } } diff --git a/test/files/pos/t7433.flags b/test/files/pos/t7433.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t7433.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t7433.scala b/test/files/pos/t7433.scala new file mode 100644 index 0000000000..f2109f4afa --- /dev/null +++ b/test/files/pos/t7433.scala @@ -0,0 +1,10 @@ +object Test { + def foo() { + try { + for (i <- 1 until 5) return + } catch { + case _: NullPointerException | _: RuntimeException => + // was: "catch block may intercept non-local return from method check" + } + } +} diff --git a/test/files/pos/t7520.scala b/test/files/pos/t7520.scala new file mode 100644 index 0000000000..747f5278e5 --- /dev/null +++ b/test/files/pos/t7520.scala @@ -0,0 +1,10 @@ +class A { + val x: Singleton with this.type = this + val y: this.type = x +} + +class B { + val x = "" + val xs: x.type with Singleton = x + val y: x.type = xs +} diff --git a/test/files/pos/t757.scala b/test/files/pos/t757.scala index 7513910d8d..fd7624cee7 100644 --- a/test/files/pos/t757.scala +++ b/test/files/pos/t757.scala @@ -1,4 +1,4 @@ -package foo { +package foo { object C { def foo { Console.println("foo") @@ -6,7 +6,7 @@ package foo { } } -package bar { +package bar { object Main extends App { foo.C.foo } diff --git a/test/files/pos/t758.scala b/test/files/pos/t758.scala index 44769d54f1..160bf37172 100644 --- a/test/files/pos/t758.scala +++ b/test/files/pos/t758.scala @@ -1,7 +1,7 @@ trait A { type T; type M >: T } -trait B extends A { - val x : String; - val u : A { type T = B.this.T } ; - type T = x.type; - type M = u.M +trait B extends A { + val x : String; + val u : A { type T = B.this.T } ; + type T = x.type; + type M = u.M } diff --git a/test/files/pos/t7584.scala b/test/files/pos/t7584.scala new file mode 100644 index 0000000000..52d127ecb9 --- /dev/null +++ b/test/files/pos/t7584.scala @@ -0,0 +1,11 @@ +object Test { + def fold[A, B](f: (A, => B) => B) = ??? + def f[A, B](x: A, y: B): B = ??? + def bip[A, B] = fold[A, B]((x, y) => f(x, y)) + def bop[A, B] = fold[A, B](f) + + // these work: + fold[Int, Int]((x, y) => f(x, y)) + fold[Int, Int](f) +} + diff --git a/test/files/pos/t7591/Demo.scala b/test/files/pos/t7591/Demo.scala new file mode 100644 index 0000000000..696d53585b --- /dev/null +++ b/test/files/pos/t7591/Demo.scala @@ -0,0 +1,83 @@ +/* NEST (New Scala Test) + * Copyright 2007-2013 LAMP/EPFL + * @author Paul Phillips + */ + +import scala.tools.cmd._ + +/** A sample command specification for illustrative purposes. + * First take advantage of the meta-options: + * + * // this command creates an executable runner script "demo" + * % scala scala.tools.cmd.Demo --self-update demo + * + * // this one creates and sources a completion file - note backticks + * % `./demo --bash` + * + * // and now you have a runner with working completion + * % ./demo --<tab> + * --action --defint --int + * --bash --defstr --str + * --defenv --self-update --unary + * + * The normal option configuration is plausibly self-explanatory. + */ +trait DemoSpec extends Spec with Meta.StdOpts with Interpolation { + lazy val referenceSpec = DemoSpec + lazy val programInfo = Spec.Info("demo", "Usage: demo [<options>]", "scala.tools.cmd.Demo") + + help("""Usage: demo [<options>]""") + heading("Unary options:") + + val optIsUnary = "unary" / "a unary option" --? ; + ("action" / "a body which may be run") --> println("Hello, I am the --action body.") + + heading("Binary options:") + val optopt = "str" / "an optional String" --| + val optoptInt = ("int" / "an optional Int") . --^[Int] + val optEnv = "defenv" / "an optional String" defaultToEnv "PATH" + val optDefault = "defstr" / "an optional String" defaultTo "default" + val optDefaultInt = "defint" / "an optional Int" defaultTo -1 + val optExpand = "alias" / "an option which expands" expandTo ("--int", "15") +} + +object DemoSpec extends DemoSpec with Property { + lazy val propMapper = new PropertyMapper(DemoSpec) + + type ThisCommandLine = SpecCommandLine + def creator(args: List[String]) = + new SpecCommandLine(args) { + override def errorFn(msg: String) = { println("Error: " + msg) ; sys.exit(0) } + } +} + +class Demo(args: List[String]) extends { + val parsed = DemoSpec(args: _*) +} with DemoSpec with Instance { + import java.lang.reflect._ + + def helpMsg = DemoSpec.helpMsg + def demoSpecMethods = this.getClass.getMethods.toList + private def isDemo(m: Method) = (m.getName startsWith "opt") && !(m.getName contains "$") && (m.getParameterTypes.isEmpty) + + def demoString(ms: List[Method]) = { + val longest = ms map (_.getName.length) max + val formatStr = " %-" + longest + "s: %s" + val xs = ms map (m => formatStr.format(m.getName, m.invoke(this))) + + xs mkString ("Demo(\n ", "\n ", "\n)\n") + } + + override def toString = demoString(demoSpecMethods filter isDemo) +} + +object Demo { + def main(args: Array[String]): Unit = { + val runner = new Demo(args.toList) + + if (args.isEmpty) + println(runner.helpMsg) + + println(runner) + } +} diff --git a/test/files/pos/t7668.scala b/test/files/pos/t7668.scala new file mode 100644 index 0000000000..222a13d039 --- /dev/null +++ b/test/files/pos/t7668.scala @@ -0,0 +1,12 @@ +trait Space { + type T + val x: T +} + +trait Extractor { + def extract(s: Space): s.T +} + +class Sub extends Extractor { + def extract(s: Space) = s.x +} diff --git a/test/files/pos/t767.scala b/test/files/pos/t767.scala index d4d7eae870..0c4067f022 100644 --- a/test/files/pos/t767.scala +++ b/test/files/pos/t767.scala @@ -4,7 +4,7 @@ abstract class AbsCell { private var value: T = init def get: T = value def set (x: T) { value = x } - + class Node { val foo = 1 } diff --git a/test/files/pos/t7689.scala b/test/files/pos/t7689.scala new file mode 100644 index 0000000000..022e7ab7a0 --- /dev/null +++ b/test/files/pos/t7689.scala @@ -0,0 +1,7 @@ +object A { + // The default getter must have an explicit return type (List[_] => Int) + // This wasn't happening since e28c3edda4. That commit encoded upper/lower + // bounds of Any/Nothing as EmptyTree, which were triggering an .isEmpty + // check in Namers#TypeTreeSubstitutor + def x(f: List[_] => Int = _ => 3) = 9 +} diff --git a/test/files/pos/t7690.scala b/test/files/pos/t7690.scala new file mode 100644 index 0000000000..e8911a93e8 --- /dev/null +++ b/test/files/pos/t7690.scala @@ -0,0 +1,17 @@ +object A +trait B[T] + +object C { + implicit def notUsed[L[x]](in: L[Int]): B[L[Int]] = ??? + + class E(val ls: Int) { + def x(f: Int => Boolean): Boolean = f(ls) + } + implicit def isUsed(ls: Int): E = new E(ls) + + def amethod(in: Int): Boolean = + in.x { i => + import A._ + "asdf" == i.toString + } +}
\ No newline at end of file diff --git a/test/files/pos/t7785.scala b/test/files/pos/t7785.scala new file mode 100644 index 0000000000..1de693d137 --- /dev/null +++ b/test/files/pos/t7785.scala @@ -0,0 +1,34 @@ +import scala.language._ + +trait R[+Repr] + +trait TraversableOps { + implicit val R: R[Nothing] = ??? + + // Removing the implicit parameter in both fixes the crash + // removing it into one only gives a valid compiler error. + trait OpsDup1[Repr] { + def force(implicit bf: R[Repr]): Any + } + + trait Ops[Repr] extends OpsDup1[Repr] { + def force(implicit bf: R[Repr], dummy: DummyImplicit): Any + } + + implicit def ct2ops[T, C[+X]](t: C[T]): + Ops[C[T]] + + def force[T](t: Option[T]) = + // ct2ops(t).force + t.force //Fails compilation on 2.10.2. + + + /* To get a closer look at the crash: + :power + val foo = typeOf[C].member(TermName("foo")) + val pt = analyzer.HasMember(TermName("force")) + val instantiated = foo.info.finalResultType.instantiateTypeParams(foo.typeParams, foo.typeParams.map(TypeVar(_))) + instantiated <:< pt + */ + def foo[T, C[+X]]: Ops[C[T]] +} diff --git a/test/files/pos/t7834.scala b/test/files/pos/t7834.scala new file mode 100644 index 0000000000..fc9a0aa09d --- /dev/null +++ b/test/files/pos/t7834.scala @@ -0,0 +1,6 @@ +class S { val q = "" } + +class B extends S { + val x1: B.super.q.type = q + val x2: B.this.q.type = q +} diff --git a/test/files/pos/t7847/A.scala b/test/files/pos/t7847/A.scala new file mode 100644 index 0000000000..b6cce6ee79 --- /dev/null +++ b/test/files/pos/t7847/A.scala @@ -0,0 +1,5 @@ +case class Blah(a: Int) + +object Blah { + def apply2(a: Int) = apply(a) +} diff --git a/test/files/pos/t7847/B.java b/test/files/pos/t7847/B.java new file mode 100644 index 0000000000..c214f2dcab --- /dev/null +++ b/test/files/pos/t7847/B.java @@ -0,0 +1,10 @@ +public final class B { + void blah() { + Blah x = Blah.apply2(1); + Blah y = Blah.apply(1); + Blah z = Blah$.MODULE$.apply(1); + + scala.Option un1 = Blah.unapply(null); + scala.Option un2 = Blah$.MODULE$.unapply(null); + } +} diff --git a/test/files/pos/t7853-partial-function.scala b/test/files/pos/t7853-partial-function.scala new file mode 100644 index 0000000000..b09254e99a --- /dev/null +++ b/test/files/pos/t7853-partial-function.scala @@ -0,0 +1,7 @@ +object Test { + + def testCons: Unit = { + def x[A](a: PartialFunction[Any, A]): A = a(0) + val eval0 = x { case list: List[Int @unchecked] => list } + } +} diff --git a/test/files/pos/t7853.scala b/test/files/pos/t7853.scala new file mode 100644 index 0000000000..b0e9221e22 --- /dev/null +++ b/test/files/pos/t7853.scala @@ -0,0 +1,11 @@ +trait S { + trait T { + this: Any => + + trait U { + trait V { + S.this + } + } + } +} diff --git a/test/files/pos/t7864.flags b/test/files/pos/t7864.flags new file mode 100644 index 0000000000..7ccd56103a --- /dev/null +++ b/test/files/pos/t7864.flags @@ -0,0 +1 @@ +-Xlint
\ No newline at end of file diff --git a/test/files/pos/t7864.scala b/test/files/pos/t7864.scala new file mode 100644 index 0000000000..b2d8911a17 --- /dev/null +++ b/test/files/pos/t7864.scala @@ -0,0 +1,5 @@ +object Test { + val f = 0; + ({ toString; (x: Any) => x})("$f ") +} + diff --git a/test/files/pos/t788.scala b/test/files/pos/t788.scala index 3da88a2d26..19638dd170 100644 --- a/test/files/pos/t788.scala +++ b/test/files/pos/t788.scala @@ -4,7 +4,7 @@ trait Test { type Node <: NodeImpl; trait NodeImpl; type Expression <: Node with ExpressionImpl; - trait ExpressionImpl extends NodeImpl { + trait ExpressionImpl extends NodeImpl { def self : Expression; } type Named <: Node with NamedImpl; diff --git a/test/files/pos/t802.scala b/test/files/pos/t802.scala index 124d4915bc..2dea7036d6 100644 --- a/test/files/pos/t802.scala +++ b/test/files/pos/t802.scala @@ -1,17 +1,17 @@ package test; trait Test { - abstract class BracesImpl { + abstract class BracesImpl { type Singleton; type Brace <: Singleton with BraceImpl; - trait BraceImpl; + trait BraceImpl; trait ForFile; } - abstract class ParensImpl extends BracesImpl { + abstract class ParensImpl extends BracesImpl { type Brace <: Singleton with BraceImpl; trait BraceImpl extends super.BraceImpl; } val parens : ParensImpl; - abstract class BracksImpl extends BracesImpl { + abstract class BracksImpl extends BracesImpl { type Brace <: Singleton with BraceImpl; trait BraceImpl extends super.BraceImpl; } diff --git a/test/files/pos/t807.scala b/test/files/pos/t807.scala index ed73fe3f97..0eeb92ea24 100644 --- a/test/files/pos/t807.scala +++ b/test/files/pos/t807.scala @@ -6,7 +6,7 @@ trait Matcher { trait HasLinks { def link(b : Boolean) : Link = null; } - + } trait BraceMatcher extends Matcher { trait BracePair { diff --git a/test/files/pos/t880.scala b/test/files/pos/t880.scala deleted file mode 100644 index cceb53c398..0000000000 --- a/test/files/pos/t880.scala +++ /dev/null @@ -1,6 +0,0 @@ -import scala.xml.Null - -class Test[A >: Null] -{ - val x : A = null -} diff --git a/test/files/pos/t911.scala b/test/files/pos/t911.scala index 224b14cda3..cfa4f49dc1 100644 --- a/test/files/pos/t911.scala +++ b/test/files/pos/t911.scala @@ -1,6 +1,6 @@ object Test { -def foo : Any = { - case class Foo {} - Foo; -} + def foo: Any = { + case class Foo() {} + Foo; + } } diff --git a/test/files/pos/t927.scala b/test/files/pos/t927.scala index 534f355045..c903f19867 100644 --- a/test/files/pos/t927.scala +++ b/test/files/pos/t927.scala @@ -7,5 +7,5 @@ object Test { } val str: Stream[Int] = List(1,2,3).iterator.toStream assert(sum(str) == 6) - + } diff --git a/test/files/pos/t946.scala b/test/files/pos/t946.scala index 9f4cdbc043..c4bd6e9ba4 100644 --- a/test/files/pos/t946.scala +++ b/test/files/pos/t946.scala @@ -1,7 +1,7 @@ object pmbugbounds { trait Bar class Foo[t <: Bar] {} - + (new Foo[Bar]) match { case _ : Foo[x] => null } diff --git a/test/files/pos/tcpoly_boundedmonad.scala b/test/files/pos/tcpoly_boundedmonad.scala index 24a911769b..8c605dc7b6 100644 --- a/test/files/pos/tcpoly_boundedmonad.scala +++ b/test/files/pos/tcpoly_boundedmonad.scala @@ -1,19 +1,19 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { - def map[S <: Bound[S]](f: T => S): MyType[S] + def map[S <: Bound[S]](f: T => S): MyType[S] - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] + (f: T => Result[S]): Result[S] def filter(p: T => Boolean): MyType[T] } class Set[T <: Ordered[T]] extends Monad[T, Set, Ordered] { - def map[S <: Ordered[S]](f: T => S): Set[S] = error("TODO") - - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def map[S <: Ordered[S]](f: T => S): Set[S] = sys.error("TODO") + + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] = error("TODO") - - def filter(p: T => Boolean): Set[T] = error("TODO") + (f: T => Result[S]): Result[S] = sys.error("TODO") + + def filter(p: T => Boolean): Set[T] = sys.error("TODO") } diff --git a/test/files/pos/tcpoly_bounds1.scala b/test/files/pos/tcpoly_bounds1.scala index 142c0b7b7f..5874cc664d 100644 --- a/test/files/pos/tcpoly_bounds1.scala +++ b/test/files/pos/tcpoly_bounds1.scala @@ -1,6 +1,6 @@ -class Foo[t[x]<: Pair[Int, x]] +class Foo[t[x]<: Pair[Int, x]] -// +// class MyPair[z](a: Int, b: z) extends Pair[Int, z](a,b) object foo extends Foo[MyPair] diff --git a/test/files/pos/tcpoly_checkkinds_mix.scala b/test/files/pos/tcpoly_checkkinds_mix.scala index 2d265da6b9..3734405f8b 100644 --- a/test/files/pos/tcpoly_checkkinds_mix.scala +++ b/test/files/pos/tcpoly_checkkinds_mix.scala @@ -2,9 +2,9 @@ trait Iterable[A <: Bound[A], Bound[_]] { type MyType[x <: Bound[x]] <: Iterable[x, Bound] def map[B <: Bound[B]](f: A => B): MyType[B] def flatMap[B <: Bound[B]](f: A => MyType[B]): MyType[B] - def filter(p: A => Boolean): MyType[A] + def filter(p: A => Boolean): MyType[A] } -trait OrderedSet[T <: Ordered[T]] extends Iterable[T, Ordered] { +trait OrderedSet[T <: Ordered[T]] extends Iterable[T, Ordered] { type MyType[x <: Ordered[x]] = OrderedSet[x] -} +} diff --git a/test/files/pos/tcpoly_gm.scala b/test/files/pos/tcpoly_gm.scala index ecaeef9679..89b66cfba6 100644 --- a/test/files/pos/tcpoly_gm.scala +++ b/test/files/pos/tcpoly_gm.scala @@ -1,4 +1,4 @@ -trait Rep[a] { +trait Rep[a] { def rep[m[x]]: m[a] // typedTypeApply must use asSeenFrom to adapt the return type // since rep is called on x: Rep[t] // a must become t @@ -9,7 +9,6 @@ case class ShowBin[b](app: b => String) object foo { def showBin[t](x: Rep[t], y: t): String = { val r: ShowBin[t] = x.rep[ShowBin] - r.app(y) + r.app(y) } } - diff --git a/test/files/pos/tcpoly_higherorder_bound_method.scala b/test/files/pos/tcpoly_higherorder_bound_method.scala index 090bb8fcf3..3905b3b96d 100644 --- a/test/files/pos/tcpoly_higherorder_bound_method.scala +++ b/test/files/pos/tcpoly_higherorder_bound_method.scala @@ -1,3 +1,3 @@ trait SkolemisationOfHigherOrderBoundInMethod { def method[A, N[X <: A], M[X <: N[A]]]: Unit -} +} diff --git a/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala b/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala index 97594d506d..f719972a17 100644 --- a/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala +++ b/test/files/pos/tcpoly_infer_explicit_tuple_wrapper.scala @@ -2,15 +2,15 @@ import scala.collection.generic.GenericTraversableTemplate import scala.collection.Iterable class IterableOps[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) { - def unzip: (CC[A1], CC[A2]) = error("foo") + def unzip: (CC[A1], CC[A2]) = sys.error("foo") } object Test { - implicit def tupleOfIterableWrapper[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) + implicit def tupleOfIterableWrapper[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) = new IterableOps[CC, A1, A2](tuple) - + val t = (List(1, 2, 3), List(6, 5, 4)) tupleOfIterableWrapper(t) unzip -}
\ No newline at end of file +} diff --git a/test/files/pos/tcpoly_infer_implicit_tuple_wrapper.scala b/test/files/pos/tcpoly_infer_implicit_tuple_wrapper.scala index 3073b298de..19243505b4 100644 --- a/test/files/pos/tcpoly_infer_implicit_tuple_wrapper.scala +++ b/test/files/pos/tcpoly_infer_implicit_tuple_wrapper.scala @@ -2,7 +2,7 @@ import scala.collection.generic.GenericTraversableTemplate import scala.collection.Iterable class IterableOps[CC[+B] <: Iterable[B] with GenericTraversableTemplate[B, CC], A1, A2](tuple: (CC[A1], Iterable[A2])) { - def unzip: (CC[A1], CC[A2]) = error("foo") + def unzip: (CC[A1], CC[A2]) = sys.error("foo") } object Test { @@ -15,4 +15,4 @@ object Test { tupleOfIterableWrapper(t) unzip t unzip -}
\ No newline at end of file +} diff --git a/test/files/pos/tcpoly_late_method_params.scala b/test/files/pos/tcpoly_late_method_params.scala index c9298918a0..e2f0bcffb3 100644 --- a/test/files/pos/tcpoly_late_method_params.scala +++ b/test/files/pos/tcpoly_late_method_params.scala @@ -1,5 +1,5 @@ trait Foo { - def flatMap[RT <: RBound[RT], RBound[_], Result[x <: RBound[x]]]: Result[RT] + def flatMap[RT <: RBound[RT], RBound[_], Result[x <: RBound[x]]]: Result[RT] // bounds for RT& = >: scala.this.Nothing <: RBound&[RT&] // bounds for x = >: scala.this.Nothing <: RBound&[x] } diff --git a/test/files/pos/tcpoly_method.scala b/test/files/pos/tcpoly_method.scala index 80dc0482fd..294b53b915 100644 --- a/test/files/pos/tcpoly_method.scala +++ b/test/files/pos/tcpoly_method.scala @@ -1,6 +1,6 @@ trait Iterable[m[+x], +t] { def flatMap[resColl[+x] <: Iterable[resColl, x], s](f: t => resColl[s]): resColl[s] - + def foo[a[x]] = "a" val x = foo[List] } diff --git a/test/files/pos/tcpoly_overloaded.scala b/test/files/pos/tcpoly_overloaded.scala index 4240074d85..4f6334685b 100644 --- a/test/files/pos/tcpoly_overloaded.scala +++ b/test/files/pos/tcpoly_overloaded.scala @@ -1,10 +1,10 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + (f: T => Result[S]): Result[S] + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S], foo: String): Result[S] + (f: T => Result[S], foo: String): Result[S] def flatMap[S <: Bound[S]] (f: T => MyType[S], foo: Int): MyType[S] } @@ -12,14 +12,14 @@ trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] { trait Test { def moo: MList[Int] class MList[T](el: T) extends Monad[T, List, Any] { - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S]): Result[S] = error("foo") - def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], + (f: T => Result[S]): Result[S] = sys.error("foo") + def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_], Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]] - (f: T => Result[S], foo: String): Result[S] = error("foo") + (f: T => Result[S], foo: String): Result[S] = sys.error("foo") def flatMap[S] - (f: T => List[S], foo: Int): List[S] = error("foo") + (f: T => List[S], foo: Int): List[S] = sys.error("foo") } val l: MList[String] = moo.flatMap[String, List, Any, MList]((x: Int) => new MList("String")) } diff --git a/test/files/pos/tcpoly_poly.scala b/test/files/pos/tcpoly_poly.scala index 50ffc7837f..1ba04e29df 100644 --- a/test/files/pos/tcpoly_poly.scala +++ b/test/files/pos/tcpoly_poly.scala @@ -1,3 +1,3 @@ -class Monad[m[x]] +class Monad[m[x]] object ml extends Monad[List] diff --git a/test/files/pos/tcpoly_return_overriding.scala b/test/files/pos/tcpoly_return_overriding.scala index 0814e73fa4..57ec8da76c 100644 --- a/test/files/pos/tcpoly_return_overriding.scala +++ b/test/files/pos/tcpoly_return_overriding.scala @@ -2,7 +2,7 @@ trait Generic[g[x]] { def unit: g[Unit] } -trait Rep[t] { +trait Rep[t] { def rep[m[x]](implicit gen: Generic[m]): m[t] } diff --git a/test/files/pos/tcpoly_seq.scala b/test/files/pos/tcpoly_seq.scala index b5f46f6b6b..48b3e1ce52 100644 --- a/test/files/pos/tcpoly_seq.scala +++ b/test/files/pos/tcpoly_seq.scala @@ -6,40 +6,40 @@ trait HOSeq { // 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] + 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 + // 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 = iterator 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 = iterator 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] = { + 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 = iterator @@ -48,9 +48,9 @@ trait HOSeq { while (elemss.hasNext) buf += elemss.next } buf.result - } + } } - + final class ListBuffer[A] { private var start: List[A] = Nil private var last: ::[A] = _ @@ -78,7 +78,7 @@ trait HOSeq { exported = !start.isEmpty start } - + /** Clears the buffer contents. */ def clear { @@ -97,13 +97,13 @@ trait HOSeq { } } } - + 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] @@ -121,14 +121,14 @@ trait HOSeq { // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t def accumulator[t]: Accumulator[List, t] = listAccumulator[t] } - + // 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 = @@ -157,18 +157,18 @@ trait HOSeq { 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 + 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/test/files/pos/tcpoly_seq_typealias.scala b/test/files/pos/tcpoly_seq_typealias.scala index 0651ad9760..fb48126ce6 100644 --- a/test/files/pos/tcpoly_seq_typealias.scala +++ b/test/files/pos/tcpoly_seq_typealias.scala @@ -6,42 +6,42 @@ trait HOSeq { // 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] + 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 + // 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[+t] { - type m[+x] - + type m[+x] + //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 = iterator 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 = iterator 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[x], s](f: t => resColl[s])(implicit buf: Accumulator[resColl, s]): resColl[s] = { + def flatMap[resColl[+x] <: Iterable[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 = iterator @@ -50,9 +50,9 @@ trait HOSeq { while (elemss.hasNext) buf += elemss.next } buf.result - } + } } - + final class ListBuffer[A] { private var start: List[A] = Nil private var last: ::[A] = _ @@ -80,7 +80,7 @@ trait HOSeq { exported = !start.isEmpty start } - + /** Clears the buffer contents. */ def clear { @@ -99,16 +99,16 @@ trait HOSeq { } } } - + 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[t] { type m[+x] = List[x] - + def head: t def tail: List[t] def isEmpty: Boolean @@ -125,14 +125,14 @@ trait HOSeq { // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t def accumulator[t]: Accumulator[List, t] = listAccumulator[t] } - + // 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 = diff --git a/test/files/pos/tcpoly_subst.scala b/test/files/pos/tcpoly_subst.scala index f8ddb9a715..88cc4d0610 100644 --- a/test/files/pos/tcpoly_subst.scala +++ b/test/files/pos/tcpoly_subst.scala @@ -1,4 +1,4 @@ object test { - def make[m[x], b]: m[b] = error("foo") + def make[m[x], b]: m[b] = sys.error("foo") val lst: List[Int] = make[List, Int] } diff --git a/test/files/pos/tcpoly_variance_pos.scala b/test/files/pos/tcpoly_variance_pos.scala index b641716d50..b63abce202 100644 --- a/test/files/pos/tcpoly_variance_pos.scala +++ b/test/files/pos/tcpoly_variance_pos.scala @@ -1,7 +1,7 @@ class A[m[+x]] { - def str: m[Object] = error("foo") + def str: m[Object] = sys.error("foo") } class B[m[+x]] extends A[m] { - override def str: m[String] = error("foo") + override def str: m[String] = sys.error("foo") } diff --git a/test/files/pos/tcpoly_wildcards.scala b/test/files/pos/tcpoly_wildcards.scala index d3bb86b591..f6d1b666d0 100644 --- a/test/files/pos/tcpoly_wildcards.scala +++ b/test/files/pos/tcpoly_wildcards.scala @@ -1,3 +1,3 @@ trait test[b[_,_]] { - def moo[a[_, _]] = error("a") + def moo[a[_, _]] = sys.error("a") } diff --git a/test/files/pos/ted.scala b/test/files/pos/ted.scala index d8ae64f29b..314f109328 100644 --- a/test/files/pos/ted.scala +++ b/test/files/pos/ted.scala @@ -9,7 +9,7 @@ object App case (b, e) => b * exponentiate(b, e - 1) } - + def main(args : Array[String]) = System.out.println(exponentiate(2, 2)) diff --git a/test/files/pos/test5.scala b/test/files/pos/test5.scala index b04de5d613..4dbafc9ac3 100644 --- a/test/files/pos/test5.scala +++ b/test/files/pos/test5.scala @@ -53,7 +53,7 @@ object test { // Check type j.P j.chk_ip(val_mp); - j.chk_ip(val_np); + j.chk_ip(val_np); // Check type i.X i.chk_ix(i.val_ix); @@ -63,6 +63,6 @@ object test { // Check j.X j.chk_ix(j.val_ix); j.chk_ix(j.val_jx); - j.chk_ix(val_njx); + j.chk_ix(val_njx); } } diff --git a/test/files/pos/test5refine.scala b/test/files/pos/test5refine.scala index 290449c3ed..5459b3b975 100644 --- a/test/files/pos/test5refine.scala +++ b/test/files/pos/test5refine.scala @@ -60,7 +60,7 @@ object test { // Check type j.P j.chk_ip(val_mp); - j.chk_ip(val_np); + j.chk_ip(val_np); // Check type i.X i.chk_ix(i.val_ix); @@ -70,6 +70,6 @@ object test { // Check j.X j.chk_ix(j.val_ix); j.chk_ix(j.val_jx); - j.chk_ix(val_njx); + j.chk_ix(val_njx); } } diff --git a/test/files/pos/testCoercionThis.scala b/test/files/pos/testCoercionThis.scala index 8bbfdcd684..5631b33306 100644 --- a/test/files/pos/testCoercionThis.scala +++ b/test/files/pos/testCoercionThis.scala @@ -11,9 +11,9 @@ object Test { // PP: is that something we really want to work? Seems like sketchville. // // These work, so I moved this out of pending. - def testCoercionThis1 = this.baz + def testCoercionThis1 = this.baz def testCoercionThis2 = (this: Foo).baz } - - class Bar { def baz = System.out.println("baz") } + + class Bar { def baz = System.out.println("baz") } } diff --git a/test/files/pos/thistypes.scala b/test/files/pos/thistypes.scala index 26339e07c4..7319cc1ecb 100644 --- a/test/files/pos/thistypes.scala +++ b/test/files/pos/thistypes.scala @@ -5,4 +5,4 @@ trait B { trait C extends B { def foo: C.this.I; -} +} diff --git a/test/files/pos/ticket0137.scala b/test/files/pos/ticket0137.scala index 72f955fe5e..94ef8e49fc 100644 --- a/test/files/pos/ticket0137.scala +++ b/test/files/pos/ticket0137.scala @@ -1,7 +1,7 @@ -trait AbsM { - abstract class MonadCompanion[M[_]] +trait AbsM { + abstract class MonadCompanion[M[_]] abstract class AbsMonadCompanion extends MonadCompanion[AM] { - def newTag: Int + def newTag: Int } type AM[_] // to trigger the bug, this must be an abstract type member that comes after the reference to it diff --git a/test/files/pos/ticket2251.scala b/test/files/pos/ticket2251.scala index b3afee4ea9..c220e85350 100644 --- a/test/files/pos/ticket2251.scala +++ b/test/files/pos/ticket2251.scala @@ -22,4 +22,18 @@ lub of List(D, C) is B[_2] forSome { type _2 >: D with C{} <: B[_1] forSome { ty // should be: B[X] forSome {type X <: B[X]} -- can this be done automatically? for now, just detect f-bounded polymorphism and fall back to more coarse approximation val data: List[A] = List(new C, new D) + + val data2 = List(new C, new D) + + val data3: List[B[X] forSome { type X <: B[_ <: A] }] = List(new C, new D) + + // Not yet -- + // val data4: List[B[X] forSome { type X <: B[X] }] = List(new C, new D) + // <console>:7: error: type mismatch; + // found : List[B[_ >: D with C <: B[_ >: D with C <: A]]] + // required: List[B[X] forSome { type X <: B[X] }] + // val data4: List[B[X] forSome { type X <: B[X] }] = List(new C, new D) + + // works + val data5 = List[B[X] forSome { type X <: B[X] }](new C, new D) } diff --git a/test/files/pos/trait-force-info.scala b/test/files/pos/trait-force-info.scala index e01d225c84..c2b33869c3 100644 --- a/test/files/pos/trait-force-info.scala +++ b/test/files/pos/trait-force-info.scala @@ -8,7 +8,7 @@ trait MyContextTrees { val self: Global val NoContext = self.analyzer.NoContext } -// +// // error: java.lang.AssertionError: assertion failed: trait Contexts.NoContext$ linkedModule: <none>List() // at scala.Predef$.assert(Predef.scala:160) // at scala.tools.nsc.symtab.classfile.ClassfileParser$innerClasses$.innerSymbol$1(ClassfileParser.scala:1211) diff --git a/test/files/pos/trait-parents.scala b/test/files/pos/trait-parents.scala index f6a2688751..c5908cdcd9 100644 --- a/test/files/pos/trait-parents.scala +++ b/test/files/pos/trait-parents.scala @@ -6,11 +6,11 @@ trait Quux object Test { def f(x: Bip) = 1 def g1(x: Foo with Bip) = f(x) - + def main(args: Array[String]): Unit = { - f(new Bip with Foo { }) + f(new Bip with Foo { }) f(new Foo with Bip { }) - g1(new Bip with Foo { }) + g1(new Bip with Foo { }) g1(new Foo with Bip { }) } } diff --git a/test/files/pos/traits.scala b/test/files/pos/traits.scala index bd64d7215a..3c6f9437a5 100644 --- a/test/files/pos/traits.scala +++ b/test/files/pos/traits.scala @@ -20,8 +20,8 @@ object Test { trait BorderedColoredShape extends Shape with Bordered with Colored { override def equals(other: Any) = other match { case that: BorderedColoredShape => ( - super.equals(that) && - super[Bordered].equals(that) && + super.equals(that) && + super[Bordered].equals(that) && super[Colored].equals(that)) case _ => false } diff --git a/test/files/pos/typealias_dubious.scala b/test/files/pos/typealias_dubious.scala index 587453a037..cdba1a64d0 100644 --- a/test/files/pos/typealias_dubious.scala +++ b/test/files/pos/typealias_dubious.scala @@ -1,15 +1,15 @@ class MailBox { - //class Message + //class Message type Message = AnyRef -} - +} + abstract class Actor { private val in = new MailBox - def send(msg: in.Message) = error("foo") + def send(msg: in.Message) = sys.error("foo") - def unstable: Actor = error("foo") + def unstable: Actor = sys.error("foo") - def dubiousSend(msg: MailBox#Message) = + def dubiousSend(msg: MailBox#Message) = unstable.send(msg) // in.Message becomes unstable.Message, but that's ok since Message is a concrete type member -} +} diff --git a/test/files/pos/typealiases.scala b/test/files/pos/typealiases.scala index 5974921ed3..d03b521f77 100644 --- a/test/files/pos/typealiases.scala +++ b/test/files/pos/typealiases.scala @@ -3,18 +3,18 @@ package foo trait Test[T] { type Check[T] = Array[T] => Unit; type MyPair[S] = (T, S) - + val pair1: (T, Int) val pair: MyPair[Int] = pair1 - + def check(xs: Array[T], c: Check[T]) = c(xs) - def check2[S](xs: Array[S], c: Check[S]) = c(xs) -} + def check2[S](xs: Array[S], c: Check[S]) = c(xs) +} -object main extends Test[Int] { - val pair1 = (1,1) +object main extends Test[Int] { + val pair1 = (1,1) implicit def topair(x: Int): Pair[Int, Int] = (x,x) - val pair2: MyPair[Int] = 1 + val pair2: MyPair[Int] = 1 val x: Short = 1 } diff --git a/test/files/pos/unapplyNeedsMemberType.scala b/test/files/pos/unapplyNeedsMemberType.scala index 2581512a7b..b423257e04 100644 --- a/test/files/pos/unapplyNeedsMemberType.scala +++ b/test/files/pos/unapplyNeedsMemberType.scala @@ -8,7 +8,7 @@ trait Gunk[a] { def unapply(s: Seq) = unapply_Cons(s) } def unapply_Cons(s: Any): Option[Tuple2[a, Seq]] -} +} class Join[a] extends Gunk[a] { type Seq = JoinSeq diff --git a/test/files/pos/unapplySeq.scala b/test/files/pos/unapplySeq.scala index 4d5409c6f7..6d13cc8b52 100644 --- a/test/files/pos/unapplySeq.scala +++ b/test/files/pos/unapplySeq.scala @@ -4,7 +4,7 @@ object FooSeq { val y = x.asInstanceOf[Bar] Some(y.size, y.name) } else None - } + } def main(args:Array[String]) = { val b = new Bar diff --git a/test/files/pos/unapplyVal.scala b/test/files/pos/unapplyVal.scala index 0d6394a90f..368b9b9375 100644 --- a/test/files/pos/unapplyVal.scala +++ b/test/files/pos/unapplyVal.scala @@ -10,7 +10,7 @@ class Buffer { def joinPat(x: Any): Unit = { x match { - case Put => + case Put => case Put(y) => println("returning "+y) } @@ -29,7 +29,7 @@ object unapplyJoins extends App { // bug #1257 object Get extends Sync val jp: PartialFunction[Any, Any] = { - case Get() => + case Get() => } } diff --git a/test/files/pos/variances-flip.scala b/test/files/pos/variances-flip.scala new file mode 100644 index 0000000000..c3ea7b571d --- /dev/null +++ b/test/files/pos/variances-flip.scala @@ -0,0 +1,7 @@ +trait Foo[-A, +B, -C, +D] { + private[this] def b: B = ??? + private[this] def d: D = ??? + + def f(p1: B => A, p2: D => C) = g(p1(b), p2(d)) + def g(x: A, y: C) = ((b, d)) +} diff --git a/test/files/pos/variances-local.scala b/test/files/pos/variances-local.scala new file mode 100644 index 0000000000..35e395095c --- /dev/null +++ b/test/files/pos/variances-local.scala @@ -0,0 +1,7 @@ +class Foo1[+T] { + private[this] type MyType = T +} + +class Foo2[+T] { + protected[this] type MyType = T +} diff --git a/test/files/pos/virtpatmat_binding_opt.scala b/test/files/pos/virtpatmat_binding_opt.scala index 962e3d7dbe..8ec931fe78 100644 --- a/test/files/pos/virtpatmat_binding_opt.scala +++ b/test/files/pos/virtpatmat_binding_opt.scala @@ -4,8 +4,8 @@ class Test { case that: Test2 => println(that) this - case _ => error("meh") + case _ => sys.error("meh") } } -class Test2 extends Test
\ No newline at end of file +class Test2 extends Test diff --git a/test/files/pos/virtpatmat_castbinder.scala b/test/files/pos/virtpatmat_castbinder.scala index 53e937e866..be269638ce 100644 --- a/test/files/pos/virtpatmat_castbinder.scala +++ b/test/files/pos/virtpatmat_castbinder.scala @@ -6,7 +6,7 @@ trait IntMapIterator[V, T] { def valueOf(tip: Tip[V]): T def pop: IntMap[V] - def next: T = + def next: T = pop match { case Bin(t@Tip(_)) => { valueOf(t) diff --git a/test/files/pos/virtpatmat_exist1.scala b/test/files/pos/virtpatmat_exist1.scala index ccb91299db..6cad017b0b 100644 --- a/test/files/pos/virtpatmat_exist1.scala +++ b/test/files/pos/virtpatmat_exist1.scala @@ -13,7 +13,7 @@ object Test { // without type ascription for the one in the body of the last flatmap of each alternative, type inference borks on the existentials // def splitArray[T >: Nothing <: Any](ad: Array[Iterable[T]]): Any = { import OptionMatching._ // runOrElse(ad.apply(0))(((x1: Iterable[T]) => ( - // or(((x4: Iterable[T]) => one(null)), + // or(((x4: Iterable[T]) => one(null)), // guard(x1.isInstanceOf[Iterable[T] with Test.HashMapCollision1[_,_]], x1.asInstanceOf[Iterable[T] with Test.HashMapCollision1[_,_]]).flatMap(((x2: Iterable[T] with Test.HashMapCollision1[_,_]) => one(x2))), // guard(x1.isInstanceOf[Test.HashSetCollision1[_]], x1.asInstanceOf[Iterable[T] with Test.HashSetCollision1[_]]).flatMap(((x3: Iterable[T] with Test.HashSetCollision1[_]) => one(x3)))): Option[Any]).orElse( // (zero: Option[Any]))) diff --git a/test/files/pos/virtpatmat_exist2.scala b/test/files/pos/virtpatmat_exist2.scala index b0e4c667b7..ee186074ab 100644 --- a/test/files/pos/virtpatmat_exist2.scala +++ b/test/files/pos/virtpatmat_exist2.scala @@ -9,11 +9,11 @@ object Test { // what's the _$1 doing there? // def grow[T >: Nothing <: Any]: ParseResult[T] = { // import OptionMatching._ - // runOrElse[MemoEntry[T], ParseResult[T]]((null: MemoEntry[T]))(((x1: MemoEntry[T]) => - // (MemoEntry.unapply[T](x1).flatMap[ParseResult[T]](((x4: Either[Nothing,ParseResult[_]]) => - // guard[Right[Nothing,ParseResult[_]]](x4.isInstanceOf[Right[Nothing,ParseResult[_]]], x4.asInstanceOf[Right[Nothing,ParseResult[_]]]).flatMap[ParseResult[T]](((cp3: Right[Nothing,ParseResult[_]]) => - // scala.Right.unapply[Nothing, ParseResult[_]](cp3).flatMap[ParseResult[T]](((x5: ParseResult[_]) => - // guard[ParseResult[_$1]](x5.ne(null), x5.asInstanceOf[ParseResult[_]]).flatMap[ParseResult[T]](((x6: ParseResult[_]) => + // runOrElse[MemoEntry[T], ParseResult[T]]((null: MemoEntry[T]))(((x1: MemoEntry[T]) => + // (MemoEntry.unapply[T](x1).flatMap[ParseResult[T]](((x4: Either[Nothing,ParseResult[_]]) => + // guard[Right[Nothing,ParseResult[_]]](x4.isInstanceOf[Right[Nothing,ParseResult[_]]], x4.asInstanceOf[Right[Nothing,ParseResult[_]]]).flatMap[ParseResult[T]](((cp3: Right[Nothing,ParseResult[_]]) => + // scala.Right.unapply[Nothing, ParseResult[_]](cp3).flatMap[ParseResult[T]](((x5: ParseResult[_]) => + // guard[ParseResult[_$1]](x5.ne(null), x5.asInstanceOf[ParseResult[_]]).flatMap[ParseResult[T]](((x6: ParseResult[_]) => // one[ParseResult[T]](x6.asInstanceOf[ParseResult[T]]))))))))): Option[ParseResult[T]] // ).orElse[ParseResult[T]]((zero: Option[ParseResult[T]])))) // } diff --git a/test/files/pos/virtpatmat_exist3.scala b/test/files/pos/virtpatmat_exist3.scala index c8f873878f..94385f32c9 100644 --- a/test/files/pos/virtpatmat_exist3.scala +++ b/test/files/pos/virtpatmat_exist3.scala @@ -4,8 +4,8 @@ class ReferenceQueue[T] { case null => null } - // def wrapper(jref: ReferenceQueue[_]): ReferenceQueue[T] = OptionMatching.runOrElse(jref)(((x1: ReferenceQueue[_]) => - // (OptionMatching.guard(null.==(x1), x1.asInstanceOf[ReferenceQueue[_]]).flatMap(((x2: ReferenceQueue[_]) => + // def wrapper(jref: ReferenceQueue[_]): ReferenceQueue[T] = OptionMatching.runOrElse(jref)(((x1: ReferenceQueue[_]) => + // (OptionMatching.guard(null.==(x1), x1.asInstanceOf[ReferenceQueue[_]]).flatMap(((x2: ReferenceQueue[_]) => // OptionMatching.one(null))): Option[ReferenceQueue[T]]).orElse( // (OptionMatching.zero: Option[ReferenceQueue[T]]))) // ) diff --git a/test/files/pos/virtpatmat_gadt_array.scala b/test/files/pos/virtpatmat_gadt_array.scala index 27e72aa03e..f3332a897f 100644 --- a/test/files/pos/virtpatmat_gadt_array.scala +++ b/test/files/pos/virtpatmat_gadt_array.scala @@ -4,12 +4,12 @@ object Test { case x: Array[AnyRef] => refArrayOps[AnyRef](x).asInstanceOf[ArrayOps[T]] case null => null } - // def genericArrayOps[T >: Nothing <: Any](xs: Array[T]): scala.collection.mutable.ArrayOps[T] - // = OptionMatching.runOrElse(xs)(((x1: Array[T]) => - // ((OptionMatching.guard(x1.isInstanceOf[Array[AnyRef]], x1.asInstanceOf[Array[T] with Array[AnyRef]]).flatMap(((x2: Array[T] with Array[AnyRef]) => + // def genericArrayOps[T >: Nothing <: Any](xs: Array[T]): scala.collection.mutable.ArrayOps[T] + // = OptionMatching.runOrElse(xs)(((x1: Array[T]) => + // ((OptionMatching.guard(x1.isInstanceOf[Array[AnyRef]], x1.asInstanceOf[Array[T] with Array[AnyRef]]).flatMap(((x2: Array[T] with Array[AnyRef]) => // OptionMatching.one(Test.this.refArrayOps[AnyRef](x2).asInstanceOf[scala.collection.mutable.ArrayOps[T]]))): Option[scala.collection.mutable.ArrayOps[T]]).orElse( - // (OptionMatching.guard(null.==(x1), x1.asInstanceOf[Array[T]]).flatMap(((x3: Array[T]) => + // (OptionMatching.guard(null.==(x1), x1.asInstanceOf[Array[T]]).flatMap(((x3: Array[T]) => // OptionMatching.one(null))): Option[scala.collection.mutable.ArrayOps[T]])): Option[scala.collection.mutable.ArrayOps[T]]).orElse((OptionMatching.zero: Option[scala.collection.mutable.ArrayOps[T]])))) - + def refArrayOps[T <: AnyRef](xs: Array[T]): ArrayOps[T] = new ArrayOps.ofRef[T](xs) }
\ No newline at end of file diff --git a/test/files/positions/Anon.scala b/test/files/positions/Anon.scala index 65eb7ae477..940fff035a 100644 --- a/test/files/positions/Anon.scala +++ b/test/files/positions/Anon.scala @@ -2,7 +2,7 @@ object Anon { trait Foo { val bar : Int } - + def foo = new Foo { override val bar = 23 } diff --git a/test/files/positions/Enclosing1.scala b/test/files/positions/Enclosing1.scala index 7c8fbaf4a0..e170187d60 100644 --- a/test/files/positions/Enclosing1.scala +++ b/test/files/positions/Enclosing1.scala @@ -1,5 +1,5 @@ object Enclosing1 { do { - + } while (true) } diff --git a/test/files/positions/ExcludedPrefix1.scala b/test/files/positions/ExcludedPrefix1.scala index 72d9756b2a..f3562c37f0 100644 --- a/test/files/positions/ExcludedPrefix1.scala +++ b/test/files/positions/ExcludedPrefix1.scala @@ -5,16 +5,16 @@ object ExcludedPrefix1 { case object BLAH - + val a = 1 - + var b = 2 - + def c = 23 - + private def d = 23 @@ -22,19 +22,19 @@ object ExcludedPrefix1 { lazy val e = 23 - + private type f = Int - + val g, h = 23 - + val (i, j) = (0, 0) - + val Pair( k, l) = (0, 0) diff --git a/test/files/positions/Overlap3.scala b/test/files/positions/Overlap3.scala index 657c12d4fd..4c5f8af9d1 100644 --- a/test/files/positions/Overlap3.scala +++ b/test/files/positions/Overlap3.scala @@ -1,3 +1,3 @@ object Overlap3 { - val (a, b) = (0, 0) + val (a, b) = (0, 0) } diff --git a/test/files/positions/Scaladoc2.scala b/test/files/positions/Scaladoc2.scala index 78bc4acb28..e52263d86c 100644 --- a/test/files/positions/Scaladoc2.scala +++ b/test/files/positions/Scaladoc2.scala @@ -4,13 +4,13 @@ object Scaladoc2 { * Foo */ def g {} - + /* * Blah blah */ def h{} h } - + def h {} } diff --git a/test/files/positions/Scaladoc3.scala b/test/files/positions/Scaladoc3.scala index bb9d66fdb4..c331b7e396 100644 --- a/test/files/positions/Scaladoc3.scala +++ b/test/files/positions/Scaladoc3.scala @@ -3,6 +3,6 @@ object Scaladoc3 { * Foo */ import scala.collection.mutable.ArrayBuffer - + def f {} } diff --git a/test/files/positions/Scaladoc4.scala b/test/files/positions/Scaladoc4.scala index f613dda7f5..133cde1c85 100644 --- a/test/files/positions/Scaladoc4.scala +++ b/test/files/positions/Scaladoc4.scala @@ -3,6 +3,6 @@ object Scaladoc4 { * Foo */ 2+2 - + def f {} } diff --git a/test/files/positions/Scaladoc6.scala b/test/files/positions/Scaladoc6.scala index 5c230edeb2..8beda625ae 100644 --- a/test/files/positions/Scaladoc6.scala +++ b/test/files/positions/Scaladoc6.scala @@ -5,6 +5,6 @@ object Scaladoc6 { */ val i = 23 } - + def f {} } diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index 3a08e2a2ea..59c841a255 100644 --- a/test/files/presentation/callcc-interpreter.check +++ b/test/files/presentation/callcc-interpreter.check @@ -2,91 +2,91 @@ reload: CallccInterpreter.scala askTypeCompletion at CallccInterpreter.scala(51,38) ================================================================================ -[response] aksTypeCompletion at (51,38) -retrieved 64 members -[accessible: true] `class AddcallccInterpreter.Add` -[accessible: true] `class AppcallccInterpreter.App` -[accessible: true] `class CcccallccInterpreter.Ccc` -[accessible: true] `class ConcallccInterpreter.Con` -[accessible: true] `class FuncallccInterpreter.Fun` -[accessible: true] `class LamcallccInterpreter.Lam` -[accessible: true] `class McallccInterpreter.M` -[accessible: true] `class NumcallccInterpreter.Num` -[accessible: true] `class VarcallccInterpreter.Var` -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(callccInterpreter.type, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method add(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value]` -[accessible: true] `method apply(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[callccInterpreter.Value]` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method callCC[A](h: (A => callccInterpreter.M[A]) => callccInterpreter.M[A])callccInterpreter.M[A]` -[accessible: true] `method clone()Object` -[accessible: true] `method ensuring(cond: Boolean)callccInterpreter.type` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)callccInterpreter.type` -[accessible: true] `method ensuring(cond: callccInterpreter.type => Boolean)callccInterpreter.type` -[accessible: true] `method ensuring(cond: callccInterpreter.type => Boolean, msg: => Any)callccInterpreter.type` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method finalize()Unit` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method id[A]=> A => A` -[accessible: true] `method interp(t: callccInterpreter.Term, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method lookup(x: callccInterpreter.Name, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` -[accessible: true] `method main(args: Array[String])Unit` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method showM(m: callccInterpreter.M[callccInterpreter.Value])String` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method test(t: callccInterpreter.Term)String` -[accessible: true] `method toString()String` -[accessible: true] `method unitM[A](a: A)callccInterpreter.M[A]` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> callccInterpreter.type` -[accessible: true] `method →[B](y: B)(callccInterpreter.type, B)` -[accessible: true] `object WrongcallccInterpreter.Wrong.type` -[accessible: true] `trait TermcallccInterpreter.Term` -[accessible: true] `trait ValuecallccInterpreter.Value` -[accessible: true] `type AnswercallccInterpreter.Answer` -[accessible: true] `type EnvironmentcallccInterpreter.Environment` -[accessible: true] `type NamecallccInterpreter.Name` -[accessible: true] `value __leftOfArrowcallccInterpreter.type` -[accessible: true] `value __resultOfEnsuringcallccInterpreter.type` -[accessible: true] `value selfAny` -[accessible: true] `value term0callccInterpreter.App` -[accessible: true] `value term1callccInterpreter.App` -[accessible: true] `value term2callccInterpreter.Add` +[response] askCompletionAt (51,38) +retrieved 63 members +abstract trait Term extends AnyRef +abstract trait Value extends AnyRef +case class Add extends callccInterpreter.Term with Product with Serializable +case class App extends callccInterpreter.Term with Product with Serializable +case class Ccc extends callccInterpreter.Term with Product with Serializable +case class Con extends callccInterpreter.Term with Product with Serializable +case class Fun extends callccInterpreter.Value with Product with Serializable +case class Lam extends callccInterpreter.Term with Product with Serializable +case class M[A] extends Product with Serializable +case class Num extends callccInterpreter.Value with Product with Serializable +case class Var extends callccInterpreter.Term with Product with Serializable +case object Wrong +def +(other: String): String +def ->[B](y: B): (callccInterpreter.type, B) +def add(a: callccInterpreter.Value,b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value] +def apply(a: callccInterpreter.Value,b: callccInterpreter.Value): callccInterpreter.M[callccInterpreter.Value] +def callCC[A](h: (A => callccInterpreter.M[A]) => callccInterpreter.M[A]): callccInterpreter.M[A] +def ensuring(cond: Boolean): callccInterpreter.type +def ensuring(cond: Boolean,msg: => Any): callccInterpreter.type +def ensuring(cond: callccInterpreter.type => Boolean): callccInterpreter.type +def ensuring(cond: callccInterpreter.type => Boolean,msg: => Any): callccInterpreter.type +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def id[A]: A => A +def interp(t: callccInterpreter.Term,e: callccInterpreter.Environment): callccInterpreter.M[callccInterpreter.Value] +def lookup(x: callccInterpreter.Name,e: callccInterpreter.Environment): callccInterpreter.M[callccInterpreter.Value] +def main(args: Array[String]): Unit +def showM(m: callccInterpreter.M[callccInterpreter.Value]): String +def test(t: callccInterpreter.Term): String +def toString(): String +def unitM[A](a: A): callccInterpreter.M[A] +def →[B](y: B): (callccInterpreter.type, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private[this] val __leftOfArrow: callccInterpreter.type +private[this] val __resultOfEnsuring: callccInterpreter.type +private[this] val __stringToFormat: callccInterpreter.type +private[this] val __thingToAdd: callccInterpreter.type +private[this] val term0: callccInterpreter.App +private[this] val term1: callccInterpreter.App +private[this] val term2: callccInterpreter.Add +protected[package lang] def clone(): Object +protected[package lang] def finalize(): Unit +type Answer = callccInterpreter.Answer +type Environment = callccInterpreter.Environment +type Name = callccInterpreter.Name ================================================================================ askType at CallccInterpreter.scala(14,21) ================================================================================ -[response] askTypeAt at (14,21) -def unitM[A >: Nothing <: Any](a: A): callccInterpreter.M[A] = callccInterpreter.this.M.apply[A](((c: A => callccInterpreter.Answer) => c.apply(a))) +[response] askTypeAt (14,21) +def unitM[A](a: A): callccInterpreter.M[A] = callccInterpreter.this.M.apply[A](((c: A => callccInterpreter.Answer) => c.apply(a))) ================================================================================ askType at CallccInterpreter.scala(16,12) ================================================================================ -[response] askTypeAt at (16,12) -def id[A >: Nothing <: Any]: A => A = ((x: A) => x) +[response] askTypeAt (16,12) +def id[A]: A => A = ((x: A) => x) ================================================================================ askType at CallccInterpreter.scala(17,25) ================================================================================ -[response] askTypeAt at (17,25) +[response] askTypeAt (17,25) def showM(m: callccInterpreter.M[callccInterpreter.Value]): String = m.in.apply(callccInterpreter.this.id[callccInterpreter.Value]).toString() ================================================================================ askType at CallccInterpreter.scala(50,30) ================================================================================ -[response] askTypeAt at (50,30) +[response] askTypeAt (50,30) def add(a: callccInterpreter.Value, b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value] = scala.this.Predef.Pair.apply[callccInterpreter.Value, callccInterpreter.Value](a, b) match { case scala.this.Predef.Pair.unapply[callccInterpreter.Value, callccInterpreter.Value](<unapply-selector>) <unapply> ((n: Int)callccInterpreter.Num((m @ _)), (n: Int)callccInterpreter.Num((n @ _))) => this.unitM[callccInterpreter.Num](callccInterpreter.this.Num.apply(m.+(n))) case _ => callccInterpreter.this.unitM[callccInterpreter.Wrong.type](callccInterpreter.this.Wrong) diff --git a/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala b/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala index 0e96dfaa05..ce3b996b96 100644 --- a/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala +++ b/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala @@ -2,8 +2,8 @@ object callccInterpreter { type Answer = Value - /** - * A continuation monad. + /** + * A continuation monad. */ case class M[A](in: (A => Answer) => Answer) { def bind[B](k: A => M[B]) = M[B](c => in (a => k(a) in c)) diff --git a/test/files/presentation/doc/doc.scala b/test/files/presentation/doc/doc.scala index 371b825026..f2233f1828 100755 --- a/test/files/presentation/doc/doc.scala +++ b/test/files/presentation/doc/doc.scala @@ -1,9 +1,9 @@ +import scala.reflect.internal.util.{ BatchSourceFile, SourceFile } import scala.tools.nsc.doc import scala.tools.nsc.doc.base._ import scala.tools.nsc.doc.base.comment._ import scala.tools.nsc.interactive._ import scala.tools.nsc.interactive.tests._ -import scala.tools.nsc.util._ object Test extends InteractiveTest { val tags = Seq( @@ -37,12 +37,20 @@ object Test extends InteractiveTest { prepre + docComment(nTags) + prepost + post } - - override lazy val compiler = { prepareSettings(settings) - new Global(settings, compilerReporter) with MemberLookupBase with CommentFactoryBase { + new Global(settings, compilerReporter) with MemberLookupBase with CommentFactoryBase with doc.ScaladocGlobalTrait { + outer => + val global: this.type = this + + override lazy val analyzer = new { + val global: outer.type = outer + } with doc.ScaladocAnalyzer with InteractiveAnalyzer { + override def newTyper(context: Context): InteractiveTyper with ScaladocTyper = + new Typer(context) with InteractiveTyper with ScaladocTyper + } + def chooseLink(links: List[LinkTo]): LinkTo = links.head def internalLink(sym: Symbol, site: Symbol) = None def toString(link: LinkTo) = link.toString @@ -59,7 +67,7 @@ object Test extends InteractiveTest { if (expanded.isEmpty) None else - Some(ask { () => parseAtSymbol(expanded, raw, pos, Some(sym.owner)) }) + Some(ask { () => parseAtSymbol(expanded, raw, pos, sym.owner) }) } } } @@ -88,12 +96,11 @@ object Test extends InteractiveTest { println("Couldn't parse") case Some(_) => val sym = compiler.ask { () => - val toplevel = definitions.EmptyPackage.info.decl(newTypeName(name)) + val toplevel = compiler.rootMirror.EmptyPackage.info.decl(TypeName(name)) if (toplevel eq NoSymbol) { - val clazz = definitions.EmptyPackage.info.decl(newTypeName(className)) - - val term = clazz.info.decl(newTermName(name)) - if (term eq NoSymbol) clazz.info.decl(newTypeName(name)) else + val clazz = compiler.rootMirror.EmptyPackage.info.decl(TypeName(className)) + val term = clazz.info.decl(TermName(name)) + if (term eq NoSymbol) clazz.info.decl(TypeName(name)) else if (term.isAccessor) term.accessed else term } else toplevel } @@ -115,16 +122,17 @@ object Test extends InteractiveTest { val baseSource = findSource("Base.scala") val derivedSource = findSource("Derived.scala") def existsText(where: Any, text: String): Boolean = where match { - case `text` => true + case s: String => s contains text case s: Seq[_] => s exists (existsText(_, text)) case p: Product => p.productIterator exists (existsText(_, text)) + case c: Comment => existsText(c.body, text) } - val (derived, base) = compiler.ask { () => - val derived = definitions.RootPackage.info.decl(newTermName("p")).info.decl(newTypeName("Derived")) + val (derived, base) = compiler.ask { () => + val derived = compiler.rootMirror.RootPackage.info.decl(newTermName("p")).info.decl(newTypeName("Derived")) (derived, derived.ancestors(0)) } val cmt1 = getComment(derived, derivedSource, (base, baseSource)::(derived, derivedSource)::Nil) - if (!existsText(cmt1, "Derived comment.")) + if (!existsText(cmt1, "This is Derived comment")) println("Unexpected Derived class comment:"+cmt1) val (fooDerived, fooBase) = compiler.ask { () => @@ -133,7 +141,7 @@ object Test extends InteractiveTest { } val cmt2 = getComment(fooDerived, derivedSource, (fooBase, baseSource)::(fooDerived, derivedSource)::Nil) - if (!existsText(cmt2, "Base method has documentation.")) + if (!existsText(cmt2, "Base method has documentation")) println("Unexpected foo method comment:"+cmt2) } } diff --git a/test/files/presentation/doc/src/p/Base.scala b/test/files/presentation/doc/src/p/Base.scala index 9031de3e3e..d91632b6f6 100755 --- a/test/files/presentation/doc/src/p/Base.scala +++ b/test/files/presentation/doc/src/p/Base.scala @@ -1,7 +1,7 @@ package p /** - * @define BaseComment $BaseVar comment. + * @define BaseComment This is $BaseVar comment. */ trait Base { /** diff --git a/test/files/presentation/hyperlinks/Runner.scala b/test/files/presentation/hyperlinks/Runner.scala index 61da49a3d7..b78e13c23a 100644 --- a/test/files/presentation/hyperlinks/Runner.scala +++ b/test/files/presentation/hyperlinks/Runner.scala @@ -7,5 +7,5 @@ object Test extends InteractiveTest { sourceFiles foreach (src => askLoadedTyped(src).get) super.runDefaultTests() } - + }
\ No newline at end of file diff --git a/test/files/presentation/hyperlinks/src/NameDefaultTests.scala b/test/files/presentation/hyperlinks/src/NameDefaultTests.scala index b218040fe3..340d223d2e 100644 --- a/test/files/presentation/hyperlinks/src/NameDefaultTests.scala +++ b/test/files/presentation/hyperlinks/src/NameDefaultTests.scala @@ -2,11 +2,11 @@ class NameDefaults { val someString = "abc" val someInt = 42 - + def foo(x: String, y: Int)(implicit logger: Int): Int = y - + implicit val l = 42 - + def bar { println() val someOtherInt = 10 diff --git a/test/files/presentation/hyperlinks/src/PatMatTests.scala b/test/files/presentation/hyperlinks/src/PatMatTests.scala index bbd0f2e7ed..7184106357 100644 --- a/test/files/presentation/hyperlinks/src/PatMatTests.scala +++ b/test/files/presentation/hyperlinks/src/PatMatTests.scala @@ -6,22 +6,22 @@ case class CaseOne(x: Int, y: List[Int]) extends BaseType case class CaseTwo(str: String) extends BaseType class PatMatTests { - + def foo(x: BaseType) { x match { case CaseOne/*#*/(10, first :: second :: Nil) => val tmp = 23 println(first/*#*/) println(tmp/*#*/) - + case CaseTwo/*#*/(mystring) => println(mystring/*#*/) } } - + def multipleAssign() { val (x, y) = ("abc", "def") - + println(x/*#*/, y/*#*/) } diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check index 44a3207d75..b15486f4ac 100644 --- a/test/files/presentation/ide-bug-1000349.check +++ b/test/files/presentation/ide-bug-1000349.check @@ -2,39 +2,39 @@ reload: CompletionOnEmptyArgMethod.scala askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17) ================================================================================ -[response] aksTypeCompletion at (2,17) -retrieved 37 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(Foo, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method clone()Object` -[accessible: true] `method ensuring(cond: Boolean)Foo` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Foo` -[accessible: true] `method ensuring(cond: Foo => Boolean)Foo` -[accessible: true] `method ensuring(cond: Foo => Boolean, msg: => Any)Foo` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method finalize()Unit` -[accessible: true] `method foo=> Foo` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> Foo` -[accessible: true] `method →[B](y: B)(Foo, B)` -[accessible: true] `value __leftOfArrowFoo` -[accessible: true] `value __resultOfEnsuringFoo` -[accessible: true] `value selfAny` +[response] askCompletionAt (2,17) +retrieved 36 members +def +(other: String): String +def ->[B](y: B): (Foo, B) +def ensuring(cond: Boolean): Foo +def ensuring(cond: Boolean,msg: => Any): Foo +def ensuring(cond: Foo => Boolean): Foo +def ensuring(cond: Foo => Boolean,msg: => Any): Foo +def equals(x$1: Any): Boolean +def foo: Foo +def formatted(fmtstr: String): String +def hashCode(): Int +def toString(): String +def →[B](y: B): (Foo, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private[this] val __leftOfArrow: Foo +private[this] val __resultOfEnsuring: Foo +private[this] val __stringToFormat: Foo +private[this] val __thingToAdd: Foo +protected[package lang] def clone(): Object +protected[package lang] def finalize(): Unit ================================================================================ diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check index 34c3b557d8..e4b8508846 100644 --- a/test/files/presentation/ide-bug-1000475.check +++ b/test/files/presentation/ide-bug-1000475.check @@ -2,114 +2,114 @@ reload: Foo.scala askTypeCompletion at Foo.scala(3,7) ================================================================================ -[response] aksTypeCompletion at (3,7) -retrieved 36 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(Object, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)Object` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Object` -[accessible: true] `method ensuring(cond: Object => Boolean)Object` -[accessible: true] `method ensuring(cond: Object => Boolean, msg: => Any)Object` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> Object` -[accessible: true] `method →[B](y: B)(Object, B)` -[accessible: true] `value __leftOfArrowObject` -[accessible: true] `value __resultOfEnsuringObject` -[accessible: true] `value selfAny` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` +[response] askCompletionAt (3,7) +retrieved 35 members +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def +(other: String): String +def ->[B](y: B): (Object, B) +def ensuring(cond: Boolean): Object +def ensuring(cond: Boolean,msg: => Any): Object +def ensuring(cond: Object => Boolean): Object +def ensuring(cond: Object => Boolean,msg: => Any): Object +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def toString(): String +def →[B](y: B): (Object, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private[this] val __leftOfArrow: Object +private[this] val __resultOfEnsuring: Object +private[this] val __stringToFormat: Object +private[this] val __thingToAdd: Object ================================================================================ askTypeCompletion at Foo.scala(6,10) ================================================================================ -[response] aksTypeCompletion at (6,10) -retrieved 36 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(Object, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)Object` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Object` -[accessible: true] `method ensuring(cond: Object => Boolean)Object` -[accessible: true] `method ensuring(cond: Object => Boolean, msg: => Any)Object` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> Object` -[accessible: true] `method →[B](y: B)(Object, B)` -[accessible: true] `value __leftOfArrowObject` -[accessible: true] `value __resultOfEnsuringObject` -[accessible: true] `value selfAny` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` +[response] askCompletionAt (6,10) +retrieved 35 members +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def +(other: String): String +def ->[B](y: B): (Object, B) +def ensuring(cond: Boolean): Object +def ensuring(cond: Boolean,msg: => Any): Object +def ensuring(cond: Object => Boolean): Object +def ensuring(cond: Object => Boolean,msg: => Any): Object +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def toString(): String +def →[B](y: B): (Object, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private[this] val __leftOfArrow: Object +private[this] val __resultOfEnsuring: Object +private[this] val __stringToFormat: Object +private[this] val __thingToAdd: Object ================================================================================ askTypeCompletion at Foo.scala(7,7) ================================================================================ -[response] aksTypeCompletion at (7,7) -retrieved 36 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(Object, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)Object` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Object` -[accessible: true] `method ensuring(cond: Object => Boolean)Object` -[accessible: true] `method ensuring(cond: Object => Boolean, msg: => Any)Object` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> Object` -[accessible: true] `method →[B](y: B)(Object, B)` -[accessible: true] `value __leftOfArrowObject` -[accessible: true] `value __resultOfEnsuringObject` -[accessible: true] `value selfAny` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` +[response] askCompletionAt (7,7) +retrieved 35 members +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def +(other: String): String +def ->[B](y: B): (Object, B) +def ensuring(cond: Boolean): Object +def ensuring(cond: Boolean,msg: => Any): Object +def ensuring(cond: Object => Boolean): Object +def ensuring(cond: Object => Boolean,msg: => Any): Object +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def toString(): String +def →[B](y: B): (Object, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private[this] val __leftOfArrow: Object +private[this] val __resultOfEnsuring: Object +private[this] val __stringToFormat: Object +private[this] val __thingToAdd: Object ================================================================================ diff --git a/test/files/presentation/ide-bug-1000475/src/Foo.scala b/test/files/presentation/ide-bug-1000475/src/Foo.scala index b963bb7a88..5dd6b7d00d 100644 --- a/test/files/presentation/ide-bug-1000475/src/Foo.scala +++ b/test/files/presentation/ide-bug-1000475/src/Foo.scala @@ -1,7 +1,7 @@ class Foo { val v = new Object v.toS/*!*/ - + val m = Map(1 -> new Object) m(1).toS/*!*/ m(1)./*!*/ diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index 4be98a6b21..be8805330a 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -2,128 +2,127 @@ reload: CrashOnLoad.scala askTypeCompletion at CrashOnLoad.scala(6,12) ================================================================================ -[response] aksTypeCompletion at (6,12) -retrieved 126 members -[accessible: true] `class GroupedIteratorIterator[B]#GroupedIterator` -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ++[B >: B](that: => scala.collection.GenTraversableOnce[B])Iterator[B]` -[accessible: true] `method ->[B](y: B)(java.util.Iterator[B], B)` -[accessible: true] `method /:[B](z: B)(op: (B, B) => B)B` -[accessible: true] `method /:\[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` -[accessible: true] `method :\[B](z: B)(op: (B, B) => B)B` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method addString(b: StringBuilder)StringBuilder` -[accessible: true] `method addString(b: StringBuilder, sep: String)StringBuilder` -[accessible: true] `method addString(b: StringBuilder, start: String, sep: String, end: String)StringBuilder` -[accessible: true] `method aggregate[B](z: B)(seqop: (B, B) => B, combop: (B, B) => B)B` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method buffered=> scala.collection.BufferedIterator[B]` -[accessible: true] `method collectFirst[B](pf: PartialFunction[B,B])Option[B]` -[accessible: true] `method collect[B](pf: PartialFunction[B,B])Iterator[B]` -[accessible: true] `method contains(elem: Any)Boolean` -[accessible: true] `method copyToArray[B >: B](xs: Array[B])Unit` -[accessible: true] `method copyToArray[B >: B](xs: Array[B], start: Int)Unit` -[accessible: true] `method copyToArray[B >: B](xs: Array[B], start: Int, len: Int)Unit` -[accessible: true] `method copyToBuffer[B >: B](dest: scala.collection.mutable.Buffer[B])Unit` -[accessible: true] `method corresponds[B](that: scala.collection.GenTraversableOnce[B])(p: (B, B) => Boolean)Boolean` -[accessible: true] `method count(p: B => Boolean)Int` -[accessible: true] `method drop(n: Int)Iterator[B]` -[accessible: true] `method dropWhile(p: B => Boolean)Iterator[B]` -[accessible: true] `method duplicate=> (Iterator[B], Iterator[B])` -[accessible: true] `method ensuring(cond: Boolean)java.util.Iterator[B]` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)java.util.Iterator[B]` -[accessible: true] `method ensuring(cond: java.util.Iterator[B] => Boolean)java.util.Iterator[B]` -[accessible: true] `method ensuring(cond: java.util.Iterator[B] => Boolean, msg: => Any)java.util.Iterator[B]` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method exists(p: B => Boolean)Boolean` -[accessible: true] `method filter(p: B => Boolean)Iterator[B]` -[accessible: true] `method filterNot(p: B => Boolean)Iterator[B]` -[accessible: true] `method find(p: B => Boolean)Option[B]` -[accessible: true] `method flatMap[B](f: B => scala.collection.GenTraversableOnce[B])Iterator[B]` -[accessible: true] `method foldLeft[B](z: B)(op: (B, B) => B)B` -[accessible: true] `method foldRight[B](z: B)(op: (B, B) => B)B` -[accessible: true] `method fold[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` -[accessible: true] `method forall(p: B => Boolean)Boolean` -[accessible: true] `method foreach[U](f: B => U)Unit` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method grouped[B >: B](size: Int)Iterator[B]#GroupedIterator[B]` -[accessible: true] `method hasDefiniteSize=> Boolean` -[accessible: true] `method hasNext()Boolean` -[accessible: true] `method hashCode()Int` -[accessible: true] `method indexOf[B >: B](elem: B)Int` -[accessible: true] `method indexWhere(p: B => Boolean)Int` -[accessible: true] `method isEmpty=> Boolean` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method isTraversableAgain=> Boolean` -[accessible: true] `method length=> Int` -[accessible: true] `method map[B](f: B => B)Iterator[B]` -[accessible: true] `method maxBy[B](f: B => B)(implicit cmp: Ordering[B])B` -[accessible: true] `method max[B >: B](implicit cmp: Ordering[B])B` -[accessible: true] `method minBy[B](f: B => B)(implicit cmp: Ordering[B])B` -[accessible: true] `method min[B >: B](implicit cmp: Ordering[B])B` -[accessible: true] `method mkString(sep: String)String` -[accessible: true] `method mkString(start: String, sep: String, end: String)String` -[accessible: true] `method mkString=> String` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method next()B` -[accessible: true] `method nonEmpty=> Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method padTo[A1 >: B](len: Int, elem: A1)Iterator[A1]` -[accessible: true] `method partition(p: B => Boolean)(Iterator[B], Iterator[B])` -[accessible: true] `method patch[B >: B](from: Int, patchElems: Iterator[B], replaced: Int)Iterator[B]` -[accessible: true] `method product[B >: B](implicit num: Numeric[B])B` -[accessible: true] `method reduceLeftOption[B >: B](op: (B, B) => B)Option[B]` -[accessible: true] `method reduceLeft[B >: B](op: (B, B) => B)B` -[accessible: true] `method reduceOption[A1 >: B](op: (A1, A1) => A1)Option[A1]` -[accessible: true] `method reduceRightOption[B >: B](op: (B, B) => B)Option[B]` -[accessible: true] `method reduceRight[B >: B](op: (B, B) => B)B` -[accessible: true] `method reduce[A1 >: B](op: (A1, A1) => A1)A1` -[accessible: true] `method remove()Unit` -[accessible: true] `method sameElements(that: Iterator[_])Boolean` -[accessible: true] `method scanLeft[B](z: B)(op: (B, B) => B)Iterator[B]` -[accessible: true] `method scanRight[B](z: B)(op: (B, B) => B)Iterator[B]` -[accessible: true] `method seq=> Iterator[B]` -[accessible: true] `method size=> Int` -[accessible: true] `method slice(from: Int, until: Int)Iterator[B]` -[accessible: true] `method sliding[B >: B](size: Int, step: Int)Iterator[B]#GroupedIterator[B]` -[accessible: true] `method span(p: B => Boolean)(Iterator[B], Iterator[B])` -[accessible: true] `method sum[B >: B](implicit num: Numeric[B])B` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method take(n: Int)Iterator[B]` -[accessible: true] `method takeWhile(p: B => Boolean)Iterator[B]` -[accessible: true] `method toArray[B >: B](implicit evidence$1: scala.reflect.ClassTag[B])Array[B]` -[accessible: true] `method toBuffer[B >: B]=> scala.collection.mutable.Buffer[B]` -[accessible: true] `method toIndexedSeq=> scala.collection.immutable.IndexedSeq[B]` -[accessible: true] `method toIterable=> Iterable[B]` -[accessible: true] `method toIterator=> Iterator[B]` -[accessible: true] `method toList=> List[B]` -[accessible: true] `method toMap[T, U](implicit ev: <:<[B,(T, U)])scala.collection.immutable.Map[T,U]` -[accessible: true] `method toSeq=> Seq[B]` -[accessible: true] `method toSet[B >: B]=> scala.collection.immutable.Set[B]` -[accessible: true] `method toStream=> scala.collection.immutable.Stream[B]` -[accessible: true] `method toString()String` -[accessible: true] `method toTraversable=> Traversable[B]` -[accessible: true] `method toVector=> Vector[B]` -[accessible: true] `method to[Col[_]](implicit cbf: scala.collection.generic.CanBuildFrom[Nothing,B,Col[B]])Col[B]` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method withFilter(p: B => Boolean)Iterator[B]` -[accessible: true] `method x=> java.util.Iterator[B]` -[accessible: true] `method zipAll[B, A1 >: B, B1 >: B](that: Iterator[B], thisElem: A1, thatElem: B1)Iterator[(A1, B1)]` -[accessible: true] `method zipWithIndex=> Iterator[(B, Int)]` -[accessible: true] `method zip[B](that: Iterator[B])Iterator[(B, B)]` -[accessible: true] `method →[B](y: B)(java.util.Iterator[B], B)` -[accessible: true] `value __leftOfArrowjava.util.Iterator[B]` -[accessible: true] `value __resultOfEnsuringjava.util.Iterator[B]` -[accessible: true] `value selfAny` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` -[accessible: false] `method reversed=> List[B]` +[response] askCompletionAt (6,12) +retrieved 124 members +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +[inaccessible] protected[this] def reversed: List[B] +class GroupedIterator[B >: A] extends AbstractIterator[Seq[B]] with Iterator[Seq[B]] +def +(other: String): String +def ++[B >: B](that: => scala.collection.GenTraversableOnce[B]): Iterator[B] +def ->[B](y: B): (java.util.Iterator[B], B) +def /:[B](z: B)(op: (B, B) => B): B +def :\[B](z: B)(op: (B, B) => B): B +def addString(b: StringBuilder): StringBuilder +def addString(b: StringBuilder,sep: String): StringBuilder +def addString(b: StringBuilder,start: String,sep: String,end: String): StringBuilder +def aggregate[B](z: => B)(seqop: (B, B) => B,combop: (B, B) => B): B +def buffered: scala.collection.BufferedIterator[B] +def collectFirst[B](pf: PartialFunction[B,B]): Option[B] +def collect[B](pf: PartialFunction[B,B]): Iterator[B] +def contains(elem: Any): Boolean +def copyToArray[B >: B](xs: Array[B]): Unit +def copyToArray[B >: B](xs: Array[B],start: Int): Unit +def copyToArray[B >: B](xs: Array[B],start: Int,len: Int): Unit +def copyToBuffer[B >: B](dest: scala.collection.mutable.Buffer[B]): Unit +def corresponds[B](that: scala.collection.GenTraversableOnce[B])(p: (B, B) => Boolean): Boolean +def count(p: B => Boolean): Int +def drop(n: Int): Iterator[B] +def dropWhile(p: B => Boolean): Iterator[B] +def duplicate: (Iterator[B], Iterator[B]) +def ensuring(cond: Boolean): java.util.Iterator[B] +def ensuring(cond: Boolean,msg: => Any): java.util.Iterator[B] +def ensuring(cond: java.util.Iterator[B] => Boolean): java.util.Iterator[B] +def ensuring(cond: java.util.Iterator[B] => Boolean,msg: => Any): java.util.Iterator[B] +def equals(x$1: Any): Boolean +def exists(p: B => Boolean): Boolean +def filter(p: B => Boolean): Iterator[B] +def filterNot(p: B => Boolean): Iterator[B] +def find(p: B => Boolean): Option[B] +def flatMap[B](f: B => scala.collection.GenTraversableOnce[B]): Iterator[B] +def foldLeft[B](z: B)(op: (B, B) => B): B +def foldRight[B](z: B)(op: (B, B) => B): B +def fold[A1 >: B](z: A1)(op: (A1, A1) => A1): A1 +def forall(p: B => Boolean): Boolean +def foreach[U](f: B => U): Unit +def formatted(fmtstr: String): String +def grouped[B >: B](size: Int): Iterator[B]#GroupedIterator[B] +def hasDefiniteSize: Boolean +def hasNext(): Boolean +def hashCode(): Int +def indexOf[B >: B](elem: B): Int +def indexWhere(p: B => Boolean): Int +def isEmpty: Boolean +def isTraversableAgain: Boolean +def length: Int +def map[B](f: B => B): Iterator[B] +def maxBy[B](f: B => B)(implicit cmp: Ordering[B]): B +def max[B >: B](implicit cmp: Ordering[B]): B +def minBy[B](f: B => B)(implicit cmp: Ordering[B]): B +def min[B >: B](implicit cmp: Ordering[B]): B +def mkString(sep: String): String +def mkString(start: String,sep: String,end: String): String +def mkString: String +def next(): B +def nonEmpty: Boolean +def padTo[A1 >: B](len: Int,elem: A1): Iterator[A1] +def partition(p: B => Boolean): (Iterator[B], Iterator[B]) +def patch[B >: B](from: Int,patchElems: Iterator[B],replaced: Int): Iterator[B] +def product[B >: B](implicit num: Numeric[B]): B +def reduceLeftOption[B >: B](op: (B, B) => B): Option[B] +def reduceLeft[B >: B](op: (B, B) => B): B +def reduceOption[A1 >: B](op: (A1, A1) => A1): Option[A1] +def reduceRightOption[B >: B](op: (B, B) => B): Option[B] +def reduceRight[B >: B](op: (B, B) => B): B +def reduce[A1 >: B](op: (A1, A1) => A1): A1 +def remove(): Unit +def sameElements(that: Iterator[_]): Boolean +def scanLeft[B](z: B)(op: (B, B) => B): Iterator[B] +def scanRight[B](z: B)(op: (B, B) => B): Iterator[B] +def seq: Iterator[B] +def size: Int +def slice(from: Int,until: Int): Iterator[B] +def sliding[B >: B](size: Int,step: Int): Iterator[B]#GroupedIterator[B] +def span(p: B => Boolean): (Iterator[B], Iterator[B]) +def sum[B >: B](implicit num: Numeric[B]): B +def take(n: Int): Iterator[B] +def takeWhile(p: B => Boolean): Iterator[B] +def toArray[B >: B](implicit evidence$1: scala.reflect.ClassTag[B]): Array[B] +def toBuffer[B >: B]: scala.collection.mutable.Buffer[B] +def toIndexedSeq: scala.collection.immutable.IndexedSeq[B] +def toIterable: Iterable[B] +def toIterator: Iterator[B] +def toList: List[B] +def toMap[T, U](implicit ev: <:<[B,(T, U)]): scala.collection.immutable.Map[T,U] +def toSeq: Seq[B] +def toSet[B >: B]: scala.collection.immutable.Set[B] +def toStream: scala.collection.immutable.Stream[B] +def toString(): String +def toTraversable: Traversable[B] +def toVector: Vector[B] +def to[Col[_]](implicit cbf: scala.collection.generic.CanBuildFrom[Nothing,B,Col[B]]): Col[B] +def withFilter(p: B => Boolean): Iterator[B] +def zipAll[B, A1 >: B, B1 >: B](that: Iterator[B],thisElem: A1,thatElem: B1): Iterator[(A1, B1)] +def zipWithIndex: Iterator[(B, Int)] +def zip[B](that: Iterator[B]): Iterator[(B, B)] +def →[B](y: B): (java.util.Iterator[B], B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private[this] val __leftOfArrow: java.util.Iterator[B] +private[this] val __resultOfEnsuring: java.util.Iterator[B] +private[this] val __stringToFormat: java.util.Iterator[B] +private[this] val __thingToAdd: java.util.Iterator[B] ================================================================================ diff --git a/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala b/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala index 21d39c8923..878bbfa19e 100644 --- a/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala +++ b/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala @@ -1,7 +1,7 @@ /** When this files is opened within the IDE, a typing error is reported. */ class A[B] extends java.lang.Iterable[B] { import scala.collection.JavaConversions._ - def iterator = Iterator.empty - + def iterator = Iterator.empty + iterator. /*!*/ }
\ No newline at end of file diff --git a/test/files/presentation/ide-t1001326/Test.scala b/test/files/presentation/ide-t1001326/Test.scala index 3091da4b40..ff63b9770a 100644 --- a/test/files/presentation/ide-t1001326/Test.scala +++ b/test/files/presentation/ide-t1001326/Test.scala @@ -3,7 +3,7 @@ import scala.reflect.internal.util.SourceFile import scala.tools.nsc.interactive.Response object Test extends InteractiveTest { - + override def execute(): Unit = { val sf = sourceFiles.find(_.file.name == "A.scala").head uniqueParseTree_t1001326(sf) @@ -11,7 +11,7 @@ object Test extends InteractiveTest { neverModifyParseTree_t1001326(sf) shouldAlwaysReturnParseTree_t1001326(sf) } - + /** * Asking twice for a parseTree on the same source should always return a new tree */ @@ -24,7 +24,7 @@ object Test extends InteractiveTest { reporter.println("Unique FAILED") } } - + /** * A parseTree should never contain any symbols or types */ @@ -35,10 +35,10 @@ object Test extends InteractiveTest { reporter.println("Unattributed FAILED") } } - + /** * Once you have obtained a parseTree it should never change - */ + */ private def neverModifyParseTree_t1001326(sf: SourceFile) { val parsedTree = compiler.parseTree(sf) loadSourceAndWaitUntilTypechecked(sf) @@ -48,7 +48,7 @@ object Test extends InteractiveTest { reporter.println("NeverModify FAILED") } } - + /** * Should always return a parse tree */ @@ -60,7 +60,7 @@ object Test extends InteractiveTest { reporter.println("AlwaysParseTree FAILED") } } - + /** * Load a source and block while it is type-checking. */ @@ -71,7 +71,7 @@ object Test extends InteractiveTest { res.get askLoadedTyped(sf).get } - + /** * Traverses a tree and makes sure that there are no types or symbols present in the tree with * the exception of the symbol for the package 'scala'. This is because that symbol will be @@ -79,13 +79,13 @@ object Test extends InteractiveTest { */ private def noSymbolsOrTypes(tree: compiler.Tree): Boolean = { tree.forAll { t => - (t.symbol == null || - t.symbol == compiler.NoSymbol || + (t.symbol == null || + t.symbol == compiler.NoSymbol || t.symbol == compiler.definitions.ScalaPackage // ignore the symbol for the scala package for now ) && ( - t.tpe == null || + t.tpe == null || t.tpe == compiler.NoType) } } - + }
\ No newline at end of file diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check index 05d6f61699..acf7e1a0fd 100644 --- a/test/files/presentation/implicit-member.check +++ b/test/files/presentation/implicit-member.check @@ -2,41 +2,41 @@ reload: ImplicitMember.scala askTypeCompletion at ImplicitMember.scala(7,7) ================================================================================ -[response] aksTypeCompletion at (7,7) -retrieved 39 members -[accessible: true] `class AppliedImplicitImplicit.AppliedImplicit` -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(Implicit.type, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method AppliedImplicit[A](x: A)Implicit.AppliedImplicit[A]` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method clone()Object` -[accessible: true] `method ensuring(cond: Boolean)Implicit.type` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Implicit.type` -[accessible: true] `method ensuring(cond: Implicit.type => Boolean)Implicit.type` -[accessible: true] `method ensuring(cond: Implicit.type => Boolean, msg: => Any)Implicit.type` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method finalize()Unit` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> Implicit.type` -[accessible: true] `method →[B](y: B)(Implicit.type, B)` -[accessible: true] `value __leftOfArrowImplicit.type` -[accessible: true] `value __resultOfEnsuringImplicit.type` -[accessible: true] `value selfAny` -[accessible: true] `value xImplicit.type` +[response] askCompletionAt (7,7) +retrieved 38 members +def +(other: String): String +def ->[B](y: B): (Implicit.type, B) +def ensuring(cond: Boolean): Implicit.type +def ensuring(cond: Boolean,msg: => Any): Implicit.type +def ensuring(cond: Implicit.type => Boolean): Implicit.type +def ensuring(cond: Implicit.type => Boolean,msg: => Any): Implicit.type +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def toString(): String +def →[B](y: B): (Implicit.type, B) +final class AppliedImplicit[A] extends AnyRef +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +implicit def AppliedImplicit[A](x: A): Implicit.AppliedImplicit[A] +private[this] val __leftOfArrow: Implicit.type +private[this] val __resultOfEnsuring: Implicit.type +private[this] val __stringToFormat: Implicit.type +private[this] val __thingToAdd: Implicit.type +private[this] val x: Implicit.type +protected[package lang] def clone(): Object +protected[package lang] def finalize(): Unit ================================================================================ diff --git a/test/files/presentation/implicit-member/src/ImplicitMember.scala b/test/files/presentation/implicit-member/src/ImplicitMember.scala index 06732f6dc6..a547b65a8e 100644 --- a/test/files/presentation/implicit-member/src/ImplicitMember.scala +++ b/test/files/presentation/implicit-member/src/ImplicitMember.scala @@ -1,8 +1,8 @@ object Implicit { final class AppliedImplicit[A](val x: A) - + implicit def AppliedImplicit[A](x: A): AppliedImplicit[A] = new AppliedImplicit(x) - + this./*!*/x }
\ No newline at end of file diff --git a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala index 950569c880..1ddeb6ac4a 100644 --- a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala +++ b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala @@ -2,8 +2,8 @@ import java.io.PrintWriter import java.io.FileOutputStream import java.util.Calendar +import scala.reflect.internal.util.BatchSourceFile import scala.tools.nsc.interactive.tests._ -import scala.tools.nsc.util._ import scala.tools.nsc.io._ import scala.tools.nsc.doc diff --git a/test/files/presentation/partial-fun.check b/test/files/presentation/partial-fun.check new file mode 100644 index 0000000000..0352d5e5c8 --- /dev/null +++ b/test/files/presentation/partial-fun.check @@ -0,0 +1,2 @@ +reload: PartialFun.scala +ArrayBuffer() diff --git a/test/files/presentation/partial-fun/Runner.scala b/test/files/presentation/partial-fun/Runner.scala new file mode 100644 index 0000000000..3edd5bb5b0 --- /dev/null +++ b/test/files/presentation/partial-fun/Runner.scala @@ -0,0 +1,10 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + override def runDefaultTests() { + sourceFiles foreach (src => askLoadedTyped(src).get) + super.runDefaultTests() + + println(compiler.unitOfFile.values.map(_.problems).mkString("", "\n", "")) + } +} diff --git a/test/files/presentation/partial-fun/partial-fun.check b/test/files/presentation/partial-fun/partial-fun.check new file mode 100644 index 0000000000..adceab8280 --- /dev/null +++ b/test/files/presentation/partial-fun/partial-fun.check @@ -0,0 +1 @@ +reload: PartialFun.scala diff --git a/test/files/presentation/partial-fun/src/PartialFun.scala b/test/files/presentation/partial-fun/src/PartialFun.scala new file mode 100644 index 0000000000..4657898ed1 --- /dev/null +++ b/test/files/presentation/partial-fun/src/PartialFun.scala @@ -0,0 +1,5 @@ +class A { + def foo { + val x: PartialFunction[Int, Int] = ({ case 0 => 0 }) + } +} diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check index b666d51de5..be80601e11 100644 --- a/test/files/presentation/ping-pong.check +++ b/test/files/presentation/ping-pong.check @@ -2,101 +2,101 @@ reload: PingPong.scala askTypeCompletion at PingPong.scala(10,23) ================================================================================ -[response] aksTypeCompletion at (10,23) -retrieved 40 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(Pong, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)Pong` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Pong` -[accessible: true] `method ensuring(cond: Pong => Boolean)Pong` -[accessible: true] `method ensuring(cond: Pong => Boolean, msg: => Any)Pong` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method poke()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> Pong` -[accessible: true] `method →[B](y: B)(Pong, B)` -[accessible: true] `value __leftOfArrowPong` -[accessible: true] `value __resultOfEnsuringPong` -[accessible: true] `value nameString` -[accessible: true] `value selfAny` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` -[accessible: false] `value pingPing` +[response] askCompletionAt (10,23) +retrieved 39 members +[inaccessible] private[this] val ping: Ping +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def +(other: String): String +def ->[B](y: B): (Pong, B) +def ensuring(cond: Boolean): Pong +def ensuring(cond: Boolean,msg: => Any): Pong +def ensuring(cond: Pong => Boolean): Pong +def ensuring(cond: Pong => Boolean,msg: => Any): Pong +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def poke(): Unit +def →[B](y: B): (Pong, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +override def toString(): String +private[this] val __leftOfArrow: Pong +private[this] val __resultOfEnsuring: Pong +private[this] val __stringToFormat: Pong +private[this] val __thingToAdd: Pong +private[this] val name: String ================================================================================ askTypeCompletion at PingPong.scala(19,20) ================================================================================ -[response] aksTypeCompletion at (19,20) -retrieved 40 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(Ping, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)Ping` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Ping` -[accessible: true] `method ensuring(cond: Ping => Boolean)Ping` -[accessible: true] `method ensuring(cond: Ping => Boolean, msg: => Any)Ping` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method loop=> Unit` -[accessible: true] `method name=> String` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method poke=> Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> Ping` -[accessible: true] `method →[B](y: B)(Ping, B)` -[accessible: true] `value __leftOfArrowPing` -[accessible: true] `value __resultOfEnsuringPing` -[accessible: true] `value pongPong` -[accessible: true] `value selfAny` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` +[response] askCompletionAt (19,20) +retrieved 39 members +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def +(other: String): String +def ->[B](y: B): (Ping, B) +def ensuring(cond: Boolean): Ping +def ensuring(cond: Boolean,msg: => Any): Ping +def ensuring(cond: Ping => Boolean): Ping +def ensuring(cond: Ping => Boolean,msg: => Any): Ping +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def loop: Unit +def name: String +def poke: Unit +def →[B](y: B): (Ping, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +override def toString(): String +private[this] val __leftOfArrow: Ping +private[this] val __resultOfEnsuring: Ping +private[this] val __stringToFormat: Ping +private[this] val __thingToAdd: Ping +private[this] val pong: Pong ================================================================================ askType at PingPong.scala(8,10) ================================================================================ -[response] askTypeAt at (8,10) +[response] askTypeAt (8,10) def loop: Unit = Ping.this.poke() ================================================================================ askType at PingPong.scala(10,10) ================================================================================ -[response] askTypeAt at (10,10) +[response] askTypeAt (10,10) def poke: Unit = Ping.this.pong.poke() ================================================================================ askType at PingPong.scala(17,10) ================================================================================ -[response] askTypeAt at (17,10) +[response] askTypeAt (17,10) private[this] val name: String = "pong" ================================================================================ diff --git a/test/files/presentation/ping-pong/src/PingPong.scala b/test/files/presentation/ping-pong/src/PingPong.scala index 08bb4e3f2d..94f52c4658 100644 --- a/test/files/presentation/ping-pong/src/PingPong.scala +++ b/test/files/presentation/ping-pong/src/PingPong.scala @@ -2,21 +2,21 @@ class Ping { val pong = new Pong(this) - + def name = "ping" - def loop/*?*/ { poke() } - + def loop/*?*/ { poke() } + def poke/*?*/ { pong./*!*/poke() } - - override def toString = name + + override def toString = name } class Pong(ping: Ping) { val name/*?*/ = "pong" - + def poke() { ping./*!*/poke() } - + override def toString = name }
\ No newline at end of file diff --git a/test/files/presentation/random.check b/test/files/presentation/random.check index fce4b69fb3..fb3500aeea 100644 --- a/test/files/presentation/random.check +++ b/test/files/presentation/random.check @@ -2,7 +2,7 @@ reload: Random.scala askType at Random.scala(18,14) ================================================================================ -[response] askTypeAt at (18,14) +[response] askTypeAt (18,14) val filter: Int => Boolean = try { java.this.lang.Integer.parseInt(args.apply(0)) match { case 1 => ((x: Int) => x.%(2).!=(0)) @@ -16,12 +16,12 @@ val filter: Int => Boolean = try { askType at Random.scala(19,30) ================================================================================ -[response] askTypeAt at (19,30) +[response] askTypeAt (19,30) 0 ================================================================================ askType at Random.scala(26,12) ================================================================================ -[response] askTypeAt at (26,12) +[response] askTypeAt (26,12) _ ================================================================================ diff --git a/test/files/presentation/random/src/Random.scala b/test/files/presentation/random/src/Random.scala index 4fff783fa4..af76a28f47 100644 --- a/test/files/presentation/random/src/Random.scala +++ b/test/files/presentation/random/src/Random.scala @@ -4,16 +4,16 @@ import java.io._ import java.net.{InetAddress,ServerSocket,Socket,SocketException} import java.util.Random -/** - * Simple client/server application using Java sockets. - * - * The server simply generates random integer values and - * the clients provide a filter function to the server - * to get only values they interested in (eg. even or - * odd values, and so on). +/** + * Simple client/server application using Java sockets. + * + * The server simply generates random integer values and + * the clients provide a filter function to the server + * to get only values they interested in (eg. even or + * odd values, and so on). */ object randomclient { - + def main(args: Array[String]) { val filter/*?*/ = try { Integer.parseInt(args(0)/*?*/) match { diff --git a/test/files/presentation/t1207.check b/test/files/presentation/t1207.check new file mode 100644 index 0000000000..84bfd79d75 --- /dev/null +++ b/test/files/presentation/t1207.check @@ -0,0 +1,53 @@ +reload: Completions.scala + +askTypeCompletion at Completions.scala(10,15) +================================================================================ +[response] askCompletionAt (10,15) +retrieved 3 members +final package bongo +final package lang +final package util +================================================================================ + +askTypeCompletion at Completions.scala(11,16) +================================================================================ +[response] askCompletionAt (11,16) +retrieved 3 members +final package bongo +final package lang +final package util +================================================================================ + +askTypeCompletion at Completions.scala(12,19) +================================================================================ +[response] askCompletionAt (12,19) +retrieved 3 members +final package bongo +final package lang +final package util +================================================================================ + +askTypeCompletion at Completions.scala(13,19) +================================================================================ +[response] askCompletionAt (13,19) +retrieved 3 members +final package bongo +final package lang +final package util +================================================================================ + +askTypeCompletion at Completions.scala(14,23) +================================================================================ +[response] askCompletionAt (14,23) +retrieved 3 members +final package bongo +final package lang +final package util +================================================================================ + +askTypeCompletion at Completions.scala(15,10) +================================================================================ +[response] askCompletionAt (15,10) +retrieved 0 members + +================================================================================ diff --git a/test/files/presentation/t1207/Test.scala b/test/files/presentation/t1207/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/t1207/Test.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest
\ No newline at end of file diff --git a/test/files/presentation/t1207/src/Completions.scala b/test/files/presentation/t1207/src/Completions.scala new file mode 100644 index 0000000000..804d4fdc3d --- /dev/null +++ b/test/files/presentation/t1207/src/Completions.scala @@ -0,0 +1,20 @@ +package other { + package bongo { } + package lang { } + package util { + package boogly + } +} + +package ticket_1001207 { + import other./*!*/ + import other.u/*!*/ + import other.uti /*!*/ + import other.util/*!*/ + import other.{lang, u/*!*/} + import j/*!*/ + + class T1207 { + + } +} diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check index c6d4762635..b2cedd689f 100644 --- a/test/files/presentation/t5708.check +++ b/test/files/presentation/t5708.check @@ -2,46 +2,46 @@ reload: Completions.scala askTypeCompletion at Completions.scala(17,9) ================================================================================ -[response] aksTypeCompletion at (17,9) -retrieved 44 members -[accessible: true] `lazy value fooInt` -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(test.Compat.type, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method pkgPrivateM=> String` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> test.Compat.type` -[accessible: true] `method →[B](y: B)(test.Compat.type, B)` -[accessible: true] `value CONST_STRINGString("constant")` -[accessible: true] `value __leftOfArrowtest.Compat.type` -[accessible: true] `value __resultOfEnsuringtest.Compat.type` -[accessible: true] `value pkgPrivateVString` -[accessible: true] `value selfAny` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` -[accessible: false] `method privateM=> String` -[accessible: false] `method protectedValM=> String` -[accessible: false] `value privateVString` -[accessible: false] `value protectedVString` +[response] askCompletionAt (17,9) +retrieved 43 members +[inaccessible] private def privateM: String +[inaccessible] private[this] val privateV: String +[inaccessible] private[this] val protectedV: String +[inaccessible] protected def protectedValM: String +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def +(other: String): String +def ->[B](y: B): (test.Compat.type, B) +def ensuring(cond: Boolean): test.Compat.type +def ensuring(cond: Boolean,msg: => Any): test.Compat.type +def ensuring(cond: test.Compat.type => Boolean): test.Compat.type +def ensuring(cond: test.Compat.type => Boolean,msg: => Any): test.Compat.type +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def toString(): String +def →[B](y: B): (test.Compat.type, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +final private[this] val CONST_STRING: String("constant") +lazy private[this] var foo: Int +private[package test] def pkgPrivateM: String +private[this] val __leftOfArrow: test.Compat.type +private[this] val __resultOfEnsuring: test.Compat.type +private[this] val __stringToFormat: test.Compat.type +private[this] val __thingToAdd: test.Compat.type +private[this] val pkgPrivateV: String ================================================================================ diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check index 3026e58f7e..4ba7dbaad9 100644 --- a/test/files/presentation/visibility.check +++ b/test/files/presentation/visibility.check @@ -2,220 +2,220 @@ reload: Completions.scala askTypeCompletion at Completions.scala(14,12) ================================================================================ -[response] aksTypeCompletion at (14,12) -retrieved 42 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method clone()Object` -[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` -[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` -[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method finalize()Unit` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method secretPrivate()Unit` -[accessible: true] `method secretProtected()Unit` -[accessible: true] `method secretProtectedInPackage()Unit` -[accessible: true] `method secretPublic()Unit` -[accessible: true] `method someTests(other: accessibility.Foo)Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> accessibility.Foo` -[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` -[accessible: true] `value __leftOfArrowaccessibility.Foo` -[accessible: true] `value __resultOfEnsuringaccessibility.Foo` -[accessible: true] `value selfAny` -[accessible: false] `method secretPrivateThis()Unit` +[response] askCompletionAt (14,12) +retrieved 41 members +[inaccessible] private[this] def secretPrivateThis(): Unit +def +(other: String): String +def ->[B](y: B): (accessibility.Foo, B) +def ensuring(cond: Boolean): accessibility.Foo +def ensuring(cond: Boolean,msg: => Any): accessibility.Foo +def ensuring(cond: accessibility.Foo => Boolean): accessibility.Foo +def ensuring(cond: accessibility.Foo => Boolean,msg: => Any): accessibility.Foo +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def secretPublic(): Unit +def someTests(other: accessibility.Foo): Unit +def toString(): String +def →[B](y: B): (accessibility.Foo, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private def secretPrivate(): Unit +private[this] val __leftOfArrow: accessibility.Foo +private[this] val __resultOfEnsuring: accessibility.Foo +private[this] val __stringToFormat: accessibility.Foo +private[this] val __thingToAdd: accessibility.Foo +protected def secretProtected(): Unit +protected[package accessibility] def secretProtectedInPackage(): Unit +protected[package lang] def clone(): Object +protected[package lang] def finalize(): Unit ================================================================================ askTypeCompletion at Completions.scala(16,11) ================================================================================ -[response] aksTypeCompletion at (16,11) -retrieved 42 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method clone()Object` -[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` -[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` -[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method finalize()Unit` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method secretPrivate()Unit` -[accessible: true] `method secretPrivateThis()Unit` -[accessible: true] `method secretProtected()Unit` -[accessible: true] `method secretProtectedInPackage()Unit` -[accessible: true] `method secretPublic()Unit` -[accessible: true] `method someTests(other: accessibility.Foo)Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> accessibility.Foo` -[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` -[accessible: true] `value __leftOfArrowaccessibility.Foo` -[accessible: true] `value __resultOfEnsuringaccessibility.Foo` -[accessible: true] `value selfAny` +[response] askCompletionAt (16,11) +retrieved 41 members +def +(other: String): String +def ->[B](y: B): (accessibility.Foo, B) +def ensuring(cond: Boolean): accessibility.Foo +def ensuring(cond: Boolean,msg: => Any): accessibility.Foo +def ensuring(cond: accessibility.Foo => Boolean): accessibility.Foo +def ensuring(cond: accessibility.Foo => Boolean,msg: => Any): accessibility.Foo +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def secretPublic(): Unit +def someTests(other: accessibility.Foo): Unit +def toString(): String +def →[B](y: B): (accessibility.Foo, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private def secretPrivate(): Unit +private[this] def secretPrivateThis(): Unit +private[this] val __leftOfArrow: accessibility.Foo +private[this] val __resultOfEnsuring: accessibility.Foo +private[this] val __stringToFormat: accessibility.Foo +private[this] val __thingToAdd: accessibility.Foo +protected def secretProtected(): Unit +protected[package accessibility] def secretProtectedInPackage(): Unit +protected[package lang] def clone(): Object +protected[package lang] def finalize(): Unit ================================================================================ askTypeCompletion at Completions.scala(22,11) ================================================================================ -[response] aksTypeCompletion at (22,11) -retrieved 42 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(accessibility.AccessibilityChecks, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method clone()Object` -[accessible: true] `method ensuring(cond: Boolean)accessibility.AccessibilityChecks` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.AccessibilityChecks` -[accessible: true] `method ensuring(cond: accessibility.AccessibilityChecks => Boolean)accessibility.AccessibilityChecks` -[accessible: true] `method ensuring(cond: accessibility.AccessibilityChecks => Boolean, msg: => Any)accessibility.AccessibilityChecks` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method finalize()Unit` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method secretProtected()Unit` -[accessible: true] `method secretProtectedInPackage()Unit` -[accessible: true] `method secretPublic()Unit` -[accessible: true] `method someTests(other: accessibility.Foo)Unit` -[accessible: true] `method someTests=> Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> accessibility.AccessibilityChecks` -[accessible: true] `method →[B](y: B)(accessibility.AccessibilityChecks, B)` -[accessible: true] `value __leftOfArrowaccessibility.AccessibilityChecks` -[accessible: true] `value __resultOfEnsuringaccessibility.AccessibilityChecks` -[accessible: true] `value selfAny` -[accessible: false] `method secretPrivate()Unit` +[response] askCompletionAt (22,11) +retrieved 41 members +[inaccessible] private def secretPrivate(): Unit +def +(other: String): String +def ->[B](y: B): (accessibility.AccessibilityChecks, B) +def ensuring(cond: Boolean): accessibility.AccessibilityChecks +def ensuring(cond: Boolean,msg: => Any): accessibility.AccessibilityChecks +def ensuring(cond: accessibility.AccessibilityChecks => Boolean): accessibility.AccessibilityChecks +def ensuring(cond: accessibility.AccessibilityChecks => Boolean,msg: => Any): accessibility.AccessibilityChecks +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def secretPublic(): Unit +def someTests(other: accessibility.Foo): Unit +def someTests: Unit +def toString(): String +def →[B](y: B): (accessibility.AccessibilityChecks, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private[this] val __leftOfArrow: accessibility.AccessibilityChecks +private[this] val __resultOfEnsuring: accessibility.AccessibilityChecks +private[this] val __stringToFormat: accessibility.AccessibilityChecks +private[this] val __thingToAdd: accessibility.AccessibilityChecks +protected def secretProtected(): Unit +protected[package accessibility] def secretProtectedInPackage(): Unit +protected[package lang] def clone(): Object +protected[package lang] def finalize(): Unit ================================================================================ askTypeCompletion at Completions.scala(28,10) ================================================================================ -[response] aksTypeCompletion at (28,10) -retrieved 42 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` -[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` -[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method secretProtectedInPackage()Unit` -[accessible: true] `method secretPublic()Unit` -[accessible: true] `method someTests(other: accessibility.Foo)Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> accessibility.Foo` -[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` -[accessible: true] `value __leftOfArrowaccessibility.Foo` -[accessible: true] `value __resultOfEnsuringaccessibility.Foo` -[accessible: true] `value selfAny` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` -[accessible: false] `method secretPrivate()Unit` -[accessible: false] `method secretPrivateThis()Unit` -[accessible: false] `method secretProtected()Unit` +[response] askCompletionAt (28,10) +retrieved 41 members +[inaccessible] private def secretPrivate(): Unit +[inaccessible] private[this] def secretPrivateThis(): Unit +[inaccessible] protected def secretProtected(): Unit +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def +(other: String): String +def ->[B](y: B): (accessibility.Foo, B) +def ensuring(cond: Boolean): accessibility.Foo +def ensuring(cond: Boolean,msg: => Any): accessibility.Foo +def ensuring(cond: accessibility.Foo => Boolean): accessibility.Foo +def ensuring(cond: accessibility.Foo => Boolean,msg: => Any): accessibility.Foo +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def secretPublic(): Unit +def someTests(other: accessibility.Foo): Unit +def toString(): String +def →[B](y: B): (accessibility.Foo, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private[this] val __leftOfArrow: accessibility.Foo +private[this] val __resultOfEnsuring: accessibility.Foo +private[this] val __stringToFormat: accessibility.Foo +private[this] val __thingToAdd: accessibility.Foo +protected[package accessibility] def secretProtectedInPackage(): Unit ================================================================================ askTypeCompletion at Completions.scala(37,8) ================================================================================ -[response] aksTypeCompletion at (37,8) -retrieved 42 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` -[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` -[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method secretPublic()Unit` -[accessible: true] `method someTests(other: accessibility.Foo)Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> accessibility.Foo` -[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` -[accessible: true] `value __leftOfArrowaccessibility.Foo` -[accessible: true] `value __resultOfEnsuringaccessibility.Foo` -[accessible: true] `value selfAny` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` -[accessible: false] `method secretPrivate()Unit` -[accessible: false] `method secretPrivateThis()Unit` -[accessible: false] `method secretProtected()Unit` -[accessible: false] `method secretProtectedInPackage()Unit` +[response] askCompletionAt (37,8) +retrieved 41 members +[inaccessible] private def secretPrivate(): Unit +[inaccessible] private[this] def secretPrivateThis(): Unit +[inaccessible] protected def secretProtected(): Unit +[inaccessible] protected[package accessibility] def secretProtectedInPackage(): Unit +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def +(other: String): String +def ->[B](y: B): (accessibility.Foo, B) +def ensuring(cond: Boolean): accessibility.Foo +def ensuring(cond: Boolean,msg: => Any): accessibility.Foo +def ensuring(cond: accessibility.Foo => Boolean): accessibility.Foo +def ensuring(cond: accessibility.Foo => Boolean,msg: => Any): accessibility.Foo +def equals(x$1: Any): Boolean +def formatted(fmtstr: String): String +def hashCode(): Int +def secretPublic(): Unit +def someTests(other: accessibility.Foo): Unit +def toString(): String +def →[B](y: B): (accessibility.Foo, B) +final def !=(x$1: Any): Boolean +final def !=(x$1: AnyRef): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def ==(x$1: AnyRef): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +private[this] val __leftOfArrow: accessibility.Foo +private[this] val __resultOfEnsuring: accessibility.Foo +private[this] val __stringToFormat: accessibility.Foo +private[this] val __thingToAdd: accessibility.Foo ================================================================================ diff --git a/test/files/presentation/visibility/src/Completions.scala b/test/files/presentation/visibility/src/Completions.scala index 098b98a0fd..8c07934915 100644 --- a/test/files/presentation/visibility/src/Completions.scala +++ b/test/files/presentation/visibility/src/Completions.scala @@ -22,7 +22,7 @@ package accessibility { this./*!*/ // should not list secretPrivate* } } - + class UnrelatedClass { def someTests(foo: Foo) { foo./*!*/ // should list public and protected[accessiblity] diff --git a/test/files/res/t597/Test.scala b/test/files/res/t597/Test.scala index 45b90bb17d..2f63f46c3d 100644 --- a/test/files/res/t597/Test.scala +++ b/test/files/res/t597/Test.scala @@ -2,7 +2,7 @@ package test; abstract class Base { type A <: Ax; - + abstract class Ax { def a = null; def string = "A"; diff --git a/test/files/res/t722/Parser.scala b/test/files/res/t722/Parser.scala index 9f54358920..5dfcd57367 100644 --- a/test/files/res/t722/Parser.scala +++ b/test/files/res/t722/Parser.scala @@ -2,7 +2,7 @@ package t722; trait Parser { trait Link { - def foo() = {} + def foo() = {} } } diff --git a/test/files/res/t735/ScalaExpressions.scala b/test/files/res/t735/ScalaExpressions.scala index 605ad51c08..f9c8ac733c 100644 --- a/test/files/res/t735/ScalaExpressions.scala +++ b/test/files/res/t735/ScalaExpressions.scala @@ -1,6 +1,6 @@ package t735; trait ScalaExpressions { - trait ExpressionFactory { + trait ExpressionFactory { def foo = 10; def bar : Int; } diff --git a/test/files/res/t743/BracesXXX.scala b/test/files/res/t743/BracesXXX.scala index d3f6e28fe9..ed7b386a88 100644 --- a/test/files/res/t743/BracesXXX.scala +++ b/test/files/res/t743/BracesXXX.scala @@ -1,6 +1,6 @@ package t743; trait BracesXXX extends ParserXXX { - trait Matchable extends IsLinked { + trait Matchable extends IsLinked { def foo : NodeImpl = null; } } diff --git a/test/files/res/t743/ParserXXX.scala b/test/files/res/t743/ParserXXX.scala index fd584b972a..d132bdbf1d 100644 --- a/test/files/res/t743/ParserXXX.scala +++ b/test/files/res/t743/ParserXXX.scala @@ -1,9 +1,9 @@ package t743; trait ParserXXX { - val foo = null; - trait NodeImpl { + val foo = null; + trait NodeImpl { trait Link extends ParserXXX.this.Link { - val from = null; + val from = null; } } trait Link { diff --git a/test/files/res/t785/ScalaNewTyper.scala b/test/files/res/t785/ScalaNewTyper.scala index 919e3b8d0e..acdba0f25d 100644 --- a/test/files/res/t785/ScalaNewTyper.scala +++ b/test/files/res/t785/ScalaNewTyper.scala @@ -1,7 +1,7 @@ package t785; trait ScalaNewTyper { private var typed : String = null; - trait HasSymbol { + trait HasSymbol { protected def foo() : Unit = {} } trait HasArgsTypeParametersImpl extends HasSymbol { diff --git a/test/files/res/t831/NewScalaParserXXX.scala b/test/files/res/t831/NewScalaParserXXX.scala index ed9b9d3b6f..958e4f99c1 100644 --- a/test/files/res/t831/NewScalaParserXXX.scala +++ b/test/files/res/t831/NewScalaParserXXX.scala @@ -10,33 +10,33 @@ trait ScalaNodeScannerXXX { //for (ns <-n; val i <- 0.until(ns)) yield f; -trait NewScalaScannerXXX extends ScalaNodeScannerXXX { +trait NewScalaScannerXXX extends ScalaNodeScannerXXX { type Unfixed <: Node with UnfixedImpl; trait UnfixedImpl extends super.UnfixedImpl with NodeImpl; type Statement <: Unfixed with StatementImpl; trait StatementImpl extends UnfixedImpl { def self : Statement; } type NewLine <: Statement with NewLineImpl; - trait NewLineImpl extends StatementImpl { - def self : NewLine; + trait NewLineImpl extends StatementImpl { + def self : NewLine; def isActive : Boolean = true; } object ArrowMode extends Enumeration { val Def, Case, Expr = Value } } -trait ScalaPrecedenceXXX extends NewScalaScannerXXX { +trait ScalaPrecedenceXXX extends NewScalaScannerXXX { type NewLine <: Statement with NewLineImpl; - trait NewLineImpl extends super.NewLineImpl with StatementImpl { - def self : NewLine; + trait NewLineImpl extends super.NewLineImpl with StatementImpl { + def self : NewLine; override def isActive = super[NewLineImpl].isActive; } } trait NewScalaParserXXX extends NewScalaScannerXXX with ScalaPrecedenceXXX { type NewLine <: Statement with NewLineImpl; trait MyNewLine extends super[NewScalaScannerXXX].NewLineImpl; - trait NewLineImpl extends MyNewLine with + trait NewLineImpl extends MyNewLine with super[ScalaPrecedenceXXX].NewLineImpl with - StatementImpl { - def self : NewLine; + StatementImpl { + def self : NewLine; override def isActive = super[MyNewLine].isActive; } } diff --git a/test/files/run/Course-2002-01.check b/test/files/run/Course-2002-01.check index 17b30bf3c2..16b491d6e2 100644 --- a/test/files/run/Course-2002-01.check +++ b/test/files/run/Course-2002-01.check @@ -1,3 +1,6 @@ +Course-2002-01.scala:41: warning: method loop in object M0 does nothing other than call itself recursively + def loop: Int = loop; + ^ 232 667 11 diff --git a/test/files/run/Course-2002-02.scala b/test/files/run/Course-2002-02.scala index 56d7298aaf..b8650108ed 100644 --- a/test/files/run/Course-2002-02.scala +++ b/test/files/run/Course-2002-02.scala @@ -100,7 +100,7 @@ object M4 { def sumInts = sum(x => x) def sumCubes = sum(x => x * x * x) - def sumReciprocals = sum(1.0/_) + def sumReciprocals = sum(1.0/_) def sumPi = { n: Int => 4 + sum(x => 4.0/(4*x+1) - 4.0/(4*x-1))(1, n) } Console.println(sumInts(1,4)) @@ -194,7 +194,7 @@ object M8 { //############################################################################ object M9 { - def accumulate[t](combiner: (t, t) => t, nullValue: t, f: Int => t, + def accumulate[t](combiner: (t, t) => t, nullValue: t, f: Int => t, next: Int => Int)(a: Int, b: Int): t = if (a > b) nullValue else combiner(f(a), accumulate(combiner, nullValue, f, next)(next(a), b)) @@ -328,9 +328,9 @@ object MD { iter(a, zero) } - def plus (x:Double,y:Double) = x+y; + def plus (x:Double,y:Double) = x+y; val sum: (Int => Double) => (Int, Int) => Double = reduce(plus , 0); - def times(x:Double,y:Double) = x*y; + def times(x:Double,y:Double) = x*y; val product: (Int => Double) => (Int, Int) => Double = reduce(times, 1); def factorial(n: Int) = product(x => x)(1 , n) diff --git a/test/files/run/Course-2002-05.scala b/test/files/run/Course-2002-05.scala index 9457fae147..e6764b92c8 100644 --- a/test/files/run/Course-2002-05.scala +++ b/test/files/run/Course-2002-05.scala @@ -129,7 +129,7 @@ object M3 { else { def isSafe(column: Int, placement: Placement): Boolean = placement forall { - pos => (pos._2 != column && + pos => (pos._2 != column && abs(pos._2 - column) != row - pos._1) } diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala index 7848ae3e8e..055ff74d81 100644 --- a/test/files/run/Course-2002-07.scala +++ b/test/files/run/Course-2002-07.scala @@ -16,13 +16,13 @@ object M0 { def isNumber: Boolean = true; def isSum: Boolean = false; def numValue: Int = n; - def leftOp: Expr = error("Number.leftOp"); - def rightOp: Expr = error("Number.rightOp"); + def leftOp: Expr = sys.error("Number.leftOp"); + def rightOp: Expr = sys.error("Number.rightOp"); } class Sum(e1: Expr, e2: Expr) extends Expr { def isNumber: Boolean = false; def isSum: Boolean = true; - def numValue: Int = error("Sum.numValue"); + def numValue: Int = sys.error("Sum.numValue"); def leftOp: Expr = e1; def rightOp: Expr = e2; } @@ -30,7 +30,7 @@ object M0 { class Prod(e1: Expr, e2: Expr) extends Expr { def isNumber: Boolean = false; def isSum: Boolean = false; - def numValue: Int = error("Prod.numValue"); + def numValue: Int = sys.error("Prod.numValue"); def leftOp: Expr = e1; def rightOp: Expr = e2; } @@ -38,15 +38,15 @@ object M0 { class Var(x: String) extends Expr { def isNumber: Boolean = false; def isSum: Boolean = false; - def numValue: Int = error("Var.numValue"); - def leftOp: Expr = error("Var.leftOp"); - def rightOp: Expr = error("Var.rightOp"); + def numValue: Int = sys.error("Var.numValue"); + def leftOp: Expr = sys.error("Var.leftOp"); + def rightOp: Expr = sys.error("Var.rightOp"); } def eval(e: Expr): Int = { if (e.isNumber) e.numValue else if (e.isSum) eval(e.leftOp) + eval(e.rightOp) - else error("unknown expression") + else sys.error("unknown expression") } def test = { @@ -375,7 +375,7 @@ object M9 { object MA { def lookup[k,v](xs: List[Pair[k,v]], k: k): v = xs match { - case List() => error("no value for " + k) + case List() => sys.error("no value for " + k) case Pair(k1,v1) :: xs1 => if (k1 == k) v1 else lookup(xs1, k) } @@ -410,7 +410,7 @@ object MA { def eval(e: Expr): Int = e match { case Number(n) => n - case Var(_) => error("cannot evaluate variable") + case Var(_) => sys.error("cannot evaluate variable") case Sum(e1, e2) => eval(e1) + eval(e2) case Prod(e1, e2) => eval(e1) * eval(e2) } @@ -453,7 +453,7 @@ object Utils { if (y == 1) x else if (y % 2 == 0) power0(x*x,y/2) else x*power0(x, y-1); def power(x: Int, y: Int): Int = (x,y) match { - case Pair(0,0) => error("power(0,0)") + case Pair(0,0) => sys.error("power(0,0)") case Pair(0,_) => 0 case Pair(1,_) => 1 case Pair(_,0) => 1 @@ -463,7 +463,7 @@ object Utils { } def lookup(entries: List[(String,Int)], key: String): Int = entries match { - case List() => error("no value for " + key) + case List() => sys.error("no value for " + key) case Pair(k,v) :: _ if (k == key) => v case _ :: rest => lookup(rest, key) } diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala index 85a83e0146..38b8363661 100644 --- a/test/files/run/Course-2002-08.scala +++ b/test/files/run/Course-2002-08.scala @@ -33,7 +33,7 @@ object M1 { if (0 < amount && amount <= balance) { balance = balance - amount; balance - } else error("insufficient funds"); + } else sys.error("insufficient funds"); } def test0 = { @@ -520,7 +520,7 @@ abstract class CircuitSimulator() extends BasicCircuitSimulator() { val w1 = new Wire(); val w2 = new Wire(); val w3 = new Wire(); - + andGate(in, ctrl(1), w3); andGate(in, ctrl(1), w2); andGate(in, ctrlN(1), w1); diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala index 384a91efd8..87f91111d8 100644 --- a/test/files/run/Course-2002-09.scala +++ b/test/files/run/Course-2002-09.scala @@ -8,8 +8,8 @@ trait Constraint { } object NoConstraint extends Constraint { - def newValue: Unit = error("NoConstraint.newValue"); - def dropValue: Unit = error("NoConstraint.dropValue"); + def newValue: Unit = sys.error("NoConstraint.newValue"); + def dropValue: Unit = sys.error("NoConstraint.dropValue"); } class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint { @@ -47,7 +47,7 @@ class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity) class Squarer(square: Quantity, root: Quantity) extends Constraint { def newValue: Unit = Pair(square.getValue, root.getValue) match { - case Pair(Some(x), _ )if (x < 0) => error("Square of negative number") + case Pair(Some(x), _ )if (x < 0) => sys.error("Square of negative number") case Pair(Some(x), _ ) => root.setValue(Math.sqrt(x), this) case Pair(_ , Some(x)) => square.setValue(x*x, this) case _ => @@ -72,8 +72,8 @@ class Eq(a: Quantity, b: Quantity) extends Constraint { } class Constant(q: Quantity, v: Double) extends Constraint { - def newValue: Unit = error("Constant.newValue"); - def dropValue: Unit = error("Constant.dropValue"); + def newValue: Unit = sys.error("Constant.newValue"); + def dropValue: Unit = sys.error("Constant.dropValue"); q connect this; q.setValue(v, this); } @@ -100,7 +100,7 @@ class Quantity() { def setValue(v: Double, setter: Constraint) = value match { case Some(v1) => - if (v != v1) error("Error! contradiction: " + v + " and " + v1); + if (v != v1) sys.error("Error! contradiction: " + v + " and " + v1); case None => informant = setter; value = Some(v); for (c <- constraints; if !(c == informant)) { diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala index c266af8c32..4bd3614fb0 100644 --- a/test/files/run/Course-2002-13.scala +++ b/test/files/run/Course-2002-13.scala @@ -42,7 +42,7 @@ object Terms { } case class Binding(name: String, term: Term) { - term match { case Var(n) if (name == n) => error("bad binding") case _ => () } + term match { case Var(n) if (name == n) => sys.error("bad binding") case _ => () } override def toString() = name + " = " + term; } @@ -168,7 +168,7 @@ class Parser(s: String) { var token: String = it.next; - def syntaxError(msg: String): Unit = error(msg + ", but " + token + " found"); + def syntaxError(msg: String): Unit = sys.error(msg + ", but " + token + " found"); def rep[a](p: => a): List[a] = { val t = p; diff --git a/test/files/run/Meter.check b/test/files/run/Meter.check index b7e2eac125..c79c51a294 100644 --- a/test/files/run/Meter.check +++ b/test/files/run/Meter.check @@ -1,3 +1,6 @@ +Meter.scala:72: warning: a.Meter and Int are unrelated: they will never compare equal + println("x == 1: "+(x == 1)) + ^ 2.0 4.0m false diff --git a/test/files/run/MeterCaseClass.check b/test/files/run/MeterCaseClass.check index 2528753657..2782704f9f 100644 --- a/test/files/run/MeterCaseClass.check +++ b/test/files/run/MeterCaseClass.check @@ -1,3 +1,6 @@ +MeterCaseClass.scala:69: warning: comparing values of types a.Meter and Int using `==' will always yield false + println("x == 1: "+(x == 1)) + ^ 2.0 Meter(4.0) false diff --git a/test/files/run/OrderingTest.scala b/test/files/run/OrderingTest.scala index 53448fbbce..8af18aaba5 100644 --- a/test/files/run/OrderingTest.scala +++ b/test/files/run/OrderingTest.scala @@ -6,7 +6,7 @@ object Test extends App { assert((cmp == 0) == (cmp2 == 0)) assert((cmp > 0) == (cmp2 < 0)) assert((cmp < 0) == (cmp2 > 0)) - } + } def testAll[T](t1 : T, t2 : T)(implicit ord : Ordering[T]) = { assert(ord.compare(t1, t2) < 0) @@ -16,8 +16,8 @@ object Test extends App { } assert(Ordering[String].compare("australopithecus", "brontausaurus") < 0) - // assert(Ordering[Unit].compare((), ()) == 0) - + // assert(Ordering[Unit].compare((), ()) == 0) + testAll("bar", "foo"); testAll[Byte](0, 1); testAll(false, true) @@ -28,7 +28,7 @@ object Test extends App { testAll[Iterable[Int]](List(1, 2), List(2)); testAll((1, "bar"), (1, "foo")) testAll((1, "foo"), (2, "bar")) - + // sortBy val words = "The quick brown fox jumped over the lazy dog".split(' ') val result = words.sortBy(x => (x.length, x.head)) diff --git a/test/files/run/Predef.readLine.scala b/test/files/run/Predef.readLine.scala index 9f07936638..54809f8071 100644 --- a/test/files/run/Predef.readLine.scala +++ b/test/files/run/Predef.readLine.scala @@ -1,4 +1,5 @@ import java.io.StringReader +import scala.io.ReadStdin.readLine object Test extends App { Console.withIn(new StringReader("")) { @@ -7,4 +8,4 @@ object Test extends App { readLine("%s prompt\n", "fancy") readLine("%s %s prompt\n", "immensely", "fancy") } -}
\ No newline at end of file +} diff --git a/test/files/run/ReplacementMatching.scala b/test/files/run/ReplacementMatching.scala index faa46419dc..05040d98a3 100644 --- a/test/files/run/ReplacementMatching.scala +++ b/test/files/run/ReplacementMatching.scala @@ -7,12 +7,12 @@ import util.matching._ object Test { - + def main(args: Array[String]) { replacementMatching groupsMatching } - + def replacementMatching { val regex = """\$\{(.+?)\}""".r val replaced = regex.replaceAllIn("Replacing: ${main}. And another method: ${foo}.", @@ -21,7 +21,7 @@ object Test { identifier }) assert(replaced == "Replacing: main. And another method: foo.") - + val regex3 = """\$\{(.+?)\}""".r val replaced3 = regex3.replaceSomeIn("Replacing: ${main}. And another: ${foo}.", (m: util.matching.Regex.Match) => { val id = m.group(1) @@ -29,7 +29,7 @@ object Test { }) assert(replaced3 == "Replacing: main. And another: ${foo}.") } - + def groupsMatching { val Date = """(\d+)/(\d+)/(\d+)""".r for (Regex.Groups(a, b, c) <- Date findFirstMatchIn "1/1/2001 marks the start of the millenium. 31/12/2000 doesn't.") { @@ -43,5 +43,5 @@ object Test { assert(c == "2001" || c == "2000") } } - + } diff --git a/test/files/run/ReverseSeqView.scala b/test/files/run/ReverseSeqView.scala index 517f1cc24c..2004791bff 100644 --- a/test/files/run/ReverseSeqView.scala +++ b/test/files/run/ReverseSeqView.scala @@ -5,14 +5,14 @@ object Test extends App { - + val lstv = List(1, 2, 3).view val lstvr = lstv.reverse assert(lstvr.iterator.toList == List(3, 2, 1)) assert(lstvr.reverse == List(1, 2, 3)) assert(lstvr.reverseIterator.toList == List(1, 2, 3)) assert(lstvr.reverseMap(_ + 1) == List(2, 3, 4)) - + } diff --git a/test/files/run/SymbolsTest.scala b/test/files/run/SymbolsTest.scala index 53caa5e62f..d5948ea168 100644 --- a/test/files/run/SymbolsTest.scala +++ b/test/files/run/SymbolsTest.scala @@ -1,6 +1,5 @@ - - +import scala.language.reflectiveCalls class Slazz { val s1 = 'myFirstSymbol diff --git a/test/files/run/UnrolledBuffer.scala b/test/files/run/UnrolledBuffer.scala index fe08e812ac..62a1f7d083 100644 --- a/test/files/run/UnrolledBuffer.scala +++ b/test/files/run/UnrolledBuffer.scala @@ -7,12 +7,12 @@ import collection.mutable.UnrolledBuffer object Test { - + def main(args: Array[String]) { val u1 = new UnrolledBuffer[Int] assert(u1.isEmpty) assert(u1.size == 0) - + u1 += 1 u1 += 2 u1 += 3 @@ -20,11 +20,11 @@ object Test { assert(u1.toList == List(1, 2, 3)) assert(u1.nonEmpty) assert(u1.size == 3) - + u1.clear assert(u1.isEmpty) assert(u1.size == 0) - + u1 += 1 u1 += 2 u1 += 3 @@ -33,56 +33,56 @@ object Test { assert(u1.size == 2) assert(u1 == UnrolledBuffer(1, 3)) assert(u1.toList == List(1, 3)) - + u1 concat UnrolledBuffer(5, 7, 9) assert(u1 == UnrolledBuffer(1, 3, 5, 7, 9)) - + val u2 = u1 map { x => (x - 1) / 2 } assert(u2 == UnrolledBuffer(0, 1, 2, 3, 4)) - + u1.clear u2.clear assert(u1.size == 0) assert(u2.size == 0) - + for (i <- 0 until 500) u1 += i for (i <- 500 until 1000) u2 += i assert(u1.size == 500) assert(u2.size == 500) assert(u1.iterator.toList == (0 until 500).toList) assert((for (elem <- u1) yield elem) sameElements (0 until 500)) - + u1 concat u2 assert(u1.size == 1000) assert(u2.size == 0) assertCorrect(u1) - + u1 concat UnrolledBuffer() assertCorrect(u1) - + val u3 = u1 map { x => x } var i = 0 for (elem <- u1) { assert(elem == u3(i)) i += 1 } - + u1.remove(999) assert(u1.size == 999) assertCorrect(u1) - + u1.remove(500) assert(u1.size == 998) assertCorrect(u1) - + u1.remove(5) assert(u1.size == 997) assertCorrect(u1) - + u1.remove(0) assert(u1.size == 996) assertCorrect(u1) - + u1.insert(0, 0) assert(u1.size == 997) assertCorrect(u1) @@ -90,15 +90,15 @@ object Test { u1.insert(5, 5) assert(u1.size == 998) assertCorrect(u1) - + u1.insert(500, 500) assert(u1.size == 999) assertCorrect(u1) - + u1.insert(999, 999) assert(u1.size == 1000) assertCorrect(u1) - + for (i <- -100 until 0) { i +=: u1 assertCorrect(u1) @@ -106,7 +106,7 @@ object Test { assert(u1.size == 1100) assertCorrect(u1) } - + def assertCorrect(u1: UnrolledBuffer[Int]) { val sz = u1.size val store = new Array[Int](sz) @@ -117,9 +117,9 @@ object Test { for (i <- 0 until sz) assert(u1(i) == (sz - i)) for (i <- 0 until sz) u1(i) = store(i) for (i <- 0 until sz) assert(store(i) == u1(i)) - + assert((u1 map { x => x }) == u1) assert(u1.iterator.toSeq.size == u1.size) } - + } diff --git a/test/files/run/WeakHashSetTest.scala b/test/files/run/WeakHashSetTest.scala index 3c8f380150..8072aa9b84 100644 --- a/test/files/run/WeakHashSetTest.scala +++ b/test/files/run/WeakHashSetTest.scala @@ -33,7 +33,7 @@ package scala.reflect.internal.util { def checkEmpty { val hs = new WeakHashSet[String]() assert(hs.size == 0) - hs.diagnostics.fullyValidate + hs.diagnostics.fullyValidate } // make sure += works @@ -85,7 +85,7 @@ package scala.reflect.internal.util { val hs = new WeakHashSet[Collider]() val elements = (0 until size).toList map {x => Collider("a" + x)} elements foreach (hs += _) - // don't throw the following into a retained collection so gc + // don't throw the following into a retained collection so gc // can remove them for (i <- 0 until size) { hs += Collider("b" + i) @@ -150,9 +150,9 @@ package scala.reflect.internal.util { hs.clear() assert(hs.size == 0) elements foreach {i => assert(!(hs contains i))} - hs.diagnostics.fullyValidate + hs.diagnostics.fullyValidate } - + // check that the iterator covers all the contents def checkIterator { val hs = new WeakHashSet[String]() @@ -161,14 +161,14 @@ package scala.reflect.internal.util { assert(elements.iterator.toList.sorted == elements.sorted) hs.diagnostics.fullyValidate } - + // check that the iterator covers all the contents even when there is a collision def checkIteratorCollisions { val hs = new WeakHashSet[Collider] val elements = (0 until 20).toList map {x => Collider("a" + x)} elements foreach (hs += _) - assert(elements.iterator.toList.sorted == elements.sorted) + assert(elements.iterator.toList.sorted == elements.sorted) hs.diagnostics.fullyValidate } } -} +} diff --git a/test/files/run/absoverride.scala b/test/files/run/absoverride.scala index 8c6de09d2a..a3c03df0d7 100644 --- a/test/files/run/absoverride.scala +++ b/test/files/run/absoverride.scala @@ -26,16 +26,16 @@ trait SyncIterator extends AbsIterator { } } trait LoggedIterator extends AbsIterator { - abstract override def next: T = { - val x = super.next; println("log: " + x); x + abstract override def next: T = { + val x = super.next; println("log: " + x); x } } -class Iter2(s: String) extends StringIterator(s) - with SyncIterator with LoggedIterator; +class Iter2(s: String) extends StringIterator(s) + with SyncIterator with LoggedIterator; object Test { def main(args: Array[String]) { class Iter extends StringIterator(args(0)) with RichIterator with SyncIterator with LoggedIterator val iter = new Iter - iter foreach Console.println + iter foreach Console.println } } diff --git a/test/files/run/abstypetags_serialize.scala b/test/files/run/abstypetags_serialize.scala index 93fb5dcd06..6ec97105fe 100644 --- a/test/files/run/abstypetags_serialize.scala +++ b/test/files/run/abstypetags_serialize.scala @@ -1,3 +1,4 @@ +import scala.language.higherKinds import java.io._ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{universe => ru} @@ -30,4 +31,4 @@ object Test extends App { } qwe -}
\ No newline at end of file +} diff --git a/test/files/run/all-overridden.check b/test/files/run/all-overridden.check new file mode 100644 index 0000000000..1b620b1176 --- /dev/null +++ b/test/files/run/all-overridden.check @@ -0,0 +1 @@ +method g diff --git a/test/files/run/all-overridden.scala b/test/files/run/all-overridden.scala new file mode 100644 index 0000000000..1b798ef748 --- /dev/null +++ b/test/files/run/all-overridden.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ + +object Test { + trait Foo { def f: Int = 5 ; def g: Int } + trait Bar extends Foo { def f: Int ; def g: Int = 5 } + + def main(args: Array[String]): Unit = { + // We should see g, but not f or $init$. + typeOf[Bar].declarations.toList.flatMap(_.allOverriddenSymbols) foreach println + } +} diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check index 7d8d181306..e3ab554d4c 100644 --- a/test/files/run/analyzerPlugins.check +++ b/test/files/run/analyzerPlugins.check @@ -7,7 +7,7 @@ annotationsConform(Int @testAnn, Int) [2] annotationsConform(Int(1) @testAnn, Int) [1] annotationsConform(Int(1), Int @testAnn) [1] annotationsConform(Nothing, Int @testAnn) [2] -annotationsConform(String @testAnn, String) [1] +annotationsConform(String @testAnn, String) [2] canAdaptAnnotations(Trees$Ident, String) [1] canAdaptAnnotations(Trees$Select, ?) [1] canAdaptAnnotations(Trees$Select, Boolean @testAnn) [1] @@ -19,27 +19,27 @@ canAdaptAnnotations(Trees$Typed, Any) [1] canAdaptAnnotations(Trees$Typed, Int) [1] lub(List(Int @testAnn, Int)) [1] pluginsPt(?, Trees$Annotated) [7] -pluginsPt(?, Trees$Apply) [8] +pluginsPt(?, Trees$Apply) [9] pluginsPt(?, Trees$ApplyImplicitView) [2] pluginsPt(?, Trees$Assign) [7] -pluginsPt(?, Trees$Block) [7] +pluginsPt(?, Trees$Block) [4] pluginsPt(?, Trees$ClassDef) [2] pluginsPt(?, Trees$DefDef) [14] -pluginsPt(?, Trees$Ident) [49] +pluginsPt(?, Trees$Ident) [50] pluginsPt(?, Trees$If) [2] -pluginsPt(?, Trees$Literal) [20] +pluginsPt(?, Trees$Literal) [16] pluginsPt(?, Trees$New) [5] pluginsPt(?, Trees$PackageDef) [1] pluginsPt(?, Trees$Return) [1] -pluginsPt(?, Trees$Select) [51] +pluginsPt(?, Trees$Select) [48] pluginsPt(?, Trees$Super) [2] pluginsPt(?, Trees$This) [20] -pluginsPt(?, Trees$TypeApply) [3] +pluginsPt(?, Trees$TypeApply) [4] pluginsPt(?, Trees$TypeBoundsTree) [2] pluginsPt(?, Trees$TypeDef) [1] -pluginsPt(?, Trees$TypeTree) [37] +pluginsPt(?, Trees$TypeTree) [39] pluginsPt(?, Trees$Typed) [1] -pluginsPt(?, Trees$ValDef) [23] +pluginsPt(?, Trees$ValDef) [21] pluginsPt(Any, Trees$Literal) [2] pluginsPt(Any, Trees$Typed) [1] pluginsPt(Array[Any], Trees$ArrayValue) [1] @@ -53,7 +53,7 @@ pluginsPt(Int @testAnn, Trees$Literal) [1] pluginsPt(Int, Trees$Apply) [1] pluginsPt(Int, Trees$Ident) [2] pluginsPt(Int, Trees$If) [1] -pluginsPt(Int, Trees$Literal) [6] +pluginsPt(Int, Trees$Literal) [5] pluginsPt(Int, Trees$Select) [3] pluginsPt(List, Trees$Apply) [1] pluginsPt(List[Any], Trees$Select) [1] @@ -65,7 +65,7 @@ pluginsPt(String, Trees$Literal) [1] pluginsPt(String, Trees$Select) [1] pluginsPt(String, Trees$Typed) [1] pluginsPt(Unit, Trees$Assign) [1] -pluginsPt(scala.annotation.Annotation, Trees$Apply) [5] +pluginsPt(testAnn, Trees$Apply) [5] pluginsTypeSig(<none>, Trees$Template) [2] pluginsTypeSig(class A, Trees$ClassDef) [1] pluginsTypeSig(class testAnn, Trees$ClassDef) [1] @@ -82,8 +82,8 @@ pluginsTypeSig(value lub1, Trees$ValDef) [2] pluginsTypeSig(value lub2, Trees$ValDef) [2] pluginsTypeSig(value param, Trees$ValDef) [2] pluginsTypeSig(value str, Trees$ValDef) [1] -pluginsTypeSig(value x, Trees$ValDef) [5] -pluginsTypeSig(value y, Trees$ValDef) [5] +pluginsTypeSig(value x, Trees$ValDef) [4] +pluginsTypeSig(value y, Trees$ValDef) [4] pluginsTypeSig(variable count, Trees$ValDef) [3] pluginsTypeSigAccessor(value annotField) [1] pluginsTypeSigAccessor(value inferField) [1] @@ -98,6 +98,7 @@ pluginsTyped(()String, Trees$Ident) [1] pluginsTyped(()String, Trees$TypeApply) [1] pluginsTyped(()scala.annotation.Annotation, Trees$Select) [1] pluginsTyped(()testAnn, Trees$Select) [10] +pluginsTyped(()type, Trees$TypeApply) [1] pluginsTyped((str: String)A <and> (param: Double)A, Trees$Select) [1] pluginsTyped((x$1: Any)Boolean <and> (x: Double)Boolean <and> (x: Float)Boolean <and> (x: Long)Boolean <and> (x: Int)Boolean <and> (x: Char)Boolean <and> (x: Short)Boolean <and> (x: Byte)Boolean, Trees$Select) [1] pluginsTyped((x$1: Int)Unit, Trees$Select) [1] @@ -110,8 +111,7 @@ pluginsTyped(<notype>, Trees$ClassDef) [2] pluginsTyped(<notype>, Trees$DefDef) [14] pluginsTyped(<notype>, Trees$PackageDef) [1] pluginsTyped(<notype>, Trees$TypeDef) [1] -pluginsTyped(<notype>, Trees$ValDef) [23] -pluginsTyped(<root>, Trees$Ident) [1] +pluginsTyped(<notype>, Trees$ValDef) [21] pluginsTyped(=> Boolean @testAnn, Trees$Select) [1] pluginsTyped(=> Double, Trees$Select) [4] pluginsTyped(=> Int, Trees$Select) [5] @@ -124,7 +124,7 @@ pluginsTyped(A, Trees$TypeTree) [4] pluginsTyped(A.super.type, Trees$Super) [1] pluginsTyped(A.this.type, Trees$This) [11] pluginsTyped(Any, Trees$TypeTree) [1] -pluginsTyped(AnyRef, Trees$Select) [2] +pluginsTyped(AnyRef, Trees$Select) [4] pluginsTyped(Array[Any], Trees$ArrayValue) [1] pluginsTyped(Boolean @testAnn, Trees$Select) [1] pluginsTyped(Boolean @testAnn, Trees$TypeTree) [4] @@ -137,12 +137,12 @@ pluginsTyped(Int @testAnn, Trees$TypeTree) [2] pluginsTyped(Int @testAnn, Trees$Typed) [2] pluginsTyped(Int(0), Trees$Literal) [3] pluginsTyped(Int(1) @testAnn, Trees$Typed) [1] -pluginsTyped(Int(1), Trees$Literal) [9] +pluginsTyped(Int(1), Trees$Literal) [8] pluginsTyped(Int(2), Trees$Literal) [1] pluginsTyped(Int, Trees$Apply) [1] pluginsTyped(Int, Trees$Ident) [2] pluginsTyped(Int, Trees$If) [2] -pluginsTyped(Int, Trees$Select) [17] +pluginsTyped(Int, Trees$Select) [15] pluginsTyped(Int, Trees$TypeTree) [13] pluginsTyped(List, Trees$Apply) [1] pluginsTyped(List, Trees$Select) [1] @@ -150,7 +150,6 @@ pluginsTyped(List[Any], Trees$Apply) [1] pluginsTyped(List[Any], Trees$Select) [1] pluginsTyped(List[Any], Trees$TypeTree) [3] pluginsTyped(Nothing, Trees$Return) [1] -pluginsTyped(Nothing, Trees$Select) [2] pluginsTyped(Object, Trees$Apply) [1] pluginsTyped(String @testAnn, Trees$Ident) [1] pluginsTyped(String @testAnn, Trees$Select) [1] @@ -160,31 +159,30 @@ pluginsTyped(String("huhu"), Trees$Literal) [1] pluginsTyped(String("str") @testAnn, Trees$Typed) [1] pluginsTyped(String("str"), Trees$Literal) [1] pluginsTyped(String("str"), Trees$Typed) [1] -pluginsTyped(String("two"), Trees$Literal) [3] +pluginsTyped(String("two"), Trees$Literal) [2] pluginsTyped(String, Trees$Apply) [2] pluginsTyped(String, Trees$Block) [2] pluginsTyped(String, Trees$Ident) [1] pluginsTyped(String, Trees$Select) [9] -pluginsTyped(String, Trees$TypeTree) [8] +pluginsTyped(String, Trees$TypeTree) [7] pluginsTyped(Unit, Trees$Apply) [2] pluginsTyped(Unit, Trees$Assign) [8] -pluginsTyped(Unit, Trees$Block) [7] +pluginsTyped(Unit, Trees$Block) [4] pluginsTyped(Unit, Trees$If) [1] -pluginsTyped(Unit, Trees$Literal) [8] +pluginsTyped(Unit, Trees$Literal) [5] pluginsTyped(Unit, Trees$TypeTree) [1] pluginsTyped([A](xs: A*)List[A], Trees$Select) [1] pluginsTyped([T <: Int]=> Int, Trees$Select) [1] -pluginsTyped([T0 >: ? <: ?]()T0, Trees$Select) [1] +pluginsTyped([T0]()T0, Trees$Select) [2] pluginsTyped([T](xs: Array[T])scala.collection.mutable.WrappedArray[T], Trees$Select) [1] -pluginsTyped(annotation.type, Trees$Select) [2] +pluginsTyped(annotation.type, Trees$Select) [4] pluginsTyped(math.type, Trees$Select) [9] pluginsTyped(scala.annotation.Annotation, Trees$Apply) [1] pluginsTyped(scala.annotation.TypeConstraint, Trees$Select) [4] +pluginsTyped(scala.annotation.TypeConstraint, Trees$TypeTree) [2] pluginsTyped(scala.collection.immutable.List.type, Trees$Select) [2] pluginsTyped(scala.collection.immutable.StringOps, Trees$ApplyImplicitView) [2] pluginsTyped(scala.collection.mutable.WrappedArray[Any], Trees$Apply) [1] -pluginsTyped(scala.type, Trees$Ident) [1] -pluginsTyped(scala.type, Trees$Select) [1] pluginsTyped(str.type, Trees$Ident) [3] pluginsTyped(testAnn, Trees$Apply) [5] pluginsTyped(testAnn, Trees$Ident) [5] @@ -192,5 +190,7 @@ pluginsTyped(testAnn, Trees$New) [5] pluginsTyped(testAnn, Trees$This) [1] pluginsTyped(testAnn, Trees$TypeTree) [2] pluginsTyped(testAnn.super.type, Trees$Super) [1] +pluginsTyped(type, Trees$Apply) [1] pluginsTyped(type, Trees$Select) [1] +pluginsTyped(type, Trees$TypeTree) [1] pluginsTypedReturn(return f, String) [1] diff --git a/test/files/run/analyzerPlugins.scala b/test/files/run/analyzerPlugins.scala index daef83fa30..4b297ff220 100644 --- a/test/files/run/analyzerPlugins.scala +++ b/test/files/run/analyzerPlugins.scala @@ -8,7 +8,9 @@ object Test extends DirectTest { def code = """ class testAnn extends annotation.TypeConstraint - class A(param: Double) extends { val x: Int = 1; val y = "two"; type T = A } with AnyRef { + class A(param: Double) extends { val x: Int = 1; val y = "two" } with AnyRef { + type T = A + val inferField = ("str": @testAnn) val annotField: Boolean @testAnn = false @@ -77,12 +79,12 @@ object Test extends DirectTest { object analyzerPlugin extends AnalyzerPlugin { def treeClass(t: Tree) = t.getClass.toString.split('.').last - override def pluginsPt(pt: Type, typer: Typer, tree: Tree, mode: Int): Type = { + override def pluginsPt(pt: Type, typer: Typer, tree: Tree, mode: Mode): Type = { output += s"pluginsPt($pt, ${treeClass(tree)})" pt } - - override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Int, pt: Type): Type = { + + override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Mode, pt: Type): Type = { output += s"pluginsTyped($tpe, ${treeClass(tree)})" tpe } @@ -98,7 +100,7 @@ object Test extends DirectTest { } - override def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Int, pt: Type): Boolean = { + override def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Boolean = { output += s"canAdaptAnnotations(${treeClass(tree)}, $pt)" false } diff --git a/test/files/run/annotatedRetyping.scala b/test/files/run/annotatedRetyping.scala index cf1b0f27b5..9b9ebd5a1e 100644 --- a/test/files/run/annotatedRetyping.scala +++ b/test/files/run/annotatedRetyping.scala @@ -40,7 +40,7 @@ object Test extends DirectTest { defTree match { case impl: Template => templates += typer.context.owner -> (impl, typer) - + case dd: DefDef if dd.symbol.isPrimaryConstructor && templates.contains(dd.symbol.owner) => val (impl, templTyper) = templates(dd.symbol.owner) for (stat <- impl.body.filterNot(_.isDef)) { @@ -50,7 +50,7 @@ object Test extends DirectTest { tpr.typed(stat) } - case _ => + case _ => } tpe } diff --git a/test/files/run/array-addition.check b/test/files/run/array-addition.check new file mode 100644 index 0000000000..7bfbd9c711 --- /dev/null +++ b/test/files/run/array-addition.check @@ -0,0 +1,4 @@ +Array(1, 2, 3, 4) +Array(1, 2, 3, 4) +Array(1) +Array(1) diff --git a/test/files/run/array-addition.scala b/test/files/run/array-addition.scala new file mode 100644 index 0000000000..8def48e85c --- /dev/null +++ b/test/files/run/array-addition.scala @@ -0,0 +1,11 @@ +object Test { + def prettyPrintArray(x: Array[_]) = println("Array(" + x.mkString(", ") + ")") + + def main(args: Array[String]): Unit = { + prettyPrintArray(Array(1,2,3) :+ 4) + prettyPrintArray(1 +: Array(2,3,4)) + prettyPrintArray(Array() :+ 1) + prettyPrintArray(1 +: Array()) + } +} + diff --git a/test/files/run/array-charSeq.scala b/test/files/run/array-charSeq.scala index f7d0586f03..53796bb9d5 100644 --- a/test/files/run/array-charSeq.scala +++ b/test/files/run/array-charSeq.scala @@ -6,6 +6,7 @@ object Test { def check(chars: CharSequence) { println("\n[check '" + chars + "'] len = " + chars.length) chars match { + case x: Predef.ArrayCharSequence => assert(x.__arrayOfChars eq arr, ((x.__arrayOfChars, arr))) case x: runtime.ArrayCharSequence => assert(x.xs eq arr, ((x.xs, arr))) case x => assert(false, x) } diff --git a/test/files/run/array-existential-bound.scala b/test/files/run/array-existential-bound.scala index bc442d39f7..cc105d8fcd 100644 --- a/test/files/run/array-existential-bound.scala +++ b/test/files/run/array-existential-bound.scala @@ -7,11 +7,11 @@ object Test extends Fooz[Array[Int]] { val f2 = new Fooz[Array[Int]] { } val f3 = new Fooz[Array[Any]] { } val f4 = new Fooz[Array[_]] { } - + def main(args: Array[String]): Unit = { println(f1.f0(Array[String]("a", "b"))) - println(f2.f0(1 to 1000 toArray)) + println(f2.f0((1 to 1000).toArray)) println(f3.f0((1 to 1000).toArray[Any])) - println(f4.f0('a' to 'z' toArray)) + println(f4.f0(('a' to 'z').toArray)) } } diff --git a/test/files/run/arrayclone-old.scala b/test/files/run/arrayclone-old.scala index c9f7556b47..fbca38b42e 100644 --- a/test/files/run/arrayclone-old.scala +++ b/test/files/run/arrayclone-old.scala @@ -16,7 +16,7 @@ object BooleanArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = false; - assert(it(0) == true) + assert(it(0) == true) } object ByteArrayClone{ @@ -24,7 +24,7 @@ object ByteArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object ShortArrayClone{ @@ -32,7 +32,7 @@ object ShortArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object CharArrayClone{ @@ -40,7 +40,7 @@ object CharArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object IntArrayClone{ @@ -48,7 +48,7 @@ object IntArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object LongArrayClone{ @@ -56,7 +56,7 @@ object LongArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object FloatArrayClone{ @@ -64,7 +64,7 @@ object FloatArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object DoubleArrayClone{ @@ -72,7 +72,7 @@ object DoubleArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = 0; - assert(it(0) == 1) + assert(it(0) == 1) } object ObjectArrayClone{ @@ -80,7 +80,7 @@ object ObjectArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = "0"; - assert(it(0) == "1") + assert(it(0) == "1") } object PolymorphicArrayClone{ @@ -88,14 +88,14 @@ object PolymorphicArrayClone{ val cloned = it.clone(); assert(cloned.sameElements(it)); cloned(0) = zero; - assert(it(0) == one) - } + assert(it(0) == one) + } testIt(Array("one", "two"), "one", "two"); class Mangler[T: Manifest](ts : T*){ // this will always be a BoxedAnyArray even after we've unboxed its contents. - val it = ts.toArray[T]; + val it = ts.toArray[T]; } val mangled = new Mangler[Int](0, 1); diff --git a/test/files/run/arraycopy.scala b/test/files/run/arraycopy.scala index 82c34c23e7..bb06200dc7 100644 --- a/test/files/run/arraycopy.scala +++ b/test/files/run/arraycopy.scala @@ -5,7 +5,7 @@ object Test { val a = new Array[Int](10) val b = new Array[Any](10) for (i <- 0 until 10) b(i) = i - + Array.copy(b, 3, a, 3, 7) assert(a.toSeq == List(0, 0, 0, 3, 4, 5, 6, 7, 8, 9)) } diff --git a/test/files/run/arrays.check b/test/files/run/arrays.check index b1f7fae1d1..c9a3a87268 100644 --- a/test/files/run/arrays.check +++ b/test/files/run/arrays.check @@ -1 +1,7 @@ +arrays.scala:248: warning: comparing values of types Unit and Unit using `==' will always yield true + check(xs(0) == u0, xs(0), u0); + ^ +arrays.scala:249: warning: comparing values of types Unit and Unit using `==' will always yield true + check(xs(1) == u1, xs(1), u1); + ^ checks: 2302 diff --git a/test/files/run/arrays.scala b/test/files/run/arrays.scala index ecebc78a6f..c8bf80ea60 100644 --- a/test/files/run/arrays.scala +++ b/test/files/run/arrays.scala @@ -107,7 +107,7 @@ object Test { val s1 = if (test1) "ok" else "KO"; val s2 = actual.toString(); val s3 = expected.toString(); - error(s0 + " - " + s1 + ": " + s2 + " != " + s3); + sys.error(s0 + " - " + s1 + ": " + s2 + " != " + s3); } checks += 1 } diff --git a/test/files/run/arrayview.scala b/test/files/run/arrayview.scala index 42ced5e9ac..97e840f5e9 100644 --- a/test/files/run/arrayview.scala +++ b/test/files/run/arrayview.scala @@ -1,6 +1,6 @@ object Test { def f = (1 to 100).toArray.view - + def main(args: Array[String]): Unit = { val xs = (f filter (_ < 50)).reverse.filter(_ % 2 == 0).map(_ / 2).flatMap(x => Array(1, x)) assert(xs.size == 48) diff --git a/test/files/run/bigDecimalCache.scala b/test/files/run/bigDecimalCache.scala index e8ebefee78..c0c709a50f 100644 --- a/test/files/run/bigDecimalCache.scala +++ b/test/files/run/bigDecimalCache.scala @@ -1,9 +1,9 @@ -object Test { +object Test { def main(args: Array[String]): Unit = { val bd5a = BigDecimal(5) val mc = java.math.MathContext.DECIMAL32 val bd5b = BigDecimal(5,mc) - + assert(bd5b.mc == mc) } } diff --git a/test/files/run/bigDecimalTest.scala b/test/files/run/bigDecimalTest.scala index 07b524c017..480305d7d4 100644 --- a/test/files/run/bigDecimalTest.scala +++ b/test/files/run/bigDecimalTest.scala @@ -28,7 +28,7 @@ object Test { // SI-4547: implicit conversion assert(5 + BigDecimal(3) == BigDecimal(8)) - + // meaningless sanity check List[BigDecimal](a, b, c, d, e, f) map (_.scale) foreach println } diff --git a/test/files/run/bitsets.check b/test/files/run/bitsets.check index 3f01d2a400..41c2ccdcb8 100644 --- a/test/files/run/bitsets.check +++ b/test/files/run/bitsets.check @@ -37,6 +37,11 @@ m2_r1 = true m2_r2 = true m2_r3 = true +b1:BitSet(5, 6, 7) +b2:BitSet(5) +b3:BitSet(5, 7) +b4:BitSet(7) +b0:BitSet(5, 6, 7) is0 = BitSet() is1 = BitSet() is2 = BitSet(2) diff --git a/test/files/run/bitsets.scala b/test/files/run/bitsets.scala index 27395683b4..5d49220749 100644 --- a/test/files/run/bitsets.scala +++ b/test/files/run/bitsets.scala @@ -4,6 +4,8 @@ //############################################################################ +import scala.language.postfixOps + object TestMutable { import scala.collection.mutable.BitSet @@ -37,6 +39,19 @@ object TestMutable { Console.println("mi1 = " + ms1.toImmutable) Console.println("mi2 = " + ms2.toImmutable) Console.println + + val N = 257 + val gen = 3 + val bs = BitSet((1 until N): _*) + (1 until N).foldLeft(gen) { + case (acc, i) => + assert(bs.size == N-i, s"Bad size for $bs, expected ${N-i} actual ${bs.size}") + assert(!bs.isEmpty, s"Unexpected isEmpty for $bs") + bs -= acc + acc*gen % N + } + assert(bs.size == 0, s"Expected size == 0 for $bs") + assert(bs.isEmpty, s"Expected isEmpty for $bs") } object TestMutable2 { @@ -81,12 +96,51 @@ object TestMutable2 { println } +object TestMutable3 { + import scala.collection.mutable.BitSet + + val b0 = BitSet(5, 6) + val b1 = BitSet(7) + val b2 = BitSet(1, 5) + val b3 = BitSet(6, 7) + val b4 = BitSet(6, 7) + + b1 |= b0 + println(s"b1:$b1") + b2 &= b0 + println(s"b2:$b2") + b3 ^= b0 + println(s"b3:$b3") + b4 &~= b0 + println(s"b4:$b4") + b0 ^= b0 |= b1 + println(s"b0:$b0") +} + +/*** +The memory requirements here are way beyond +what a test should exercise. + +object TestMutable4 { + import scala.collection.mutable.BitSet + + val bMax = BitSet(Int.MaxValue) + println(s"bMax:$bMax") + bMax.foreach(println) + + val bLarge = BitSet(2000000001) + println(s"bLarge:$bLarge") + + println(bMax == bLarge) +} +***/ + object TestImmutable { import scala.collection.immutable.BitSet val is0 = BitSet() - val is1 = BitSet.fromArray(Array()) - val is2 = BitSet.fromArray(Array(4)) + val is1 = BitSet.fromBitMask(Array()) + val is2 = BitSet.fromBitMask(Array(4)) val is3 = BitSet.empty Console.println("is0 = " + is0) @@ -155,6 +209,8 @@ object TestImmutable2 { object Test extends App { TestMutable TestMutable2 + TestMutable3 + // TestMutable4 TestImmutable TestImmutable2 } diff --git a/test/files/run/blame_eye_triple_eee-double.check b/test/files/run/blame_eye_triple_eee-double.check new file mode 100644 index 0000000000..5e46d91a8f --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-double.check @@ -0,0 +1,9 @@ +if (NaN == NaN) is good +if (x == x) is good +if (x == NaN) is good +if (NaN != NaN) is good +if (x != x) is good +if (NaN != x) is good +x matching was good +NaN matching was good +loop with NaN was goood diff --git a/test/files/run/blame_eye_triple_eee-double.flags b/test/files/run/blame_eye_triple_eee-double.flags new file mode 100644 index 0000000000..c9b68d70dc --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-double.flags @@ -0,0 +1 @@ +-optimise diff --git a/test/files/run/blame_eye_triple_eee-double.scala b/test/files/run/blame_eye_triple_eee-double.scala new file mode 100644 index 0000000000..1640aead40 --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-double.scala @@ -0,0 +1,61 @@ +object Test extends App { + import Double.NaN + + // NaN must not equal NaN no matter what optimizations are applied + // All the following will seem redundant, but to an optimizer + // they can appear different + + val x = NaN + + if (NaN == NaN) + println("if (NaN == NaN) is broken") + else + println("if (NaN == NaN) is good") + + if (x == x) + println("if (x == x) is broken") + else + println("if (x == x) is good") + + if (x == NaN) + println("if (x == NaN) is broken") + else + println("if (x == NaN) is good") + + if (NaN != NaN) + println("if (NaN != NaN) is good") + else + println("if (NaN != NaN) broken") + + if (x != x) + println("if (x != x) is good") + else + println("if (x != x) broken") + + if (NaN != x) + println("if (NaN != x) is good") + else + println("if (NaN != x) is broken") + + x match { + case 0.0d => println("x matched 0!") + case NaN => println("x matched NaN!") + case _ => println("x matching was good") + } + + NaN match { + case 0.0d => println("NaN matched 0!") + case NaN => println("NaN matched NaN!") + case _ => println("NaN matching was good") + } + + var z = 0.0d + var i = 0 + while (i < 10) { + if (i % 2 == 0) z = NaN + else z = NaN + i += 1 + } + if (z.isNaN && i == 10) println("loop with NaN was goood") + else println("loop with NaN was broken") +} diff --git a/test/files/run/blame_eye_triple_eee-float.check b/test/files/run/blame_eye_triple_eee-float.check new file mode 100644 index 0000000000..5e46d91a8f --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-float.check @@ -0,0 +1,9 @@ +if (NaN == NaN) is good +if (x == x) is good +if (x == NaN) is good +if (NaN != NaN) is good +if (x != x) is good +if (NaN != x) is good +x matching was good +NaN matching was good +loop with NaN was goood diff --git a/test/files/run/blame_eye_triple_eee-float.flags b/test/files/run/blame_eye_triple_eee-float.flags new file mode 100644 index 0000000000..c9b68d70dc --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-float.flags @@ -0,0 +1 @@ +-optimise diff --git a/test/files/run/blame_eye_triple_eee-float.scala b/test/files/run/blame_eye_triple_eee-float.scala new file mode 100644 index 0000000000..4deb9f3d60 --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-float.scala @@ -0,0 +1,61 @@ +object Test extends App { + import Float.NaN + + // NaN must not equal NaN no matter what optimizations are applied + // All the following will seem redundant, but to an optimizer + // they can appear different + + val x = NaN + + if (NaN == NaN) + println("if (NaN == NaN) is broken") + else + println("if (NaN == NaN) is good") + + if (x == x) + println("if (x == x) is broken") + else + println("if (x == x) is good") + + if (x == NaN) + println("if (x == NaN) is broken") + else + println("if (x == NaN) is good") + + if (NaN != NaN) + println("if (NaN != NaN) is good") + else + println("if (NaN != NaN) broken") + + if (x != x) + println("if (x != x) is good") + else + println("if (x != x) broken") + + if (NaN != x) + println("if (NaN != x) is good") + else + println("if (NaN != x) is broken") + + x match { + case 0.0f => println("x matched 0!") + case NaN => println("x matched NaN!") + case _ => println("x matching was good") + } + + NaN match { + case 0.0f => println("NaN matched 0!") + case NaN => println("NaN matched NaN!") + case _ => println("NaN matching was good") + } + + var z = 0.0f + var i = 0 + while (i < 10) { + if (i % 2 == 0) z = NaN + else z = NaN + i += 1 + } + if (z.isNaN && i == 10) println("loop with NaN was goood") + else println("loop with NaN was broken") +} diff --git a/test/files/run/boolexprs.scala b/test/files/run/boolexprs.scala index 4f1c4b161a..b9b4faea9c 100644 --- a/test/files/run/boolexprs.scala +++ b/test/files/run/boolexprs.scala @@ -10,7 +10,7 @@ class Counter { object Test1 { var flag = false; - def flip: Boolean = { val tmp = flag; flag = !flag; tmp } + def flip: Boolean = { val tmp = flag; flag = !flag; tmp } def run: Int = { val c = new Counter; c.incrThen(flip || flip); diff --git a/test/files/run/bridges.scala b/test/files/run/bridges.scala index fda86eabc6..eb036bd781 100644 --- a/test/files/run/bridges.scala +++ b/test/files/run/bridges.scala @@ -3588,7 +3588,7 @@ object Test { errors = errors + 1; } } catch { - case exception => { + case exception: Throwable => { Console.print(name + " raised exception " + exception); Console.println; errors = errors + 1; diff --git a/test/files/run/bugs.scala b/test/files/run/bugs.scala index ca598603bb..ba8449c299 100644 --- a/test/files/run/bugs.scala +++ b/test/files/run/bugs.scala @@ -304,7 +304,7 @@ object Bug250Test { // Bug 257 object Bug257Test { - def sayhello(): Unit = { Console.println("I should come 1st and 2nd"); }; + def sayhello(): Unit = { Console.println("I should come 1st and 2nd"); }; def sayhi(): Unit = { Console.println("I should come last"); }; def f1(x: Unit): Unit = (); @@ -444,7 +444,7 @@ object Test { try { test; } catch { - case exception => + case exception: Throwable => Console.print("Exception in thread \"" + Thread.currentThread + "\" " + exception); Console.println; errors += 1 diff --git a/test/files/run/case-class-23.check b/test/files/run/case-class-23.check new file mode 100644 index 0000000000..888ed2c9eb --- /dev/null +++ b/test/files/run/case-class-23.check @@ -0,0 +1,2 @@ +23 +(1,23) diff --git a/test/files/run/case-class-23.scala b/test/files/run/case-class-23.scala new file mode 100644 index 0000000000..92b719574a --- /dev/null +++ b/test/files/run/case-class-23.scala @@ -0,0 +1,33 @@ +case class TwentyThree( + _1: Int, + _2: Int, + _3: Int, + _4: Int, + _5: Int, + _6: Int, + _7: Int, + _8: Int, + _9: Int, + _10: Int, + _11: Int, + _12: Int, + _13: Int, + _14: Int, + _15: Int, + _16: Int, + _17: Int, + _18: Int, + _19: Int, + _20: Int, + _21: Int, + _22: Int, + _23: Int +) + +object Test extends App { + val x = new TwentyThree(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23) + println(x._23) + assert(x.copy(_1 = 1) == x) + val TwentyThree(a, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, b) = x + println((a, b)) +} diff --git a/test/files/run/caseClassEquality.scala b/test/files/run/caseClassEquality.scala index 4940d80951..c11d7ad0d1 100644 --- a/test/files/run/caseClassEquality.scala +++ b/test/files/run/caseClassEquality.scala @@ -11,25 +11,25 @@ object Test { case _ => false } } - + case class CS1(xs: Any*) class CS2(xs: Seq[_]*) extends CS1(xs: _*) class CS3(xs: IndexedSeq[Int]*) extends CS2(xs: _*) - + case class H1(x: Int, y: Double) class H2(x: Double, y: Int) extends H1(y, x) - + def main(args: Array[String]): Unit = { assert(C1(5) == new C2(5)) assert(new C2(5) == C1(5)) assert(C1(5).hashCode == new C2(5).hashCode) assert(new C2(5).hashCode == C1(5).hashCode) - + assert(C1(5) != new C3(5)) assert(new C3(5) != C1(5)) - + assert(CS1(List(1d,2d), Seq[Float](3f, 4f)) == new CS3(IndexedSeq(1,2), IndexedSeq(3, 4))) - + assert(H1(5, 10d) == new H2(10d, 5)) assert(H1(5, 10d).hashCode == new H2(10d, 5).hashCode) } diff --git a/test/files/run/caseclasses.scala b/test/files/run/caseclasses.scala index 5aafea59e3..668c984f3d 100644 --- a/test/files/run/caseclasses.scala +++ b/test/files/run/caseclasses.scala @@ -1,6 +1,6 @@ case class Foo(x: Int)(y: Int) -case class Bar +case class Bar() abstract class Base abstract case class Abs(x: Int) extends Base diff --git a/test/files/run/castsingleton.scala b/test/files/run/castsingleton.scala index 47bd613079..339f5e00cf 100644 --- a/test/files/run/castsingleton.scala +++ b/test/files/run/castsingleton.scala @@ -8,4 +8,4 @@ object Test extends App { } empty(L()) -} +} diff --git a/test/files/run/checked.scala b/test/files/run/checked.scala index 06bc0c05e5..e4db9c0916 100644 --- a/test/files/run/checked.scala +++ b/test/files/run/checked.scala @@ -23,9 +23,9 @@ trait T { // Should not throw class D extends B with T { val sum = x + y + z + b1 + b2 + t1 + t2 - override def toString = + override def toString = "sum = " + sum - + } abstract class NeedsXEarly { @@ -91,7 +91,7 @@ class TestInterference extends { object Test extends App { - + def shouldThrow(t: => Unit) = try { t println("[FAIL]: No UFE thrown") diff --git a/test/files/run/classfile-format-51.scala b/test/files/run/classfile-format-51.scala index 378caa7936..f92382d89b 100644 --- a/test/files/run/classfile-format-51.scala +++ b/test/files/run/classfile-format-51.scala @@ -91,14 +91,14 @@ object Test extends DirectTest { val bytes = cw.toByteArray() val fos = new FileOutputStream(new File(s"${testOutput.path}/$invokerClassName.class")) - try + try fos write bytes finally fos.close() } - def code = + def code = """ object Driver { val invoker = new DynamicInvoker() @@ -112,14 +112,14 @@ object Driver { System.setErr(System.out) try { // this test is only valid under JDK 1.7+ - testUnderJavaAtLeast("1.7") { + testUnderJavaAtLeast("1.7") { generateClass() compile() () } otherwise { () } - } + } finally System.setErr(prevErr) } diff --git a/test/files/run/classfile-format-52.scala b/test/files/run/classfile-format-52.scala index 7afa09ae0b..e12c84124c 100644 --- a/test/files/run/classfile-format-52.scala +++ b/test/files/run/classfile-format-52.scala @@ -7,7 +7,7 @@ import asm.{AnnotationVisitor, ClassWriter, FieldVisitor, Handle, MethodVisitor, import Opcodes._ // This test ensures that we can read JDK 8 (classfile format 52) files, including those -// with default methods. To do that it first uses ASM to generate an interface called +// with default methods. To do that it first uses ASM to generate an interface called // HasDefaultMethod. Then it runs a normal compile on Scala source that extends that // interface. Any failure will be dumped to std out. // @@ -40,14 +40,14 @@ object Test extends DirectTest { val bytes = cw.toByteArray() val fos = new FileOutputStream(new File(s"${testOutput.path}/$interfaceName.class")) - try + try fos write bytes finally fos.close() } - def code = + def code = """ class Driver extends HasDefaultMethod { println(publicMethod()) @@ -65,12 +65,12 @@ class Driver extends HasDefaultMethod { generateInterface() compile() Class.forName("Driver").newInstance() - () + () } otherwise { println("hello from publicMethod") - println("hello from staticMethod") + println("hello from staticMethod") } - } + } finally System.setErr(prevErr) } diff --git a/test/files/run/classmanifests_new_alias.scala b/test/files/run/classmanifests_new_alias.scala index 12bd93bab6..777bd5dd6d 100644 --- a/test/files/run/classmanifests_new_alias.scala +++ b/test/files/run/classmanifests_new_alias.scala @@ -1,5 +1,7 @@ + +@deprecated("Suppress warnings", since="2.11") object Test extends App { type CM[T] = ClassManifest[T] println(implicitly[CM[Int]]) println(implicitly[CM[Int]] eq Manifest.Int) -}
\ No newline at end of file +} diff --git a/test/files/run/classmanifests_new_core.scala b/test/files/run/classmanifests_new_core.scala index 63dbfab25c..0a9c58e8e1 100644 --- a/test/files/run/classmanifests_new_core.scala +++ b/test/files/run/classmanifests_new_core.scala @@ -1,4 +1,5 @@ +@deprecated("Suppress warnings", since="2.11") object Test extends App { println(classManifest[Int]) println(classManifest[Int] eq Manifest.Int) -}
\ No newline at end of file +} diff --git a/test/files/run/classof.check b/test/files/run/classof.check index 0d650b87c0..83e292352d 100644 --- a/test/files/run/classof.check +++ b/test/files/run/classof.check @@ -17,6 +17,6 @@ class [Lscala.runtime.BoxedUnit; class [I class [D class [Lscala.collection.immutable.List; -Functions: +Functions: interface scala.Function2 interface scala.Function1 diff --git a/test/files/run/classof.scala b/test/files/run/classof.scala index 10c07d2e51..257829e976 100644 --- a/test/files/run/classof.scala +++ b/test/files/run/classof.scala @@ -13,19 +13,19 @@ object Test { println(classOf[Long]) println(classOf[Float]) println(classOf[Double]) - + println("Class types") println(classOf[SomeClass]) println(classOf[List[Array[Float]]]) println(classOf[(String, Map[Int, String])]) println("Arrays:") - println(classOf[Array[Unit]]) + println(classOf[Array[Unit]]) println(classOf[Array[Int]]) println(classOf[Array[Double]]) println(classOf[Array[List[String]]]) - println("Functions: ") + println("Functions:") println(classOf[(Int, Int) => Unit]) println(classOf[Int => Boolean]) } diff --git a/test/files/run/collection-conversions.scala b/test/files/run/collection-conversions.scala index d842742230..cd05f68e26 100644 --- a/test/files/run/collection-conversions.scala +++ b/test/files/run/collection-conversions.scala @@ -8,11 +8,11 @@ object Test { def printResult[A,B](msg: String, obj: A, expected: B)(implicit tag: ClassTag[A], tag2: ClassTag[B]) = { print(" :" + msg +": ") - val isArray = obj match { - case x: Array[Int] => true + val isArray = obj match { + case x: Array[Int] => true case _ => false } - val expectedEquals = + val expectedEquals = if(isArray) obj.asInstanceOf[Array[Int]].toSeq == expected.asInstanceOf[Array[Int]].toSeq else obj == expected val tagEquals = tag == tag2 @@ -49,7 +49,7 @@ object Test { printResult("[Copy] ParVector", col.to[ParVector], testParVector) printResult("[Copy] ParArray ", col.to[ParArray], testParArray) } - + def main(args: Array[String]): Unit = { testConversion("iterator", (1 to 3).iterator) testConversion("Vector", Vector(1,2,3)) diff --git a/test/files/run/collection-stacks.check b/test/files/run/collection-stacks.check new file mode 100644 index 0000000000..aa25cd1fa6 --- /dev/null +++ b/test/files/run/collection-stacks.check @@ -0,0 +1,14 @@ +3-2-1: true +3-2-1: true +apply +3: true +3: true +1: true +1: true +top +3: true +3: true +pop +2-1: true +3: true +2-1: true diff --git a/test/files/run/collection-stacks.scala b/test/files/run/collection-stacks.scala new file mode 100644 index 0000000000..be9fbbf1ae --- /dev/null +++ b/test/files/run/collection-stacks.scala @@ -0,0 +1,38 @@ +import scala.collection.{ immutable, mutable } + +object Test extends App { + def mutableStack[T](xs: T*): mutable.Stack[T] = { + val s = new mutable.Stack[T] + s.pushAll(xs) + s + } + + def immutableStack[T](xs: T*): immutable.Stack[T] = { + immutable.Stack.empty[T] pushAll xs + } + + def check[T](expected: T, got: T) { + println(got + ": " + (expected == got)) + } + + // check #957 + check("3-2-1", immutableStack(1, 2, 3).iterator.mkString("-")) + check("3-2-1", mutableStack(1, 2, 3).iterator.mkString("-")) + + println("apply") + check(3, immutableStack(1, 2, 3).apply(0)) + check(3, mutableStack(1, 2, 3).apply(0)) + check(1, immutableStack(1, 2, 3).apply(2)) + check(1, mutableStack(1, 2, 3).apply(2)) + + println("top") + check(3, immutableStack(1, 2, 3).top) + check(3, mutableStack(1, 2, 3).top) + + println("pop") + check("2-1", immutableStack(1, 2, 3).pop.mkString("-")) + check(3, mutableStack(1, 2, 3).pop()) + check("2-1", { val s = mutableStack(1, 2, 3); s.pop(); s.toList.mkString("-") }) +} + +// vim: set ts=2 sw=2 et: diff --git a/test/files/run/collections-toSelf.scala b/test/files/run/collections-toSelf.scala index 2adbc22af7..02f1dd6a95 100644 --- a/test/files/run/collections-toSelf.scala +++ b/test/files/run/collections-toSelf.scala @@ -2,7 +2,7 @@ object Test { val map = Map(1 -> 2) val set = Set(1, 2) val seq = collection.immutable.Seq(1, 2) - + def main(args: Array[String]): Unit = { assert(map.toMap eq map) assert(set.toSet eq set) diff --git a/test/files/run/collections.scala b/test/files/run/collections.scala index 69c40fae80..2b19ff4e75 100644 --- a/test/files/run/collections.scala +++ b/test/files/run/collections.scala @@ -1,5 +1,6 @@ -import collection._ +import scala.collection._ import scala.compat.Platform.currentTime +import scala.language.postfixOps object Test extends App { @@ -61,7 +62,7 @@ object Test extends App { } time { var x = 0 - for (i <- 0 to 10000) + for (i <- 0 to 10000) s get i match { case Some(i) => x += i case None => @@ -96,7 +97,7 @@ object Test extends App { } time { var x = 0 - for (i <- 0 to 10000) + for (i <- 0 to 10000) s get i match { case Some(i) => x += i case None => diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala index 54adeb7cda..8dce69afc9 100644 --- a/test/files/run/colltest1.scala +++ b/test/files/run/colltest1.scala @@ -1,4 +1,8 @@ -import collection._ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ +import scala.collection._ +import scala.language.postfixOps object Test extends App { @@ -61,7 +65,7 @@ object Test extends App { assert(ten.toStream == ten) assert(ten.toString endsWith "(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)") assert(ten.mkString("[", "; ", "]") endsWith "[1; 2; 3; 4; 5; 6; 7; 8; 9; 10]") - } + } def orderedIterableTest(empty: Iterable[Int]) { orderedTraversableTest(empty) @@ -84,7 +88,7 @@ object Test extends App { assert(ten(0) == 1 && ten(9) == 10) assert((ten lengthCompare 10) == 0 && (ten lengthCompare 1) > 0 && (ten lengthCompare 11) < 0) assert((ten isDefinedAt 0) && (ten isDefinedAt 9)) - assert(!(ten isDefinedAt -1)); + assert(!(ten isDefinedAt -1)); assert(!(ten isDefinedAt 10)) val tenten = ten zip ten assert((tenten map (_._1)) == ten) @@ -174,8 +178,8 @@ object Test extends App { m ++= ('J' to 'Z') map (x => (x.toString -> x.toString)) println(m.toList.sorted) assert(!m.isEmpty) - assert(m.keySet forall (k => (m get k) == Some(k))) - assert(m.keySet forall (k => (m apply k) == k)) + assert(m.keySet forall (k => (m get k) == Some(k))) + assert(m.keySet forall (k => (m apply k) == k)) assert(m.keySet forall (m contains)) assert(m.getOrElse("7", "@") == "@") assert(m.keySet.size == 26) diff --git a/test/files/run/comparable-comparator.scala b/test/files/run/comparable-comparator.scala index ac943c63bb..f059cc52f3 100644 --- a/test/files/run/comparable-comparator.scala +++ b/test/files/run/comparable-comparator.scala @@ -1,7 +1,7 @@ object Test { import java.util.Comparator - + class C1(val s: String) extends Comparable[C1] { def compareTo(other: C1) = s compareTo other.s override def toString = s @@ -10,18 +10,19 @@ object Test { def compareTo(other: C2) = s compareTo other.s override def toString = s } - + implicit val cmp: Comparator[C2] = new Comparator[C2] { def compare(p1: C2, p2: C2) = p2.s compareTo p1.s } - val strs = "zip foo bar baz aggle bing bong" split ' ' toList + val words = "zip foo bar baz aggle bing bong" split ' ' + val strs = words.toList val c1s = strs map (x => new C1(x)) val c2s = strs map (x => new C2(x)) - + val sorted1 = c1s.sorted map (_.s) val sorted2 = c2s.sorted map (_.s) - + def main(args: Array[String]): Unit = { assert(sorted1 == sorted2.reverse) } diff --git a/test/files/run/compiler-asSeenFrom.check b/test/files/run/compiler-asSeenFrom.check index 47d40b0331..7305504115 100644 --- a/test/files/run/compiler-asSeenFrom.check +++ b/test/files/run/compiler-asSeenFrom.check @@ -1,6 +1,54 @@ class C { type seen from prefix is ---- ---------------- -- + C.this.I[Int] C[List[T3]] C[List[T3]]#I[Int] + C.this.I[Int] C[T1] C[T1]#I[Int] + C.this.I[Int] D[A1] D[A1]#I[Int] + C.this.I[Int] D[T3] D[T3]#I[Int] + C.this.I[List[Int]] C[List[T3]] C[List[T3]]#I[List[Int]] + C.this.I[List[Int]] C[T1] C[T1]#I[List[Int]] + C.this.I[List[Int]] D[A1] D[A1]#I[List[Int]] + C.this.I[List[Int]] D[T3] D[T3]#I[List[Int]] + C.this.I[T1] C[List[T3]] C[List[T3]]#I[List[T3]] + C.this.I[T1] C[T1] C[T1]#I[T1] + C.this.I[T1] D[A1] D[A1]#I[A1] + C.this.I[T1] D[T3] D[T3]#I[T3] + C.this.I[T2] C[List[T3]] C[List[T3]]#I[T2] + C.this.I[T2] C[T1] C[T1]#I[T2] + C.this.I[T2] D[A1] D[A1]#I[T2] + C.this.I[T2] D[T3] D[T3]#I[T2] + C.this.I[T3] C[List[T3]] C[List[T3]]#I[T3] + C.this.I[T3] C[T1] C[T1]#I[T3] + C.this.I[T3] D[A1] D[A1]#I[T3] + C.this.I[T3] D[T3] D[T3]#I[T3] + C.this.I[T4] C[List[T3]] C[List[T3]]#I[T4] + C.this.I[T4] C[T1] C[T1]#I[T4] + C.this.I[T4] D[A1] D[A1]#I[T4] + C.this.I[T4] D[T3] D[T3]#I[T4] + C.this.J[Int] C[List[T3]] C[List[T3]]#J[Int] + C.this.J[Int] C[T1] C[T1]#J[Int] + C.this.J[Int] D[A1] D[A1]#J[Int] + C.this.J[Int] D[T3] D[T3]#J[Int] + C.this.J[List[Int]] C[List[T3]] C[List[T3]]#J[List[Int]] + C.this.J[List[Int]] C[T1] C[T1]#J[List[Int]] + C.this.J[List[Int]] D[A1] D[A1]#J[List[Int]] + C.this.J[List[Int]] D[T3] D[T3]#J[List[Int]] + C.this.J[T1] C[List[T3]] C[List[T3]]#J[List[T3]] + C.this.J[T1] C[T1] C[T1]#J[T1] + C.this.J[T1] D[A1] D[A1]#J[A1] + C.this.J[T1] D[T3] D[T3]#J[T3] + C.this.J[T2] C[List[T3]] C[List[T3]]#J[T2] + C.this.J[T2] C[T1] C[T1]#J[T2] + C.this.J[T2] D[A1] D[A1]#J[T2] + C.this.J[T2] D[T3] D[T3]#J[T2] + C.this.J[T3] C[List[T3]] C[List[T3]]#J[T3] + C.this.J[T3] C[T1] C[T1]#J[T3] + C.this.J[T3] D[A1] D[A1]#J[T3] + C.this.J[T3] D[T3] D[T3]#J[T3] + C.this.J[T4] C[List[T3]] C[List[T3]]#J[T4] + C.this.J[T4] C[T1] C[T1]#J[T4] + C.this.J[T4] D[A1] D[A1]#J[T4] + C.this.J[T4] D[T3] D[T3]#J[T4] C[List[T3]]#I[T1] D[A1] C[List[T3]]#I[A1] C[List[T3]]#I[T1] D[T3] C[List[T3]]#I[T3] C[List[T3]]#J[T1] D[A1] C[List[T3]]#J[A1] @@ -49,6 +97,8 @@ class C { class D { type seen from prefix is ---- ---------------- -- + C.this.I[T3] D[A1] C.this.I[A1] + C.this.J[T3] D[A1] C.this.J[A1] C[List[T3]]#I[Int] D[A1] C[List[A1]]#I[Int] C[List[T3]]#I[List[Int]] D[A1] C[List[A1]]#I[List[Int]] C[List[T3]]#I[T1] D[A1] C[List[A1]]#I[T1] @@ -73,6 +123,42 @@ class D { class I { type seen from prefix is ---- ---------------- -- + C.this.I[Int] D.this.J[T4] D.this.cD.I[Int] + C.this.I[Int] Z.dZ.J[A2] Z.dZ.cD.I[Int] + C.this.I[Int] Z.dZ.J[P] Z.dZ.cD.I[Int] + C.this.I[List[Int]] D.this.J[T4] D.this.cD.I[List[Int]] + C.this.I[List[Int]] Z.dZ.J[A2] Z.dZ.cD.I[List[Int]] + C.this.I[List[Int]] Z.dZ.J[P] Z.dZ.cD.I[List[Int]] + C.this.I[T1] D.this.J[T4] D.this.cD.I[List[T3]] + C.this.I[T1] Z.dZ.J[A2] Z.dZ.cD.I[List[A1]] + C.this.I[T1] Z.dZ.J[P] Z.dZ.cD.I[List[A1]] + C.this.I[T2] D.this.J[T4] D.this.cD.I[T4] + C.this.I[T2] Z.dZ.J[A2] Z.dZ.cD.I[A2] + C.this.I[T2] Z.dZ.J[P] Z.dZ.cD.I[P] + C.this.I[T3] D.this.J[T4] D.this.cD.I[T3] + C.this.I[T3] Z.dZ.J[A2] Z.dZ.cD.I[T3] + C.this.I[T3] Z.dZ.J[P] Z.dZ.cD.I[T3] + C.this.I[T4] D.this.J[T4] D.this.cD.I[T4] + C.this.I[T4] Z.dZ.J[A2] Z.dZ.cD.I[T4] + C.this.I[T4] Z.dZ.J[P] Z.dZ.cD.I[T4] + C.this.J[Int] D.this.J[T4] D.this.cD.J[Int] + C.this.J[Int] Z.dZ.J[A2] Z.dZ.cD.J[Int] + C.this.J[Int] Z.dZ.J[P] Z.dZ.cD.J[Int] + C.this.J[List[Int]] D.this.J[T4] D.this.cD.J[List[Int]] + C.this.J[List[Int]] Z.dZ.J[A2] Z.dZ.cD.J[List[Int]] + C.this.J[List[Int]] Z.dZ.J[P] Z.dZ.cD.J[List[Int]] + C.this.J[T1] D.this.J[T4] D.this.cD.J[List[T3]] + C.this.J[T1] Z.dZ.J[A2] Z.dZ.cD.J[List[A1]] + C.this.J[T1] Z.dZ.J[P] Z.dZ.cD.J[List[A1]] + C.this.J[T2] D.this.J[T4] D.this.cD.J[T4] + C.this.J[T2] Z.dZ.J[A2] Z.dZ.cD.J[A2] + C.this.J[T2] Z.dZ.J[P] Z.dZ.cD.J[P] + C.this.J[T3] D.this.J[T4] D.this.cD.J[T3] + C.this.J[T3] Z.dZ.J[A2] Z.dZ.cD.J[T3] + C.this.J[T3] Z.dZ.J[P] Z.dZ.cD.J[T3] + C.this.J[T4] D.this.J[T4] D.this.cD.J[T4] + C.this.J[T4] Z.dZ.J[A2] Z.dZ.cD.J[T4] + C.this.J[T4] Z.dZ.J[P] Z.dZ.cD.J[T4] C[List[T3]]#I[T1] D.this.J[T4] C[List[T3]]#I[List[T3]] C[List[T3]]#I[T1] Z.dZ.J[A2] C[List[T3]]#I[List[A1]] C[List[T3]]#I[T1] Z.dZ.J[P] C[List[T3]]#I[List[A1]] @@ -137,6 +223,14 @@ class I { class J { type seen from prefix is ---- ---------------- -- + C.this.I[T3] Z.dZ.J[A2] C.this.I[A1] + C.this.I[T3] Z.dZ.J[P] C.this.I[A1] + C.this.I[T4] Z.dZ.J[A2] C.this.I[A2] + C.this.I[T4] Z.dZ.J[P] C.this.I[P] + C.this.J[T3] Z.dZ.J[A2] C.this.J[A1] + C.this.J[T3] Z.dZ.J[P] C.this.J[A1] + C.this.J[T4] Z.dZ.J[A2] C.this.J[A2] + C.this.J[T4] Z.dZ.J[P] C.this.J[P] C[List[T3]]#I[Int] Z.dZ.J[A2] C[List[A1]]#I[Int] C[List[T3]]#I[Int] Z.dZ.J[P] C[List[A1]]#I[Int] C[List[T3]]#I[List[Int]] Z.dZ.J[A2] C[List[A1]]#I[List[Int]] diff --git a/test/files/run/compiler-asSeenFrom.scala b/test/files/run/compiler-asSeenFrom.scala index 19feb45101..7020469bb2 100644 --- a/test/files/run/compiler-asSeenFrom.scala +++ b/test/files/run/compiler-asSeenFrom.scala @@ -1,6 +1,10 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import scala.tools.nsc._ import scala.tools.partest.CompilerTest import scala.collection.{ mutable, immutable, generic } +import scala.language.postfixOps /** It's too messy but it's better than not having it. */ @@ -107,7 +111,7 @@ package ll { def check(source: String, unit: global.CompilationUnit) = { import syms._ - afterTyper { + exitingTyper { val typeArgs = List[Type](IntClass.tpe, ListClass[Int]) ++ tparams.map(_.tpe) permute(typeArgs) foreach println } @@ -117,6 +121,5 @@ package ll { println(sigs.mkString(x + " { // after " + ph + "\n ", "\n ", "\n}\n")) } } - true } } diff --git a/test/files/run/concat-two-strings.scala b/test/files/run/concat-two-strings.scala index ad796fe0ee..c8881aa146 100644 --- a/test/files/run/concat-two-strings.scala +++ b/test/files/run/concat-two-strings.scala @@ -8,7 +8,7 @@ object Test { def f4(x: List[Int]) = "" + x def f5(x: Any) = "" + x def f6(x: AnyVal) = "" + x - + def main(args: Array[String]): Unit = { List(f1("a"), f2(5), f3(null), f3(Array('a')), f4(List(1)), f5(null), f6(55d)) mkString "" } diff --git a/test/files/run/concurrent-map-conversions.scala b/test/files/run/concurrent-map-conversions.scala index 0350b69642..d23d5bbbe4 100644 --- a/test/files/run/concurrent-map-conversions.scala +++ b/test/files/run/concurrent-map-conversions.scala @@ -4,33 +4,33 @@ object Test { - + def main(args: Array[String]) { testConversions() testConverters() } - + def needPackageConcurrentMap(map: collection.concurrent.Map[Int, Int]) { } def needJavaConcurrent(map: java.util.concurrent.ConcurrentMap[Int, Int]) { } - + def testConversions() { import collection.JavaConversions._ val skiplist = new java.util.concurrent.ConcurrentSkipListMap[Int, Int] val ctrie = new collection.concurrent.TrieMap[Int, Int] - + needPackageConcurrentMap(skiplist) needJavaConcurrent(ctrie) } - + def testConverters() { import collection.JavaConverters._ val skiplist = new java.util.concurrent.ConcurrentSkipListMap[Int, Int] val ctrie = new collection.concurrent.TrieMap[Int, Int] - + needPackageConcurrentMap(skiplist.asScala) needJavaConcurrent(ctrie.asJava) } - + } diff --git a/test/files/run/concurrent-stream.scala b/test/files/run/concurrent-stream.scala index 42c695964e..9d5ba0428e 100644 --- a/test/files/run/concurrent-stream.scala +++ b/test/files/run/concurrent-stream.scala @@ -1,32 +1,33 @@ // test concurrent calls to Stream.tail +@deprecated("Suppress warnings", since="2.11") object Test { -def slowRange(from: Int, until: Int, cons: (Int, => Stream[Int]) => Stream[Int]): Stream[Int] = { - var current = from - def next: Stream[Int] = { - Thread.sleep(100) - if (current >= until) Stream.empty - else { - val stream = cons(current, next) - current += 1 - stream + def slowRange(from: Int, until: Int, cons: (Int, => Stream[Int]) => Stream[Int]): Stream[Int] = { + var current = from + def next: Stream[Int] = { + Thread.sleep(100) + if (current >= until) Stream.empty + else { + val stream = cons(current, next) + current += 1 + stream + } } + next } - next -} -def testCons(cons: (Int, => Stream[Int]) => Stream[Int]): Unit = { - import scala.actors.Actor._ + def testCons(cons: (Int, => Stream[Int]) => Stream[Int]): Unit = { + import scala.actors.Actor._ - val stream = slowRange(0, 10, cons) - val main = self - actor { main ! stream.toList } - actor { main ! stream.toList } - val eval0 = receive { case list: List[Int] => list } - val eval1 = receive { case list: List[Int] => list } - println("Evaluation 0: " + eval0) - println("Evaluation 1: " + eval1) -} + val stream = slowRange(0, 10, cons) + val main = self + actor { main ! stream.toList } + actor { main ! stream.toList } + val eval0 = receive { case list: List[Int @unchecked] => list } + val eval1 = receive { case list: List[Int @unchecked] => list } + println("Evaluation 0: " + eval0) + println("Evaluation 1: " + eval1) + } def main(args: Array[String]) { println("Testing standard cons.") diff --git a/test/files/run/constant-optimization.check b/test/files/run/constant-optimization.check new file mode 100644 index 0000000000..957ffc5a87 --- /dev/null +++ b/test/files/run/constant-optimization.check @@ -0,0 +1,5 @@ +testBothReachable: good +testOneReachable: good +testAllReachable: good +testOneUnreachable: good +testDefaultUnreachable: good diff --git a/test/files/run/constant-optimization.flags b/test/files/run/constant-optimization.flags new file mode 100644 index 0000000000..c9b68d70dc --- /dev/null +++ b/test/files/run/constant-optimization.flags @@ -0,0 +1 @@ +-optimise diff --git a/test/files/run/constant-optimization.scala b/test/files/run/constant-optimization.scala new file mode 100644 index 0000000000..5d13272f3b --- /dev/null +++ b/test/files/run/constant-optimization.scala @@ -0,0 +1,61 @@ +object Test extends App { + def testBothReachable() { + val i = util.Random.nextInt + val x = if (i % 2 == 0) null else "good" + val y = if (x == null) "good" else x + "" + println(s"testBothReachable: $y") + } + + def testOneReachable() { + val i = 1 + val x = if (i != 1) null else "good" + val y = if (x == null) "good" else x + "" + println(s"testOneReachable: $y") + } + + def testAllReachable() { + val i = util.Random.nextInt + val y = (i % 2) match { + case 0 => "good" + case 1 => "good" + case _ => "good" + } + println(s"testAllReachable: $y") + } + + def testOneUnreachable() { + val i = util.Random.nextInt + val x = if (i % 2 == 0) { + 1 + } else { + 2 + } + val y = x match { + case 0 => "good" + case 1 => "good" + case _ => "good" + } + println(s"testOneUnreachable: $y") + } + + def testDefaultUnreachable() { + val i = util.Random.nextInt + val x = if (i % 2 == 0) { + 1 + } else { + 2 + } + val y = x match { + case 1 => "good" + case 2 => "good" + case _ => "good" + } + println(s"testDefaultUnreachable: $y") + } + + testBothReachable() + testOneReachable() + testAllReachable() + testOneUnreachable() + testDefaultUnreachable() +} diff --git a/test/files/run/constant-type.check b/test/files/run/constant-type.check index dfd8be5297..77bdf618e6 100644 --- a/test/files/run/constant-type.check +++ b/test/files/run/constant-type.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> :power ** Power User mode enabled - BEEP WHIR GYVE ** ** :phase has been set to 'typer'. ** @@ -13,18 +11,16 @@ scala> :power scala> val s = transformedType(StringClass.toType).asInstanceOf[Type] s: $r.intp.global.Type = String -scala> { println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } +scala> { println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } Class[String](classOf[java.lang.String]) -scala> { afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } +scala> { exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } Class(classOf[java.lang.String]) -scala> { ConstantType(Constant(s)); println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } +scala> { ConstantType(Constant(s)); println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } Class[String](classOf[java.lang.String]) -scala> { ConstantType(Constant(s)); afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } +scala> { ConstantType(Constant(s)); exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } Class(classOf[java.lang.String]) scala> - -scala> diff --git a/test/files/run/constant-type.scala b/test/files/run/constant-type.scala index 84539e2895..373746af4a 100644 --- a/test/files/run/constant-type.scala +++ b/test/files/run/constant-type.scala @@ -9,9 +9,9 @@ object Test extends ReplTest { def code = """ :power val s = transformedType(StringClass.toType).asInstanceOf[Type] -{ println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } -{ afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } -{ ConstantType(Constant(s)); println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } -{ ConstantType(Constant(s)); afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } +{ println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } +{ exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } +{ ConstantType(Constant(s)); println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } +{ ConstantType(Constant(s)); exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } """ } diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index 85c4f41872..f022aac1b2 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -1,10 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - -scala> - scala> class Annot(obj: Any) extends annotation.Annotation with annotation.TypeConstraint defined class Annot @@ -14,7 +10,7 @@ scala> class A { val x = "hello" val y: Int @Annot(x) = 10 override def toString = "an A" -} +} defined class A scala> @@ -22,7 +18,7 @@ scala> scala> val a = new A a: A = an A -scala> val y = a.y // should rewrite "this.x" to "a.x" +scala> val y = a.y // should rewrite "this.x" to "a.x" y: Int @Annot(a.x) = 10 scala> var a2 = new A @@ -37,7 +33,7 @@ scala> object Stuff { val x = "hello" val y : Int @Annot(x) = 10 } -defined module Stuff +defined object Stuff scala> @@ -127,7 +123,7 @@ defined class rep scala> scala> object A { val x = "hello" : String @ rep } -defined module A +defined object A warning: previously defined class A is not a companion to object A. Companions must be defined together; you may wish to use :paste mode for this. @@ -154,5 +150,3 @@ scala> val x : Int @Where(self > 0 && self < 100) = 3 x: Int @Where(self.>(0).&&(self.<(100))) = 3 scala> - -scala> diff --git a/test/files/run/constrained-types.scala b/test/files/run/constrained-types.scala index 38ae076c06..91bd856d00 100644 --- a/test/files/run/constrained-types.scala +++ b/test/files/run/constrained-types.scala @@ -15,10 +15,10 @@ class A { val x = "hello" val y: Int @Annot(x) = 10 override def toString = "an A" -} +} val a = new A -val y = a.y // should rewrite "this.x" to "a.x" +val y = a.y // should rewrite "this.x" to "a.x" var a2 = new A val y2 = a2.y // should drop the annotation diff --git a/test/files/run/contrib674.check b/test/files/run/contrib674.check new file mode 100644 index 0000000000..78325c1810 --- /dev/null +++ b/test/files/run/contrib674.check @@ -0,0 +1,3 @@ +contrib674.scala:15: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 1 + ^ diff --git a/test/files/run/contrib674.scala b/test/files/run/contrib674.scala index f6b46d13c6..45c9871fc4 100644 --- a/test/files/run/contrib674.scala +++ b/test/files/run/contrib674.scala @@ -5,11 +5,11 @@ object Test extends App { try { 1 } catch { - case e => + case e: Throwable => } finally { try { } catch { - case e => + case e: Throwable => } } 1 diff --git a/test/files/run/ctor-order.scala b/test/files/run/ctor-order.scala index a223ff77e8..5f5871691a 100644 --- a/test/files/run/ctor-order.scala +++ b/test/files/run/ctor-order.scala @@ -8,7 +8,7 @@ class Outer { class X extends { /* The constructor of X should set this.$outer to the outer instance - * *before* calling the super constructors. This is tested by + * *before* calling the super constructors. This is tested by * mixin M1, which tries to access global from the enclosing class. */ val outer = Outer.this diff --git a/test/files/run/ctries-new/concmap.scala b/test/files/run/ctries-new/concmap.scala index 3ec0256afb..76916564a7 100644 --- a/test/files/run/ctries-new/concmap.scala +++ b/test/files/run/ctries-new/concmap.scala @@ -5,17 +5,17 @@ import collection.concurrent.TrieMap object ConcurrentMapSpec extends Spec { - + val initsz = 500 val secondsz = 750 - + def test() { "support put" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) assert(ct.put(new Wrap(i), i) == None) for (i <- 0 until initsz) assert(ct.put(new Wrap(i), -i) == Some(i)) } - + "support put if absent" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) ct.update(new Wrap(i), i) @@ -24,7 +24,7 @@ object ConcurrentMapSpec extends Spec { for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), -i) == None) for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), i) == Some(-i)) } - + "support remove if mapped to a specific value" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) ct.update(new Wrap(i), i) @@ -32,7 +32,7 @@ object ConcurrentMapSpec extends Spec { for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == true) for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == false) } - + "support replace if mapped to a specific value" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) ct.update(new Wrap(i), i) @@ -41,7 +41,7 @@ object ConcurrentMapSpec extends Spec { for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i, -i - 2) == false) for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i, 0) == false) } - + "support replace if present" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) ct.update(new Wrap(i), i) @@ -49,17 +49,17 @@ object ConcurrentMapSpec extends Spec { for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i) == Some(-i)) for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i) == None) } - + def assertEqual(a: Any, b: Any) = { if (a != b) println(a, b) assert(a == b) } - + "support replace if mapped to a specific value, using several threads" in { val ct = new TrieMap[Wrap, Int] val sz = 55000 for (i <- 0 until sz) ct.update(new Wrap(i), i) - + class Updater(index: Int, offs: Int) extends Thread { override def run() { var repeats = 0 @@ -74,24 +74,24 @@ object ConcurrentMapSpec extends Spec { //println("Thread %d repeats: %d".format(index, repeats)) } } - + val threads = for (i <- 0 until 16) yield new Updater(i, sz / 32 * i) threads.foreach(_.start()) threads.foreach(_.join()) - + for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), i) - + val threads2 = for (i <- 0 until 15) yield new Updater(i, sz / 32 * i) threads2.foreach(_.start()) threads2.foreach(_.join()) - + for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), -i) } - + "support put if absent, several threads" in { val ct = new TrieMap[Wrap, Int] val sz = 110000 - + class Updater(offs: Int) extends Thread { override def run() { for (i <- 0 until sz) { @@ -101,19 +101,19 @@ object ConcurrentMapSpec extends Spec { } } } - + val threads = for (i <- 0 until 16) yield new Updater(sz / 32 * i) threads.foreach(_.start()) threads.foreach(_.join()) - + for (i <- 0 until sz) assert(ct(new Wrap(i)) == i) } - + "support remove if mapped to a specific value, several threads" in { val ct = new TrieMap[Wrap, Int] val sz = 55000 for (i <- 0 until sz) ct.update(new Wrap(i), i) - + class Remover(offs: Int) extends Thread { override def run() { for (i <- 0 until sz) { @@ -123,19 +123,19 @@ object ConcurrentMapSpec extends Spec { } } } - + val threads = for (i <- 0 until 16) yield new Remover(sz / 32 * i) threads.foreach(_.start()) threads.foreach(_.join()) - + for (i <- 0 until sz) assert(ct.get(new Wrap(i)) == None) } - + "have all or none of the elements depending on the oddity" in { val ct = new TrieMap[Wrap, Int] val sz = 65000 for (i <- 0 until sz) ct(new Wrap(i)) = i - + class Modifier(index: Int, offs: Int) extends Thread { override def run() { for (j <- 0 until sz) { @@ -151,38 +151,38 @@ object ConcurrentMapSpec extends Spec { } } } - + def modify(n: Int) = { val threads = for (i <- 0 until n) yield new Modifier(i, sz / n * i) threads.foreach(_.start()) threads.foreach(_.join()) } - + modify(16) for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), Some(i)) modify(15) for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), None) } - + "compute size correctly" in { val ct = new TrieMap[Wrap, Int] val sz = 36450 for (i <- 0 until sz) ct(new Wrap(i)) = i - + assertEqual(ct.size, sz) assertEqual(ct.size, sz) } - + "compute size correctly in parallel" in { val ct = new TrieMap[Wrap, Int] val sz = 36450 for (i <- 0 until sz) ct(new Wrap(i)) = i val pct = ct.par - + assertEqual(pct.size, sz) assertEqual(pct.size, sz) } - + } - + } diff --git a/test/files/run/ctries-new/iterator.scala b/test/files/run/ctries-new/iterator.scala index b953a40e00..bb1175e61b 100644 --- a/test/files/run/ctries-new/iterator.scala +++ b/test/files/run/ctries-new/iterator.scala @@ -1,144 +1,134 @@ - - - - import collection._ import collection.concurrent.TrieMap - - object IteratorSpec extends Spec { - + def test() { "work for an empty trie" in { val ct = new TrieMap val it = ct.iterator - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] } - + def nonEmptyIteratorCheck(sz: Int) { val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + val it = ct.iterator val tracker = mutable.Map[Wrap, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for a 1 element trie" in { nonEmptyIteratorCheck(1) } - + "work for a 2 element trie" in { nonEmptyIteratorCheck(2) } - + "work for a 3 element trie" in { nonEmptyIteratorCheck(3) } - + "work for a 5 element trie" in { nonEmptyIteratorCheck(5) } - + "work for a 10 element trie" in { nonEmptyIteratorCheck(10) } - + "work for a 20 element trie" in { nonEmptyIteratorCheck(20) } - + "work for a 50 element trie" in { nonEmptyIteratorCheck(50) } - + "work for a 100 element trie" in { nonEmptyIteratorCheck(100) } - + "work for a 1k element trie" in { nonEmptyIteratorCheck(1000) } - + "work for a 5k element trie" in { nonEmptyIteratorCheck(5000) } - + "work for a 75k element trie" in { nonEmptyIteratorCheck(75000) } - + "work for a 250k element trie" in { nonEmptyIteratorCheck(500000) } - + def nonEmptyCollideCheck(sz: Int) { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until sz) ct.put(new DumbHash(i), i) - + val it = ct.iterator val tracker = mutable.Map[DumbHash, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for colliding hashcodes, 2 element trie" in { nonEmptyCollideCheck(2) } - + "work for colliding hashcodes, 3 element trie" in { nonEmptyCollideCheck(3) } - + "work for colliding hashcodes, 5 element trie" in { nonEmptyCollideCheck(5) } - + "work for colliding hashcodes, 10 element trie" in { nonEmptyCollideCheck(10) } - + "work for colliding hashcodes, 100 element trie" in { nonEmptyCollideCheck(100) } - + "work for colliding hashcodes, 500 element trie" in { nonEmptyCollideCheck(500) } - + "work for colliding hashcodes, 5k element trie" in { nonEmptyCollideCheck(5000) } - + def assertEqual(a: Map[Wrap, Int], b: Map[Wrap, Int]) { if (a != b) { println(a.size + " vs " + b.size) - // println(a) - // println(b) - // println(a.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) - // println(b.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) } assert(a == b) } - + "be consistent when taken with concurrent modifications" in { val sz = 25000 val W = 15 @@ -146,40 +136,40 @@ object IteratorSpec extends Spec { val checks = 5 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Modifier extends Thread { override def run() { for (i <- 0 until sz) ct.putIfAbsent(new Wrap(i), i) match { case Some(_) => ct.remove(new Wrap(i)) - case None => + case None => } } } - + def consistentIteration(ct: TrieMap[Wrap, Int], checks: Int) { class Iter extends Thread { override def run() { val snap = ct.readOnlySnapshot() val initial = mutable.Map[Wrap, Int]() for (kv <- snap) initial += kv - + for (i <- 0 until checks) { assertEqual(snap.iterator.toMap, initial) } } } - + val iter = new Iter iter.start() iter.join() } - + val threads = for (_ <- 0 until W) yield new Modifier threads.foreach(_.start()) for (_ <- 0 until S) consistentIteration(ct, checks) threads.foreach(_.join()) } - + "be consistent with a concurrent removal with a well defined order" in { val sz = 150000 val sgroupsize = 10 @@ -187,17 +177,16 @@ object IteratorSpec extends Spec { val removerslowdown = 50 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Remover extends Thread { override def run() { for (i <- 0 until sz) { assert(ct.remove(new Wrap(i)) == Some(i)) for (i <- 0 until removerslowdown) ct.get(new Wrap(i)) // slow down, mate } - //println("done removing") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -210,7 +199,7 @@ object IteratorSpec extends Spec { } new Iter } - + val remover = new Remover remover.start() for (_ <- 0 until sgroupnum) { @@ -218,27 +207,25 @@ object IteratorSpec extends Spec { iters.foreach(_.start()) iters.foreach(_.join()) } - //println("done with iterators") remover.join() } - + "be consistent with a concurrent insertion with a well defined order" in { val sz = 150000 val sgroupsize = 10 val sgroupnum = 10 val inserterslowdown = 50 val ct = new TrieMap[Wrap, Int] - + class Inserter extends Thread { override def run() { for (i <- 0 until sz) { assert(ct.put(new Wrap(i), i) == None) for (i <- 0 until inserterslowdown) ct.get(new Wrap(i)) // slow down, mate } - //println("done inserting") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -251,7 +238,7 @@ object IteratorSpec extends Spec { } new Iter } - + val inserter = new Inserter inserter.start() for (_ <- 0 until sgroupnum) { @@ -259,31 +246,30 @@ object IteratorSpec extends Spec { iters.foreach(_.start()) iters.foreach(_.join()) } - //println("done with iterators") inserter.join() } - + "work on a yet unevaluated snapshot" in { val sz = 50000 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.update(new Wrap(i), i) - + val snap = ct.snapshot() val it = snap.iterator - + while (it.hasNext) it.next() } - + "be duplicated" in { val sz = 50 val ct = collection.parallel.mutable.ParTrieMap((0 until sz) zip (0 until sz): _*) val it = ct.splitter for (_ <- 0 until (sz / 2)) it.next() val dupit = it.dup - + it.toList shouldEqual dupit.toList } - + } - + } diff --git a/test/files/run/ctries-new/lnode.scala b/test/files/run/ctries-new/lnode.scala index 92a31088e5..4cc97050e5 100644 --- a/test/files/run/ctries-new/lnode.scala +++ b/test/files/run/ctries-new/lnode.scala @@ -5,23 +5,23 @@ import collection.concurrent.TrieMap object LNodeSpec extends Spec { - + val initsz = 1500 val secondsz = 1750 - + def test() { "accept elements with the same hash codes" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) ct.update(new DumbHash(i), i) } - + "lookup elements with the same hash codes" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) ct.update(new DumbHash(i), i) for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == Some(i)) for (i <- initsz until secondsz) assert(ct.get(new DumbHash(i)) == None) } - + "remove elements with the same hash codes" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) ct.update(new DumbHash(i), i) @@ -31,7 +31,7 @@ object LNodeSpec extends Spec { } for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == None) } - + "put elements with the same hash codes if absent" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) ct.put(new DumbHash(i), i) @@ -40,7 +40,7 @@ object LNodeSpec extends Spec { for (i <- initsz until secondsz) assert(ct.putIfAbsent(new DumbHash(i), i) == None) for (i <- initsz until secondsz) assert(ct.lookup(new DumbHash(i)) == i) } - + "replace elements with the same hash codes" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None) @@ -49,13 +49,13 @@ object LNodeSpec extends Spec { for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == -i) for (i <- 0 until initsz) assert(ct.replace(new DumbHash(i), -i, i) == true) } - + "remove elements with the same hash codes if mapped to a specific value" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None) for (i <- 0 until initsz) assert(ct.remove(new DumbHash(i), i) == true) } - + } - + } diff --git a/test/files/run/ctries-new/main.scala b/test/files/run/ctries-new/main.scala index d7fe087e4d..34f3ec2ccf 100644 --- a/test/files/run/ctries-new/main.scala +++ b/test/files/run/ctries-new/main.scala @@ -21,6 +21,9 @@ object Test { trait Spec { + implicit def implicitously = scala.language.implicitConversions + implicit def reflectively = scala.language.reflectiveCalls + implicit def str2ops(s: String) = new { def in[U](body: =>U) { // just execute body @@ -37,11 +40,11 @@ trait Spec { var produced = false try body catch { - case e => if (e.getClass == implicitly[ClassTag[T]].runtimeClass) produced = true + case e: Throwable => if (e.getClass == implicitly[ClassTag[T]].runtimeClass) produced = true } finally { assert(produced, "Did not produce exception of type: " + implicitly[ClassTag[T]]) } } } -}
\ No newline at end of file +} diff --git a/test/files/run/ctries-new/snapshot.scala b/test/files/run/ctries-new/snapshot.scala index 5fe77d445b..57155d49c6 100644 --- a/test/files/run/ctries-new/snapshot.scala +++ b/test/files/run/ctries-new/snapshot.scala @@ -8,22 +8,22 @@ import collection.concurrent.TrieMap object SnapshotSpec extends Spec { - + def test() { "support snapshots" in { val ctn = new TrieMap ctn.snapshot() ctn.readOnlySnapshot() - + val ct = new TrieMap[Int, Int] for (i <- 0 until 100) ct.put(i, i) ct.snapshot() ct.readOnlySnapshot() } - + "empty 2 quiescent snapshots in isolation" in { val sz = 4000 - + class Worker(trie: TrieMap[Wrap, Int]) extends Thread { override def run() { for (i <- 0 until sz) { @@ -34,46 +34,46 @@ object SnapshotSpec extends Spec { } } } - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) val snapt = ct.snapshot() - + val original = new Worker(ct) val snapshot = new Worker(snapt) original.start() snapshot.start() original.join() snapshot.join() - + for (i <- 0 until sz) { assert(ct.get(new Wrap(i)) == None) assert(snapt.get(new Wrap(i)) == None) } } - + def consistentReadOnly(name: String, readonly: Map[Wrap, Int], sz: Int, N: Int) { @volatile var e: Exception = null - + // reads possible entries once and stores them // then reads all these N more times to check if the // state stayed the same class Reader(trie: Map[Wrap, Int]) extends Thread { setName("Reader " + name) - + override def run() = try check() catch { case ex: Exception => e = ex } - + def check() { val initial = mutable.Map[Wrap, Int]() for (i <- 0 until sz) trie.get(new Wrap(i)) match { case Some(i) => initial.put(new Wrap(i), i) case None => // do nothing } - + for (k <- 0 until N) { for (i <- 0 until sz) { val tres = trie.get(new Wrap(i)) @@ -84,21 +84,21 @@ object SnapshotSpec extends Spec { } } } - + val reader = new Reader(readonly) reader.start() reader.join() - + if (e ne null) { e.printStackTrace() throw e } } - + // traverses the trie `rep` times and modifies each entry class Modifier(trie: TrieMap[Wrap, Int], index: Int, rep: Int, sz: Int) extends Thread { setName("Modifier %d".format(index)) - + override def run() { for (k <- 0 until rep) { for (i <- 0 until sz) trie.putIfAbsent(new Wrap(i), i) match { @@ -108,85 +108,85 @@ object SnapshotSpec extends Spec { } } } - + // removes all the elements from the trie class Remover(trie: TrieMap[Wrap, Int], index: Int, totremovers: Int, sz: Int) extends Thread { setName("Remover %d".format(index)) - + override def run() { for (i <- 0 until sz) trie.remove(new Wrap((i + sz / totremovers * index) % sz)) } } - + "have a consistent quiescent read-only snapshot" in { val sz = 10000 val N = 100 val W = 10 - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i val readonly = ct.readOnlySnapshot() val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) - + threads.foreach(_.start()) consistentReadOnly("qm", readonly, sz, N) threads.foreach(_.join()) } - + // now, we check non-quiescent snapshots, as these permit situations // where a thread is caught in the middle of the update when a snapshot is taken - + "have a consistent non-quiescent read-only snapshot, concurrent with removes only" in { val sz = 1250 val W = 100 val S = 5000 - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i val threads = for (i <- 0 until W) yield new Remover(ct, i, W, sz) - + threads.foreach(_.start()) for (i <- 0 until S) consistentReadOnly("non-qr", ct.readOnlySnapshot(), sz, 5) threads.foreach(_.join()) } - + "have a consistent non-quiescent read-only snapshot, concurrent with modifications" in { val sz = 1000 val N = 7000 val W = 10 val S = 7000 - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) - + threads.foreach(_.start()) for (i <- 0 until S) consistentReadOnly("non-qm", ct.readOnlySnapshot(), sz, 5) threads.foreach(_.join()) } - + def consistentNonReadOnly(name: String, trie: TrieMap[Wrap, Int], sz: Int, N: Int) { @volatile var e: Exception = null - + // reads possible entries once and stores them // then reads all these N more times to check if the // state stayed the same class Worker extends Thread { setName("Worker " + name) - + override def run() = try check() catch { case ex: Exception => e = ex } - + def check() { val initial = mutable.Map[Wrap, Int]() for (i <- 0 until sz) trie.get(new Wrap(i)) match { case Some(i) => initial.put(new Wrap(i), i) case None => // do nothing } - + for (k <- 0 until N) { // modify for ((key, value) <- initial) { @@ -194,7 +194,7 @@ object SnapshotSpec extends Spec { val newv = -oldv trie.replace(key, oldv, newv) } - + // check for (i <- 0 until sz) if (initial.contains(new Wrap(i))) { val expected = if (k % 2 == 0) -i else i @@ -206,27 +206,27 @@ object SnapshotSpec extends Spec { } } } - + val worker = new Worker worker.start() worker.join() - + if (e ne null) { e.printStackTrace() throw e } } - + "have a consistent non-quiescent snapshot, concurrent with modifications" in { val sz = 9000 val N = 1000 val W = 10 val S = 400 - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) - + threads.foreach(_.start()) for (i <- 0 until S) { consistentReadOnly("non-qm", ct.snapshot(), sz, 5) @@ -234,7 +234,7 @@ object SnapshotSpec extends Spec { } threads.foreach(_.join()) } - + "work when many concurrent snapshots are taken, concurrent with modifications" in { val sz = 12000 val W = 10 @@ -243,7 +243,7 @@ object SnapshotSpec extends Spec { val snaptimes = 600 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i - + class Snapshooter extends Thread { setName("Snapshooter") override def run() { @@ -254,14 +254,14 @@ object SnapshotSpec extends Spec { } } } - + val mods = for (i <- 0 until W) yield new Modifier(ct, i, modifytimes, sz) val shooters = for (i <- 0 until S) yield new Snapshooter val threads = mods ++ shooters threads.foreach(_.start()) threads.foreach(_.join()) } - + } - + } diff --git a/test/files/run/ctries-old/concmap.scala b/test/files/run/ctries-old/concmap.scala index 3ec0256afb..affc6fe294 100644 --- a/test/files/run/ctries-old/concmap.scala +++ b/test/files/run/ctries-old/concmap.scala @@ -2,20 +2,21 @@ import collection.concurrent.TrieMap +import Test.Spec object ConcurrentMapSpec extends Spec { - + val initsz = 500 val secondsz = 750 - + def test() { "support put" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) assert(ct.put(new Wrap(i), i) == None) for (i <- 0 until initsz) assert(ct.put(new Wrap(i), -i) == Some(i)) } - + "support put if absent" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) ct.update(new Wrap(i), i) @@ -24,7 +25,7 @@ object ConcurrentMapSpec extends Spec { for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), -i) == None) for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), i) == Some(-i)) } - + "support remove if mapped to a specific value" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) ct.update(new Wrap(i), i) @@ -32,7 +33,7 @@ object ConcurrentMapSpec extends Spec { for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == true) for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == false) } - + "support replace if mapped to a specific value" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) ct.update(new Wrap(i), i) @@ -41,7 +42,7 @@ object ConcurrentMapSpec extends Spec { for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i, -i - 2) == false) for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i, 0) == false) } - + "support replace if present" in { val ct = new TrieMap[Wrap, Int] for (i <- 0 until initsz) ct.update(new Wrap(i), i) @@ -49,17 +50,17 @@ object ConcurrentMapSpec extends Spec { for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i) == Some(-i)) for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i) == None) } - + def assertEqual(a: Any, b: Any) = { if (a != b) println(a, b) assert(a == b) } - + "support replace if mapped to a specific value, using several threads" in { val ct = new TrieMap[Wrap, Int] val sz = 55000 for (i <- 0 until sz) ct.update(new Wrap(i), i) - + class Updater(index: Int, offs: Int) extends Thread { override def run() { var repeats = 0 @@ -74,24 +75,24 @@ object ConcurrentMapSpec extends Spec { //println("Thread %d repeats: %d".format(index, repeats)) } } - + val threads = for (i <- 0 until 16) yield new Updater(i, sz / 32 * i) threads.foreach(_.start()) threads.foreach(_.join()) - + for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), i) - + val threads2 = for (i <- 0 until 15) yield new Updater(i, sz / 32 * i) threads2.foreach(_.start()) threads2.foreach(_.join()) - + for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), -i) } - + "support put if absent, several threads" in { val ct = new TrieMap[Wrap, Int] val sz = 110000 - + class Updater(offs: Int) extends Thread { override def run() { for (i <- 0 until sz) { @@ -101,19 +102,19 @@ object ConcurrentMapSpec extends Spec { } } } - + val threads = for (i <- 0 until 16) yield new Updater(sz / 32 * i) threads.foreach(_.start()) threads.foreach(_.join()) - + for (i <- 0 until sz) assert(ct(new Wrap(i)) == i) } - + "support remove if mapped to a specific value, several threads" in { val ct = new TrieMap[Wrap, Int] val sz = 55000 for (i <- 0 until sz) ct.update(new Wrap(i), i) - + class Remover(offs: Int) extends Thread { override def run() { for (i <- 0 until sz) { @@ -123,19 +124,19 @@ object ConcurrentMapSpec extends Spec { } } } - + val threads = for (i <- 0 until 16) yield new Remover(sz / 32 * i) threads.foreach(_.start()) threads.foreach(_.join()) - + for (i <- 0 until sz) assert(ct.get(new Wrap(i)) == None) } - + "have all or none of the elements depending on the oddity" in { val ct = new TrieMap[Wrap, Int] val sz = 65000 for (i <- 0 until sz) ct(new Wrap(i)) = i - + class Modifier(index: Int, offs: Int) extends Thread { override def run() { for (j <- 0 until sz) { @@ -151,38 +152,38 @@ object ConcurrentMapSpec extends Spec { } } } - + def modify(n: Int) = { val threads = for (i <- 0 until n) yield new Modifier(i, sz / n * i) threads.foreach(_.start()) threads.foreach(_.join()) } - + modify(16) for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), Some(i)) modify(15) for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), None) } - + "compute size correctly" in { val ct = new TrieMap[Wrap, Int] val sz = 36450 for (i <- 0 until sz) ct(new Wrap(i)) = i - + assertEqual(ct.size, sz) assertEqual(ct.size, sz) } - + "compute size correctly in parallel" in { val ct = new TrieMap[Wrap, Int] val sz = 36450 for (i <- 0 until sz) ct(new Wrap(i)) = i val pct = ct.par - + assertEqual(pct.size, sz) assertEqual(pct.size, sz) } - + } - + } diff --git a/test/files/run/ctries-old/iterator.scala b/test/files/run/ctries-old/iterator.scala index b953a40e00..127f6c9f06 100644 --- a/test/files/run/ctries-old/iterator.scala +++ b/test/files/run/ctries-old/iterator.scala @@ -5,129 +5,130 @@ import collection._ import collection.concurrent.TrieMap +import Test.Spec object IteratorSpec extends Spec { - + def test() { "work for an empty trie" in { val ct = new TrieMap val it = ct.iterator - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] } - + def nonEmptyIteratorCheck(sz: Int) { val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + val it = ct.iterator val tracker = mutable.Map[Wrap, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for a 1 element trie" in { nonEmptyIteratorCheck(1) } - + "work for a 2 element trie" in { nonEmptyIteratorCheck(2) } - + "work for a 3 element trie" in { nonEmptyIteratorCheck(3) } - + "work for a 5 element trie" in { nonEmptyIteratorCheck(5) } - + "work for a 10 element trie" in { nonEmptyIteratorCheck(10) } - + "work for a 20 element trie" in { nonEmptyIteratorCheck(20) } - + "work for a 50 element trie" in { nonEmptyIteratorCheck(50) } - + "work for a 100 element trie" in { nonEmptyIteratorCheck(100) } - + "work for a 1k element trie" in { nonEmptyIteratorCheck(1000) } - + "work for a 5k element trie" in { nonEmptyIteratorCheck(5000) } - + "work for a 75k element trie" in { nonEmptyIteratorCheck(75000) } - + "work for a 250k element trie" in { nonEmptyIteratorCheck(500000) } - + def nonEmptyCollideCheck(sz: Int) { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until sz) ct.put(new DumbHash(i), i) - + val it = ct.iterator val tracker = mutable.Map[DumbHash, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for colliding hashcodes, 2 element trie" in { nonEmptyCollideCheck(2) } - + "work for colliding hashcodes, 3 element trie" in { nonEmptyCollideCheck(3) } - + "work for colliding hashcodes, 5 element trie" in { nonEmptyCollideCheck(5) } - + "work for colliding hashcodes, 10 element trie" in { nonEmptyCollideCheck(10) } - + "work for colliding hashcodes, 100 element trie" in { nonEmptyCollideCheck(100) } - + "work for colliding hashcodes, 500 element trie" in { nonEmptyCollideCheck(500) } - + "work for colliding hashcodes, 5k element trie" in { nonEmptyCollideCheck(5000) } - + def assertEqual(a: Map[Wrap, Int], b: Map[Wrap, Int]) { if (a != b) { println(a.size + " vs " + b.size) @@ -138,7 +139,7 @@ object IteratorSpec extends Spec { } assert(a == b) } - + "be consistent when taken with concurrent modifications" in { val sz = 25000 val W = 15 @@ -146,40 +147,40 @@ object IteratorSpec extends Spec { val checks = 5 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Modifier extends Thread { override def run() { for (i <- 0 until sz) ct.putIfAbsent(new Wrap(i), i) match { case Some(_) => ct.remove(new Wrap(i)) - case None => + case None => } } } - + def consistentIteration(ct: TrieMap[Wrap, Int], checks: Int) { class Iter extends Thread { override def run() { val snap = ct.readOnlySnapshot() val initial = mutable.Map[Wrap, Int]() for (kv <- snap) initial += kv - + for (i <- 0 until checks) { assertEqual(snap.iterator.toMap, initial) } } } - + val iter = new Iter iter.start() iter.join() } - + val threads = for (_ <- 0 until W) yield new Modifier threads.foreach(_.start()) for (_ <- 0 until S) consistentIteration(ct, checks) threads.foreach(_.join()) } - + "be consistent with a concurrent removal with a well defined order" in { val sz = 150000 val sgroupsize = 10 @@ -187,7 +188,7 @@ object IteratorSpec extends Spec { val removerslowdown = 50 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Remover extends Thread { override def run() { for (i <- 0 until sz) { @@ -197,7 +198,7 @@ object IteratorSpec extends Spec { //println("done removing") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -210,7 +211,7 @@ object IteratorSpec extends Spec { } new Iter } - + val remover = new Remover remover.start() for (_ <- 0 until sgroupnum) { @@ -221,14 +222,14 @@ object IteratorSpec extends Spec { //println("done with iterators") remover.join() } - + "be consistent with a concurrent insertion with a well defined order" in { val sz = 150000 val sgroupsize = 10 val sgroupnum = 10 val inserterslowdown = 50 val ct = new TrieMap[Wrap, Int] - + class Inserter extends Thread { override def run() { for (i <- 0 until sz) { @@ -238,7 +239,7 @@ object IteratorSpec extends Spec { //println("done inserting") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -251,7 +252,7 @@ object IteratorSpec extends Spec { } new Iter } - + val inserter = new Inserter inserter.start() for (_ <- 0 until sgroupnum) { @@ -262,28 +263,28 @@ object IteratorSpec extends Spec { //println("done with iterators") inserter.join() } - + "work on a yet unevaluated snapshot" in { val sz = 50000 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.update(new Wrap(i), i) - + val snap = ct.snapshot() val it = snap.iterator - + while (it.hasNext) it.next() } - + "be duplicated" in { val sz = 50 val ct = collection.parallel.mutable.ParTrieMap((0 until sz) zip (0 until sz): _*) val it = ct.splitter for (_ <- 0 until (sz / 2)) it.next() val dupit = it.dup - + it.toList shouldEqual dupit.toList } - + } - + } diff --git a/test/files/run/ctries-old/lnode.scala b/test/files/run/ctries-old/lnode.scala index 92a31088e5..f9eb9ce877 100644 --- a/test/files/run/ctries-old/lnode.scala +++ b/test/files/run/ctries-old/lnode.scala @@ -3,25 +3,26 @@ import collection.concurrent.TrieMap +import Test.Spec object LNodeSpec extends Spec { - + val initsz = 1500 val secondsz = 1750 - + def test() { "accept elements with the same hash codes" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) ct.update(new DumbHash(i), i) } - + "lookup elements with the same hash codes" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) ct.update(new DumbHash(i), i) for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == Some(i)) for (i <- initsz until secondsz) assert(ct.get(new DumbHash(i)) == None) } - + "remove elements with the same hash codes" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) ct.update(new DumbHash(i), i) @@ -31,7 +32,7 @@ object LNodeSpec extends Spec { } for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == None) } - + "put elements with the same hash codes if absent" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) ct.put(new DumbHash(i), i) @@ -40,7 +41,7 @@ object LNodeSpec extends Spec { for (i <- initsz until secondsz) assert(ct.putIfAbsent(new DumbHash(i), i) == None) for (i <- initsz until secondsz) assert(ct.lookup(new DumbHash(i)) == i) } - + "replace elements with the same hash codes" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None) @@ -49,13 +50,13 @@ object LNodeSpec extends Spec { for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == -i) for (i <- 0 until initsz) assert(ct.replace(new DumbHash(i), -i, i) == true) } - + "remove elements with the same hash codes if mapped to a specific value" in { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None) for (i <- 0 until initsz) assert(ct.remove(new DumbHash(i), i) == true) } - + } - + } diff --git a/test/files/run/ctries-old/main.scala b/test/files/run/ctries-old/main.scala index 78ba7f0db1..f714bcdcdc 100644 --- a/test/files/run/ctries-old/main.scala +++ b/test/files/run/ctries-old/main.scala @@ -5,6 +5,7 @@ +@deprecated("Suppress warnings", since="2.11") object Test { def main(args: Array[String]) { @@ -14,11 +15,13 @@ object Test { SnapshotSpec.test() } -} trait Spec { + implicit def implicitously = scala.language.implicitConversions + implicit def reflectively = scala.language.reflectiveCalls + implicit def str2ops(s: String) = new { def in[U](body: =>U) { // just execute body @@ -35,7 +38,7 @@ trait Spec { var produced = false try body catch { - case e => if (e.getClass == implicitly[ClassManifest[T]].erasure) produced = true + case e: Throwable => if (e.getClass == implicitly[ClassManifest[T]].erasure) produced = true } finally { assert(produced, "Did not produce exception of type: " + implicitly[ClassManifest[T]]) } @@ -43,3 +46,4 @@ trait Spec { } } +} diff --git a/test/files/run/ctries-old/snapshot.scala b/test/files/run/ctries-old/snapshot.scala index 5fe77d445b..dfc2034e56 100644 --- a/test/files/run/ctries-old/snapshot.scala +++ b/test/files/run/ctries-old/snapshot.scala @@ -5,25 +5,26 @@ import collection._ import collection.concurrent.TrieMap +import Test.Spec object SnapshotSpec extends Spec { - + def test() { "support snapshots" in { val ctn = new TrieMap ctn.snapshot() ctn.readOnlySnapshot() - + val ct = new TrieMap[Int, Int] for (i <- 0 until 100) ct.put(i, i) ct.snapshot() ct.readOnlySnapshot() } - + "empty 2 quiescent snapshots in isolation" in { val sz = 4000 - + class Worker(trie: TrieMap[Wrap, Int]) extends Thread { override def run() { for (i <- 0 until sz) { @@ -34,46 +35,46 @@ object SnapshotSpec extends Spec { } } } - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) val snapt = ct.snapshot() - + val original = new Worker(ct) val snapshot = new Worker(snapt) original.start() snapshot.start() original.join() snapshot.join() - + for (i <- 0 until sz) { assert(ct.get(new Wrap(i)) == None) assert(snapt.get(new Wrap(i)) == None) } } - + def consistentReadOnly(name: String, readonly: Map[Wrap, Int], sz: Int, N: Int) { @volatile var e: Exception = null - + // reads possible entries once and stores them // then reads all these N more times to check if the // state stayed the same class Reader(trie: Map[Wrap, Int]) extends Thread { setName("Reader " + name) - + override def run() = try check() catch { case ex: Exception => e = ex } - + def check() { val initial = mutable.Map[Wrap, Int]() for (i <- 0 until sz) trie.get(new Wrap(i)) match { case Some(i) => initial.put(new Wrap(i), i) case None => // do nothing } - + for (k <- 0 until N) { for (i <- 0 until sz) { val tres = trie.get(new Wrap(i)) @@ -84,21 +85,21 @@ object SnapshotSpec extends Spec { } } } - + val reader = new Reader(readonly) reader.start() reader.join() - + if (e ne null) { e.printStackTrace() throw e } } - + // traverses the trie `rep` times and modifies each entry class Modifier(trie: TrieMap[Wrap, Int], index: Int, rep: Int, sz: Int) extends Thread { setName("Modifier %d".format(index)) - + override def run() { for (k <- 0 until rep) { for (i <- 0 until sz) trie.putIfAbsent(new Wrap(i), i) match { @@ -108,85 +109,85 @@ object SnapshotSpec extends Spec { } } } - + // removes all the elements from the trie class Remover(trie: TrieMap[Wrap, Int], index: Int, totremovers: Int, sz: Int) extends Thread { setName("Remover %d".format(index)) - + override def run() { for (i <- 0 until sz) trie.remove(new Wrap((i + sz / totremovers * index) % sz)) } } - + "have a consistent quiescent read-only snapshot" in { val sz = 10000 val N = 100 val W = 10 - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i val readonly = ct.readOnlySnapshot() val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) - + threads.foreach(_.start()) consistentReadOnly("qm", readonly, sz, N) threads.foreach(_.join()) } - + // now, we check non-quiescent snapshots, as these permit situations // where a thread is caught in the middle of the update when a snapshot is taken - + "have a consistent non-quiescent read-only snapshot, concurrent with removes only" in { val sz = 1250 val W = 100 val S = 5000 - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i val threads = for (i <- 0 until W) yield new Remover(ct, i, W, sz) - + threads.foreach(_.start()) for (i <- 0 until S) consistentReadOnly("non-qr", ct.readOnlySnapshot(), sz, 5) threads.foreach(_.join()) } - + "have a consistent non-quiescent read-only snapshot, concurrent with modifications" in { val sz = 1000 val N = 7000 val W = 10 val S = 7000 - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) - + threads.foreach(_.start()) for (i <- 0 until S) consistentReadOnly("non-qm", ct.readOnlySnapshot(), sz, 5) threads.foreach(_.join()) } - + def consistentNonReadOnly(name: String, trie: TrieMap[Wrap, Int], sz: Int, N: Int) { @volatile var e: Exception = null - + // reads possible entries once and stores them // then reads all these N more times to check if the // state stayed the same class Worker extends Thread { setName("Worker " + name) - + override def run() = try check() catch { case ex: Exception => e = ex } - + def check() { val initial = mutable.Map[Wrap, Int]() for (i <- 0 until sz) trie.get(new Wrap(i)) match { case Some(i) => initial.put(new Wrap(i), i) case None => // do nothing } - + for (k <- 0 until N) { // modify for ((key, value) <- initial) { @@ -194,7 +195,7 @@ object SnapshotSpec extends Spec { val newv = -oldv trie.replace(key, oldv, newv) } - + // check for (i <- 0 until sz) if (initial.contains(new Wrap(i))) { val expected = if (k % 2 == 0) -i else i @@ -206,27 +207,27 @@ object SnapshotSpec extends Spec { } } } - + val worker = new Worker worker.start() worker.join() - + if (e ne null) { e.printStackTrace() throw e } } - + "have a consistent non-quiescent snapshot, concurrent with modifications" in { val sz = 9000 val N = 1000 val W = 10 val S = 400 - + val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) - + threads.foreach(_.start()) for (i <- 0 until S) { consistentReadOnly("non-qm", ct.snapshot(), sz, 5) @@ -234,7 +235,7 @@ object SnapshotSpec extends Spec { } threads.foreach(_.join()) } - + "work when many concurrent snapshots are taken, concurrent with modifications" in { val sz = 12000 val W = 10 @@ -243,7 +244,7 @@ object SnapshotSpec extends Spec { val snaptimes = 600 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(new Wrap(i)) = i - + class Snapshooter extends Thread { setName("Snapshooter") override def run() { @@ -254,14 +255,14 @@ object SnapshotSpec extends Spec { } } } - + val mods = for (i <- 0 until W) yield new Modifier(ct, i, modifytimes, sz) val shooters = for (i <- 0 until S) yield new Snapshooter val threads = mods ++ shooters threads.foreach(_.start()) threads.foreach(_.join()) } - + } - + } diff --git a/test/files/run/dead-code-elimination.scala b/test/files/run/dead-code-elimination.scala index 1af17c936b..fd3f2a996a 100644 --- a/test/files/run/dead-code-elimination.scala +++ b/test/files/run/dead-code-elimination.scala @@ -1,9 +1,9 @@ -// This testcase is a snippet that did not compile correctly under -// pre-release 2.10.x. The relevant discussion around it can be +// This testcase is a snippet that did not compile correctly under +// pre-release 2.10.x. The relevant discussion around it can be // found at: // https://groups.google.com/forum/?fromgroups#!topic/scala-internals/qcyTjk8euUI[1-25] -// +// // The reason it did not compile is related to the fact that ICode // ops did not correctly define the stack entries they consumed and // the dead code elimination phase was unable to correctly reconstruct @@ -12,7 +12,7 @@ // Originally, this did not compile, but I included it in the run // tests because this was ASM-dependand and did not happen for GenJVM. // -// Thus, we run the code and force the loading of class B -- if the +// Thus, we run the code and force the loading of class B -- if the // bytecode is incorrect, it will fail the test. final class A { @@ -27,7 +27,7 @@ final class A { object Test { def main(args: Array[String]): Unit = { - // force the loading of B + // force the loading of B (new A).f } } diff --git a/test/files/run/deeps.check b/test/files/run/deeps.check new file mode 100644 index 0000000000..a68e474f62 --- /dev/null +++ b/test/files/run/deeps.check @@ -0,0 +1,87 @@ +testEquals1 +false +false +true + +testEquals2 +false +false +true + +testEquals3 +x=Array(1) +y=Array(1) +false +false +true + +x=Array(Array(1), Array(1)) +y=Array(Array(1), Array(1)) +false +false +true + +x=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +y=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +false +false +true + +testEquals4 +false +false +true +false +false +true +Array(true, false) +Array(true, false) +[true;false] +true;false + +Array(Array(true, false), Array(true, false)) +Array(Array(true, false), Array(true, false)) +[Array(true, false);Array(true, false)] +Array(true, false);Array(true, false) + +Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false))) +Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false))) +[Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false))] +Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false)) + +Array(1.0, 0.0) +Array(1.0, 0.0) +[1.0;0.0] +1.0;0.0 + +Array(Array(1.0, 0.0), Array(1.0, 0.0)) +Array(Array(1.0, 0.0), Array(1.0, 0.0)) +[Array(1.0, 0.0);Array(1.0, 0.0)] +Array(1.0, 0.0);Array(1.0, 0.0) + +Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0))) +Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0))) +[Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0))] +Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0)) + +Array(a, b) +Array(a, b) +[a;b] +a;b + +Array(Array(a, b), Array(a, b)) +Array(Array(a, b), Array(a, b)) +[Array(a, b);Array(a, b)] +Array(a, b);Array(a, b) + +Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b))) +Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b))) +[Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b))] +Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b)) + +[Array(true, false); Array(false)] +[Array(1, 2); Array(3)] +[Array(1, 2); Array(3)] + +Array(boo, and, foo) +Array(a) diff --git a/test/files/run/deeps.scala b/test/files/run/deeps.scala new file mode 100644 index 0000000000..6049cc6024 --- /dev/null +++ b/test/files/run/deeps.scala @@ -0,0 +1,114 @@ +//############################################################################ +// deepEquals / deep.toString +//############################################################################ + +//############################################################################ +// need to revisit array equqality +object Test { + + def testEquals1 { + println(Array(1) == Array(1)) + println(Array(1) equals Array(1)) + println(Array(1).deep == Array(1).deep) + println + } + + def testEquals2 { + println(Array(Array(1), Array(2)) == Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)) equals Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)).deep equals Array(Array(1), Array(2)).deep) + println + } + + def testEquals3 { + val a1 = Array(1) + val b1 = Array(1) + val a2 = Array(a1, b1) + val b2 = Array(a1, b1) + val a3 = Array(a2, b2) + val b3 = Array(a2, b2) + def test[T](x: Array[T], y: Array[T]) { + println("x=" + x.deep.toString) + println("y=" + y.deep.toString) + println(x == y) + println(x equals y) + println(x.deep == y.deep) + println + } + test(a1, b1) + test(a2, b2) + test(a3, b3) + } + + def testEquals4 { + println("boo:and:foo".split(':') == "boo:and:foo".split(':')) + println("boo:and:foo".split(':') equals "boo:and:foo".split(':')) + println("boo:and:foo".split(':').deep == "boo:and:foo".split(':').deep) + + val xs = new java.util.ArrayList[String](); xs.add("a") + val ys = new java.util.ArrayList[String](); ys.add("a") + println(xs.toArray == ys.toArray) + println(xs.toArray equals ys.toArray) + println(xs.toArray.deep == ys.toArray.deep) + } + + def testToString1 { + def sweep(s: String) = ( + s.replaceAll("D@[0-9a-fA-F]+", "D@0000000") + .replaceAll("Z@[0-9a-fA-F]+", "Z@0000000") + .replaceAll(";@[0-9a-fA-F]+", ";@0000000") + ) + def test[T](a: Array[T]) { + println(sweep(a.deep.toString)) + println(a.deep.toString) + println(a.deep.mkString("[", ";", "]")) + println(a.deep.mkString(";")) + println + } + + val ba1 = Array(true, false) + val ba2 = Array(ba1, ba1) + val ba3 = Array(ba2, ba2) + test(ba1) + test(ba2) + test(ba3) + + val da1 = Array(1.0d, 0.0d) + val da2 = Array(da1, da1) + val da3 = Array(da2, da2) + test(da1) + test(da2) + test(da3) + + val sa1 = Array("a", "b") + val sa2 = Array(sa1, sa1) + val sa3 = Array(sa2, sa2) + test(sa1) + test(sa2) + test(sa3) + } + + def testToString2 { + println(Array(Array(true, false), Array(false)).deep.mkString("[", "; ", "]")) + println(Array(Array('1', '2'), Array('3')).deep.mkString("[", "; ", "]")) + println(Array(Array(1, 2), Array(3)).deep.mkString("[", "; ", "]")) + println + } + + def testToString3 { + println("boo:and:foo".split(':').deep.toString) + + val xs = new java.util.ArrayList[String](); xs.add("a") + println(xs.toArray.deep.toString) + } + + def main(args: Array[String]): Unit = { + println("testEquals1") ; testEquals1 + println("testEquals2") ; testEquals2 + println("testEquals3") ; testEquals3 + println("testEquals4") ; testEquals4 + testToString1 + testToString2 + testToString3 + } +} diff --git a/test/files/run/delay-bad.check b/test/files/run/delay-bad.check index 9d9c828a03..2ae88267c5 100644 --- a/test/files/run/delay-bad.check +++ b/test/files/run/delay-bad.check @@ -1,3 +1,9 @@ +delay-bad.scala:53: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + f(new C { 5 }) + ^ +delay-bad.scala:73: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + f(new { val x = 5 } with E() { 5 }) + ^ // new C { } diff --git a/test/files/run/delay-good.check b/test/files/run/delay-good.check index 8eb04c7cff..b4f6b04af7 100644 --- a/test/files/run/delay-good.check +++ b/test/files/run/delay-good.check @@ -1,3 +1,9 @@ +delay-good.scala:53: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + f(new C { 5 }) + ^ +delay-good.scala:73: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + f(new { val x = 5 } with E() { 5 }) + ^ // new C { } diff --git a/test/files/run/deprecate-early-type-defs.check b/test/files/run/deprecate-early-type-defs.check new file mode 100644 index 0000000000..1ee01df13e --- /dev/null +++ b/test/files/run/deprecate-early-type-defs.check @@ -0,0 +1,3 @@ +deprecate-early-type-defs.scala:1: warning: early type members are deprecated. Move them to the regular body: the semantics are the same. +object Test extends { type T = Int } with App + ^ diff --git a/test/files/run/deprecate-early-type-defs.flags b/test/files/run/deprecate-early-type-defs.flags new file mode 100644 index 0000000000..c36e713ab8 --- /dev/null +++ b/test/files/run/deprecate-early-type-defs.flags @@ -0,0 +1 @@ +-deprecation
\ No newline at end of file diff --git a/test/files/run/deprecate-early-type-defs.scala b/test/files/run/deprecate-early-type-defs.scala new file mode 100644 index 0000000000..99e42166f2 --- /dev/null +++ b/test/files/run/deprecate-early-type-defs.scala @@ -0,0 +1 @@ +object Test extends { type T = Int } with App
\ No newline at end of file diff --git a/test/files/run/distinct.scala b/test/files/run/distinct.scala index 09e5a0734a..0b8971e8a9 100644 --- a/test/files/run/distinct.scala +++ b/test/files/run/distinct.scala @@ -3,9 +3,9 @@ */ object Test { val alphabet = 'a' to 'z' mkString "" - val alphaList = 'a' to 'z' toList + val alphaList = ('a' to 'z').toList def shuffled = util.Random.shuffle(alphaList) - + def main(args: Array[String]): Unit = { val longList = alphaList ++ (1 to 9 flatMap (_ => shuffled)) val result = longList.distinct mkString "" diff --git a/test/files/run/duration-coarsest.scala b/test/files/run/duration-coarsest.scala new file mode 100644 index 0000000000..51cb79287a --- /dev/null +++ b/test/files/run/duration-coarsest.scala @@ -0,0 +1,28 @@ +import scala.concurrent.duration._ +import scala.language.postfixOps + +object Test extends App { + List( + (60 minutes, 1 hour), + (2000 millis, 2 seconds), + (2000 micros, 2 millis), + (2000 nanos, 2 micros), + (2000000 nanos, 2 millis), + (48 hours, 2 days), + (5 seconds, 5 seconds), + (1 second, 1 second) + ) foreach { + case (x, expected) => + val actual = x.toCoarsest + assert(actual.unit == expected.unit, s"$actual, $expected") + assert(actual.length == expected.length, s"$actual, $expected") + } + + List( + 45 minutes, + 500 millis, + 1500 millis, + 23 hours, + 40 days + ) foreach (x => assert(x == x.toCoarsest, x)) +}
\ No newline at end of file diff --git a/test/files/run/elidable-noflags.scala b/test/files/run/elidable-noflags.scala index 5192e34096..1b9c5118bb 100644 --- a/test/files/run/elidable-noflags.scala +++ b/test/files/run/elidable-noflags.scala @@ -9,7 +9,7 @@ object Test { @elidable(100000) def f5() = println("Good for me, I was not elided.") @elidable(OFF) def f6() = println("Good for me, I was not elided.") @elidable(ALL) def f7() = println("ESPECIALLY good for me, I was not elided.") - + def main(args: Array[String]): Unit = { f1() f2() diff --git a/test/files/run/emptypf.scala b/test/files/run/emptypf.scala index 8aa0906a1b..eb3e3e6380 100644 --- a/test/files/run/emptypf.scala +++ b/test/files/run/emptypf.scala @@ -5,10 +5,10 @@ object Test { case s => s.length } } - + def main(args: Array[String]): Unit = { println(f("abc")) - println(f("def")) + println(f("def")) println(PartialFunction.empty[String, Int] isDefinedAt "abc") } } diff --git a/test/files/run/enrich-gentraversable.scala b/test/files/run/enrich-gentraversable.scala index 52eded55fd..36412e650e 100644 --- a/test/files/run/enrich-gentraversable.scala +++ b/test/files/run/enrich-gentraversable.scala @@ -1,3 +1,6 @@ +import scala.language.implicitConversions +import scala.language.postfixOps + object Test extends App { import scala.collection.{GenTraversableOnce,GenTraversableLike} import scala.collection.generic._ @@ -10,22 +13,22 @@ object Test extends App { } implicit def filterMap[Repr, A](r: Repr)(implicit fr: IsTraversableLike[Repr]): FilterMapImpl[fr.A,Repr] = new FilterMapImpl[fr.A, Repr](fr.conversion(r)) - + val l = List(1, 2, 3, 4, 5) val fml = l.filterMap(i => if(i % 2 == 0) Some(i) else None) typed[List[Int]](fml) println(fml) - + val a = Array(1, 2, 3, 4, 5) val fma = a.filterMap(i => if(i % 2 == 0) Some(i) else None) typed[Array[Int]](fma) println(fma.deep) - + val s = "Hello World" val fms1 = s.filterMap(c => if(c >= 'A' && c <= 'Z') Some(c) else None) typed[String](fms1) println(fms1) - + val fms2 = s.filterMap(c =>if(c % 2 == 0) Some(c.toInt) else None) typed[IndexedSeq[Int]](fms2) println(fms2) @@ -35,28 +38,28 @@ object Test extends App { final def filterMap[B, That](f: A => Option[B])(implicit cbf: CanBuildFrom[Repr, B, That]): That = { val b = cbf() for(e <- r.seq) f(e) foreach (b +=) - + b.result } } implicit def filterMap[Repr, A](r: Repr)(implicit fr: IsTraversableOnce[Repr]): FilterMapImpl[fr.A,Repr] = new FilterMapImpl[fr.A, Repr](fr.conversion(r)) - + val l = List(1, 2, 3, 4, 5) val fml = l.filterMap(i => if(i % 2 == 0) Some(i) else None) typed[List[Int]](fml) println(fml) - + val a = Array(1, 2, 3, 4, 5) val fma = a.filterMap(i => if(i % 2 == 0) Some(i) else None) typed[Array[Int]](fma) println(fma.deep) - + val s = "Hello World" val fms1 = s.filterMap(c => if(c >= 'A' && c <= 'Z') Some(c) else None) typed[String](fms1) println(fms1) - + val fms2 = s.filterMap(c =>if(c % 2 == 0) Some(c.toInt) else None) typed[IndexedSeq[Int]](fms2) println(fms2) diff --git a/test/files/run/enums.scala b/test/files/run/enums.scala index 9cdeed2691..3aad7ec320 100644 --- a/test/files/run/enums.scala +++ b/test/files/run/enums.scala @@ -36,8 +36,11 @@ object Test2 { object Test3 { - object Direction extends Enumeration("North", "South", "East", "West") { - val North, South, East, West = Value; + object Direction extends Enumeration { + val North = Value("North") + val South = Value("South") + val East = Value("East") + val West = Value("West") } def run: Int = { @@ -48,8 +51,11 @@ object Test3 { object Test4 { - object Direction extends Enumeration("North", "South", "East", "West") { - val North, South, East, West = Value; + object Direction extends Enumeration { + val North = Value("North") + val South = Value("South") + val East = Value("East") + val West = Value("West") } def run: Int = { diff --git a/test/files/run/equality.scala b/test/files/run/equality.scala index 68055fd012..ff59898821 100644 --- a/test/files/run/equality.scala +++ b/test/files/run/equality.scala @@ -2,7 +2,7 @@ object Test { import scala.runtime.ScalaRunTime.hash - + def makeFromInt(x: Int) = List( x.toByte, x.toShort, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x) ) ::: ( @@ -11,26 +11,26 @@ object Test def makeFromDouble(x: Double) = List( x.toShort, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x.toInt), BigDecimal(x) ) - + def main(args: Array[String]): Unit = { var xs = makeFromInt(5) for (x <- xs ; y <- xs) { assert(x == y, x + " == " + y) assert(hash(x) == hash(y), "hash(%s) == hash(%s)".format(x, y)) } - + xs = makeFromInt(-5) for (x <- xs ; y <- xs) { assert(x == y, x + " == " + y) assert(hash(x) == hash(y), "hash(%s) == hash(%s)".format(x, y)) } - + xs = makeFromDouble(500.0) for (x <- xs ; y <- xs) { assert(x == y, x + " == " + y) assert(hash(x) == hash(y), "hash(%s) == hash(%s)".format(x, y)) } - + // negatives val bigLong = new java.util.concurrent.atomic.AtomicLong(Long.MaxValue) assert(-1 != bigLong && bigLong != -1) // bigLong.intValue() == -1 diff --git a/test/files/run/eta-expand-star2.check b/test/files/run/eta-expand-star2.check index ce01362503..cbf4781255 100644 --- a/test/files/run/eta-expand-star2.check +++ b/test/files/run/eta-expand-star2.check @@ -1 +1,2 @@ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details hello diff --git a/test/files/run/exceptions-2.check b/test/files/run/exceptions-2.check index 9a3044cd4f..4f8244800a 100644 --- a/test/files/run/exceptions-2.check +++ b/test/files/run/exceptions-2.check @@ -1,3 +1,6 @@ +exceptions-2.scala:267: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + try { 1 } catch { case e: java.io.IOException => () } + ^ nested1: Innermost finally Outermost finally diff --git a/test/files/run/exceptions-2.scala b/test/files/run/exceptions-2.scala index d0312a49b2..8d755c3809 100644 --- a/test/files/run/exceptions-2.scala +++ b/test/files/run/exceptions-2.scala @@ -42,14 +42,14 @@ object NoExcep { def method4 = try { Console.println(".."); } catch { - case _ => error(".."); + case _: Throwable => sys.error(".."); } } object Test { def nested1: Unit = try { try { - error("nnnnoooo"); + sys.error("nnnnoooo"); } finally { Console.println("Innermost finally"); } @@ -59,7 +59,7 @@ object Test { def nested2 = try { try { - error("nnnnoooo"); + sys.error("nnnnoooo"); } finally { Console.println("Innermost finally"); } @@ -68,7 +68,7 @@ object Test { Console.println("Outermost finally"); } - def mixed = + def mixed = try { if (10 > 0) throw Leaf(10); @@ -107,7 +107,7 @@ object Test { case Leaf(a) => Console.println(a); } } catch { - case npe: NullPointerException => + case npe: NullPointerException => Console.println("Caught an NPE"); } @@ -134,74 +134,74 @@ object Test { () } finally { try { - error("a"); + sys.error("a"); } catch { - case _ => Console.println("Silently ignore exception in finally"); + case _: Throwable => Console.println("Silently ignore exception in finally"); } } } - def valInFinally: Unit = - try { + def valInFinally: Unit = + try { } finally { val fin = "Abc"; Console.println(fin); - }; + } - def tryAndValInFinally: Unit = + def tryAndValInFinally: Unit = try { } finally { val fin = "Abc"; try { Console.println(fin); - } catch { case _ => () } - }; + } catch { case _: Throwable => () } + } - def returnInBody: Unit = try { + def returnInBody: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); } - } finally { + } finally { Console.println("Outer finally"); } - def returnInBodySynch: Unit = try { + def returnInBodySynch: Unit = try { synchronized { try { Console.println("Synchronized normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); } } - } finally { + } finally { Console.println("Outer finally"); } - def returnInBodyAndInFinally: Unit = try { + def returnInBodyAndInFinally: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { Console.println("inner finally"); return } - } finally { + } finally { Console.println("Outer finally"); return } - def returnInBodyAndInFinally2: Unit = try { + def returnInBodyAndInFinally2: Unit = try { try { Console.println("Normal execution..."); - return + return Console.println("non reachable code"); } finally { try { @@ -211,7 +211,7 @@ object Test { Console.println("finally inside finally"); } } - } finally { + } finally { Console.println("Outer finally"); return } @@ -249,11 +249,11 @@ object Test { def execute(f: => Unit) = try { f; } catch { - case _ => (); + case _: Throwable => () } - def returnWithFinallyClean: Int = try { + def returnWithFinallyClean: Int = try { try { Console.println("Normal execution..."); return 10 @@ -262,7 +262,7 @@ object Test { } finally { Console.println("inner finally"); } - } finally { + } finally { Console.println("Outer finally"); try { 1 } catch { case e: java.io.IOException => () } } @@ -294,7 +294,7 @@ object Test { Console.println("mixed: "); execute(mixed); - + Console.println("withValue1:"); execute(withValue1); @@ -322,7 +322,7 @@ object Test { Console.println("NoExcep.method3:"); execute(NoExcep.method3); - + Console.println("NoExcep.method4:"); execute(NoExcep.method4); diff --git a/test/files/run/exceptions-nest.scala b/test/files/run/exceptions-nest.scala index 841e6b1c67..432d600d13 100644 --- a/test/files/run/exceptions-nest.scala +++ b/test/files/run/exceptions-nest.scala @@ -5,9 +5,9 @@ object Test extends App { println(test3) println(test4) println(test5) - try { println(test6) } catch { case _ => println("OK") } + try { println(test6) } catch { case _: Throwable => println("OK") } println(test7) - try { println(test8) } catch { case _ => println("OK") } + try { println(test8) } catch { case _: Throwable => println("OK") } println(test9) println(test10) println(test11) @@ -19,7 +19,7 @@ object Test extends App { x = 2 } catch { case _: NullPointerException => x = 3 - case _ => x = 4 + case _: Throwable => x = 4 } x } @@ -31,12 +31,12 @@ object Test extends App { try { x = 21 } catch { - case _ => x = 22 + case _: Throwable => x = 22 } x = 23 } catch { case _: NullPointerException => x = 3 - case _ => x = 4 + case _: Throwable => x = 4 } x } @@ -44,10 +44,10 @@ object Test extends App { def test3 = { var x = 1 try { - try{x = 2} catch { case _ => x = 4 } + try{x = 2} catch { case _: Throwable => x = 4 } } catch { case _: NullPointerException => x = 3 - case _ => x = 4 + case _: Throwable => x = 4 } x } @@ -58,7 +58,7 @@ object Test extends App { x = 2 } catch { case _: NullPointerException => x = 3 - case _ => x = 4 + case _: Throwable => x = 4 } try { x = 5 @@ -73,8 +73,8 @@ object Test extends App { try { x = 2 } catch { - case _: NullPointerException => try { x = 3 } catch { case f => throw f } - case _ => x = 4; try { x = 41 } catch { case _: Exception => x = 42 }; x = 43 + case _: NullPointerException => try { x = 3 } catch { case f: Throwable => throw f } + case _: Throwable => x = 4; try { x = 41 } catch { case _: Exception => x = 42 }; x = 43 } x } @@ -87,7 +87,7 @@ object Test extends App { } catch { case e: NullPointerException => throw e - case _ => + case _: Throwable => x = 3 return 1000 } finally { @@ -105,7 +105,7 @@ object Test extends App { try { x = 4 } catch { - case _ => x = 5 + case _: Throwable => x = 5 } } x @@ -116,7 +116,7 @@ object Test extends App { try { throw new NullPointerException } catch { - case e => throw e + case e: Throwable => throw e } x } @@ -124,7 +124,7 @@ object Test extends App { def test9 = { try { "" match { case s: String => 10 - }} catch { case _ => 20 } + }} catch { case _: Throwable => 20 } } var x10 = 1 @@ -135,7 +135,7 @@ object Test extends App { def test11 { try { () } - catch { case e => () } + catch { case e: Throwable => () } } class E1 extends Exception diff --git a/test/files/run/exceptions.scala b/test/files/run/exceptions.scala index fc3566f85e..f0fe76946b 100644 --- a/test/files/run/exceptions.scala +++ b/test/files/run/exceptions.scala @@ -6,8 +6,8 @@ abstract class IntMap[A] { def lookup(key: Int): A = this match { - case Empty() => error("KO") - case _ => error("ok") + case Empty() => sys.error("KO") + case _ => sys.error("ok") } } @@ -32,7 +32,7 @@ object exceptions { val value = try { map.lookup(key) } catch { - case e => e.getMessage() + case e: Throwable => e.getMessage() } check("lookup(" + key + ")", value, "KO"); } diff --git a/test/files/run/existential-rangepos.check b/test/files/run/existential-rangepos.check new file mode 100644 index 0000000000..1212b60bae --- /dev/null +++ b/test/files/run/existential-rangepos.check @@ -0,0 +1,13 @@ +[[syntax trees at end of patmat]] // newSource1.scala +[0:76]package [0:0]<empty> { + [0:76]abstract class A[[17:18]T[17:18]] extends [20:76][76]scala.AnyRef { + [76]def <init>(): [20]A[T] = [76]{ + [76][76][76]A.super.<init>(); + [20]() + }; + [24:51]private[this] val foo: [28]Set[_ <: T] = [47:51]null; + [28]<stable> <accessor> def foo: [28]Set[_ <: T] = [28][28]A.this.foo; + [54:74]<stable> <accessor> def bar: [58]Set[_ <: T] + } +} + diff --git a/test/files/run/existential-rangepos.scala b/test/files/run/existential-rangepos.scala new file mode 100644 index 0000000000..7d2b0810d3 --- /dev/null +++ b/test/files/run/existential-rangepos.scala @@ -0,0 +1,13 @@ +import scala.tools.partest._ + +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp -Yrangepos -Xprint:patmat -Xprint-pos -d " + testOutput.path + + override def code = """ +abstract class A[T] { + val foo: Set[_ <: T] = null + val bar: Set[_ <: T] +}""".trim + + override def show(): Unit = Console.withErr(System.out)(compile()) +} diff --git a/test/files/run/existentials-in-compiler.check b/test/files/run/existentials-in-compiler.check index 0d7a9298b4..b0d852865d 100644 --- a/test/files/run/existentials-in-compiler.check +++ b/test/files/run/existentials-in-compiler.check @@ -8,22 +8,22 @@ abstract trait BippyLike[A <: AnyRef, B <: List[A], This <: extest.BippyLike[A,B extest.BippyLike[A,B,This] forSome { A <: AnyRef; B <: List[A]; This <: extest.BippyLike[A,B,This] with extest.Bippy[A,B] } abstract trait Contra[-A >: AnyRef, -B] extends AnyRef - extest.Contra[_ >: AnyRef, _] + extest.Contra[AnyRef, _] abstract trait ContraLike[-A >: AnyRef, -B >: List[A]] extends AnyRef extest.ContraLike[A,B] forSome { -A >: AnyRef; -B >: List[A] } abstract trait Cov01[+A <: AnyRef, +B] extends AnyRef - extest.Cov01[_ <: AnyRef, _] + extest.Cov01[AnyRef,Any] abstract trait Cov02[+A <: AnyRef, B] extends AnyRef - extest.Cov02[_ <: AnyRef, _] + extest.Cov02[AnyRef, _] abstract trait Cov03[+A <: AnyRef, -B] extends AnyRef - extest.Cov03[_ <: AnyRef, _] + extest.Cov03[AnyRef, _] abstract trait Cov04[A <: AnyRef, +B] extends AnyRef - extest.Cov04[_ <: AnyRef, _] + extest.Cov04[_ <: AnyRef, Any] abstract trait Cov05[A <: AnyRef, B] extends AnyRef extest.Cov05[_ <: AnyRef, _] @@ -32,7 +32,7 @@ abstract trait Cov06[A <: AnyRef, -B] extends AnyRef extest.Cov06[_ <: AnyRef, _] abstract trait Cov07[-A <: AnyRef, +B] extends AnyRef - extest.Cov07[_ <: AnyRef, _] + extest.Cov07[_ <: AnyRef, Any] abstract trait Cov08[-A <: AnyRef, B] extends AnyRef extest.Cov08[_ <: AnyRef, _] @@ -41,16 +41,16 @@ abstract trait Cov09[-A <: AnyRef, -B] extends AnyRef extest.Cov09[_ <: AnyRef, _] abstract trait Cov11[+A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov11[_ <: AnyRef, _ <: List[_]] + extest.Cov11[AnyRef,List[_]] abstract trait Cov12[+A <: AnyRef, B <: List[_]] extends AnyRef - extest.Cov12[_ <: AnyRef, _ <: List[_]] + extest.Cov12[AnyRef, _ <: List[_]] abstract trait Cov13[+A <: AnyRef, -B <: List[_]] extends AnyRef - extest.Cov13[_ <: AnyRef, _ <: List[_]] + extest.Cov13[AnyRef, _ <: List[_]] abstract trait Cov14[A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov14[_ <: AnyRef, _ <: List[_]] + extest.Cov14[_ <: AnyRef, List[_]] abstract trait Cov15[A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov15[_ <: AnyRef, _ <: List[_]] @@ -59,7 +59,7 @@ abstract trait Cov16[A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov16[_ <: AnyRef, _ <: List[_]] abstract trait Cov17[-A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov17[_ <: AnyRef, _ <: List[_]] + extest.Cov17[_ <: AnyRef, List[_]] abstract trait Cov18[-A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov18[_ <: AnyRef, _ <: List[_]] @@ -68,16 +68,16 @@ abstract trait Cov19[-A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov19[_ <: AnyRef, _ <: List[_]] abstract trait Cov21[+A, +B] extends AnyRef - extest.Cov21[_, _] + extest.Cov21[Any,Any] abstract trait Cov22[+A, B] extends AnyRef - extest.Cov22[_, _] + extest.Cov22[Any, _] abstract trait Cov23[+A, -B] extends AnyRef - extest.Cov23[_, _] + extest.Cov23[Any, _] abstract trait Cov24[A, +B] extends AnyRef - extest.Cov24[_, _] + extest.Cov24[_, Any] abstract trait Cov25[A, B] extends AnyRef extest.Cov25[_, _] @@ -86,7 +86,7 @@ abstract trait Cov26[A, -B] extends AnyRef extest.Cov26[_, _] abstract trait Cov27[-A, +B] extends AnyRef - extest.Cov27[_, _] + extest.Cov27[_, Any] abstract trait Cov28[-A, B] extends AnyRef extest.Cov28[_, _] @@ -122,16 +122,16 @@ abstract trait Cov39[-A, -B, C <: Tuple2[_, _]] extends AnyRef extest.Cov39[_, _, _ <: Tuple2[_, _]] abstract trait Cov41[+A >: Null, +B] extends AnyRef - extest.Cov41[_ >: Null, _] + extest.Cov41[Any,Any] abstract trait Cov42[+A >: Null, B] extends AnyRef - extest.Cov42[_ >: Null, _] + extest.Cov42[Any, _] abstract trait Cov43[+A >: Null, -B] extends AnyRef - extest.Cov43[_ >: Null, _] + extest.Cov43[Any, _] abstract trait Cov44[A >: Null, +B] extends AnyRef - extest.Cov44[_ >: Null, _] + extest.Cov44[_ >: Null, Any] abstract trait Cov45[A >: Null, B] extends AnyRef extest.Cov45[_ >: Null, _] @@ -140,7 +140,7 @@ abstract trait Cov46[A >: Null, -B] extends AnyRef extest.Cov46[_ >: Null, _] abstract trait Cov47[-A >: Null, +B] extends AnyRef - extest.Cov47[_ >: Null, _] + extest.Cov47[_ >: Null, Any] abstract trait Cov48[-A >: Null, B] extends AnyRef extest.Cov48[_ >: Null, _] @@ -149,7 +149,7 @@ abstract trait Cov49[-A >: Null, -B] extends AnyRef extest.Cov49[_ >: Null, _] abstract trait Covariant[+A <: AnyRef, +B] extends AnyRef - extest.Covariant[_ <: AnyRef, _] + extest.Covariant[AnyRef,Any] abstract trait CovariantLike[+A <: AnyRef, +B <: List[A], +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B]] extends AnyRef extest.CovariantLike[A,B,This] forSome { +A <: AnyRef; +B <: List[A]; +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B] } diff --git a/test/files/run/existentials-in-compiler.scala b/test/files/run/existentials-in-compiler.scala index c69d1217fd..f5a0aa98d0 100644 --- a/test/files/run/existentials-in-compiler.scala +++ b/test/files/run/existentials-in-compiler.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import scala.tools.nsc._ import scala.tools.partest.CompilerTest import scala.collection.{ mutable, immutable, generic } @@ -71,14 +74,13 @@ package extest { } """ - def check(source: String, unit: global.CompilationUnit) = { - getRequiredPackage("extest").moduleClass.info.decls.toList.filter(_.isType).map(_.initialize).sortBy(_.name.toString) foreach { clazz => - afterTyper { + override def check(source: String, unit: global.CompilationUnit) { + getPackage("extest").moduleClass.info.decls.toList.filter(_.isType).map(_.initialize).sortBy(_.name.toString) foreach { clazz => + exitingTyper { clazz.info println(clazz.defString) println(" " + classExistentialType(clazz) + "\n") } } - true } } diff --git a/test/files/run/existentials.scala b/test/files/run/existentials.scala index 3977d47417..bdd6fb93ee 100644 --- a/test/files/run/existentials.scala +++ b/test/files/run/existentials.scala @@ -1,8 +1,11 @@ +import scala.language.existentials +import scala.language.reflectiveCalls + class Foo { class Line { case class Cell[T](var x: T) def f[T](x: Any): Cell[t1] forSome { type t1 } = x match { case y: Cell[t] => y } - + var x: Cell[T] forSome { type T } = new Cell(1) println({ x = new Cell("abc"); x }) } @@ -12,7 +15,7 @@ class FooW { class Line { case class Cell[T](var x: T) def f[T](x: Any): Cell[ _ ] = x match { case y: Cell[t] => y } - + var x: Cell[_] = new Cell(1) println({ x = new Cell("abc"); x }) } diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check index 8f7dd701ac..7f02866a29 100644 --- a/test/files/run/existentials3-new.check +++ b/test/files/run/existentials3-new.check @@ -1,8 +1,8 @@ Bar.type, t=TypeRef, s=type Bar.type Bar, t=TypeRef, s=type Bar -Test.ToS, t=RefinedType, s=f3 -Test.ToS, t=RefinedType, s=f4 -Test.ToS, t=RefinedType, s=f5 +Test.ToS, t=RefinedType, s=<refinement of Test.ToS> +Test.ToS, t=RefinedType, s=<refinement of Test.ToS> +Test.ToS, t=RefinedType, s=<refinement of Test.ToS> () => Test.ToS, t=TypeRef, s=trait Function0 () => Test.ToS, t=TypeRef, s=trait Function0 $anon, t=TypeRef, s=type $anon @@ -12,9 +12,9 @@ List[Seq[Int]], t=TypeRef, s=class List List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List Bar.type, t=TypeRef, s=type Bar.type Bar, t=TypeRef, s=type Bar -Test.ToS, t=RefinedType, s=g3 -Test.ToS, t=RefinedType, s=g4 -Test.ToS, t=RefinedType, s=g5 +Test.ToS, t=RefinedType, s=<refinement of Test.ToS> +Test.ToS, t=RefinedType, s=<refinement of Test.ToS> +Test.ToS, t=RefinedType, s=<refinement of Test.ToS> () => Test.ToS, t=TypeRef, s=trait Function0 () => Test.ToS, t=TypeRef, s=trait Function0 $anon, t=TypeRef, s=type $anon diff --git a/test/files/run/existentials3-new.scala b/test/files/run/existentials3-new.scala index 110c8eff7a..6112a7b856 100644 --- a/test/files/run/existentials3-new.scala +++ b/test/files/run/existentials3-new.scala @@ -1,3 +1,4 @@ +import scala.language.existentials import scala.reflect.runtime.universe._ object Test { @@ -77,4 +78,4 @@ object Misc { } def g1 = o1.f1 _ def g2 = o1.f2 _ -}
\ No newline at end of file +} diff --git a/test/files/run/existentials3-old.scala b/test/files/run/existentials3-old.scala index 944160ff12..c021c0e71e 100644 --- a/test/files/run/existentials3-old.scala +++ b/test/files/run/existentials3-old.scala @@ -1,3 +1,5 @@ +import scala.language.existentials + object Test { trait ToS { final override def toString = getClass.getName } diff --git a/test/files/run/exoticnames.scala b/test/files/run/exoticnames.scala index fa0e5e6ec5..98f9a88776 100644 --- a/test/files/run/exoticnames.scala +++ b/test/files/run/exoticnames.scala @@ -1,7 +1,7 @@ // this is a run-test because the compiler should emit bytecode that'll pass the JVM's verifier object Test extends App { - def `(` = error("bla") - def `.` = error("bla") - def `)` = error("bla") - def `,` = error("bla") + def `(` = sys.error("bla") + def `.` = sys.error("bla") + def `)` = sys.error("bla") + def `,` = sys.error("bla") } diff --git a/test/files/run/finally.scala b/test/files/run/finally.scala index 635123cc4d..2c01edaaef 100644 --- a/test/files/run/finally.scala +++ b/test/files/run/finally.scala @@ -7,17 +7,17 @@ object Test extends App { try { bar } catch { - case e => println(e) + case e: Throwable => println(e) } } - + // test that finally is not covered by any exception handlers. def bar { try { println("hi") } catch { - case e => println("SHOULD NOT GET HERE") + case e: Throwable => println("SHOULD NOT GET HERE") } finally { println("In Finally") @@ -26,33 +26,33 @@ object Test extends App { } // return in catch (finally is executed) - def retCatch { + def retCatch { try { throw new Exception } catch { - case e => + case e: Throwable => println(e); return } finally println("in finally") } // throw in catch (finally is executed, exception propagated) - def throwCatch { + def throwCatch { try { throw new Exception } catch { - case e => + case e: Throwable => println(e); throw e } finally println("in finally") } // return inside body (finally is executed) - def retBody { + def retBody { try { return } catch { - case e => + case e: Throwable => println(e); throw e } finally println("in finally") @@ -63,7 +63,7 @@ object Test extends App { try { throw new Exception } catch { - case e => + case e: Throwable => println(e); } finally println("in finally") } @@ -75,7 +75,7 @@ object Test extends App { finally { println("in finally 1") return - } + } } finally println("in finally 2") } @@ -89,17 +89,17 @@ object Test extends App { throw new Exception } } catch { - case e => println(e) + case e: Throwable => println(e) } } // nested finallies with return value - def nestedFinalies: Int = + def nestedFinalies: Int = try { try { return 10 } finally { - try { () } catch { case _ => () } + try { () } catch { case _: Throwable => () } println("in finally 1") } } finally { @@ -111,7 +111,7 @@ object Test extends App { try { m } catch { - case e => println("COUGHT: " + e) + case e: Throwable => println("COUGHT: " + e) } println("-" * 40) } diff --git a/test/files/run/flat-flat-flat.scala b/test/files/run/flat-flat-flat.scala index d57696b3a3..80868b9c5e 100644 --- a/test/files/run/flat-flat-flat.scala +++ b/test/files/run/flat-flat-flat.scala @@ -2,7 +2,7 @@ object Test { def f1 = List(Iterator(Some(1), None, Some(2)), Iterator(Some(3), None)) def f2 = Iterator(List(Some(1), None, Some(2)), List(Some(3), None), Nil) def f3 = List(Some(Iterator(1)), None, Some(Iterator(2, 3))) - + def main(args: Array[String]): Unit = { assert(f1.flatten.flatten.toList == List(1, 2, 3)) assert(f2.flatten.flatten.toList == List(1, 2, 3)) diff --git a/test/files/run/fors.check b/test/files/run/fors.check deleted file mode 100644 index 08ecc8ed5f..0000000000 --- a/test/files/run/fors.check +++ /dev/null @@ -1,46 +0,0 @@ - -testOld -1 2 3 -2 -2 -3 -1 2 3 -1 2 3 -0 1 2 3 4 5 6 7 8 9 -0 2 4 6 8 -0 2 4 6 8 -a b c -b c -b c - - -<head><title>Scala</title></head> - - -<body>1 2 3</body> - - -<head><title>Scala</title></head> - -testNew -3 -1 2 3 -1 2 3 -0 1 2 3 4 5 6 7 8 9 -0 2 4 6 8 -0 2 4 6 8 -0 2 4 6 8 -0 2 4 6 8 -0 2 4 6 8 -0 2 4 6 8 -0 2 4 6 8 -a b c - - -<head><title>Scala</title></head> - - -<body>1 2 3</body> - - -<head><title>Scala</title></head> diff --git a/test/files/run/fors.scala b/test/files/run/fors.scala deleted file mode 100644 index 54afdc710b..0000000000 --- a/test/files/run/fors.scala +++ /dev/null @@ -1,97 +0,0 @@ -//############################################################################ -// for-comprehensions (old and new syntax) -//############################################################################ - -//############################################################################ - -object Test extends App { - val xs = List(1, 2, 3) - val ys = List('a, 'b, 'c) - - def it = 0 until 10 - - val ar = "abc".toCharArray - - val xml = - <html> - <head><title>Scala</title></head> - <body>{xs}</body> - </html>; - - /////////////////// old syntax /////////////////// - - def testOld { - println("\ntestOld") - - // lists - for (x <- xs) print(x + " "); println - for (x <- xs; - if x % 2 == 0) print(x + " "); println - for {x <- xs - if x % 2 == 0} print(x + " "); println - var n = 0 - for (_ <- xs) n += 1; println(n) - for ((x, y) <- xs zip ys) print(x + " "); println - for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println - - // iterators - for (x <- it) print(x + " "); println - for (x <- it; - if x % 2 == 0) print(x + " "); println - for {x <- it - if x % 2 == 0} print(x + " "); println - - // arrays - for (x <- ar) print(x + " "); println - for (x <- ar; - if x.toInt > 97) print(x + " "); println - for {x <- ar - if x.toInt > 97} print(x + " "); println - - // sequences - for (x <- xml.child) println(x) - for (x <- xml.child; - if x.label == "head") println(x) - } - - /////////////////// new syntax /////////////////// - - def testNew { - println("\ntestNew") - - // lists - var n = 0 - for (_ <- xs) n += 1; println(n) - for ((x, y) <- xs zip ys) print(x + " "); println - for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println - - // iterators - for (x <- it) print(x + " "); println - for (x <- it if x % 2 == 0) print(x + " "); println - for (x <- it; if x % 2 == 0) print(x + " "); println - for (x <- it; - if x % 2 == 0) print(x + " "); println - for (x <- it - if x % 2 == 0) print(x + " "); println - for {x <- it - if x % 2 == 0} print(x + " "); println - for (x <- it; - y = 2 - if x % y == 0) print(x + " "); println - for {x <- it - y = 2 - if x % y == 0} print(x + " "); println - - // arrays - for (x <- ar) print(x + " "); println - - // sequences - for (x <- xml.child) println(x) - for (x <- xml.child if x.label == "head") println(x) - } - - //////////////////////////////////////////////////// - - testOld - testNew -} diff --git a/test/files/run/forvaleq.scala b/test/files/run/forvaleq.scala index 2a958802b6..8c1824a769 100644 --- a/test/files/run/forvaleq.scala +++ b/test/files/run/forvaleq.scala @@ -2,7 +2,7 @@ import scala.collection.immutable.Queue import scala.{List=>L} - + object Test { // redefine some symbols to make it extra hard class List @@ -16,11 +16,11 @@ object Test { case _ if (x<10) => x case _ => firstDigit(x / 10) } - - + + { - // a basic test case - + // a basic test case + val input = L.range(0,20) val oddFirstTimesTwo = for {x <- input @@ -32,7 +32,7 @@ object Test { { // a test case with patterns - + val input = L.range(0, 20) val oddFirstTimesTwo = for {x <- input @@ -43,10 +43,10 @@ object Test { yield a + b println(oddFirstTimesTwo) } - + { // make sure it works on non-Ls - + // val input: Queue = Queue.Empty[int].incl(L.range(0,20)) val input = L.range(0, 20).iterator val oddFirstTimesTwo = @@ -54,36 +54,36 @@ object Test { xf = firstDigit(x) if xf % 2 == 1} yield x*2 - println(oddFirstTimesTwo.toList) + println(oddFirstTimesTwo.toList) } - + { // yield the computed value - + val input = L.range(0,20) val oddFirstTimesTwo = for {x <- input xf = firstDigit(x) if xf % 2 == 1} yield xf*2 - println(oddFirstTimesTwo) + println(oddFirstTimesTwo) } { // make sure the function is only called once var count: Int = 0 - + def fdct(x: Int) = { count += 1 firstDigit(x) } - + val input = L.range(0,20) for {x <- input xf = fdct(x) if xf % 2 == 1} yield xf - + println("called " + count + " times") } diff --git a/test/files/run/gadts.scala b/test/files/run/gadts.scala index 4ab3ef681a..57c7fc8af0 100644 --- a/test/files/run/gadts.scala +++ b/test/files/run/gadts.scala @@ -2,8 +2,8 @@ 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], +case class If[T](c: Term[Boolean], + t1: Term[T], t2: Term[T]) extends Term[T] object Test extends App { diff --git a/test/files/run/genericValueClass.scala b/test/files/run/genericValueClass.scala index 68162bb685..9398390a80 100644 --- a/test/files/run/genericValueClass.scala +++ b/test/files/run/genericValueClass.scala @@ -1,11 +1,14 @@ -final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal { - @inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) - def →[B](y: B): Tuple2[A, B] = ->(y) -} + +import scala.language.implicitConversions object Test extends App { + class ArrowAssocClass[A](val __leftOfArrow: A) extends AnyVal { + @inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y) + def →[B](y: B): Tuple2[A, B] = ->(y) + } + { - @inline implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x) + @inline implicit def ArrowAssoc[A](x: A): ArrowAssocClass[A] = new ArrowAssocClass(x) val x = 1 -> "abc" println(x) } diff --git a/test/files/run/getClassTest-old.scala b/test/files/run/getClassTest-old.scala index 951cc8d931..789dd4d162 100644 --- a/test/files/run/getClassTest-old.scala +++ b/test/files/run/getClassTest-old.scala @@ -50,6 +50,7 @@ class MoreAnyRefs { def f4 = (new A { def bippy() = 5 }).getClass() } +@deprecated("Suppress warnings", since="2.11") object Test { def returnTypes[T: Manifest] = ( manifest[T].erasure.getMethods.toList diff --git a/test/files/run/global-showdef.scala b/test/files/run/global-showdef.scala index 71ba7b8bb3..0dbaba979d 100644 --- a/test/files/run/global-showdef.scala +++ b/test/files/run/global-showdef.scala @@ -1,6 +1,7 @@ import scala.tools.nsc._ -import io.{ AbstractFile } -import util.{ SourceFile, BatchSourceFile, stringFromStream } +import scala.reflect.io.AbstractFile +import scala.tools.nsc.util.stringFromStream +import scala.reflect.internal.util.{ SourceFile, BatchSourceFile } import scala.tools.nsc.reporters.ConsoleReporter object Test { @@ -39,8 +40,8 @@ object Bippy { new Global(settings) } - - def slurp(body: => Unit): String = stringFromStream { stream => + + def slurp(body: => Unit): String = stringFromStream { stream => Console.withOut(stream) { Console.withErr(stream) { body @@ -53,15 +54,15 @@ object Bippy { val run = new compiler.Run() run.compileSources(List(src)) } - output split "\\n" toList + (output split "\\n").toList } def showClass(name: String) = lines("-Yshow:typer", "-Xshow-class", name) def showObject(name: String) = lines("-Yshow:typer", "-Xshow-object", name) - + def show(xs: List[String]) = { xs filter (x => (x contains "def showdefTestMember") || (x startsWith "<<-- ")) foreach println } - + def main(args: Array[String]) { show(List("Bippy", "Bippy#BippyType", "Bippy.BippyType", "Bippy#Boppity", "Bippy#Boppity#Boo") flatMap showClass) show(List("Bippy", "Bippy#Boppity#Boo") flatMap showObject) diff --git a/test/files/run/groupby.scala b/test/files/run/groupby.scala index fe08f52812..a751e65e80 100644 --- a/test/files/run/groupby.scala +++ b/test/files/run/groupby.scala @@ -3,8 +3,8 @@ // Fixes #3422 object Test { - - def main(args: Array[String]) { + + def main(args: Array[String]) { val arr = Array.range(0,10) val map = arr groupBy (_%2) val v1 = map(0) @@ -14,5 +14,5 @@ object Test { // hash map by default. assert(v1 eq v2) } - + } diff --git a/test/files/run/hashCodeBoxesRunTime.scala b/test/files/run/hashCodeBoxesRunTime.scala index 081a73376e..ba1a30f5fb 100644 --- a/test/files/run/hashCodeBoxesRunTime.scala +++ b/test/files/run/hashCodeBoxesRunTime.scala @@ -4,16 +4,16 @@ object Test { import java.{ lang => jl } import scala.runtime.BoxesRunTime.{ hashFromNumber, hashFromObject } - + def allSame[T](xs: List[T]) = assert(xs.distinct.size == 1, "failed: " + xs) - + def mkNumbers(x: Int): List[Number] = List(x.toByte, x.toShort, x, x.toLong, x.toFloat, x.toDouble) - + def testLDF(x: Long) = allSame(List[Number](x, x.toDouble, x.toFloat) map hashFromNumber) - + def main(args: Array[String]): Unit = { - List(Byte.MinValue, -1, 0, 1, Byte.MaxValue) foreach { n => + List(Byte.MinValue, -1, 0, 1, Byte.MaxValue) foreach { n => val hashes = mkNumbers(n) map hashFromNumber allSame(hashes) if (n >= 0) { @@ -21,7 +21,7 @@ object Test assert(charCode == hashes.head) } } - + testLDF(Short.MaxValue.toLong) testLDF(Short.MinValue.toLong) } diff --git a/test/files/run/hashhash.scala b/test/files/run/hashhash.scala index f9fc067398..3b9d1479cf 100644 --- a/test/files/run/hashhash.scala +++ b/test/files/run/hashhash.scala @@ -1,7 +1,7 @@ object Test { def confirmSame(x: Any) = assert(x.## == x.hashCode, "%s.## != %s.hashCode".format(x, x)) def confirmDifferent(x: Any) = assert(x.## != x.hashCode, "%s.## == %s.hashCode (but should not)".format(x, x)) - + def main(args: Array[String]): Unit = { /** Just a little sanity check, not to be confused with a unit test. */ List(5, 5.5f, "abc", new AnyRef, ()) foreach confirmSame diff --git a/test/files/run/hashset.check b/test/files/run/hashset.check new file mode 100644 index 0000000000..9542a1ff48 --- /dev/null +++ b/test/files/run/hashset.check @@ -0,0 +1,26 @@ +*** HashSet primitives +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + +*** HashSet Strings with null +null true +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null +null false +0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true + +*** ParHashSet primitives +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + +*** ParHashSet Strings with null +null true +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null +null false +0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true + diff --git a/test/files/run/hashset.scala b/test/files/run/hashset.scala new file mode 100644 index 0000000000..a4d49c142e --- /dev/null +++ b/test/files/run/hashset.scala @@ -0,0 +1,48 @@ +import scala.collection.generic.{Growable, Shrinkable} +import scala.collection.GenSet +import scala.collection.mutable.FlatHashTable +import scala.collection.mutable.HashSet +import scala.collection.parallel.mutable.ParHashSet + +object Test extends App { + test(new Creator{ + def create[A] = new HashSet[A] + def hashSetType = "HashSet" + }) + + test(new Creator{ + def create[A] = new ParHashSet[A] + def hashSetType = "ParHashSet" + }) + + + def test(creator : Creator) { + println("*** " + creator.hashSetType + " primitives") + val h1 = creator.create[Int] + for (i <- 0 until 20) h1 += i + println((for (i <- 0 until 20) yield i + " " + (h1 contains i)).toList.sorted mkString(",")) + println((for (i <- 20 until 40) yield i + " " + (h1 contains i)).toList.sorted mkString(",")) + println(h1.toList.sorted mkString ",") + println + + println("*** " + creator.hashSetType + " Strings with null") + val h2 = creator.create[String] + h2 += null + for (i <- 0 until 20) h2 += "" + i + println("null " + (h2 contains null)) + println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println((for (i <- 20 until 40) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println((h2.toList map {x => "" + x}).sorted mkString ",") + + h2 -= null + h2 -= "" + 0 + println("null " + (h2 contains null)) + println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println + } + + trait Creator { + def create[A] : GenSet[A] with Cloneable with FlatHashTable[A] with Growable[A] with Shrinkable[A] + def hashSetType : String + } +}
\ No newline at end of file diff --git a/test/files/run/hashsetremove.check b/test/files/run/hashsetremove.check new file mode 100644 index 0000000000..8de9826895 --- /dev/null +++ b/test/files/run/hashsetremove.check @@ -0,0 +1,6 @@ +remove 0 should be false, was false +contains 1 should be true, was true +remove 1 should be true, was true +contains 1 should be false, was false +remove 1 should be false, was false +contains 1 should be false, was false diff --git a/test/files/run/hashsetremove.scala b/test/files/run/hashsetremove.scala new file mode 100644 index 0000000000..7b82a9909b --- /dev/null +++ b/test/files/run/hashsetremove.scala @@ -0,0 +1,13 @@ +import scala.collection.mutable.HashSet + + +object Test extends App { + val h = new HashSet[Int] + h += 1 + println(s"remove 0 should be false, was ${h remove 0}") + println(s"contains 1 should be true, was ${h contains 1}") + println(s"remove 1 should be true, was ${h remove 1}") + println(s"contains 1 should be false, was ${h contains 1}") + println(s"remove 1 should be false, was ${h remove 1}") + println(s"contains 1 should be false, was ${h contains 1}") + }
\ No newline at end of file diff --git a/test/files/run/idempotency-case-classes.check b/test/files/run/idempotency-case-classes.check index e0453883ff..5a8d0ad9d3 100644 --- a/test/files/run/idempotency-case-classes.check +++ b/test/files/run/idempotency-case-classes.check @@ -47,7 +47,7 @@ C(2,3) case <synthetic> def unapply(x$0: C): Option[(Int, Int)] = if (x$0.==(null)) scala.this.None else - Some.apply[(Int, Int)](Tuple2.apply[Int, Int](x$0.x, x$0.y)); + Some.apply[(Int, Int)](scala.Tuple2.apply[Int, Int](x$0.x, x$0.y)); <synthetic> private def readResolve(): Object = C }; Predef.println(C.apply(2, 3)) diff --git a/test/files/run/idempotency-partial-functions.check b/test/files/run/idempotency-partial-functions.check deleted file mode 100644 index 5c8a411655..0000000000 --- a/test/files/run/idempotency-partial-functions.check +++ /dev/null @@ -1,2 +0,0 @@ -error!! -error! diff --git a/test/files/run/idempotency-this.check b/test/files/run/idempotency-this.check index 8faf703d97..88b8288adf 100644 --- a/test/files/run/idempotency-this.check +++ b/test/files/run/idempotency-this.check @@ -1,4 +1,4 @@ List() List.apply[String]("") -Apply(TypeApply(Select(Ident(scala.collection.immutable.List), newTermName("apply")), List(TypeTree().setOriginal(Select(Ident(scala.Predef), newTypeName("String"))))), List(Literal(Constant("")))) +Apply(TypeApply(Select(Ident(scala.collection.immutable.List), TermName("apply")), List(TypeTree().setOriginal(Select(Ident(scala.Predef), TypeName("String"))))), List(Literal(Constant("")))) List() diff --git a/test/files/run/impconvtimes.scala b/test/files/run/impconvtimes.scala index 8c5ab61779..477a16a890 100644 --- a/test/files/run/impconvtimes.scala +++ b/test/files/run/impconvtimes.scala @@ -1,3 +1,5 @@ +import scala.language.implicitConversions + object Test { abstract class Unit object NoUnit extends Unit diff --git a/test/files/run/implicits.scala b/test/files/run/implicits.scala index a30f60f6d0..5681a9d484 100644 --- a/test/files/run/implicits.scala +++ b/test/files/run/implicits.scala @@ -1,3 +1,5 @@ +import scala.language.implicitConversions + object A { object B { implicit def int2string(x: Int) = "["+x.toString+"]" diff --git a/test/files/run/indexedSeq.scala b/test/files/run/indexedSeq.scala index 9744f47f63..b1a2b1bc60 100644 --- a/test/files/run/indexedSeq.scala +++ b/test/files/run/indexedSeq.scala @@ -1,10 +1,11 @@ object Test { - import scala.collection.{ mutable, immutable, generic } - + import scala.collection.immutable + def checkIdentity[A](xs: immutable.IndexedSeq[A]) = assert(xs.toIndexedSeq eq xs) - + def main(args: Array[String]): Unit = { - checkIdentity(immutable.Vector(1 to 10: _*)) - checkIdentity(1 to 10 toIndexedSeq) + def r = 1 to 10 + checkIdentity(immutable.Vector(r: _*)) + checkIdentity(r.toIndexedSeq) } } diff --git a/test/files/run/infix.scala b/test/files/run/infix.scala index 700e4347ac..a867d03ce8 100644 --- a/test/files/run/infix.scala +++ b/test/files/run/infix.scala @@ -9,4 +9,3 @@ object Test extends App { case null op (0, 0) op (1, 1) op (2, 2) => Console.println("OK") } } - diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check index 50a9d87557..7c885d2cc9 100644 --- a/test/files/run/inline-ex-handlers.check +++ b/test/files/run/inline-ex-handlers.check @@ -21,8 +21,8 @@ 92 RETURN(REF(class Object)) @@ -246,3 +245,3 @@ startBlock: 1 -- blocks: [1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18] -+ blocks: [1,2,3,4,5,6,8,10,11,12,13,14,15,16,17,18] +- blocks: [1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18] ++ blocks: [1,2,3,4,5,6,8,11,12,13,14,15,16,17,18] @@ -257,5 +256,2 @@ 92 SCOPE_ENTER value x1 @@ -72,8 +72,8 @@ 106 CALL_METHOD scala.Predef.println (dynamic) @@ -518,3 +517,3 @@ startBlock: 1 -- blocks: [1,2,3,4,6,7,8,9,10] -+ blocks: [1,2,3,4,6,7,8,9,10,11,12,13] +- blocks: [1,2,3,4,6,7,9,10] ++ blocks: [1,3,4,6,7,9,10,11,12,13] @@ -547,4 +546,9 @@ 306 CALL_METHOD MyException.<init> (static-instance) @@ -104,8 +104,12 @@ + ? JUMP 13 + 3: -@@ -575,2 +586,14 @@ +@@ -573,5 +584,14 @@ + 310 CALL_METHOD scala.Predef.println (dynamic) +- 310 JUMP 2 ++ 300 RETURN(UNIT) +- 2: + 13: + 310 LOAD_MODULE object Predef + 310 CALL_PRIMITIVE(StartConcat) @@ -116,44 +120,42 @@ + 310 CALL_PRIMITIVE(StringConcat(REF(class String))) + 310 CALL_PRIMITIVE(EndConcat) + 310 CALL_METHOD scala.Predef.println (dynamic) -+ 310 JUMP 2 -+ - 2: -@@ -583,6 +606,6 @@ + 300 RETURN(UNIT) +@@ -583,6 +603,6 @@ with finalizer: null -- catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6 -+ catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6 +- catch (Throwable) in ArrayBuffer(7, 9, 10) starting at: 6 ++ catch (Throwable) in ArrayBuffer(7, 9, 10, 11) starting at: 6 consisting of blocks: List(6) with finalizer: null -- catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10) starting at: 3 -+ catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10, 11, 12) starting at: 3 +- catch (Throwable) in ArrayBuffer(4, 6, 7, 9, 10) starting at: 3 ++ catch (Throwable) in ArrayBuffer(4, 6, 7, 9, 10, 11, 12) starting at: 3 consisting of blocks: List(3) -@@ -618,3 +641,3 @@ +@@ -618,3 +638,3 @@ startBlock: 1 -- blocks: [1,2,3,4,5,6,7,9,10] -+ blocks: [1,2,3,4,5,6,7,9,10,11,12] +- blocks: [1,3,4,5,6,8,9] ++ blocks: [1,3,4,5,6,8,9,10,11] -@@ -642,4 +665,10 @@ +@@ -642,4 +662,10 @@ 78 CALL_METHOD java.lang.IllegalArgumentException.<init> (static-instance) - 78 THROW(IllegalArgumentException) + ? STORE_LOCAL(value e) -+ ? JUMP 11 ++ ? JUMP 10 -+ 11: ++ 10: + 81 LOAD_LOCAL(value e) + ? STORE_LOCAL(variable exc1) -+ ? JUMP 12 ++ ? JUMP 11 + - 9: -@@ -671,3 +700,4 @@ + 8: +@@ -668,3 +694,4 @@ 81 LOAD_LOCAL(value e) - 81 THROW(Exception) + ? STORE_LOCAL(variable exc1) -+ ? JUMP 12 ++ ? JUMP 11 -@@ -688,2 +718,15 @@ +@@ -685,2 +712,15 @@ -+ 12: ++ 11: + 83 LOAD_MODULE object Predef + 83 CONSTANT("finally") + 83 CALL_METHOD scala.Predef.println (dynamic) @@ -167,33 +169,33 @@ + 84 THROW(Throwable) + } -@@ -693,3 +736,3 @@ +@@ -690,3 +730,3 @@ with finalizer: null -- catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3 -+ catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3 +- catch (<none>) in ArrayBuffer(4, 5, 6, 8) starting at: 3 ++ catch (<none>) in ArrayBuffer(4, 5, 6, 8, 10) starting at: 3 consisting of blocks: List(3) -@@ -717,5 +760,5 @@ +@@ -714,5 +754,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value message, value x, value ex6, value x4, value x5, value message, value x + locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value x, value ex6, value x4, value x5, value x startBlock: 1 -- blocks: [1,2,3,4,5,6,9,11,14,15,16,19,21,22,24,25] -+ blocks: [1,2,3,4,5,6,9,11,14,15,16,19,21,22,24,25,26,27,28] +- blocks: [1,3,4,5,6,9,13,14,15,18,20,21,23,24] ++ blocks: [1,3,4,5,6,9,13,14,15,18,20,21,23,24,25,26,27] -@@ -743,4 +786,11 @@ +@@ -740,4 +780,11 @@ 172 CALL_METHOD MyException.<init> (static-instance) - 172 THROW(MyException) + ? STORE_LOCAL(value ex6) -+ ? JUMP 26 ++ ? JUMP 25 -+ 26: ++ 25: + 170 LOAD_LOCAL(value ex6) + 170 STORE_LOCAL(value x4) + 170 SCOPE_ENTER value x4 -+ 170 JUMP 15 ++ 170 JUMP 14 + - 24: -@@ -786,8 +836,5 @@ + 23: +@@ -780,8 +827,5 @@ 175 SCOPE_ENTER value x5 - 175 LOAD_LOCAL(value x5) - 175 CALL_METHOD MyException.message (dynamic) @@ -204,7 +206,7 @@ + ? LOAD_LOCAL(value x5) + 176 CALL_METHOD MyException.message (dynamic) 176 CALL_METHOD scala.Predef.println (dynamic) -@@ -795,5 +842,7 @@ +@@ -789,5 +833,7 @@ 177 DUP(REF(class MyException)) - 177 LOAD_LOCAL(value message) + ? LOAD_LOCAL(value x5) @@ -212,24 +214,24 @@ 177 CALL_METHOD MyException.<init> (static-instance) - 177 THROW(MyException) + ? STORE_LOCAL(value ex6) -+ ? JUMP 27 ++ ? JUMP 26 -@@ -801,3 +850,4 @@ +@@ -795,3 +841,4 @@ 170 LOAD_LOCAL(value ex6) - 170 THROW(Throwable) + ? STORE_LOCAL(value ex6) -+ ? JUMP 27 ++ ? JUMP 26 -@@ -811,2 +861,8 @@ +@@ -805,2 +852,8 @@ -+ 27: ++ 26: + 169 LOAD_LOCAL(value ex6) + 169 STORE_LOCAL(value x4) + 169 SCOPE_ENTER value x4 + 169 JUMP 5 + 5: -@@ -821,8 +877,5 @@ +@@ -815,8 +868,5 @@ 180 SCOPE_ENTER value x5 - 180 LOAD_LOCAL(value x5) - 180 CALL_METHOD MyException.message (dynamic) @@ -240,7 +242,7 @@ + ? LOAD_LOCAL(value x5) + 181 CALL_METHOD MyException.message (dynamic) 181 CALL_METHOD scala.Predef.println (dynamic) -@@ -830,5 +883,7 @@ +@@ -824,5 +874,7 @@ 182 DUP(REF(class MyException)) - 182 LOAD_LOCAL(value message) + ? LOAD_LOCAL(value x5) @@ -248,17 +250,17 @@ 182 CALL_METHOD MyException.<init> (static-instance) - 182 THROW(MyException) + ? STORE_LOCAL(variable exc2) -+ ? JUMP 28 ++ ? JUMP 27 -@@ -836,3 +891,4 @@ +@@ -830,3 +882,4 @@ 169 LOAD_LOCAL(value ex6) - 169 THROW(Throwable) + ? STORE_LOCAL(variable exc2) -+ ? JUMP 28 ++ ? JUMP 27 -@@ -853,2 +909,15 @@ +@@ -847,2 +900,15 @@ -+ 28: ++ 27: + 184 LOAD_MODULE object Predef + 184 CONSTANT("finally") + 184 CALL_METHOD scala.Predef.println (dynamic) @@ -272,16 +274,16 @@ + 185 THROW(Throwable) + } -@@ -858,6 +927,6 @@ +@@ -852,6 +918,6 @@ with finalizer: null -- catch (Throwable) in ArrayBuffer(14, 15, 16, 19, 21, 22, 24) starting at: 4 -+ catch (Throwable) in ArrayBuffer(14, 15, 16, 19, 21, 22, 24, 26) starting at: 4 - consisting of blocks: List(9, 6, 5, 4) +- catch (Throwable) in ArrayBuffer(13, 14, 15, 18, 20, 21, 23) starting at: 4 ++ catch (Throwable) in ArrayBuffer(13, 14, 15, 18, 20, 21, 23, 25) starting at: 4 + consisting of blocks: List(9, 8, 6, 5, 4) with finalizer: null -- catch (<none>) in ArrayBuffer(4, 5, 6, 9, 14, 15, 16, 19, 21, 22, 24) starting at: 3 -+ catch (<none>) in ArrayBuffer(4, 5, 6, 9, 14, 15, 16, 19, 21, 22, 24, 26, 27) starting at: 3 +- catch (<none>) in ArrayBuffer(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23) starting at: 3 ++ catch (<none>) in ArrayBuffer(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23, 25, 26) starting at: 3 consisting of blocks: List(3) -@@ -885,5 +954,5 @@ +@@ -879,5 +945,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, value e, value ex6, value x4, value x5, value message, value x + locals: value args, variable result, value e, value ex6, value x4, value x5, value x @@ -289,7 +291,7 @@ - blocks: [1,2,3,6,7,8,11,13,14,16] + blocks: [1,2,3,6,7,8,11,13,14,16,17] -@@ -911,4 +980,11 @@ +@@ -905,4 +971,11 @@ 124 CALL_METHOD MyException.<init> (static-instance) - 124 THROW(MyException) + ? STORE_LOCAL(value ex6) @@ -302,7 +304,7 @@ + 122 JUMP 7 + 16: -@@ -936,8 +1012,5 @@ +@@ -930,8 +1003,5 @@ 127 SCOPE_ENTER value x5 - 127 LOAD_LOCAL(value x5) - 127 CALL_METHOD MyException.message (dynamic) @@ -313,12 +315,12 @@ + ? LOAD_LOCAL(value x5) + 127 CALL_METHOD MyException.message (dynamic) 127 CALL_METHOD scala.Predef.println (dynamic) -@@ -970,3 +1043,3 @@ +@@ -964,3 +1034,3 @@ with finalizer: null - catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16) starting at: 3 + catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16, 17) starting at: 3 consisting of blocks: List(3) -@@ -994,5 +1067,5 @@ +@@ -988,5 +1058,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, value ex6, value x4, value x5, value message, value x, value e + locals: value args, variable result, value ex6, value x4, value x5, value x, value e @@ -326,7 +328,7 @@ - blocks: [1,2,3,4,5,8,12,13,14,16] + blocks: [1,2,3,5,8,12,13,14,16,17] -@@ -1020,4 +1093,13 @@ +@@ -1014,4 +1084,13 @@ 148 CALL_METHOD MyException.<init> (static-instance) - 148 THROW(MyException) + ? STORE_LOCAL(value ex6) @@ -341,13 +343,13 @@ + 154 CZJUMP (BOOL)NE ? 5 : 8 + 16: -@@ -1041,5 +1123,2 @@ +@@ -1035,5 +1114,2 @@ 145 SCOPE_ENTER value x4 - 145 JUMP 4 - - 4: 154 LOAD_LOCAL(value x4) -@@ -1053,8 +1132,5 @@ +@@ -1047,8 +1123,5 @@ 154 SCOPE_ENTER value x5 - 154 LOAD_LOCAL(value x5) - 154 CALL_METHOD MyException.message (dynamic) @@ -358,12 +360,12 @@ + ? LOAD_LOCAL(value x5) + 154 CALL_METHOD MyException.message (dynamic) 154 CALL_METHOD scala.Predef.println (dynamic) -@@ -1275,3 +1351,3 @@ +@@ -1269,3 +1342,3 @@ startBlock: 1 - blocks: [1,2,3,4,5,7] + blocks: [1,2,3,4,5,7,8] -@@ -1299,4 +1375,11 @@ +@@ -1293,4 +1366,11 @@ 38 CALL_METHOD java.lang.IllegalArgumentException.<init> (static-instance) - 38 THROW(IllegalArgumentException) + ? STORE_LOCAL(value e) @@ -376,7 +378,7 @@ + 42 JUMP 2 + 7: -@@ -1346,5 +1429,5 @@ +@@ -1340,5 +1420,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, value ex6, value x4, value x5, value message, value x + locals: value args, variable result, value ex6, value x4, value x5, value x @@ -384,13 +386,13 @@ - blocks: [1,2,3,4,5,8,10,11,13,14,16] + blocks: [1,2,3,5,8,10,11,13,14,16,17] -@@ -1372,3 +1455,4 @@ +@@ -1366,3 +1446,4 @@ 203 CALL_METHOD MyException.<init> (static-instance) - 203 THROW(MyException) + ? STORE_LOCAL(value ex6) + ? JUMP 17 -@@ -1392,4 +1476,13 @@ +@@ -1386,4 +1467,13 @@ 209 CALL_METHOD MyException.<init> (static-instance) - 209 THROW(MyException) + ? STORE_LOCAL(value ex6) @@ -405,13 +407,13 @@ + 212 CZJUMP (BOOL)NE ? 5 : 8 + 16: -@@ -1405,5 +1498,2 @@ +@@ -1399,5 +1489,2 @@ 200 SCOPE_ENTER value x4 - 200 JUMP 4 - - 4: 212 LOAD_LOCAL(value x4) -@@ -1417,8 +1507,5 @@ +@@ -1411,8 +1498,5 @@ 212 SCOPE_ENTER value x5 - 212 LOAD_LOCAL(value x5) - 212 CALL_METHOD MyException.message (dynamic) @@ -422,12 +424,12 @@ + ? LOAD_LOCAL(value x5) + 213 CALL_METHOD MyException.message (dynamic) 213 CALL_METHOD scala.Predef.println (dynamic) -@@ -1466,3 +1553,3 @@ +@@ -1460,3 +1544,3 @@ startBlock: 1 - blocks: [1,2,3,4,5,7] + blocks: [1,2,3,4,5,7,8] -@@ -1490,4 +1577,11 @@ +@@ -1484,4 +1568,11 @@ 58 CALL_METHOD java.lang.IllegalArgumentException.<init> (static-instance) - 58 THROW(IllegalArgumentException) + ? STORE_LOCAL(value e) @@ -440,12 +442,12 @@ + 62 JUMP 2 + 7: -@@ -1539,3 +1633,3 @@ +@@ -1533,3 +1624,3 @@ startBlock: 1 -- blocks: [1,2,3,4] -+ blocks: [1,2,3,4,5] +- blocks: [1,3,4] ++ blocks: [1,3,4,5] -@@ -1559,4 +1653,9 @@ +@@ -1553,4 +1644,9 @@ 229 CALL_METHOD MyException.<init> (static-instance) - 229 THROW(MyException) + ? JUMP 5 @@ -456,20 +458,20 @@ + 228 THROW(Throwable) + 3: -@@ -1565,3 +1664,3 @@ +@@ -1559,3 +1655,3 @@ 228 MONITOR_EXIT - ? THROW(Throwable) + 228 THROW(Throwable) -@@ -1593,5 +1692,5 @@ +@@ -1587,5 +1683,5 @@ def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, variable result, variable monitor2, variable monitorResult1 + locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1 startBlock: 1 -- blocks: [1,2,3,4] -+ blocks: [1,2,3,4,5] +- blocks: [1,3,4] ++ blocks: [1,3,4,5] -@@ -1618,4 +1717,12 @@ +@@ -1612,4 +1708,12 @@ 245 CALL_METHOD MyException.<init> (static-instance) - 245 THROW(MyException) + ? STORE_LOCAL(value exception$1) @@ -483,7 +485,7 @@ + 244 THROW(Throwable) + 3: -@@ -1624,3 +1731,3 @@ +@@ -1618,3 +1722,3 @@ 244 MONITOR_EXIT - ? THROW(Throwable) + 244 THROW(Throwable) diff --git a/test/files/run/inline-ex-handlers.scala b/test/files/run/inline-ex-handlers.scala index a96b938e13..964594d258 100644 --- a/test/files/run/inline-ex-handlers.scala +++ b/test/files/run/inline-ex-handlers.scala @@ -1,7 +1,7 @@ -import scala.tools.partest.IcodeTest +import scala.tools.partest.IcodeComparison -object Test extends IcodeTest { - override def printIcodeAfterPhase = "inlineExceptionHandlers" +object Test extends IcodeComparison { + override def printIcodeAfterPhase = "inlinehandlers" } import scala.util.Random._ diff --git a/test/files/run/inliner-infer.scala b/test/files/run/inliner-infer.scala index ea83966c52..e41d6ae5c7 100644 --- a/test/files/run/inliner-infer.scala +++ b/test/files/run/inliner-infer.scala @@ -7,8 +7,8 @@ object Test extends App { @annotation.tailrec def walk(xs: MyList): Unit = { - if (xs.isEmpty) - println("empty") + if (xs.isEmpty) + println("empty") else { println("non-empty") walk(MyNil) @@ -26,4 +26,3 @@ object MyNil extends MyList { override def isEmpty = true } - diff --git a/test/files/run/inner-obj-auto.scala b/test/files/run/inner-obj-auto.scala index aa2e29326f..00ea5119cc 100644 --- a/test/files/run/inner-obj-auto.scala +++ b/test/files/run/inner-obj-auto.scala @@ -3,15 +3,15 @@ /* ================================================================================ Automatically generated on 2011-05-11. Do Not Edit (unless you have to). (2-level nesting) - ================================================================================ */ + ================================================================================ */ class Class2_1 { - + class Class1_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -25,22 +25,22 @@ class Class2_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Class1_2).run } } object Object3_1 { - + class Class1_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -54,22 +54,22 @@ object Object3_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Class1_2).run } // trigger } trait Trait4_1 { - + class Class1_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -83,22 +83,22 @@ trait Trait4_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Class1_2).run } } class Class6_1 { - + object Object5_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -112,22 +112,22 @@ class Class6_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } // trigger } - + def run { Object5_2.run } } object Object7_1 { - + object Object5_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -141,22 +141,22 @@ object Object7_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } // trigger } - + def run { Object5_2.run } // trigger } trait Trait8_1 { - + object Object5_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -170,22 +170,22 @@ trait Trait8_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } // trigger } - + def run { Object5_2.run } } class Class10_1 { - + trait Trait9_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -199,22 +199,22 @@ class Class10_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Trait9_2 {}).run } } object Object11_1 { - + trait Trait9_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -228,22 +228,22 @@ object Object11_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Trait9_2 {}).run } // trigger } trait Trait12_1 { - + trait Trait9_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -257,22 +257,22 @@ trait Trait12_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Trait9_2 {}).run } } class Class14_1 { - + def method13_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -286,22 +286,22 @@ class Class14_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { method13_2 } } object Object15_1 { - + def method13_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -315,22 +315,22 @@ object Object15_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { method13_2 } // trigger } trait Trait16_1 { - + def method13_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -344,22 +344,22 @@ trait Trait16_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { method13_2 } } class Class18_1 { - + private def method17_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -373,22 +373,22 @@ class Class18_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { method17_2 } } object Object19_1 { - + private def method17_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -402,22 +402,22 @@ object Object19_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { method17_2 } // trigger } trait Trait20_1 { - + private def method17_2 { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -431,22 +431,22 @@ trait Trait20_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { method17_2 } } class Class22_1 { - + val fun21_2 = () => { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -460,22 +460,22 @@ class Class22_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { fun21_2() } } object Object23_1 { - + val fun21_2 = () => { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -489,22 +489,22 @@ object Object23_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { fun21_2() } // trigger } trait Trait24_1 { - + val fun21_2 = () => { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -518,23 +518,23 @@ trait Trait24_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { fun21_2() } } class Class26_1 { - + class Class25_2 { - { // in primary constructor + { // in primary constructor var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -548,24 +548,24 @@ class Class26_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Class25_2) } } object Object27_1 { - + class Class25_2 { - { // in primary constructor + { // in primary constructor var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -579,24 +579,24 @@ object Object27_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Class25_2) } // trigger } trait Trait28_1 { - + class Class25_2 { - { // in primary constructor + { // in primary constructor var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -610,24 +610,24 @@ trait Trait28_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Class25_2) } } class Class30_1 { - + trait Trait29_2 { - { // in primary constructor + { // in primary constructor var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -641,24 +641,24 @@ class Class30_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Trait29_2 {}) } } object Object31_1 { - + trait Trait29_2 { - { // in primary constructor + { // in primary constructor var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -672,24 +672,24 @@ object Object31_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Trait29_2 {}) } // trigger } trait Trait32_1 { - + trait Trait29_2 { - { // in primary constructor + { // in primary constructor var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -703,23 +703,23 @@ trait Trait32_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Trait29_2 {}) } } class Class34_1 { - + lazy val lzvalue33_2 = { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -733,22 +733,22 @@ class Class34_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { lzvalue33_2 } } object Object35_1 { - + lazy val lzvalue33_2 = { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -762,22 +762,22 @@ object Object35_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { lzvalue33_2 } // trigger } trait Trait36_1 { - + lazy val lzvalue33_2 = { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -791,22 +791,22 @@ trait Trait36_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { lzvalue33_2 } } class Class38_1 { - + val value37_2 = { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -820,22 +820,22 @@ class Class38_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { value37_2 } } object Object39_1 { - + val value37_2 = { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -849,22 +849,22 @@ object Object39_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { value37_2 } // trigger } trait Trait40_1 { - + val value37_2 = { var ObjCounter = 0 - + object Obj { ObjCounter += 1} Obj // one @@ -878,22 +878,22 @@ trait Trait40_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } runTest // trigger } - + def run { value37_2 } } class Class42_1 { - + class Class41_2 { var ObjCounter = 0 - + private object Obj { ObjCounter += 1} Obj // one @@ -907,22 +907,22 @@ class Class42_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Class41_2).run } } object Object43_1 { - + class Class41_2 { var ObjCounter = 0 - + private object Obj { ObjCounter += 1} Obj // one @@ -936,22 +936,22 @@ object Object43_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Class41_2).run } // trigger } trait Trait44_1 { - + class Class41_2 { var ObjCounter = 0 - + private object Obj { ObjCounter += 1} Obj // one @@ -965,22 +965,22 @@ trait Trait44_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Class41_2).run } } class Class46_1 { - + object Object45_2 { var ObjCounter = 0 - + private object Obj { ObjCounter += 1} Obj // one @@ -994,22 +994,22 @@ class Class46_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } // trigger } - + def run { Object45_2.run } } object Object47_1 { - + object Object45_2 { var ObjCounter = 0 - + private object Obj { ObjCounter += 1} Obj // one @@ -1023,22 +1023,22 @@ object Object47_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } // trigger } - + def run { Object45_2.run } // trigger } trait Trait48_1 { - + object Object45_2 { var ObjCounter = 0 - + private object Obj { ObjCounter += 1} Obj // one @@ -1052,22 +1052,22 @@ trait Trait48_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } // trigger } - + def run { Object45_2.run } } class Class50_1 { - + trait Trait49_2 { var ObjCounter = 0 - + private object Obj { ObjCounter += 1} Obj // one @@ -1081,22 +1081,22 @@ class Class50_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Trait49_2 {}).run } } object Object51_1 { - + trait Trait49_2 { var ObjCounter = 0 - + private object Obj { ObjCounter += 1} Obj // one @@ -1110,22 +1110,22 @@ object Object51_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Trait49_2 {}).run } // trigger } trait Trait52_1 { - + trait Trait49_2 { var ObjCounter = 0 - + private object Obj { ObjCounter += 1} Obj // one @@ -1139,22 +1139,22 @@ trait Trait52_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("failed "); e.printStackTrace() + case e: Throwable => print("failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Trait49_2 {}).run } } class Class54_1 { - + class Class53_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1172,22 +1172,22 @@ class Class54_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Class53_2).run } } object Object55_1 { - + class Class53_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1205,22 +1205,22 @@ object Object55_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Class53_2).run } // trigger } trait Trait56_1 { - + class Class53_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1238,22 +1238,22 @@ trait Trait56_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Class53_2).run } } class Class58_1 { - + object Object57_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1271,22 +1271,22 @@ class Class58_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } def run { runTest } // trigger } - + def run { Object57_2.run } } object Object59_1 { - + object Object57_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1304,22 +1304,22 @@ object Object59_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } def run { runTest } // trigger } - + def run { Object57_2.run } // trigger } trait Trait60_1 { - + object Object57_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1337,22 +1337,22 @@ trait Trait60_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } def run { runTest } // trigger } - + def run { Object57_2.run } } class Class62_1 { - + trait Trait61_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1370,22 +1370,22 @@ class Class62_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Trait61_2 {}).run } } object Object63_1 { - + trait Trait61_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1403,22 +1403,22 @@ object Object63_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Trait61_2 {}).run } // trigger } trait Trait64_1 { - + trait Trait61_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1436,22 +1436,22 @@ trait Trait64_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } def run { runTest } } - + def run { (new Trait61_2 {}).run } } class Class66_1 { - + def method65_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1469,22 +1469,22 @@ class Class66_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { method65_2 } } object Object67_1 { - + def method65_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1502,22 +1502,22 @@ object Object67_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { method65_2 } // trigger } trait Trait68_1 { - + def method65_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1535,22 +1535,22 @@ trait Trait68_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { method65_2 } } class Class70_1 { - + private def method69_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1568,22 +1568,22 @@ class Class70_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { method69_2 } } object Object71_1 { - + private def method69_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1601,22 +1601,22 @@ object Object71_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { method69_2 } // trigger } trait Trait72_1 { - + private def method69_2 { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1634,22 +1634,22 @@ trait Trait72_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { method69_2 } } class Class74_1 { - + val fun73_2 = () => { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1667,22 +1667,22 @@ class Class74_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { fun73_2() } } object Object75_1 { - + val fun73_2 = () => { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1700,22 +1700,22 @@ object Object75_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { fun73_2() } // trigger } trait Trait76_1 { - + val fun73_2 = () => { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1733,23 +1733,23 @@ trait Trait76_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { fun73_2() } } class Class78_1 { - + class Class77_2 { - { // in primary constructor + { // in primary constructor @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1767,24 +1767,24 @@ class Class78_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Class77_2) } } object Object79_1 { - + class Class77_2 { - { // in primary constructor + { // in primary constructor @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1802,24 +1802,24 @@ object Object79_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Class77_2) } // trigger } trait Trait80_1 { - + class Class77_2 { - { // in primary constructor + { // in primary constructor @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1837,24 +1837,24 @@ trait Trait80_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Class77_2) } } class Class82_1 { - + trait Trait81_2 { - { // in primary constructor + { // in primary constructor @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1872,24 +1872,24 @@ class Class82_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Trait81_2 {}) } } object Object83_1 { - + trait Trait81_2 { - { // in primary constructor + { // in primary constructor @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1907,24 +1907,24 @@ object Object83_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Trait81_2 {}) } // trigger } trait Trait84_1 { - + trait Trait81_2 { - { // in primary constructor + { // in primary constructor @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1942,23 +1942,23 @@ trait Trait84_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger - } + } } - + def run { (new Trait81_2 {}) } } class Class90_1 { - + val value89_2 = { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -1976,22 +1976,22 @@ class Class90_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { value89_2 } } trait Trait92_1 { - + val value89_2 = { @volatile var ObjCounter = 0 - + object Obj { ObjCounter += 1} def multiThreadedAccess() { @@ -2009,13 +2009,13 @@ trait Trait92_1 { assert(ObjCounter == 1, "multiple instances: " + ObjCounter) println("ok") } catch { - case e => print("multi-threaded failed "); e.printStackTrace() + case e: Throwable => print("multi-threaded failed "); e.printStackTrace() } } runTest // trigger } - + def run { value89_2 } } diff --git a/test/files/run/interop_classtags_are_classmanifests.scala b/test/files/run/interop_classtags_are_classmanifests.scala index 91b9d89c6e..62d85c3ce3 100644 --- a/test/files/run/interop_classtags_are_classmanifests.scala +++ b/test/files/run/interop_classtags_are_classmanifests.scala @@ -1,5 +1,6 @@ -import scala.reflect.{ClassTag, classTag} +import scala.reflect.ClassTag +@deprecated("Suppress warnings", since="2.11") object Test extends App { def classTagIsClassManifest[T: ClassTag] = { println(classManifest[T]) @@ -8,4 +9,4 @@ object Test extends App { classTagIsClassManifest[Int] classTagIsClassManifest[String] classTagIsClassManifest[Array[Int]] -}
\ No newline at end of file +} diff --git a/test/files/run/interop_manifests_are_classtags.scala b/test/files/run/interop_manifests_are_classtags.scala index 03479e527a..705038ece7 100644 --- a/test/files/run/interop_manifests_are_classtags.scala +++ b/test/files/run/interop_manifests_are_classtags.scala @@ -1,5 +1,6 @@ import scala.reflect.{ClassTag, classTag} +@deprecated("Suppress warnings", since="2.11") object Test extends App { def classManifestIsClassTag[T: ClassManifest] = { println(classTag[T]) @@ -20,4 +21,4 @@ object Test extends App { manifestIsClassTag[Int] manifestIsClassTag[String] manifestIsClassTag[Array[Int]] -}
\ No newline at end of file +} diff --git a/test/files/run/interpolation.flags b/test/files/run/interpolation.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/interpolation.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/interpolationArgs.check b/test/files/run/interpolationArgs.check index 155991e618..983214cbee 100644 --- a/test/files/run/interpolationArgs.check +++ b/test/files/run/interpolationArgs.check @@ -1,2 +1,2 @@ -java.lang.IllegalArgumentException: wrong number of arguments for interpolated string -java.lang.IllegalArgumentException: wrong number of arguments for interpolated string +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 3 parts +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 1 parts diff --git a/test/files/run/interpolationArgs.flags b/test/files/run/interpolationArgs.flags deleted file mode 100644 index e1b37447c9..0000000000 --- a/test/files/run/interpolationArgs.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental
\ No newline at end of file diff --git a/test/files/run/interpolationArgs.scala b/test/files/run/interpolationArgs.scala index eb13767907..ffb254b63f 100644 --- a/test/files/run/interpolationArgs.scala +++ b/test/files/run/interpolationArgs.scala @@ -1,5 +1,5 @@ object Test extends App { - try { scala.StringContext("p1", "p2", "p3").s("e1") } catch { case ex => println(ex) } - try { scala.StringContext("p1").s("e1") } catch { case ex => println(ex) } + try { scala.StringContext("p1", "p2", "p3").s("e1") } catch { case ex: Throwable => println(ex) } + try { scala.StringContext("p1").s("e1") } catch { case ex: Throwable => println(ex) } } diff --git a/test/files/run/interpolationMultiline1.flags b/test/files/run/interpolationMultiline1.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/interpolationMultiline1.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/interpolationMultiline2.flags b/test/files/run/interpolationMultiline2.flags deleted file mode 100644 index e1b37447c9..0000000000 --- a/test/files/run/interpolationMultiline2.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental
\ No newline at end of file diff --git a/test/files/run/interpolationMultiline2.scala b/test/files/run/interpolationMultiline2.scala index f6a682c3ce..2de4c4b22e 100644 --- a/test/files/run/interpolationMultiline2.scala +++ b/test/files/run/interpolationMultiline2.scala @@ -2,14 +2,15 @@ object Test extends App { def test1(n: Int) = { val old = "old" - try { println(s"""Bob is ${s"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(s"""Bob is ${f"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(f"""Bob is ${s"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(f"""Bob is ${f"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(f"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(f"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(s"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) } - try { println(s"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) } + val catcher: PartialFunction[Throwable, Unit] = { case e => println(e) } + try { println(s"""Bob is ${s"$n"} years ${s"$old"}!""") } catch catcher + try { println(s"""Bob is ${f"$n"} years ${s"$old"}!""") } catch catcher + try { println(f"""Bob is ${s"$n"} years ${s"$old"}!""") } catch catcher + try { println(f"""Bob is ${f"$n"} years ${s"$old"}!""") } catch catcher + try { println(f"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch catcher + try { println(f"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch catcher + try { println(s"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch catcher + try { println(s"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch catcher } test1(1) diff --git a/test/files/run/io-position.check b/test/files/run/io-position.check Binary files differdeleted file mode 100644 index 09f743d750..0000000000 --- a/test/files/run/io-position.check +++ /dev/null diff --git a/test/files/run/io-position.scala b/test/files/run/io-position.scala deleted file mode 100644 index 1093704fa4..0000000000 --- a/test/files/run/io-position.scala +++ /dev/null @@ -1,13 +0,0 @@ -object Test { - Console.setErr(Console.out) - - def main(args: Array[String]): Unit = { - try { - xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<foo>"), false).document() - } catch { - case e:Exception => println(e.getMessage) - } - } - -} - diff --git a/test/files/run/iq.scala b/test/files/run/iq.scala index e5f9e4705a..31859cf867 100644 --- a/test/files/run/iq.scala +++ b/test/files/run/iq.scala @@ -9,8 +9,8 @@ object iq { /* Create an empty queue. */ val q: Queue[Int] = Queue.empty - /* Test isEmpty. - * Expected: Empty + /* Test isEmpty. + * Expected: Empty */ if (q.isEmpty) { Console.println("Empty") @@ -20,14 +20,14 @@ object iq { //val q2 = q + 42 + 0 // deprecated val q2 = q.enqueue(42).enqueue(0) - /* Test is empty and dequeue. + /* Test is empty and dequeue. * Expected: Head: 42 */ val q4 = if (q2.isEmpty) { Console.println("Empty") q2 - } + } else { val (head, q3) = q2.dequeue Console.println("Head: " + head) @@ -36,8 +36,8 @@ 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) + /* Test toString. + * Expected: Head: q5: Queue(0,1,2,3,4,5,6,7,8,9) */ Console.println("q5: " + q5) /* Test apply @@ -59,7 +59,7 @@ object iq { //val q8 = q7 + 10 + 11 //deprecated val q8 = q7.enqueue(10).enqueue(11) /* Test dequeu - * Expected: q8: Queue(2,3,4,5,6,7,8,9,10,11) + * Expected: q8: Queue(2,3,4,5,6,7,8,9,10,11) */ Console.println("q8: " + q8) val q9 = Queue(2,3,4,5,6,7,8,9,10,11) @@ -70,14 +70,14 @@ object iq { Console.println("q8 == q9: " + (q8 == q9)) /* Testing elements - * Expected: Elements: 1 2 3 4 5 6 7 8 9 + * Expected: Elements: 1 2 3 4 5 6 7 8 9 */ - Console.print("Elements: "); + Console.print("Elements: "); q6.iterator.foreach(e => Console.print(" "+ e + " ")) - Console.println; + Console.println; /* Testing mkString - * Expected: String: <1-2-3-4-5-6-7-8-9> + * Expected: String: <1-2-3-4-5-6-7-8-9> */ Console.println("String: " + q6.mkString("<","-",">")) @@ -89,7 +89,7 @@ object iq { /* Testing front * Expected: Front: 1 */ - Console.println("Front: " + q6.front); + Console.println("Front: " + q6.front); } } diff --git a/test/files/run/is-valid-num.scala b/test/files/run/is-valid-num.scala index 402eff99d6..d314015dd4 100644 --- a/test/files/run/is-valid-num.scala +++ b/test/files/run/is-valid-num.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ object Test { def x = BigInt("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") def y = BigDecimal("" + (Short.MaxValue + 1) + ".0") @@ -124,7 +127,7 @@ object Test { checkBigInt2(biExp2(128) - biExp2(128 - pf)) checkBigInt2(biExp2(128) - biExp2(128 - pf - 1)) checkBigInt2(biExp2(128)) - + checkBigInt2(biExp2(1023)) checkBigInt2(biExp2(1024) - biExp2(1024 - pd)) checkBigInt2(biExp2(1024) - biExp2(1024 - pd - 1)) diff --git a/test/files/run/issue192.scala b/test/files/run/issue192.scala index d8db8b5816..8e6d13e5e1 100644 --- a/test/files/run/issue192.scala +++ b/test/files/run/issue192.scala @@ -1,16 +1,18 @@ +import scala.language.reflectiveCalls + object Test extends App { - + def f1(p: Any{def unary_+ : Int}) = +p def f2(p: Any{def unary_- : Int}) = -p def f3(p: Any{def unary_~ : Int}) = ~p def f4(p: Any{def unary_! : Boolean}) = !p - + def f5(p: Any{def +(q: Int): Int}) = p + 7 def f6(p: Any{def -(q: Int): Int}) = p - 7 def f7(p: Any{def *(q: Int): Int}) = p * 7 def f8(p: Any{def /(q: Int): Int}) = p / 7 def f9(p: Any{def %(q: Int): Int}) = p % 7 - + def f10(p: Any{def |(q: Int): Int}) = p | 7 def f11(p: Any{def |(q: Boolean): Boolean}) = p | true def f12(p: Any{def ^(q: Int): Int}) = p ^ 7 @@ -19,11 +21,11 @@ object Test extends App { def f15(p: Any{def &(q: Boolean): Boolean}) = p & true def f16(p: Any{def ||(q: Boolean): Boolean}) = p || true def f17(p: Any{def &&(q: Boolean): Boolean}) = p && true - + def f18(p: Any{def <<(q: Int): Int}) = p << 7 def f19(p: Any{def >>(q: Int): Int}) = p >> 7 def f20(p: Any{def >>>(q: Int): Int}) = p >>> 7 - + def f21(p: Any{def toByte: Byte}) = p.toByte def f22(p: Any{def toShort: Short}) = p.toShort def f23(p: Any{def toChar: Char}) = p.toChar @@ -31,28 +33,28 @@ object Test extends App { def f25(p: Any{def toLong: Long}) = p.toLong def f26(p: Any{def toFloat: Float}) = p.toFloat def f27(p: Any{def toDouble: Double}) = p.toDouble - + def f28(p: Any{def ==(q: Int): Boolean}) = p == 7 def f29(p: Any{def !=(q: Int): Boolean}) = p != 7 def f30(p: Any{def ==(q: Boolean): Boolean}) = p == true def f31(p: Any{def !=(q: Boolean): Boolean}) = p != true - + def f32(p: Any{def <(q: Int): Boolean}) = p < 7 def f33(p: Any{def <=(q: Int): Boolean}) = p <= 7 def f34(p: Any{def >=(q: Int): Boolean}) = p >= 7 def f35(p: Any{def >(q: Int): Boolean}) = p > 7 - + print("f1 = "); println(f1(1) == +1) print("f2 = "); println(f2(1) == -1) print("f3 = "); println(f3(1) == ~1) print("f4 = "); println(f4(true) == !true) - + print("f5 = "); println(f5(4) == (4 + 7)) print("f6 = "); println(f6(4) == (4 - 7)) print("f7 = "); println(f7(4) == (4 * 7)) print("f8 = "); println(f8(4) == (4 / 7)) print("f9 = "); println(f9(4) == (4 % 7)) - + print("f10 = "); println(f10(4) == (4 | 7)) print("f11 = "); println(f11(false) == (false | true)) print("f12 = "); println(f12(4) == (4 ^ 7)) @@ -61,11 +63,11 @@ object Test extends App { print("f15 = "); println(f15(false) == (false & true)) print("f16 = "); println(f16(false) == (false || true)) print("f17 = "); println(f17(false) == (false && true)) - + print("f18 = "); println(f18(4) == (4 << 7)) print("f19 = "); println(f19(-4) == (-4 >> 7)) print("f20 = "); println(f20(-4) == (-4 >>> 7)) - + print("f21 = "); println(f21(4.2) == (4.2.toByte)) print("f22 = "); println(f22(4.2) == (4.2.toShort)) print("f23 = "); println(f23(4.2) == (4.2.toChar)) @@ -73,17 +75,17 @@ object Test extends App { print("f25 = "); println(f25(4.2) == (4.2.toLong)) print("f26 = "); println(f26(4.2) == (4.2.toFloat)) print("f27 = "); println(f27(4.2) == (4.2.toDouble)) - + print("f28 = "); println(f28(4) == (4 == 7)) print("f29 = "); println(f29(4) == (4 != 7)) print("f30 = "); println(f30(false) == (false == true)) print("f31 = "); println(f31(false) == (false != true)) - + print("f32 = "); println(f32(4) == (4 < 7)) print("f33 = "); println(f33(4) == (4 <= 7)) print("f34 = "); println(f34(4) == (4 >= 7)) print("f35 = "); println(f35(4) == (4 > 7)) - + println("ok") - + } diff --git a/test/files/run/iterator-concat.check b/test/files/run/iterator-concat.check new file mode 100644 index 0000000000..23835b07ae --- /dev/null +++ b/test/files/run/iterator-concat.check @@ -0,0 +1,4 @@ +100 +1000 +10000 +100000 diff --git a/test/files/run/iterator-concat.scala b/test/files/run/iterator-concat.scala new file mode 100644 index 0000000000..f11363410f --- /dev/null +++ b/test/files/run/iterator-concat.scala @@ -0,0 +1,15 @@ +object Test { + // Create `size` Function0s, each of which evaluates to an Iterator + // which produces 1. Then fold them over ++ to get a single iterator, + // which should sum to "size". + def mk(size: Int): Iterator[Int] = { + val closures = (1 to size).toList.map(x => (() => Iterator(1))) + closures.foldLeft(Iterator.empty: Iterator[Int])((res, f) => res ++ f()) + } + def main(args: Array[String]): Unit = { + println(mk(100).sum) + println(mk(1000).sum) + println(mk(10000).sum) + println(mk(100000).sum) + } +} diff --git a/test/files/run/iterator-from.scala b/test/files/run/iterator-from.scala new file mode 100644 index 0000000000..269e859657 --- /dev/null +++ b/test/files/run/iterator-from.scala @@ -0,0 +1,71 @@ +/* This file tests iteratorFrom, keysIteratorFrom, and valueIteratorFrom on various sorted sets and maps + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ + +import scala.util.{Random => R} +import scala.collection._ +import scala.math.Ordered + +object Test extends App { + val maxLength = 25 + val maxKey = 50 + val maxValue = 50 + + def testSet[A <% Ordered[A]](set: SortedSet[A], list: List[A]) { + val distinctSorted = list.distinct.sorted + assertEquals("Set size wasn't the same as list sze", set.size, distinctSorted.size) + + for(key <- distinctSorted) { + val clazz = set.getClass + val iteratorFrom = (set iteratorFrom key).toList + check(clazz, list, s"set iteratorFrom $key", s"(set from $key).iterator", iteratorFrom, (set from key).iterator.toList) + check(clazz, list, s"set.iteratorFrom $key", s"distinctSorted dropWhile (_ < $key)", iteratorFrom, distinctSorted dropWhile (_ < key)) + check(clazz, list, s"set iteratorFrom $key", s"set keysIterator from $key", iteratorFrom, (set keysIteratorFrom key).toList) + } + } + + def testMap[A <% Ordered[A], B](map: SortedMap[A, B], list: List[(A, B)]) { + val distinctSorted = distinctByKey(list).sortBy(_._1) + assertEquals("Map size wasn't the same as list sze", map.size, distinctSorted.size) + + for(keyValue <- distinctSorted) { + val key = keyValue._1 + val clazz = map.getClass + val iteratorFrom = (map iteratorFrom key).toList + check(clazz, list, s"map iteratorFrom $key", s"(map from $key).iterator", iteratorFrom, (map from key).iterator.toList) + check(clazz, list, s"map iteratorFrom $key", s"distinctSorted dropWhile (_._1 < $key)", iteratorFrom, distinctSorted dropWhile (_._1 < key)) + check(clazz, list, s"map iteratorFrom $key map (_._1)", s"map keysIteratorFrom $key", iteratorFrom map (_._1), (map keysIteratorFrom key).toList) + check(clazz, list, s"map iteratorFrom $key map (_._2)", s"map valuesIteratorFrom $key", iteratorFrom map (_._2), (map valuesIteratorFrom key).toList) + } + } + + def check[A](clazz: Class[_], list: List[_], m1: String, m2: String, l1: List[A], l2: List[A]) { + assertEquals(s"$clazz: `$m1` didn't match `$m2` on list $list", l1, l2) + } + + def assertEquals[A](msg: String, x: A, y: A) { + assert(x == y, s"$msg\n1: $x\n2: $y") + } + + def distinctByKey[A,B](list: List[(A, B)]) : List[(A,B)] = list.groupBy(_._1).map(_._2.last).toList + + object Weekday extends Enumeration { + type Weekday = Value + val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value + } + + 0 until maxLength foreach {length => + val keyValues = (0 until length map {_ => (R nextInt maxKey, R nextInt maxValue)}).toList + val keys = keyValues map (_._2) + testSet(immutable.BitSet(keys:_*), keys) + testSet(immutable.TreeSet(keys:_*), keys) + testSet(mutable.TreeSet(keys:_*), keys) + val days = keys map {n => Weekday(n % Weekday.values.size)} + testSet(Weekday.ValueSet(days:_*), days) + + val treeMap = immutable.TreeMap(keyValues:_*) + testMap(treeMap, keyValues) + testMap(treeMap.filterKeys(_ % 2 == 0), keyValues filter (_._1 % 2 == 0)) + testMap(treeMap mapValues (_ + 1), keyValues map {case (k,v) => (k, v + 1)}) + } +} diff --git a/test/files/run/iterator-iterate-lazy.scala b/test/files/run/iterator-iterate-lazy.scala index 73886f192b..92b170062e 100644 --- a/test/files/run/iterator-iterate-lazy.scala +++ b/test/files/run/iterator-iterate-lazy.scala @@ -1,5 +1,5 @@ object Test { def main(args: Array[String]): Unit = { - Iterator.iterate(1 to 5 toList)(_.tail).takeWhile(_.nonEmpty).map(_.head).toList + Iterator.iterate((1 to 5).toList)(_.tail).takeWhile(_.nonEmpty).map(_.head).toList } } diff --git a/test/files/run/iterator3444.scala b/test/files/run/iterator3444.scala index 2d0643bd56..1d0713addc 100644 --- a/test/files/run/iterator3444.scala +++ b/test/files/run/iterator3444.scala @@ -2,22 +2,22 @@ // ticked #3444 object Test { - + def main(args: Array[String]) { val it = (1 to 12).toSeq.iterator - + assert(it.next == 1) assert(it.take(2).toList == List(2, 3)) - + val jt = (4 to 12).toSeq.iterator assert(jt.next == 4) assert(jt.drop(5).toList == List(10, 11, 12)) - + val kt = (1 until 10).toSeq.iterator assert(kt.drop(50).toList == Nil) - + val mt = (1 until 5).toSeq.iterator assert(mt.take(50).toList == List(1, 2, 3, 4)) } - + } diff --git a/test/files/run/iterators.scala b/test/files/run/iterators.scala index b85291cd72..57e05d3472 100644 --- a/test/files/run/iterators.scala +++ b/test/files/run/iterators.scala @@ -4,6 +4,8 @@ //############################################################################ +import scala.language.postfixOps + object Test { def check_from: Int = { @@ -82,16 +84,16 @@ object Test { var xs4 = a.slice(0, 4).iterator.toList; xs0.length + xs1.length + xs2.length + xs3.length + xs4.length } - + def check_toSeq: String = List(1, 2, 3, 4, 5).iterator.toSeq.mkString("x") - + def check_indexOf: String = { val i = List(1, 2, 3, 4, 5).indexOf(4) val j = List(1, 2, 3, 4, 5).indexOf(16) "" + i + "x" + j } - + def check_findIndexOf: String = { val i = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 4 } val j = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 16 } diff --git a/test/files/run/java-erasure.scala b/test/files/run/java-erasure.scala index 0441ad705b..c9f9b0ad51 100644 --- a/test/files/run/java-erasure.scala +++ b/test/files/run/java-erasure.scala @@ -3,7 +3,7 @@ object Test { list add "a" list add "c" list add "b" - + def main(args: Array[String]): Unit = { println(java.util.Collections.max(list)) } diff --git a/test/files/run/json.check b/test/files/run/json.check deleted file mode 100644 index d4d2b41658..0000000000 --- a/test/files/run/json.check +++ /dev/null @@ -1,21 +0,0 @@ -Passed compare: {"name" : "value"} -Passed compare: {"name" : "va1ue"} -Passed compare: {"name" : {"name1" : "va1ue1", "name2" : "va1ue2"}} -Passed parse : {"name" : "\""} -Passed compare: Map(function -> add_symbol) -Passed compare: [{"a" : "team"}, {"b" : 52.0}] -Passed compare: Map() -Passed compare: List() -Passed compare: [4.0, 1.0, 3.0, 2.0, 6.0, 5.0, 8.0, 7.0] -Passed parse : {"age" : 0.0} -Passed compare: {"name" : "va1ue"} -Passed compare: {"name" : {"name1" : "va1ue1", "name2" : "va1ue2"}} -Passed compare: [4.0, 1.0, 3.0, 2.0, 6.0, 5.0, 8.0, 7.0] -Passed compare: {"\u006e\u0061\u006d\u0065" : "\u0076\u0061\u006c"} - -Passed compare: Map(firstName -> John, lastName -> Smith, address -> Map(streetAddress -> 21 2nd Street, city -> New York, state -> NY, postalCode -> 10021.0), phoneNumbers -> List(212 732-1234, 646 123-4567)) - -Passed parse : {"addresses" : [{"format" : "us", "type" : "work", "value" : "1234 Main StnSpringfield, TX 78080-1216"}, {"format" : "us", "type" : "home", "value" : "5678 Main StnSpringfield, TX 78080-1316"}], "emailaddrs" : [{"type" : "work", "value" : "kelly@seankelly.biz"}, {"pref" : 1.0, "type" : "home", "value" : "kelly@seankelly.tv"}], "fullname" : "Sean Kelly", "org" : "SK Consulting", "telephones" : [{"pref" : 1.0, "type" : "work", "value" : "+1 214 555 1212"}, {"type" : "fax", "value" : "+1 214 555 1213"}, {"type" : "mobile", "value" : "+1 214 555 1214"}], "urls" : [{"type" : "work", "value" : "http:\/\/seankelly.biz\/"}, {"type" : "home", "value" : "http:\/\/seankelly.tv\/"}]} - -Passed parse : {"web-app" : {"servlet" : [{"init-param" : {"cachePackageTagsRefresh" : 60.0, "cachePackageTagsStore" : 200.0, "cachePackageTagsTrack" : 200.0, "cachePagesDirtyRead" : 10.0, "cachePagesRefresh" : 10.0, "cachePagesStore" : 100.0, "cachePagesTrack" : 200.0, "cacheTemplatesRefresh" : 15.0, "cacheTemplatesStore" : 50.0, "cacheTemplatesTrack" : 100.0, "configGlossary:adminEmail" : "ksm@pobox.com", "configGlossary:installationAt" : "Philadelphia, PA", "configGlossary:poweredBy" : "Cofax", "configGlossary:poweredByIcon" : "\/images\/cofax.gif", "configGlossary:staticPath" : "\/content\/static", "dataStoreClass" : "org.cofax.SqlDataStore", "dataStoreConnUsageLimit" : 100.0, "dataStoreDriver" : "com.microsoft.jdbc.sqlserver.SQLServerDriver", "dataStoreInitConns" : 10.0, "dataStoreLogFile" : "\/usr\/local\/tomcat\/logs\/datastore.log", "dataStoreLogLevel" : "debug", "dataStoreMaxConns" : 100.0, "dataStoreName" : "cofax", "dataStorePassword" : "dataStoreTestQuery", "dataStoreTestQuery" : "SET NOCOUNT ON;select test='test';", "dataStoreUrl" : "jdbc:microsoft:sqlserver:\/\/LOCALHOST:1433;DatabaseName=goon", "dataStoreUser" : "sa", "defaultFileTemplate" : "articleTemplate.htm", "defaultListTemplate" : "listTemplate.htm", "jspFileTemplate" : "articleTemplate.jsp", "jspListTemplate" : "listTemplate.jsp", "maxUrlLength" : 500.0, "redirectionClass" : "org.cofax.SqlRedirection", "searchEngineFileTemplate" : "forSearchEngines.htm", "searchEngineListTemplate" : "forSearchEnginesList.htm", "searchEngineRobotsDb" : "WEB-INF\/robots.db", "templateLoaderClass" : "org.cofax.FilesTemplateLoader", "templateOverridePath" : "", "templatePath" : "templates", "templateProcessorClass" : "org.cofax.WysiwygTemplate", "useDataStore" : true, "useJSP" : false}, "servlet-class" : "org.cofax.cds.CDSServlet", "servlet-name" : "cofaxCDS"}, {"init-param" : {"mailHost" : "mail1", "mailHostOverride" : "mail2"}, "servlet-class" : "org.cofax.cds.EmailServlet", "servlet-name" : "cofaxEmail"}, {"servlet-class" : "org.cofax.cds.AdminServlet", "servlet-name" : "cofaxAdmin"}, {"servlet-class" : "org.cofax.cds.FileServlet", "servlet-name" : "fileServlet"}, {"init-param" : {"adminGroupID" : 4.0, "betaServer" : true, "dataLog" : 1.0, "dataLogLocation" : "\/usr\/local\/tomcat\/logs\/dataLog.log", "dataLogMaxSize" : "", "fileTransferFolder" : "\/usr\/local\/tomcat\/webapps\/content\/fileTransferFolder", "log" : 1.0, "logLocation" : "\/usr\/local\/tomcat\/logs\/CofaxTools.log", "logMaxSize" : "", "lookInContext" : 1.0, "removePageCache" : "\/content\/admin\/remove?cache=pages&id=", "removeTemplateCache" : "\/content\/admin\/remove?cache=templates&id=", "templatePath" : "toolstemplates\/"}, "servlet-class" : "org.cofax.cms.CofaxToolsServlet", "servlet-name" : "cofaxTools"}], "servlet-mapping" : {"cofaxAdmin" : "\/admin\/*", "cofaxCDS" : "\/", "cofaxEmail" : "\/cofaxutil\/aemail\/*", "cofaxTools" : "\/tools\/*", "fileServlet" : "\/static\/*"}, "taglib" : {"taglib-location" : "\/WEB-INF\/tlds\/cofax.tld", "taglib-uri" : "cofax.tld"}}} - diff --git a/test/files/run/json.scala b/test/files/run/json.scala deleted file mode 100644 index a81f12564c..0000000000 --- a/test/files/run/json.scala +++ /dev/null @@ -1,283 +0,0 @@ -import scala.util.parsing.json._ -import scala.collection.immutable.TreeMap - -object Test extends App { - /* This method converts parsed JSON back into real JSON notation with objects in - * sorted-key order. Not required by the spec, but it allows us to do a stable - * toString comparison. */ - def jsonToString(in : Any) : String = in match { - case l : List[_] => "[" + l.map(jsonToString).mkString(", ") + "]" - case m : Map[String,_] => "{" + m.iterator.toList - .sortWith({ (x,y) => x._1 < y._1 }) - .map({ case (k,v) => "\"" + k + "\": " + jsonToString(v) }) - .mkString(", ") + "}" - case s : String => "\"" + s + "\"" - case x => x.toString - } - - /* - * This method takes input JSON values and sorts keys on objects. - */ - def sortJSON(in : Any) : Any = in match { - case l : List[_] => l.map(sortJSON) - case m : Map[String,_] => TreeMap(m.mapValues(sortJSON).iterator.toSeq : _*) - // For the object versions, sort their contents, ugly casts and all... - case JSONObject(data) => JSONObject(sortJSON(data).asInstanceOf[Map[String,Any]]) - case JSONArray(data) => JSONArray(sortJSON(data).asInstanceOf[List[Any]]) - case x => x - } - - // For this one, just parsing should be considered a pass - def printJSON(given : String) { - JSON parseRaw given match { - case None => println("Parse failed for \"%s\"".format(given)) - case Some(parsed) => println("Passed parse : " + sortJSON(parsed)) - } - } - - // For this usage, do a raw parse (to JSONObject/JSONArray) - def printJSON(given : String, expected : JSONType) { - printJSON(given, JSON.parseRaw, expected) - } - - // For this usage, do a raw parse (to JSONType and subclasses) - def printJSONFull(given : String, expected : Any) { - printJSON(given, JSON.parseFull, expected) - } - - // For this usage, do configurable parsing so that you can do raw if desired - def printJSON[T](given : String, parser : String => T, expected : Any) { - parser(given) match { - case None => println("Parse failed for \"%s\"".format(given)) - case Some(parsed) => if (parsed == expected) { - println("Passed compare: " + parsed) - } else { - val eStr = sortJSON(expected).toString - val pStr = sortJSON(parsed).toString - stringDiff(eStr,pStr) - } - } - } - - def stringDiff (expected : String, actual : String) { - if (expected != actual) { - // Figure out where the Strings differ and generate a marker - val mismatchPosition = expected.toList.zip(actual.toList).indexWhere({case (x,y) => x != y}) match { - case -1 => Math.min(expected.length, actual.length) - case x => x - } - val reason = (" " * mismatchPosition) + "^" - println("Expected: %s\nGot : %s \n %s".format(expected, actual, reason)) - - } else { - println("Passed compare: " + actual) - } - } - - - // The library should differentiate between lower case "l" and number "1" (ticket #136) - printJSON("{\"name\" : \"value\"}", JSONObject(Map("name" -> "value"))) - printJSON("{\"name\" : \"va1ue\"}", JSONObject(Map("name" -> "va1ue"))) - printJSON("{\"name\" : { \"name1\" : \"va1ue1\", \"name2\" : \"va1ue2\" } }", - JSONObject(Map("name" -> JSONObject(Map("name1" -> "va1ue1", "name2" -> "va1ue2"))))) - - // Unicode escapes should be handled properly - printJSON("{\"name\" : \"\\u0022\"}") - - // The library should return a map for JSON objects (ticket #873) - printJSONFull("{\"function\" : \"add_symbol\"}", Map("function" -> "add_symbol")) - - // The library should recurse into arrays to find objects (ticket #2207) - printJSON("[{\"a\" : \"team\"},{\"b\" : 52}]", JSONArray(List(JSONObject(Map("a" -> "team")), JSONObject(Map("b" -> 52.0))))) - - // The library should differentiate between empty maps and lists (ticket #3284) - printJSONFull("{}", Map()) - printJSONFull("[]", List()) - - // Lists should be returned in the same order as specified - printJSON("[4,1,3,2,6,5,8,7]", JSONArray(List[Double](4,1,3,2,6,5,8,7))) - - // Additional tests - printJSON("{\"age\": 0}") - - // The library should do a proper toString representation using default and custom renderers (ticket #3605) - stringDiff("{\"name\" : \"va1ue\"}", JSONObject(Map("name" -> "va1ue")).toString) - stringDiff("{\"name\" : {\"name1\" : \"va1ue1\", \"name2\" : \"va1ue2\"}}", - JSONObject(Map("name" -> JSONObject(TreeMap("name1" -> "va1ue1", "name2" -> "va1ue2")))).toString) - - stringDiff("[4.0, 1.0, 3.0, 2.0, 6.0, 5.0, 8.0, 7.0]", JSONArray(List[Double](4,1,3,2,6,5,8,7)).toString) - - // A test method that escapes all characters in strings - def escapeEverything (in : Any) : String = in match { - case s : String => "\"" + s.map(c => "\\u%04x".format(c : Int)).mkString + "\"" - case jo : JSONObject => jo.toString(escapeEverything) - case ja : JSONArray => ja.toString(escapeEverything) - case other => other.toString - } - - stringDiff("{\"\\u006e\\u0061\\u006d\\u0065\" : \"\\u0076\\u0061\\u006c\"}", JSONObject(Map("name" -> "val")).toString(escapeEverything)) - - println - - // from http://en.wikipedia.org/wiki/JSON - val sample1 = """ -{ - "firstName": "John", - "lastName": "Smith", - "address": { - "streetAddress": "21 2nd Street", - "city": "New York", - "state": "NY", - "postalCode": 10021 - }, - "phoneNumbers": [ - "212 732-1234", - "646 123-4567" - ] -}""" - - // Should be equivalent to: - val sample1Obj = Map( - "firstName" -> "John", - "lastName" -> "Smith", - "address" -> Map( - "streetAddress" -> "21 2nd Street", - "city" -> "New York", - "state" -> "NY", - "postalCode" -> 10021 - ), - "phoneNumbers"-> List( - "212 732-1234", - "646 123-4567" - ) - ) - - - printJSONFull(sample1, sample1Obj) - println - - // from http://www.developer.com/lang/jscript/article.php/3596836 - val sample2 = """ -{ - "fullname": "Sean Kelly", - "org": "SK Consulting", - "emailaddrs": [ - {"type": "work", "value": "kelly@seankelly.biz"}, - {"type": "home", "pref": 1, "value": "kelly@seankelly.tv"} - ], - "telephones": [ - {"type": "work", "pref": 1, "value": "+1 214 555 1212"}, - {"type": "fax", "value": "+1 214 555 1213"}, - {"type": "mobile", "value": "+1 214 555 1214"} - ], - "addresses": [ - {"type": "work", "format": "us", - "value": "1234 Main StnSpringfield, TX 78080-1216"}, - {"type": "home", "format": "us", - "value": "5678 Main StnSpringfield, TX 78080-1316"} - ], - "urls": [ - {"type": "work", "value": "http://seankelly.biz/"}, - {"type": "home", "value": "http://seankelly.tv/"} - ] -}""" - - printJSON(sample2) - println - - // from http://json.org/example.html - val sample3 = """ -{"web-app": { - "servlet": [ - { - "servlet-name": "cofaxCDS", - "servlet-class": "org.cofax.cds.CDSServlet", - "init-param": { - "configGlossary:installationAt": "Philadelphia, PA", - "configGlossary:adminEmail": "ksm@pobox.com", - "configGlossary:poweredBy": "Cofax", - "configGlossary:poweredByIcon": "/images/cofax.gif", - "configGlossary:staticPath": "/content/static", - "templateProcessorClass": "org.cofax.WysiwygTemplate", - "templateLoaderClass": "org.cofax.FilesTemplateLoader", - "templatePath": "templates", - "templateOverridePath": "", - "defaultListTemplate": "listTemplate.htm", - "defaultFileTemplate": "articleTemplate.htm", - "useJSP": false, - "jspListTemplate": "listTemplate.jsp", - "jspFileTemplate": "articleTemplate.jsp", - "cachePackageTagsTrack": 200, - "cachePackageTagsStore": 200, - "cachePackageTagsRefresh": 60, - "cacheTemplatesTrack": 100, - "cacheTemplatesStore": 50, - "cacheTemplatesRefresh": 15, - "cachePagesTrack": 200, - "cachePagesStore": 100, - "cachePagesRefresh": 10, - "cachePagesDirtyRead": 10, - "searchEngineListTemplate": "forSearchEnginesList.htm", - "searchEngineFileTemplate": "forSearchEngines.htm", - "searchEngineRobotsDb": "WEB-INF/robots.db", - "useDataStore": true, - "dataStoreClass": "org.cofax.SqlDataStore", - "redirectionClass": "org.cofax.SqlRedirection", - "dataStoreName": "cofax", - "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver", - "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon", - "dataStoreUser": "sa", - "dataStorePassword": "dataStoreTestQuery", - "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';", - "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log", - "dataStoreInitConns": 10, - "dataStoreMaxConns": 100, - "dataStoreConnUsageLimit": 100, - "dataStoreLogLevel": "debug", - "maxUrlLength": 500}}, - { - "servlet-name": "cofaxEmail", - "servlet-class": "org.cofax.cds.EmailServlet", - "init-param": { - "mailHost": "mail1", - "mailHostOverride": "mail2"}}, - { - "servlet-name": "cofaxAdmin", - "servlet-class": "org.cofax.cds.AdminServlet"}, - - { - "servlet-name": "fileServlet", - "servlet-class": "org.cofax.cds.FileServlet"}, - { - "servlet-name": "cofaxTools", - "servlet-class": "org.cofax.cms.CofaxToolsServlet", - "init-param": { - "templatePath": "toolstemplates/", - "log": 1, - "logLocation": "/usr/local/tomcat/logs/CofaxTools.log", - "logMaxSize": "", - "dataLog": 1, - "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log", - "dataLogMaxSize": "", - "removePageCache": "/content/admin/remove?cache=pages&id=", - "removeTemplateCache": "/content/admin/remove?cache=templates&id=", - "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder", - "lookInContext": 1, - "adminGroupID": 4, - "betaServer": true}}], - "servlet-mapping": { - "cofaxCDS": "/", - "cofaxEmail": "/cofaxutil/aemail/*", - "cofaxAdmin": "/admin/*", - "fileServlet": "/static/*", - "cofaxTools": "/tools/*"}, - - "taglib": { - "taglib-uri": "cofax.tld", - "taglib-location": "/WEB-INF/tlds/cofax.tld"} - } -}""" - - printJSON(sample3) - println -} diff --git a/test/files/run/jtptest.check b/test/files/run/jtptest.check deleted file mode 100644 index 95dbd28437..0000000000 --- a/test/files/run/jtptest.check +++ /dev/null @@ -1,7 +0,0 @@ -[1.4] parsed: 1.1 -[1.3] parsed: 1. -[1.3] parsed: .1 -[1.1] failure: string matching regex `(\d+(\.\d*)?|\d*\.\d+)' expected but `!' found - -!1 -^ diff --git a/test/files/run/jtptest.scala b/test/files/run/jtptest.scala deleted file mode 100644 index 4d0eef9153..0000000000 --- a/test/files/run/jtptest.scala +++ /dev/null @@ -1,17 +0,0 @@ - -import scala.util.parsing.combinator.JavaTokenParsers -import scala.util.parsing.input.CharArrayReader - -object TestJavaTokenParsers extends JavaTokenParsers { -} - -object Test { - import TestJavaTokenParsers._ - - def main(args : Array[String]) { - println(decimalNumber(new CharArrayReader("1.1".toCharArray))) - println(decimalNumber(new CharArrayReader("1.".toCharArray))) - println(decimalNumber(new CharArrayReader(".1".toCharArray))) - println(decimalNumber(new CharArrayReader("!1".toCharArray))) - } -} diff --git a/test/files/run/kind-repl-command.check b/test/files/run/kind-repl-command.check new file mode 100644 index 0000000000..1c292572e6 --- /dev/null +++ b/test/files/run/kind-repl-command.check @@ -0,0 +1,28 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :kind scala.Option +scala.Option's kind is F[+A] + +scala> :k (Int, Int) => Int +scala.Function2's kind is F[-A1,-A2,+A3] + +scala> :k -v Either +scala.util.Either's kind is F[+A1,+A2] +* -(+)-> * -(+)-> * +This is a type constructor: a 1st-order-kinded type. + +scala> :k -v scala.collection.generic.ImmutableSortedMapFactory +scala.collection.generic.ImmutableSortedMapFactory's kind is X[CC[A,B] <: scala.collection.immutable.SortedMap[A,B] with scala.collection.SortedMapLike[A,B,CC[A,B]]] +(* -> * -> *(scala.collection.immutable.SortedMap[A,B] with scala.collection.SortedMapLike[A,B,CC[A,B]])) -> * +This is a type constructor that takes type constructor(s): a higher-kinded type. + +scala> :k new { def empty = false } +AnyRef{def empty: Boolean}'s kind is A + +scala> :k Nonexisting +<console>:8: error: not found: value Nonexisting + Nonexisting + ^ + +scala> diff --git a/test/files/run/kind-repl-command.scala b/test/files/run/kind-repl-command.scala new file mode 100644 index 0000000000..df1fafb667 --- /dev/null +++ b/test/files/run/kind-repl-command.scala @@ -0,0 +1,12 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |:kind scala.Option + |:k (Int, Int) => Int + |:k -v Either + |:k -v scala.collection.generic.ImmutableSortedMapFactory + |:k new { def empty = false } + |:k Nonexisting + """.stripMargin +} diff --git a/test/files/run/kmpSliceSearch.scala b/test/files/run/kmpSliceSearch.scala index 0f7e052d5f..e72f78bfed 100644 --- a/test/files/run/kmpSliceSearch.scala +++ b/test/files/run/kmpSliceSearch.scala @@ -12,7 +12,7 @@ object Test { } def main(args: Array[String]) { val rng = new scala.util.Random(java.lang.Integer.parseInt("kmp",36)) - + // Make sure we agree with naive implementation for (h <- Array(2,5,1000)) { for (i <- 0 to 100) { @@ -38,7 +38,7 @@ object Test { } } } - + // Check performance^Wcorrectness of common small test cases val haystacks = List[Seq[Int]]( Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15), @@ -52,8 +52,8 @@ object Test { List(1,1,1,1,1,2), 5 to 9 ) - (haystacks zip needles) foreach { - case (hay, nee) => + (haystacks zip needles) foreach { + case (hay, nee) => println(hay.indexOfSlice(nee,2) + " " + hay.lastIndexOfSlice(nee,13)) } } diff --git a/test/files/run/lazy-exprs.check b/test/files/run/lazy-exprs.check index e77d204251..2efb8ceb4a 100644 --- a/test/files/run/lazy-exprs.check +++ b/test/files/run/lazy-exprs.check @@ -1,3 +1,11 @@ +lazy-exprs.scala:38: warning: match may not be exhaustive. +It would fail on the following input: Some((x: String forSome x not in Z1)) + t match { + ^ +lazy-exprs.scala:62: warning: match may not be exhaustive. +It would fail on the following input: Some((x: String forSome x not in LazyField)) + t match { + ^ forced <z1> lazy val in scrutinee: ok forced <z1> diff --git a/test/files/run/lazy-exprs.scala b/test/files/run/lazy-exprs.scala index fc724bd10b..204c4b564b 100644 --- a/test/files/run/lazy-exprs.scala +++ b/test/files/run/lazy-exprs.scala @@ -2,7 +2,7 @@ object TestExpressions { def patmatchScrut { lazy val z1: Option[String] = { println("forced <z1>"); Some("lazy z1") } - + val res = z1 match { case Some(msg) => msg case None => "failed" @@ -17,10 +17,10 @@ object TestExpressions { def patmatchCase { val t: Option[String] = Some("test") val res = t match { - case Some(msg) => + case Some(msg) => lazy val z1 = { println("forced <z1>"); "lazy z1" } z1 - + case None => "failed" } print("lazy val in case: ") @@ -36,9 +36,9 @@ object TestExpressions { print("lazy val in case: ") val t: Option[String] = Some("lazy Z1") t match { - case Some(Z1) => + case Some(Z1) => println("ok") - + case None => println("failed") } @@ -60,13 +60,13 @@ object TestExpressions { print("lazy val in pattern: ") val t: Option[String] = Some("LazyField") t match { - case Some(LazyField) => + case Some(LazyField) => println("ok") - + case None => println("failed") } - } + } lazy val (x, y) = ({print("x"); "x"}, {print("y"); "y"}) def testPatLazyVal { diff --git a/test/files/run/lazy-locals.check b/test/files/run/lazy-locals.check index d1cc754f2c..9e88a55d18 100644 --- a/test/files/run/lazy-locals.check +++ b/test/files/run/lazy-locals.check @@ -1,3 +1,9 @@ +lazy-locals.scala:153: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + { + ^ +lazy-locals.scala:159: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + { + ^ forced lazy val q q = 10 forced lazy val t diff --git a/test/files/run/lazy-locals.scala b/test/files/run/lazy-locals.scala index aca15d0357..b28b28e35d 100644 --- a/test/files/run/lazy-locals.scala +++ b/test/files/run/lazy-locals.scala @@ -59,7 +59,7 @@ object Test extends App { val sum3 = t00 + t01 + t02 + t03 + t04 + t05 + t06 + t07 + t08 + t09 + t10 + t11 + t12 + t13 + t14 + t15 + t16 + t17 + t18 + t19 + t20 + t21 + t22 + t23 + t24 + t25 + t26 + - t27 + t28 + t29 + t30 + t31 + t27 + t28 + t29 + t30 + t31 @@ -120,7 +120,7 @@ object Test extends App { t } - /** test recursive method with lazy vals and a all vals forced */ + /** test recursive method with lazy vals and all vals forced */ def testLazyRecMany(n: Int): Int = { lazy val t = { println("forced lazy val t at n = " + n); 42 } if (n > 0) { @@ -175,18 +175,18 @@ object Test extends App { // see #1589 object NestedLazyVals { - lazy val x = { + lazy val x = { lazy val y = { println("forcing y"); 42; } println("forcing x") - y + y } - + val x1 = 5 + { lazy val y = 10 ; y } - + println(x) println(x1) } - + trait TNestedLazyVals { lazy val x = { lazy val y = 42; y } } diff --git a/test/files/run/lazy-override-run.scala b/test/files/run/lazy-override-run.scala index d197408775..6016c3c8be 100644 --- a/test/files/run/lazy-override-run.scala +++ b/test/files/run/lazy-override-run.scala @@ -20,7 +20,7 @@ object Test extends App { val b = new B print("b.x=") - println(b.x) + println(b.x) print("b.z=") - println(b.z) + println(b.z) } diff --git a/test/files/run/lazy-traits.scala b/test/files/run/lazy-traits.scala index f04c0b8b1f..38207672db 100644 --- a/test/files/run/lazy-traits.scala +++ b/test/files/run/lazy-traits.scala @@ -1,5 +1,5 @@ trait A { - lazy val z1 = { + lazy val z1 = { println("<forced z1>") "lazy z1" } @@ -7,7 +7,7 @@ trait A { /** Simple class which mixes in one lazy val. */ class Cls extends AnyRef with A { - override def toString = + override def toString = "z1 = " + z1 } @@ -18,7 +18,7 @@ class Cls2 extends AnyRef with A { "lazy z2" } - override def toString = + override def toString = "z1 = " + z1 + " z2 = " + z2 } @@ -34,7 +34,7 @@ class ClsB extends Object with B { println("<forced zc1>") "lazy zc1" } - override def toString = + override def toString = "z1 = " + z1 + " zb1 = " + zb1 + " zc1 = " + zc1 } @@ -73,39 +73,39 @@ class OverflownLazyFields extends Object with A { lazy val zc30 = { println("<forced zc30>"); "lazy zc30" } lazy val zc31 = { println("<forced zc31>"); "lazy zc31" } - override def toString = - "\nzc00 = " + zc00 + - "\nzc01 = " + zc01 + - "\nzc02 = " + zc02 + - "\nzc03 = " + zc03 + - "\nzc04 = " + zc04 + - "\nzc05 = " + zc05 + - "\nzc06 = " + zc06 + - "\nzc07 = " + zc07 + - "\nzc08 = " + zc08 + - "\nzc09 = " + zc09 + - "\nzc10 = " + zc10 + - "\nzc11 = " + zc11 + - "\nzc12 = " + zc12 + - "\nzc13 = " + zc13 + - "\nzc14 = " + zc14 + - "\nzc15 = " + zc15 + - "\nzc16 = " + zc16 + - "\nzc17 = " + zc17 + - "\nzc18 = " + zc18 + - "\nzc19 = " + zc19 + - "\nzc20 = " + zc20 + - "\nzc21 = " + zc21 + - "\nzc22 = " + zc22 + - "\nzc23 = " + zc23 + - "\nzc24 = " + zc24 + - "\nzc25 = " + zc25 + - "\nzc26 = " + zc26 + - "\nzc27 = " + zc27 + - "\nzc28 = " + zc28 + - "\nzc29 = " + zc29 + - "\nzc30 = " + zc30 + - "\nzc31 = " + zc31 + + override def toString = + "\nzc00 = " + zc00 + + "\nzc01 = " + zc01 + + "\nzc02 = " + zc02 + + "\nzc03 = " + zc03 + + "\nzc04 = " + zc04 + + "\nzc05 = " + zc05 + + "\nzc06 = " + zc06 + + "\nzc07 = " + zc07 + + "\nzc08 = " + zc08 + + "\nzc09 = " + zc09 + + "\nzc10 = " + zc10 + + "\nzc11 = " + zc11 + + "\nzc12 = " + zc12 + + "\nzc13 = " + zc13 + + "\nzc14 = " + zc14 + + "\nzc15 = " + zc15 + + "\nzc16 = " + zc16 + + "\nzc17 = " + zc17 + + "\nzc18 = " + zc18 + + "\nzc19 = " + zc19 + + "\nzc20 = " + zc20 + + "\nzc21 = " + zc21 + + "\nzc22 = " + zc22 + + "\nzc23 = " + zc23 + + "\nzc24 = " + zc24 + + "\nzc25 = " + zc25 + + "\nzc26 = " + zc26 + + "\nzc27 = " + zc27 + + "\nzc28 = " + zc28 + + "\nzc29 = " + zc29 + + "\nzc30 = " + zc30 + + "\nzc31 = " + zc31 + "\nz1 = " + z1 } diff --git a/test/files/run/lift-and-unlift.scala b/test/files/run/lift-and-unlift.scala index a4a5d9502e..9cd85666e8 100644 --- a/test/files/run/lift-and-unlift.scala +++ b/test/files/run/lift-and-unlift.scala @@ -5,21 +5,21 @@ object Test { val evens2: PartialFunction[Int, Int] = { case x if x % 2 == 0 => x } - + def main(args: Array[String]): Unit = { val f1 = evens1 _ val f2 = evens2.lift - + assert(1 to 10 forall (x => f1(x) == f2(x))) - + val f3 = unlift(f1) val f4 = unlift(f2) - + assert(1 to 10 forall { x => if (!f3.isDefinedAt(x)) !f4.isDefinedAt(x) else f3(x) == f4(x) }) - + assert(f1 eq f3.lift) assert(f4 eq unlift(f2)) assert(f4 eq evens2) diff --git a/test/files/run/list_map.scala b/test/files/run/list_map.scala new file mode 100755 index 0000000000..fba3aae228 --- /dev/null +++ b/test/files/run/list_map.scala @@ -0,0 +1,26 @@ +import collection.immutable.ListMap + +object Test { + def testImmutableMinus() { + val empty = ListMap.empty[Int, Int] + + val m0 = ListMap(1 -> 1, 2 -> 2) + val m1 = m0 - 3 + assert (m1 eq m0) + val m2 = m0 - 1 + assert (m2.size == 1) + val m3 = m2 - 2 + assert (m3 eq empty) + + val m4 = ListMap(1 -> 1, 2 -> 2, 3 -> 3) + val m5 = m4 - 1 + assert (m5 == ListMap(2 -> 2, 3 -> 3)) + assert (m5.toList == (2, 2)::(3, 3)::Nil) + + assert ((empty - 1) eq empty) + } + + def main(args: Array[String]) { + testImmutableMinus() + } +} diff --git a/test/files/run/lists-run.scala b/test/files/run/lists-run.scala index ccfe5bc260..05767b9005 100644 --- a/test/files/run/lists-run.scala +++ b/test/files/run/lists-run.scala @@ -2,9 +2,11 @@ * * @author Stephane Micheloud */ +import scala.language.postfixOps + object Test { def main(args: Array[String]) { - Test_multiset.run() // multiset operations: union, intersect, diff + Test_multiset.run() // multiset operations: union, intersect, diff Test1.run() //count, exists, filter, .. Test2.run() //#468 Test3.run() //#1691 @@ -54,7 +56,7 @@ object Test_multiset { assert(List(3, 2) == (vs diff xs), "vs_diff_xs") assert(isSubListOf(xs filterNot (vs contains), xs diff vs), "xs_subset_vs") - // tests adapted from Thomas Jung + // tests adapted from Thomas Jung assert({ def sort(zs: List[Int]) = zs sortWith ( _ > _ ) sort(xs intersect ys) == sort(ys intersect xs) @@ -62,7 +64,7 @@ object Test_multiset { assert({ def cardinality[A](zs: List[A], e: A): Int = zs count (e == _) val intersection = xs intersect ys - xs forall (e => cardinality(intersection, e) == (cardinality(xs, e) + xs forall (e => cardinality(intersection, e) == (cardinality(xs, e) min cardinality(ys, e))) }, "obey min cardinality") assert({ @@ -133,7 +135,7 @@ object Test2 { def run() { val xs1 = List(1, 2, 3) val xs2 = List(0) - + val ys1 = xs1 ::: List(4) assert(List(1, 2, 3, 4) == ys1, "check_:::") @@ -153,7 +155,7 @@ object Test3 { List.range(1, 10, 0) } catch { case e: IllegalArgumentException => () - case _ => throw new Error("List.range(1, 10, 0)") + case _: Throwable => throw new Error("List.range(1, 10, 0)") } assert(List.range(10, 0, -2) == List(10, 8, 6, 4, 2)) } diff --git a/test/files/run/literals.check b/test/files/run/literals.check index f53c879dea..5f948762b7 100644 --- a/test/files/run/literals.check +++ b/test/files/run/literals.check @@ -1,3 +1,4 @@ +warning: there were 18 deprecation warning(s); re-run with -deprecation for details test '\u0024' == '$' was successful test '\u005f' == '_' was successful test 65.asInstanceOf[Char] == 'A' was successful @@ -43,7 +44,6 @@ test 0x8000000000000000L == -9223372036854775808L was successful test 0xffffffffffffffffL == -1L was successful test 1e1f == 10.0f was successful -test 2.f == 2.0f was successful test .3f == 0.3f was successful test 0f == 0.0f was successful test 3.14f == 3.14f was successful @@ -53,8 +53,6 @@ test 1.asInstanceOf[Float] == 1.0 was successful test 1l.asInstanceOf[Float] == 1.0 was successful test 1e1 == 10.0 was successful -test 2. == 2.0 was successful -test 2.d == 2.0 was successful test .3 == 0.3 was successful test 0.0 == 0.0 was successful test 0d == 0.0 was successful diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala index 32bc29fda8..7676125339 100644 --- a/test/files/run/literals.scala +++ b/test/files/run/literals.scala @@ -105,7 +105,7 @@ object Test { // float check_success("1e1f == 10.0f", 1e1f, 10.0f) - check_success("2.f == 2.0f", 2.f, 2.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("3.14f == 3.14f", 3.14f, 3.14f) @@ -118,8 +118,8 @@ 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("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) diff --git a/test/files/neg/t696a.flags b/test/files/run/longmap.check index e69de29bb2..e69de29bb2 100644 --- a/test/files/neg/t696a.flags +++ b/test/files/run/longmap.check diff --git a/test/files/run/longmap.scala b/test/files/run/longmap.scala new file mode 100644 index 0000000000..1f18eebd31 --- /dev/null +++ b/test/files/run/longmap.scala @@ -0,0 +1,8 @@ +object Test extends App{ + import scala.collection.immutable.LongMap; + + val it = LongMap(8L -> 2, 11L -> 3, 1L -> 2, 7L -> 13); + + assert(it.firstKey == 1L); + assert(it.lastKey == 11L); +} diff --git a/test/files/run/lub-visibility.check b/test/files/run/lub-visibility.check index 3461d1bf6b..f76579412e 100644 --- a/test/files/run/lub-visibility.check +++ b/test/files/run/lub-visibility.check @@ -1,14 +1,11 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> // should infer List[scala.collection.immutable.Seq[Nothing]] scala> // but reverted that for SI-5534. scala> val x = List(List(), Vector()) -x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq{def dropRight(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def takeRight(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def drop(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def take(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]}]; def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.Ab... -scala> +x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing] with java.io.Serializable] = List(List(), Vector()) scala> diff --git a/test/files/run/macro-abort-fresh.check b/test/files/run/macro-abort-fresh.check index 75ad5e79f8..87491f6e48 100644 --- a/test/files/run/macro-abort-fresh.check +++ b/test/files/run/macro-abort-fresh.check @@ -1,6 +1,6 @@ $1$ qwe1 qwe2 -reflective compilation has failed: +reflective compilation has failed: blargh diff --git a/test/files/run/macro-abort-fresh/Macros_1.scala b/test/files/run/macro-abort-fresh/Macros_1.scala index af1e292588..415b76852f 100644 --- a/test/files/run/macro-abort-fresh/Macros_1.scala +++ b/test/files/run/macro-abort-fresh/Macros_1.scala @@ -5,7 +5,7 @@ object Impls { import c.universe._ println(c.fresh()) println(c.fresh("qwe")) - println(c.fresh(newTypeName("qwe"))) + println(c.fresh(TypeName("qwe"))) c.abort(NoPosition, "blargh") } } diff --git a/test/files/run/macro-abort-fresh/Test_2.scala b/test/files/run/macro-abort-fresh/Test_2.scala index 0b9986e9f6..61f0bdfadc 100644 --- a/test/files/run/macro-abort-fresh/Test_2.scala +++ b/test/files/run/macro-abort-fresh/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala index 646634c972..ce30366c61 100644 --- a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala +++ b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala @@ -3,19 +3,19 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala index aa1e52e4aa..a601af6dde 100644 --- a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala +++ b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala @@ -3,19 +3,19 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } } diff --git a/test/files/run/macro-basic-mamd-mi/Impls_1.scala b/test/files/run/macro-basic-mamd-mi/Impls_1.scala index 061aa2d4a3..6e5983bdec 100644 --- a/test/files/run/macro-basic-mamd-mi/Impls_1.scala +++ b/test/files/run/macro-basic-mamd-mi/Impls_1.scala @@ -3,17 +3,17 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala index 0ca0be5a48..56c5252f31 100644 --- a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala +++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala @@ -6,7 +6,9 @@ object Impls { def refToFoo(dummy: Int) = macro refToFoo_impl def refToFoo_impl(c: Ctx)(dummy: c.Expr[Int]) = { import c.universe._ - val body = Select(Ident(newTermName("Impls")), newTermName("foo")) + val body = Select(Ident(TermName("Impls")), TermName("foo")) + val global = c.universe.asInstanceOf[scala.tools.nsc.Global] + global.analyzer.markMacroImplRef(body.asInstanceOf[global.Tree]) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-bundle.check b/test/files/run/macro-bundle.check new file mode 100644 index 0000000000..2107454960 --- /dev/null +++ b/test/files/run/macro-bundle.check @@ -0,0 +1,3 @@ +() +Int +() diff --git a/test/files/neg/macro-invalidimpl-i.flags b/test/files/run/macro-bundle.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-i.flags +++ b/test/files/run/macro-bundle.flags diff --git a/test/files/run/macro-bundle/Impls_Macros_1.scala b/test/files/run/macro-bundle/Impls_Macros_1.scala new file mode 100644 index 0000000000..3f651c9a43 --- /dev/null +++ b/test/files/run/macro-bundle/Impls_Macros_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.macros.Context +import scala.reflect.macros.Macro + +trait Impl extends Macro { + def mono = c.literalUnit + def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString) + def weird = macro mono +} + +object Macros { + def mono = macro Impl.mono + def poly[T] = macro Impl.poly[T] +}
\ No newline at end of file diff --git a/test/files/run/macro-bundle/Test_2.scala b/test/files/run/macro-bundle/Test_2.scala new file mode 100644 index 0000000000..428f809f9d --- /dev/null +++ b/test/files/run/macro-bundle/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + println(Macros.mono) + println(Macros.poly[Int]) + println(new Impl{val c = ???}.weird) +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-block.flags b/test/files/run/macro-declared-in-block.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-block.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-class.flags b/test/files/run/macro-declared-in-class-class.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-class-class.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-object.flags b/test/files/run/macro-declared-in-class-object.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-class-object.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class.flags b/test/files/run/macro-declared-in-class.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-class.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class/Impls_1.scala b/test/files/run/macro-declared-in-class/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-class/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-default-param.flags b/test/files/run/macro-declared-in-default-param.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-default-param.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-implicit-class.flags b/test/files/run/macro-declared-in-implicit-class.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-implicit-class.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-method.flags b/test/files/run/macro-declared-in-method.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-method.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-method/Impls_1.scala b/test/files/run/macro-declared-in-method/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-method/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class.flags b/test/files/run/macro-declared-in-object-class.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-object-class.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class/Impls_1.scala b/test/files/run/macro-declared-in-object-class/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-object-class/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object.flags b/test/files/run/macro-declared-in-object-object.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-object-object.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object/Impls_1.scala b/test/files/run/macro-declared-in-object-object/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-object-object/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object.flags b/test/files/run/macro-declared-in-object.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-object.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object/Impls_1.scala b/test/files/run/macro-declared-in-object/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-object/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object.flags b/test/files/run/macro-declared-in-package-object.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-package-object.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object/Impls_1.scala b/test/files/run/macro-declared-in-package-object/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-package-object/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement.flags b/test/files/run/macro-declared-in-refinement.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-refinement.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement/Impls_1.scala b/test/files/run/macro-declared-in-refinement/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-refinement/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait.flags b/test/files/run/macro-declared-in-trait.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-declared-in-trait.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait/Impls_1.scala b/test/files/run/macro-declared-in-trait/Impls_1.scala deleted file mode 100644 index 6f06f6d3f0..0000000000 --- a/test/files/run/macro-declared-in-trait/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx) = { - import c.{prefix => prefix} - import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-a.check b/test/files/run/macro-def-infer-return-type-a.check deleted file mode 100644 index f70d7bba4a..0000000000 --- a/test/files/run/macro-def-infer-return-type-a.check +++ /dev/null @@ -1 +0,0 @@ -42
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-a.flags b/test/files/run/macro-def-infer-return-type-a.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-def-infer-return-type-a.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-a/Impls_1.scala b/test/files/run/macro-def-infer-return-type-a/Impls_1.scala deleted file mode 100644 index 52c9f9c3e9..0000000000 --- a/test/files/run/macro-def-infer-return-type-a/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = x -} diff --git a/test/files/run/macro-def-infer-return-type-a/Macros_Test_2.scala b/test/files/run/macro-def-infer-return-type-a/Macros_Test_2.scala deleted file mode 100644 index 60fe9dc1c2..0000000000 --- a/test/files/run/macro-def-infer-return-type-a/Macros_Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - def foo(x: Int) = macro Impls.foo - println(foo(42)) -}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b.flags b/test/files/run/macro-def-infer-return-type-b.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-def-infer-return-type-b.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-b/Impls_Macros_1.scala b/test/files/run/macro-def-infer-return-type-b/Impls_Macros_1.scala deleted file mode 100644 index 8a0f18c01b..0000000000 --- a/test/files/run/macro-def-infer-return-type-b/Impls_Macros_1.scala +++ /dev/null @@ -1,10 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T](c: Ctx)(x: c.Expr[T]) = - throw new Error("an implementation is missing") -} - -object Macros { - def foo[T](x: T) = macro Impls.foo[T] -}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b/Test_2.scala b/test/files/run/macro-def-infer-return-type-b/Test_2.scala deleted file mode 100644 index ea0fd4bbff..0000000000 --- a/test/files/run/macro-def-infer-return-type-b/Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test extends App { - import scala.reflect.runtime.universe._ - import scala.reflect.runtime.{currentMirror => cm} - import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) - try cm.mkToolBox().eval(tree) - catch { case ex: Throwable => println(ex.getMessage) } -} diff --git a/test/files/run/macro-def-infer-return-type-c.check b/test/files/run/macro-def-infer-return-type-c.check deleted file mode 100644 index f70d7bba4a..0000000000 --- a/test/files/run/macro-def-infer-return-type-c.check +++ /dev/null @@ -1 +0,0 @@ -42
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-c.flags b/test/files/run/macro-def-infer-return-type-c.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-def-infer-return-type-c.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-c/Impls_1.scala b/test/files/run/macro-def-infer-return-type-c/Impls_1.scala deleted file mode 100644 index 78db67eebf..0000000000 --- a/test/files/run/macro-def-infer-return-type-c/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T](c: Ctx)(x: c.Expr[T]): c.Expr[T] = x -} diff --git a/test/files/run/macro-def-infer-return-type-c/Macros_Test_2.scala b/test/files/run/macro-def-infer-return-type-c/Macros_Test_2.scala deleted file mode 100644 index 967d16f6de..0000000000 --- a/test/files/run/macro-def-infer-return-type-c/Macros_Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - def foo[T](x: T) = macro Impls.foo[T] - println(foo(42)) -}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b.check b/test/files/run/macro-def-infer-return-type.check index ae2dc7a06f..fbd164f139 100644 --- a/test/files/run/macro-def-infer-return-type-b.check +++ b/test/files/run/macro-def-infer-return-type.check @@ -1,6 +1,8 @@ -reflective compilation has failed: +42 +reflective compilation has failed: exception during macro expansion: java.lang.Error: an implementation is missing - at Impls$.foo(Impls_Macros_1.scala:5) + at Impls2$.foo(Impls_1.scala:9) +42 diff --git a/test/files/neg/macro-invalidret-nontree.flags b/test/files/run/macro-def-infer-return-type.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidret-nontree.flags +++ b/test/files/run/macro-def-infer-return-type.flags 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 new file mode 100644 index 0000000000..f8636fe725 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type/Impls_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context + +object Impls1 { + def foo(c: Context)(x: c.Expr[Int]) = x +} + +object Impls2 { + def foo[T](c: Context)(x: c.Expr[T]) = + throw new Error("an implementation is missing") +} + +object Impls3 { + def foo[T](c: Context)(x: c.Expr[T]): c.Expr[T] = x +} 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 new file mode 100644 index 0000000000..f579586b7f --- /dev/null +++ b/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala @@ -0,0 +1,24 @@ +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-a.flags b/test/files/run/macro-def-path-dependent-a.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-def-path-dependent-a.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-b.check b/test/files/run/macro-def-path-dependent-b.check deleted file mode 100644 index 7658ad2c24..0000000000 --- a/test/files/run/macro-def-path-dependent-b.check +++ /dev/null @@ -1 +0,0 @@ -it works diff --git a/test/files/run/macro-def-path-dependent-b.flags b/test/files/run/macro-def-path-dependent-b.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-def-path-dependent-b.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-c.check b/test/files/run/macro-def-path-dependent-c.check deleted file mode 100644 index 7658ad2c24..0000000000 --- a/test/files/run/macro-def-path-dependent-c.check +++ /dev/null @@ -1 +0,0 @@ -it works diff --git a/test/files/run/macro-def-path-dependent-c.flags b/test/files/run/macro-def-path-dependent-c.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-def-path-dependent-c.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d1.check b/test/files/run/macro-def-path-dependent-d1.check deleted file mode 100644 index 7658ad2c24..0000000000 --- a/test/files/run/macro-def-path-dependent-d1.check +++ /dev/null @@ -1 +0,0 @@ -it works diff --git a/test/files/run/macro-def-path-dependent-d1.flags b/test/files/run/macro-def-path-dependent-d1.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-def-path-dependent-d1.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d2.check b/test/files/run/macro-def-path-dependent-d2.check deleted file mode 100644 index 7658ad2c24..0000000000 --- a/test/files/run/macro-def-path-dependent-d2.check +++ /dev/null @@ -1 +0,0 @@ -it works diff --git a/test/files/run/macro-def-path-dependent-d2.flags b/test/files/run/macro-def-path-dependent-d2.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-def-path-dependent-d2.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d2/Test_3.scala b/test/files/run/macro-def-path-dependent-d2/Test_3.scala deleted file mode 100644 index 7dffc5107d..0000000000 --- a/test/files/run/macro-def-path-dependent-d2/Test_3.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends App { - println("it works") -}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-annotation.check b/test/files/run/macro-def-path-dependent.check index 7658ad2c24..7658ad2c24 100644 --- a/test/files/run/macro-declared-in-annotation.check +++ b/test/files/run/macro-def-path-dependent.check diff --git a/test/files/neg/macro-invalidret-nonuniversetree.flags b/test/files/run/macro-def-path-dependent.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidret-nonuniversetree.flags +++ b/test/files/run/macro-def-path-dependent.flags diff --git a/test/files/run/macro-def-path-dependent-a/Test_2.scala b/test/files/run/macro-def-path-dependent/Dummy.scala index 7dffc5107d..7dffc5107d 100644 --- a/test/files/run/macro-def-path-dependent-a/Test_2.scala +++ b/test/files/run/macro-def-path-dependent/Dummy.scala diff --git a/test/files/run/macro-def-path-dependent-a/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent/Test_1.scala index 3a91e41ff9..06c15e16c9 100644 --- a/test/files/run/macro-def-path-dependent-a/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_1.scala @@ -1,3 +1,5 @@ +package test1 + import scala.reflect.macros.{Context => Ctx} trait Exprs { diff --git a/test/files/run/macro-def-path-dependent-b/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent/Test_2.scala index cf9f9ebd0e..f1e9909981 100644 --- a/test/files/run/macro-def-path-dependent-b/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_2.scala @@ -1,3 +1,5 @@ +package test2 + import scala.reflect.macros.{Context => Ctx} trait Exprs { diff --git a/test/files/run/macro-def-path-dependent-c/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent/Test_3.scala index 6cb374d9ba..9f5efe5e47 100644 --- a/test/files/run/macro-def-path-dependent-c/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_3.scala @@ -1,3 +1,5 @@ +package test3 + import scala.reflect.macros.{Context => Ctx} trait Exprs { diff --git a/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent/Test_4.scala index 69d9708b2a..3af920d739 100644 --- a/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_4.scala @@ -1,3 +1,5 @@ +package test4 + import scala.reflect.runtime.universe._ import scala.reflect.macros.Context import scala.reflect.api.Universe diff --git a/test/files/run/macro-def-path-dependent-d2/Impls_1.scala b/test/files/run/macro-def-path-dependent/Test_5.scala index 7fa9c3579e..bc32fb92de 100644 --- a/test/files/run/macro-def-path-dependent-d2/Impls_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_5.scala @@ -1,3 +1,5 @@ +package test56 + import scala.reflect.runtime.universe._ import scala.reflect.macros.Context import scala.reflect.api.Universe diff --git a/test/files/run/macro-def-path-dependent-d2/Macros_2.scala b/test/files/run/macro-def-path-dependent/Test_6.scala index 65ce4d8bd2..6267743473 100644 --- a/test/files/run/macro-def-path-dependent-d2/Macros_2.scala +++ b/test/files/run/macro-def-path-dependent/Test_6.scala @@ -1,3 +1,5 @@ +package test56 + import scala.reflect.runtime.universe._ import scala.reflect.macros.Context import scala.reflect.api.Universe diff --git a/test/files/run/macro-duplicate.check b/test/files/run/macro-duplicate.check index e69de29bb2..58781b719a 100644 --- a/test/files/run/macro-duplicate.check +++ b/test/files/run/macro-duplicate.check @@ -0,0 +1,3 @@ +Test_2.scala:5: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + Macros.foo + ^ diff --git a/test/files/run/macro-duplicate/Impls_Macros_1.scala b/test/files/run/macro-duplicate/Impls_Macros_1.scala index de81923330..85a581585f 100644 --- a/test/files/run/macro-duplicate/Impls_Macros_1.scala +++ b/test/files/run/macro-duplicate/Impls_Macros_1.scala @@ -10,11 +10,11 @@ object Macros { case Template(_, _, ctor :: defs) => val defs1 = defs collect { case ddef @ DefDef(mods, name, tparams, vparamss, tpt, body) => - val future = Select(Select(Select(Ident(newTermName("scala")), newTermName("concurrent")), newTermName("package")), newTermName("future")) - val Future = Select(Select(Ident(newTermName("scala")), newTermName("concurrent")), newTypeName("Future")) + val future = Select(Select(Select(Ident(TermName("scala")), TermName("concurrent")), TermName("package")), TermName("future")) + val Future = Select(Select(Ident(TermName("scala")), TermName("concurrent")), TypeName("Future")) val tpt1 = if (tpt.isEmpty) tpt else AppliedTypeTree(Future, List(tpt)) val body1 = Apply(future, List(body)) - val name1 = newTermName("async" + name.toString.capitalize) + val name1 = TermName("async" + name.toString.capitalize) DefDef(mods, name1, tparams, vparamss, tpt1, body1) } Template(Nil, emptyValDef, ctor +: defs ::: defs1) @@ -26,4 +26,4 @@ object Macros { } def foo = macro impl -}
\ No newline at end of file +} diff --git a/test/files/run/macro-enclosures.check b/test/files/run/macro-enclosures.check new file mode 100644 index 0000000000..36bb67e194 --- /dev/null +++ b/test/files/run/macro-enclosures.check @@ -0,0 +1,32 @@ +enclosingPackage = package test { + object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo + } +} +enclosingClass = object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingImpl = object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingTemplate = scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingMethod = def test = Macros.foo +enclosingDef = def test = Macros.foo diff --git a/test/files/neg/macro-invalidshape-a.flags b/test/files/run/macro-enclosures.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-a.flags +++ b/test/files/run/macro-enclosures.flags diff --git a/test/files/run/macro-enclosures/Impls_Macros_1.scala b/test/files/run/macro-enclosures/Impls_Macros_1.scala new file mode 100644 index 0000000000..cd54028676 --- /dev/null +++ b/test/files/run/macro-enclosures/Impls_Macros_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = c.universe.reify { + println("enclosingPackage = " + c.literal(c.enclosingPackage.toString).splice) + println("enclosingClass = " + c.literal(c.enclosingClass.toString).splice) + println("enclosingImpl = " + c.literal(c.enclosingImpl.toString).splice) + println("enclosingTemplate = " + c.literal(c.enclosingTemplate.toString).splice) + println("enclosingMethod = " + c.literal(c.enclosingMethod.toString).splice) + println("enclosingDef = " + c.literal(c.enclosingDef.toString).splice) + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-enclosures/Test_2.scala b/test/files/run/macro-enclosures/Test_2.scala new file mode 100644 index 0000000000..779fe5211e --- /dev/null +++ b/test/files/run/macro-enclosures/Test_2.scala @@ -0,0 +1,11 @@ +object Test extends App { + test.Test.test +} + +package test { + object Test { + def test = { + Macros.foo + } + } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-argument/Macros_1.scala b/test/files/run/macro-expand-implicit-argument/Macros_1.scala index d9fd5b8cb0..b2c7b4d6ca 100644 --- a/test/files/run/macro-expand-implicit-argument/Macros_1.scala +++ b/test/files/run/macro-expand-implicit-argument/Macros_1.scala @@ -41,14 +41,14 @@ object Macros { def const(x:Int) = Literal(Constant(x)) val n = as.length - val arr = newTermName("arr") + val arr = TermName("arr") - val create = Apply(Select(ct.tree, newTermName("newArray")), List(const(n))) + val create = Apply(Select(ct.tree, TermName("newArray")), List(const(n))) val arrtpe = TypeTree(implicitly[c.WeakTypeTag[Array[A]]].tpe) val valdef = ValDef(Modifiers(), arr, arrtpe, create) val updates = (0 until n).map { - i => Apply(Select(Ident(arr), newTermName("update")), List(const(i), as(i).tree)) + i => Apply(Select(Ident(arr), TermName("update")), List(const(i), as(i).tree)) } val exprs = (Seq(valdef) ++ updates ++ Seq(Ident(arr))).toList diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala index 082e6b2efe..ac1e55c9b2 100644 --- a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(x.tree)) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala index cceb038f05..aa1fc7a358 100644 --- a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = { import c.universe._ - val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt")))) + val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt")))) c.Expr[Option[Int]](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala index 81ebd63c5f..22047eeb36 100644 --- a/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala +++ b/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala @@ -1,4 +1,5 @@ object Macros { + import scala.language.implicitConversions implicit def foo(x: String): Option[Int] = macro Impls.foo } @@ -7,4 +8,4 @@ object Test extends App { println("2": Option[Int]) val s: Int = "2" getOrElse 0 println(s) -}
\ No newline at end of file +} diff --git a/test/files/run/macro-expand-implicit-macro-is-view.flags b/test/files/run/macro-expand-implicit-macro-is-view.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-implicit-macro-is-view.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala index cceb038f05..aa1fc7a358 100644 --- a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = { import c.universe._ - val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt")))) + val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt")))) c.Expr[Option[Int]](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala index 0ff1fb80ca..0d99f32d7e 100644 --- a/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala +++ b/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala @@ -1,4 +1,7 @@ + object Macros { + import scala.language.experimental.macros + import scala.language.implicitConversions implicit def foo(x: String): Option[Int] = macro Impls.foo } @@ -6,4 +9,4 @@ object Test extends App { import Macros._ def bar[T <% Option[Int]](x: T) = println(x) println("2") -}
\ No newline at end of file +} diff --git a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala index 11e07932c3..4fddc13d68 100644 --- a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala +++ b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala @@ -3,8 +3,8 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._ - val sum = Apply(Select(x.tree, newTermName("$minus")), List(y.tree)) - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + val sum = Apply(Select(x.tree, TermName("$minus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-generic.check b/test/files/run/macro-expand-nullary-generic.check index 42976f4baf..0470d239dc 100644 --- a/test/files/run/macro-expand-nullary-generic.check +++ b/test/files/run/macro-expand-nullary-generic.check @@ -1,6 +1,6 @@ -it works WeakTypeTag[Int] -it works WeakTypeTag[Int] -it works WeakTypeTag[Int] -it works WeakTypeTag[Int] -it works WeakTypeTag[Int] +fooNullary[Int] +fooEmpty[Int] +fooEmpty[Int] +barNullary[Int] +barEmpty[Int] kkthxbai diff --git a/test/files/run/macro-expand-nullary-generic/Impls_1.scala b/test/files/run/macro-expand-nullary-generic/Impls_1.scala index 1180c83a40..5dfdd5c539 100644 --- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala @@ -2,14 +2,14 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def impl[T: c.WeakTypeTag](c: Ctx) = { + def impl[T: c.WeakTypeTag](c: Ctx)(meth: String) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.WeakTypeTag[T]])))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(s"$meth[${c.weakTypeOf[T]}]")))) c.Expr[Unit](body) } - def fooNullary[T: c.WeakTypeTag](c: Ctx) = impl[T](c) - def fooEmpty[T: c.WeakTypeTag](c: Ctx)() = impl[T](c) - def barNullary[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c) - def barEmpty[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c) + def fooNullary[T: c.WeakTypeTag](c: Ctx) = impl[T](c)("fooNullary") + def fooEmpty[T: c.WeakTypeTag](c: Ctx)() = impl[T](c)("fooEmpty") + def barNullary[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c)("barNullary") + def barEmpty[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c)("barEmpty") }
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-nongeneric.check b/test/files/run/macro-expand-nullary-nongeneric.check index 9ab5f3a2bc..cb7e766394 100644 --- a/test/files/run/macro-expand-nullary-nongeneric.check +++ b/test/files/run/macro-expand-nullary-nongeneric.check @@ -1,6 +1,6 @@ -it works -it works -it works -it works -it works +fooNullary +fooEmpty +fooEmpty +barNullary +barEmpty kkthxbai diff --git a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala index c6bd1cdbf1..d23c671c84 100644 --- a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala @@ -1,14 +1,15 @@ +import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def impl(c: Ctx) = { + def impl(c: Ctx)(meth: String) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(meth)))) c.Expr[Unit](body) } - def fooNullary(c: Ctx) = impl(c) - def fooEmpty(c: Ctx)() = impl(c) - def barNullary(c: Ctx)(x: c.Expr[Int]) = impl(c) - def barEmpty(c: Ctx)(x: c.Expr[Int])() = impl(c) + def fooNullary(c: Ctx) = impl(c)("fooNullary") + def fooEmpty(c: Ctx)() = impl(c)("fooEmpty") + def barNullary(c: Ctx)(x: c.Expr[Int]) = impl(c)("barNullary") + def barEmpty(c: Ctx)(x: c.Expr[Int])() = impl(c)("barEmpty") }
\ No newline at end of file diff --git a/test/files/run/macro-expand-overload/Impls_1.scala b/test/files/run/macro-expand-overload/Impls_1.scala index f7c240d9ca..1c672f6040 100644 --- a/test/files/run/macro-expand-overload/Impls_1.scala +++ b/test/files/run/macro-expand-overload/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { import c.{prefix => prefix} import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-override/Impls_1.scala b/test/files/run/macro-expand-override/Impls_1.scala index ec93dd4111..69ef57d18d 100644 --- a/test/files/run/macro-expand-override/Impls_1.scala +++ b/test/files/run/macro-expand-override/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { import c.{prefix => prefix} import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-recursive/Impls_1.scala b/test/files/run/macro-expand-recursive/Impls_1.scala index 61db5c4a9b..47dd398454 100644 --- a/test/files/run/macro-expand-recursive/Impls_1.scala +++ b/test/files/run/macro-expand-recursive/Impls_1.scala @@ -3,13 +3,13 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works")))) c.Expr[Unit](body) } def fooFoo(c: Ctx) = { import c.universe._ - val body = Select(Ident(newTermName("Macros")), newTermName("foo")) + val body = Select(Ident(TermName("Macros")), TermName("foo")) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-a.flags b/test/files/run/macro-expand-tparams-bounds-a.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-bounds-a.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-a/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-bounds-a/Macros_Test_2.scala deleted file mode 100644 index b498e6f65b..0000000000 --- a/test/files/run/macro-expand-tparams-bounds-a/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo[U <: String] = macro Impls.foo[U] -} - -object Test extends App { - import Macros._ - foo[String] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-b.flags b/test/files/run/macro-expand-tparams-bounds-b.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-bounds-b.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala deleted file mode 100644 index c11c89151c..0000000000 --- a/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala +++ /dev/null @@ -1,7 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -class C - -object Impls { - def foo[U <: C](c: Ctx): c.Expr[Unit] = c.literalUnit -} diff --git a/test/files/run/macro-expand-tparams-bounds-b/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-bounds-b/Macros_Test_2.scala deleted file mode 100644 index 1a261e9f73..0000000000 --- a/test/files/run/macro-expand-tparams-bounds-b/Macros_Test_2.scala +++ /dev/null @@ -1,10 +0,0 @@ -class D extends C - -object Macros { - def foo[T <: D] = macro Impls.foo[T] -} - -object Test extends App { - import Macros._ - foo[D] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-a.check b/test/files/run/macro-expand-tparams-bounds.check index e69de29bb2..e69de29bb2 100644 --- a/test/files/run/macro-expand-tparams-bounds-a.check +++ b/test/files/run/macro-expand-tparams-bounds.check diff --git a/test/files/neg/macro-invalidshape-b.flags b/test/files/run/macro-expand-tparams-bounds.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-b.flags +++ b/test/files/run/macro-expand-tparams-bounds.flags diff --git a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala new file mode 100644 index 0000000000..f9103aaf8f --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala @@ -0,0 +1,12 @@ +import scala.reflect.macros.Context + +object Impls1 { + def foo[U <: String](c: Context): c.Expr[Unit] = c.literalUnit +} + +class C +class D extends C + +object Impls2 { + def foo[U <: C](c: Context): c.Expr[Unit] = c.literalUnit +} 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 new file mode 100644 index 0000000000..37a4bcb2b9 --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala @@ -0,0 +1,12 @@ +object Macros1 { + def foo[U <: String] = macro Impls1.foo[U] +} + +object Macros2 { + def foo[T <: D] = macro Impls2.foo[T] +} + +object Test extends App { + Macros1.foo[String] + Macros2.foo[D] +} diff --git a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala index 72b420d92f..f748ab855f 100644 --- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala @@ -5,7 +5,7 @@ object Impls { def foo[U: c.WeakTypeTag](c: Ctx) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala index 33770516df..c729aada51 100644 --- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala @@ -5,7 +5,7 @@ object Impls { def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-only-in-impl.flags b/test/files/run/macro-expand-tparams-only-in-impl.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-only-in-impl.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala b/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala deleted file mode 100644 index 9b8dafaa97..0000000000 --- a/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U <: String](c: Ctx): c.Expr[Unit] = c.literalUnit -} diff --git a/test/files/run/macro-expand-tparams-only-in-impl/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-only-in-impl/Macros_Test_2.scala deleted file mode 100644 index 218c7aec7f..0000000000 --- a/test/files/run/macro-expand-tparams-only-in-impl/Macros_Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Macros { - def foo = macro Impls.foo[String] -} - -object Test extends App { - import Macros._ - foo -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-optional.flags b/test/files/run/macro-expand-tparams-optional.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-optional.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-a.check b/test/files/run/macro-expand-tparams-prefix-a.check deleted file mode 100644 index ca44a4f652..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-a.check +++ /dev/null @@ -1,4 +0,0 @@ -WeakTypeTag[Int] -WeakTypeTag[Int] -WeakTypeTag[String] -WeakTypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-a.flags b/test/files/run/macro-expand-tparams-prefix-a.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-a.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala deleted file mode 100644 index 33770516df..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { - import c.universe._ - val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-a/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-a/Macros_Test_2.scala deleted file mode 100644 index 81ccb7ff42..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-a/Macros_Test_2.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test extends App { - class C[T] { - def foo[U](x: U) = macro Impls.foo[U] - } - - new C[Int]().foo(42) - new C[Boolean]().foo(42) - new C[Int]().foo("42") - new C[String]().foo(true) -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b.check b/test/files/run/macro-expand-tparams-prefix-b.check deleted file mode 100644 index 2ff2ce435d..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-b.check +++ /dev/null @@ -1,2 +0,0 @@ -WeakTypeTag[Boolean] WeakTypeTag[Int] -WeakTypeTag[Boolean] WeakTypeTag[String] diff --git a/test/files/run/macro-expand-tparams-prefix-b.flags b/test/files/run/macro-expand-tparams-prefix-b.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-b.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala deleted file mode 100644 index 9378e67712..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala +++ /dev/null @@ -1,12 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { - import c.universe._ - val T = implicitly[c.WeakTypeTag[T]] - val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) - c.Expr[Unit](body) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-b/Macros_Test_2.scala deleted file mode 100644 index a4a0acfe8b..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-b/Macros_Test_2.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test extends App { - class C[T] { - def foo[U](x: U) = macro Impls.foo[T, U] - } - - object D extends C[Boolean] - - D.foo(42) - D.foo("42") -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1.check b/test/files/run/macro-expand-tparams-prefix-c1.check deleted file mode 100644 index 0f24f74db1..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c1.check +++ /dev/null @@ -1,3 +0,0 @@ -WeakTypeTag[Int] -WeakTypeTag[String] -WeakTypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-c1.flags b/test/files/run/macro-expand-tparams-prefix-c1.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c1.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala deleted file mode 100644 index afdd7d4f7a..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala +++ /dev/null @@ -1,13 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { - import c.universe._ - c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(())))) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-c1/Macros_Test_2.scala deleted file mode 100644 index 4fa0c8cb33..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c1/Macros_Test_2.scala +++ /dev/null @@ -1,11 +0,0 @@ -class D[T] { - class C[U] { - def foo[V] = macro Impls.foo[T, U, V] - } -} - -object Test extends App { - val outer1 = new D[Int] - val outer2 = new outer1.C[String] - outer2.foo[Boolean] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2.check b/test/files/run/macro-expand-tparams-prefix-c2.check deleted file mode 100644 index 0f24f74db1..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c2.check +++ /dev/null @@ -1,3 +0,0 @@ -WeakTypeTag[Int] -WeakTypeTag[String] -WeakTypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-c2.flags b/test/files/run/macro-expand-tparams-prefix-c2.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c2.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala deleted file mode 100644 index 3c2838208a..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala +++ /dev/null @@ -1,19 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { - import c.universe._ - c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(())))) - } -} - -class D[T] { - class C[U] { - def foo[V] = macro Impls.foo[T, U, V] - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Test_2.scala b/test/files/run/macro-expand-tparams-prefix-c2/Test_2.scala deleted file mode 100644 index e729d4a536..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-c2/Test_2.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test extends App { - val outer1 = new D[Int] - val outer2 = new outer1.C[String] - outer2.foo[Boolean] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1.check b/test/files/run/macro-expand-tparams-prefix-d1.check deleted file mode 100644 index 7832503256..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-d1.check +++ /dev/null @@ -1,3 +0,0 @@ -WeakTypeTag[T] -WeakTypeTag[U] -WeakTypeTag[Boolean] diff --git a/test/files/run/macro-expand-tparams-prefix-d1.flags b/test/files/run/macro-expand-tparams-prefix-d1.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-d1.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala deleted file mode 100644 index afdd7d4f7a..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala +++ /dev/null @@ -1,13 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.{Context => Ctx} - -object Impls { - def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { - import c.universe._ - c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(())))) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-d1/Macros_Test_2.scala deleted file mode 100644 index 8222a6d1e8..0000000000 --- a/test/files/run/macro-expand-tparams-prefix-d1/Macros_Test_2.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Test extends App { - class D[T] { - class C[U] { - def foo[V] = macro Impls.foo[T, U, V] - foo[Boolean] - } - } - - val outer1 = new D[Int] - new outer1.C[String] -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix.check b/test/files/run/macro-expand-tparams-prefix.check new file mode 100644 index 0000000000..7397958066 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix.check @@ -0,0 +1,20 @@ +===Macros1=== +WeakTypeTag[Int] +WeakTypeTag[Int] +WeakTypeTag[String] +WeakTypeTag[Boolean] +===Macros2=== +WeakTypeTag[Boolean] WeakTypeTag[Int] +WeakTypeTag[Boolean] WeakTypeTag[String] +===Macros3=== +WeakTypeTag[Int] +WeakTypeTag[String] +WeakTypeTag[Boolean] +===Macros4=== +WeakTypeTag[Int] +WeakTypeTag[String] +WeakTypeTag[Boolean] +===Macros5=== +WeakTypeTag[T] +WeakTypeTag[U] +WeakTypeTag[Boolean] diff --git a/test/files/neg/macro-invalidshape-c.flags b/test/files/run/macro-expand-tparams-prefix.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-c.flags +++ b/test/files/run/macro-expand-tparams-prefix.flags diff --git a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala new file mode 100644 index 0000000000..e92396d1b4 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala @@ -0,0 +1,40 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.macros.Context + +object Impls1 { + def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = { + import c.universe._ + val U = implicitly[c.WeakTypeTag[U]] + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) + c.Expr[Unit](body) + } +} + +object Impls2 { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = { + import c.universe._ + val T = implicitly[c.WeakTypeTag[T]] + val U = implicitly[c.WeakTypeTag[U]] + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) + c.Expr[Unit](body) + } +} + +object Impls345 { + def foo[T, U: c.WeakTypeTag, V](c: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { + import c.universe._ + c.Expr(Block(List( + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))), + Literal(Constant(())))) + } +} + +object Macros4 { + class D[T] { + class C[U] { + def foo[V] = macro Impls345.foo[T, U, V] + } + } +} 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 new file mode 100644 index 0000000000..2b1730d36e --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala @@ -0,0 +1,57 @@ +object Macros1 { + class C[T] { + def foo[U](x: U) = macro Impls1.foo[U] + } +} + +object Macros2 { + class C[T] { + def foo[U](x: U) = macro Impls2.foo[T, U] + } +} + +object Macros3 { + class D[T] { + class C[U] { + def foo[V] = macro Impls345.foo[T, U, V] + } + } +} + +// object Macros4 is declared in Impls_1.scala + +object Macros5 { + class D[T] { + class C[U] { + def foo[V] = macro Impls345.foo[T, U, V] + foo[Boolean] + } + } +} + +object Test extends App { + println("===Macros1===") + new Macros1.C[Int]().foo(42) + new Macros1.C[Boolean]().foo(42) + new Macros1.C[Int]().foo("42") + new Macros1.C[String]().foo(true) + + println("===Macros2===") + object D2 extends Macros2.C[Boolean] + D2.foo(42) + D2.foo("42") + + println("===Macros3===") + val outer31 = new Macros3.D[Int] + val outer32 = new outer31.C[String] + outer32.foo[Boolean] + + println("===Macros4===") + val outer41 = new Macros4.D[Int] + val outer42 = new outer41.C[String] + outer42.foo[Boolean] + + println("===Macros5===") + val outer1 = new Macros5.D[Int] + new outer1.C[String] +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-a.check b/test/files/run/macro-expand-unapply-a.check new file mode 100644 index 0000000000..7c2976e51e --- /dev/null +++ b/test/files/run/macro-expand-unapply-a.check @@ -0,0 +1,2 @@ +(1,2) +(1,2,3) diff --git a/test/files/neg/macro-invalidsig-context-bounds.flags b/test/files/run/macro-expand-unapply-a.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.flags +++ b/test/files/run/macro-expand-unapply-a.flags diff --git a/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala new file mode 100644 index 0000000000..61d6345f16 --- /dev/null +++ b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context + +object Helper { + def unapplySeq[T](x: List[T]): Option[Seq[T]] = List.unapplySeq[T](x) +} + +object Macros { + def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = { + c.universe.reify(Helper.unapplySeq(x.splice)) + } + + object UnapplyMacro { + def unapplySeq[T](x: List[T]): Option[Seq[T]] = macro impl[T] + } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-a/Test_2.scala b/test/files/run/macro-expand-unapply-a/Test_2.scala new file mode 100644 index 0000000000..6169d86b19 --- /dev/null +++ b/test/files/run/macro-expand-unapply-a/Test_2.scala @@ -0,0 +1,6 @@ +import Macros._ + +object Test extends App { + List(1, 2) match { case UnapplyMacro(x, y) => println((x, y)) } + List(1, 2, 3) match { case UnapplyMacro(x, y, z) => println((x, y, z)) } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.check b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.check index 1c3ecfdefb..2709b57038 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.check +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.check @@ -1,4 +1,4 @@ -reflective compilation has failed: +reflective compilation has failed: no `: _*' annotation allowed here (such annotations are only allowed in arguments to *-parameters) diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala index 2ef8f04be9..f6c1d27d54 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala index c832826d64..b844012d53 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 @@ -6,7 +6,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala index 3c7f94f605..363ff0e0aa 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala @@ -7,7 +7,7 @@ object Impls { case List(Typed(stripped, Ident(wildstar))) if wildstar == tpnme.WILDCARD_STAR => List(stripped) case _ => ??? } - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), stripped_xs) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), stripped_xs) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala index 2066893bdc..0b61ab2f9b 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala @@ -7,7 +7,7 @@ object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala index 2ef8f04be9..f6c1d27d54 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala index 2066893bdc..0b61ab2f9b 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala @@ -7,7 +7,7 @@ object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index 7c40045c0f..95d746980e 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -7,10 +7,10 @@ object Impls { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + U.tpe))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo_targs...")))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("U is: " + U.tpe))))), Literal(Constant(()))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-impl-relaxed.check b/test/files/run/macro-impl-relaxed.check new file mode 100644 index 0000000000..487b116534 --- /dev/null +++ b/test/files/run/macro-impl-relaxed.check @@ -0,0 +1,4 @@ +2 +2 +2 +2 diff --git a/test/files/run/macro-impl-relaxed/Macros_1.scala b/test/files/run/macro-impl-relaxed/Macros_1.scala new file mode 100644 index 0000000000..af62646b4e --- /dev/null +++ b/test/files/run/macro-impl-relaxed/Macros_1.scala @@ -0,0 +1,14 @@ +import language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def implUU(c: Context)(x: c.Tree): c.Tree = x + def implTU(c: Context)(x: c.Expr[Int]): c.Tree = x.tree + def implUT(c: Context)(x: c.Tree): c.Expr[Int] = c.Expr[Int](x) + def implTT(c: Context)(x: c.Expr[Int]): c.Expr[Int] = x + + def fooUU(x: Int): Int = macro implUU + def fooTU(x: Int): Int = macro implTU + def fooUT(x: Int): Int = macro implUT + def fooTT(x: Int): Int = macro implTT +}
\ No newline at end of file diff --git a/test/files/run/macro-impl-relaxed/Test_2.scala b/test/files/run/macro-impl-relaxed/Test_2.scala new file mode 100644 index 0000000000..2eaeef0fd0 --- /dev/null +++ b/test/files/run/macro-impl-relaxed/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + println(Macros.fooUU(2)) + println(Macros.fooTU(2)) + println(Macros.fooUT(2)) + println(Macros.fooTT(2)) +}
\ No newline at end of file diff --git a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala index 56c23f5faf..738c88bbc8 100644 --- a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala @@ -4,7 +4,7 @@ object Impls { def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = { import unconventionalName.universe._ val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo..."))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo..."))))), Literal(Constant(()))) unconventionalName.Expr[Unit](body) } diff --git a/test/files/neg/macro-invalidsig-ctx-badargc.flags b/test/files/run/macro-impl-tparam-only-in-impl.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-badargc.flags +++ b/test/files/run/macro-impl-tparam-only-in-impl.flags diff --git a/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala index 9b8dafaa97..9b8dafaa97 100644 --- a/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala +++ b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala diff --git a/test/files/neg/macro-invalidimpl-h/Macros_Test_2.scala b/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala index 218c7aec7f..218c7aec7f 100644 --- a/test/files/neg/macro-invalidimpl-h/Macros_Test_2.scala +++ b/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala diff --git a/test/files/run/macro-expand-tparams-optional.check b/test/files/run/macro-impl-tparam-typetag-is-optional.check index b4a0f394c1..b4a0f394c1 100644 --- a/test/files/run/macro-expand-tparams-optional.check +++ b/test/files/run/macro-impl-tparam-typetag-is-optional.check diff --git a/test/files/neg/macro-invalidsig-ctx-badtype.flags b/test/files/run/macro-impl-tparam-typetag-is-optional.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-badtype.flags +++ b/test/files/run/macro-impl-tparam-typetag-is-optional.flags diff --git a/test/files/run/macro-expand-tparams-optional/Impls_1.scala b/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala index 3b829e2e09..ace7a6cd26 100644 --- a/test/files/run/macro-expand-tparams-optional/Impls_1.scala +++ b/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo[U](c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("don't know U")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("don't know U")))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-optional/Macros_Test_2.scala b/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala index e72c27881a..e72c27881a 100644 --- a/test/files/run/macro-expand-tparams-optional/Macros_Test_2.scala +++ b/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.check b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.check index 916195145e..1d531f6d86 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.check +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.check @@ -1,4 +1,4 @@ -reflective compilation has failed: +reflective compilation has failed: type mismatch; found : String("42") diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala index 0b9986e9f6..61f0bdfadc 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-nontypeable.check b/test/files/run/macro-invalidret-nontypeable.check index cf7acb0d60..25cef2c786 100644 --- a/test/files/run/macro-invalidret-nontypeable.check +++ b/test/files/run/macro-invalidret-nontypeable.check @@ -1,3 +1,3 @@ -reflective compilation has failed: +reflective compilation has failed: not found: value IDoNotExist diff --git a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala index fb0d55208c..869a5a41fa 100644 --- a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx) = { import c.universe._ - val body = Ident(newTermName("IDoNotExist")) + val body = Ident(TermName("IDoNotExist")) c.Expr[Int](body) } } diff --git a/test/files/run/macro-invalidret-nontypeable/Test_2.scala b/test/files/run/macro-invalidret-nontypeable/Test_2.scala index 0daee49a08..7cd474ff52 100644 --- a/test/files/run/macro-invalidret-nontypeable/Test_2.scala +++ b/test/files/run/macro-invalidret-nontypeable/Test_2.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-badret.check b/test/files/run/macro-invalidusage-badret.check index 221732eefc..9225b716d6 100644 --- a/test/files/run/macro-invalidusage-badret.check +++ b/test/files/run/macro-invalidusage-badret.check @@ -1,4 +1,4 @@ -reflective compilation has failed: +reflective compilation has failed: type mismatch; found : Int(42) diff --git a/test/files/run/macro-invalidusage-badret/Test_2.scala b/test/files/run/macro-invalidusage-badret/Test_2.scala index 5cb0be5ddd..fc71353f54 100644 --- a/test/files/run/macro-invalidusage-badret/Test_2.scala +++ b/test/files/run/macro-invalidusage-badret/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Typed(Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))), Ident(newTypeName("String"))) + val tree = Typed(Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))), Ident(TypeName("String"))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams.check b/test/files/run/macro-invalidusage-partialapplication-with-tparams.check index f1d5e925fa..6cbcb9e5af 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams.check +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams.check @@ -1,3 +1,3 @@ -reflective compilation has failed: +reflective compilation has failed: -macros cannot be partially applied +too few argument lists for macro invocation diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala index 4583a726cf..8a93161af5 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[T]) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(x.tree.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(x.tree.toString)))) c.Expr[Unit](body) } } diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala index e453d0b70c..9a34c62e0f 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-invalidusage-partialapplication.check b/test/files/run/macro-invalidusage-partialapplication.check index f1d5e925fa..6cbcb9e5af 100644 --- a/test/files/run/macro-invalidusage-partialapplication.check +++ b/test/files/run/macro-invalidusage-partialapplication.check @@ -1,3 +1,3 @@ -reflective compilation has failed: +reflective compilation has failed: -macros cannot be partially applied +too few argument lists for macro invocation diff --git a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala index 5866469499..3ac9cd2a8d 100644 --- a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala @@ -3,8 +3,8 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._ - val sum = Apply(Select(x.tree, newTermName("$plus")), List(y.tree)) - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + val sum = Apply(Select(x.tree, TermName("$plus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) c.Expr[Unit](body) } } diff --git a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala index dc48c127f4..75b8c139d4 100644 --- a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala +++ b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(40)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(40)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala index b863ac048b..50a1782431 100644 --- a/test/files/run/macro-openmacros/Impls_Macros_1.scala +++ b/test/files/run/macro-openmacros/Impls_Macros_1.scala @@ -14,7 +14,7 @@ object Macros { } import c.universe._ - val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), newTermName("foo"))) else c.literalUnit + val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), TermName("foo"))) else c.literalUnit c.universe.reify { println(c.literal(normalizePaths(c.enclosingMacros.toString)).splice) next.splice diff --git a/test/files/run/macro-parse-position-malformed.check b/test/files/run/macro-parse-position-malformed.check new file mode 100644 index 0000000000..00f0bc5b62 --- /dev/null +++ b/test/files/run/macro-parse-position-malformed.check @@ -0,0 +1 @@ +failed with 'source-<macro>,line-1,offset=7' position and '')' expected but eof found.' message diff --git a/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala new file mode 100644 index 0000000000..2417eb6897 --- /dev/null +++ b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala @@ -0,0 +1,17 @@ +import scala.language.experimental.macros +import scala.reflect.macros.{Context => Ctx, ParseException} + +object Macros { + def impl(c: Ctx)() = { + import c.universe._ + val out = try { + c.parse("foo(bar") + "didn't fail" + } catch { + case e: ParseException => + s"failed with '${e.pos}' position and '${e.msg}' message" + } + c.Expr[String](Literal(Constant(out))) + } + def foo(): String = macro impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-c/Test_2.scala b/test/files/run/macro-parse-position-malformed/Test_2.scala index e75a8ba101..cff569bd81 100644 --- a/test/files/neg/macro-invalidimpl-c/Test_2.scala +++ b/test/files/run/macro-parse-position-malformed/Test_2.scala @@ -1,3 +1,3 @@ object Test extends App { - new Macros().foo(42) -}
\ No newline at end of file + println(Macros.foo) +} diff --git a/test/files/run/macro-parse-position.check b/test/files/run/macro-parse-position.check new file mode 100644 index 0000000000..3da0320696 --- /dev/null +++ b/test/files/run/macro-parse-position.check @@ -0,0 +1,5 @@ +false +source-<macro>,line-1,offset=4 +8 +foo bar + diff --git a/test/files/run/macro-parse-position/Impls_Macros_1.scala b/test/files/run/macro-parse-position/Impls_Macros_1.scala new file mode 100644 index 0000000000..b6f1ebbcd5 --- /dev/null +++ b/test/files/run/macro-parse-position/Impls_Macros_1.scala @@ -0,0 +1,12 @@ +import scala.language.experimental.macros +import scala.reflect.macros.{Context => Ctx} + +object Macros { + def impl(c: Ctx)() = { + import c.universe._ + val t = c.parse("foo bar") + val out = s"${t.pos == NoPosition}\n${t.pos}\n${t.pos.source.content.length}\n${new String(t.pos.source.content)}" + c.Expr[String](Literal(Constant(out))) + } + def foo(): String = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-b/Test_2.scala b/test/files/run/macro-parse-position/Test_2.scala index 7dffc5107d..cff569bd81 100644 --- a/test/files/run/macro-def-path-dependent-b/Test_2.scala +++ b/test/files/run/macro-parse-position/Test_2.scala @@ -1,3 +1,3 @@ object Test extends App { - println("it works") -}
\ No newline at end of file + println(Macros.foo) +} diff --git a/test/files/run/macro-quasiquotes.check b/test/files/run/macro-quasiquotes.check new file mode 100644 index 0000000000..94ebaf9001 --- /dev/null +++ b/test/files/run/macro-quasiquotes.check @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/test/files/run/macro-quasiquotes/Macros_1.scala b/test/files/run/macro-quasiquotes/Macros_1.scala new file mode 100644 index 0000000000..b64eec8743 --- /dev/null +++ b/test/files/run/macro-quasiquotes/Macros_1.scala @@ -0,0 +1,15 @@ +import language.experimental.macros +import scala.reflect.macros.Macro + +trait Impls extends Macro { + import c.universe._ + def impl1 = q"println(1)" + def impl2 = q"{ println(2); println(3) }" + def impl3 = q"4" +} + +object Macros { + def m1 = macro Impls.impl1 + def m2 = macro Impls.impl2 + def m3 = macro Impls.impl3 +}
\ No newline at end of file diff --git a/test/files/run/macro-quasiquotes/Test_2.scala b/test/files/run/macro-quasiquotes/Test_2.scala new file mode 100644 index 0000000000..4be193938f --- /dev/null +++ b/test/files/run/macro-quasiquotes/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + Macros.m1 + Macros.m2 + println(Macros.m3) +} diff --git a/test/files/run/macro-range/Common_1.scala b/test/files/run/macro-range/Common_1.scala index 5c4bc211fc..4083e6126e 100644 --- a/test/files/run/macro-range/Common_1.scala +++ b/test/files/run/macro-range/Common_1.scala @@ -43,5 +43,5 @@ abstract class Utils { LabelDef(lname, Nil, rhs) } def makeBinop(left: Tree, op: String, right: Tree): Tree = - Apply(Select(left, newTermName(op)), List(right)) + Apply(Select(left, TermName(op)), List(right)) } diff --git a/test/files/run/macro-range/Expansion_Impossible_2.scala b/test/files/run/macro-range/Expansion_Impossible_2.scala index 57e0cee97f..ca0db48822 100644 --- a/test/files/run/macro-range/Expansion_Impossible_2.scala +++ b/test/files/run/macro-range/Expansion_Impossible_2.scala @@ -16,11 +16,11 @@ object Impls { // scala"($_this: RangeDefault).foreach($f)" c.Expr(c.prefix.tree match { case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" => - val iname = newTermName("$i") - val hname = newTermName("$h") + val iname = TermName("$i") + val hname = TermName("$h") def iref = Ident(iname) def href = Ident(hname) - val labelname = newTermName("$while") + val labelname = TermName("$while") val cond = makeBinop(iref, "$less", href) val body = Block( List(makeApply(f.tree, List(iref))), @@ -37,8 +37,8 @@ object Impls { case _ => Apply( Select( - Typed(c.prefix.tree, Ident(newTypeName("RangeDefault"))), - newTermName("foreach")), + Typed(c.prefix.tree, Ident(TypeName("RangeDefault"))), + TermName("foreach")), List(f.tree)) }) } diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala index fa559334d4..51e0264ed5 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } } diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala index 2e64c01e35..267d1bc7b0 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala @@ -2,6 +2,6 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) println(cm.mkToolBox().eval(tree)) } diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala index 5d7e077731..4261a6d45d 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala index 70560009b1..13cd953bde 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 @@ -8,12 +8,12 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val macrobody = Select(Ident(newTermName("Impls")), newTermName("foo")) - val macroparam = ValDef(NoMods, newTermName("x"), TypeTree(definitions.IntClass.toType), EmptyTree) - val macrodef = DefDef(Modifiers(MACRO), newTermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody) + 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 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, newTermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) - val macroapp = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val module = ModuleDef(NoMods, TermName("Macros"), Template(Nil, emptyValDef, 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") println(toolbox.eval(tree)) diff --git a/test/files/run/macro-reify-freevars.check b/test/files/run/macro-reify-freevars.check index f13806889e..f618e307b2 100644 --- a/test/files/run/macro-reify-freevars.check +++ b/test/files/run/macro-reify-freevars.check @@ -1,3 +1,3 @@ -reflective compilation has failed: +reflective compilation has failed: Macro expansion contains free term variable code defined by map in Macros_1.scala:9:9. Have you forgotten to use splice when splicing this variable into a reifee? If you have troubles tracking free term variables, consider using -Xlog-free-terms diff --git a/test/files/run/macro-reify-freevars/Test_2.scala b/test/files/run/macro-reify-freevars/Test_2.scala index 7af9d89bdb..c2d0118e17 100644 --- a/test/files/run/macro-reify-freevars/Test_2.scala +++ b/test/files/run/macro-reify-freevars/Test_2.scala @@ -2,10 +2,10 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val q = New(AppliedTypeTree(Select(Select(Select(Ident(newTermName("scala")), newTermName("collection")), newTermName("slick")), newTypeName("Queryable")), List(Ident(newTermName("Int"))))) - val x = ValDef(NoMods, newTermName("x"), Ident(newTermName("Int")), EmptyTree) - val fn = Function(List(x), Apply(Select(Ident(newTermName("x")), newTermName("$plus")), List(Literal(Constant("5"))))) - val tree = Apply(Select(q, newTermName("map")), List(fn)) + val q = New(AppliedTypeTree(Select(Select(Select(Ident(TermName("scala")), TermName("collection")), TermName("slick")), TypeName("Queryable")), List(Ident(TermName("Int"))))) + val x = ValDef(NoMods, TermName("x"), Ident(TermName("Int")), EmptyTree) + val fn = Function(List(x), Apply(Select(Ident(TermName("x")), TermName("$plus")), List(Literal(Constant("5"))))) + val tree = Apply(Select(q, TermName("map")), List(fn)) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala index b4351c2c53..bb6a45e11e 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 @@ -28,7 +28,7 @@ object QueryableMacros{ val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( - Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree )) + Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree )) ).asInstanceOf[Tree] ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} 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 b4351c2c53..bb6a45e11e 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 @@ -28,7 +28,7 @@ object QueryableMacros{ val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( - Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree )) + Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree )) ).asInstanceOf[Tree] ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} diff --git a/test/files/run/macro-reify-splice-outside-reify/Test_2.scala b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala index 54bd03fcd2..dbc17e7c15 100644 --- a/test/files/run/macro-reify-splice-outside-reify/Test_2.scala +++ b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) try println(cm.mkToolBox().eval(tree)) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-reify-tagless-a.check b/test/files/run/macro-reify-tagless-a.check index 231741edc5..d160e8043c 100644 --- a/test/files/run/macro-reify-tagless-a.check +++ b/test/files/run/macro-reify-tagless-a.check @@ -1,3 +1,3 @@ -reflective compilation has failed: +reflective compilation has failed: Macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. Have you forgotten to use c.WeakTypeTag annotation for this type parameter? If you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/macro-reify-tagless-a/Test_2.scala b/test/files/run/macro-reify-tagless-a/Test_2.scala index 584c4bdf5b..afb418a755 100644 --- a/test/files/run/macro-reify-tagless-a/Test_2.scala +++ b/test/files/run/macro-reify-tagless-a/Test_2.scala @@ -6,9 +6,9 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tpt = AppliedTypeTree(Ident(definitions.ListClass), List(Ident(definitions.StringClass))) - val rhs = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant("hello world")))) - val list = ValDef(NoMods, newTermName("list"), tpt, rhs) - val tree = Block(List(list), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name)))) + val rhs = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant("hello world")))) + val list = ValDef(NoMods, TermName("list"), tpt, rhs) + val tree = Block(List(list), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Ident(list.name)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-reify-type/Macros_1.scala b/test/files/run/macro-reify-type/Macros_1.scala index 06de05735d..c4d1d9f8ad 100644 --- a/test/files/run/macro-reify-type/Macros_1.scala +++ b/test/files/run/macro-reify-type/Macros_1.scala @@ -8,7 +8,7 @@ object StaticReflect { import c.universe._ val nameName: TermName = name.tree match { - case Literal(Constant(str: String)) => newTermName(str) + case Literal(Constant(str: String)) => TermName(str) case _ => c.error(c.enclosingPosition, s"Method name not constant.") ; return reify(ru.NoType) } val clazz = weakTypeOf[A] @@ -17,8 +17,8 @@ object StaticReflect { case NoSymbol => c.error(c.enclosingPosition, s"No member called $nameName in $clazz.") ; reify(ru.NoType) case member => val mtpe = member typeSignatureIn clazz - val mtag = c.reifyType(treeBuild.mkRuntimeUniverseRef, Select(treeBuild.mkRuntimeUniverseRef, newTermName("rootMirror")), mtpe) - val mtree = Select(mtag, newTermName("tpe")) + val mtag = c.reifyType(treeBuild.mkRuntimeUniverseRef, Select(treeBuild.mkRuntimeUniverseRef, TermName("rootMirror")), mtpe) + val mtree = Select(mtag, TermName("tpe")) c.Expr[ru.Type](mtree) } diff --git a/test/files/run/macro-reify-type/Test_2.scala b/test/files/run/macro-reify-type/Test_2.scala index 9beaf98681..1f35973531 100644 --- a/test/files/run/macro-reify-type/Test_2.scala +++ b/test/files/run/macro-reify-type/Test_2.scala @@ -7,10 +7,10 @@ object Test extends App { //val $m: $u.Mirror = scala.reflect.runtime.universe.rootMirror; //import $u._, $m._, Flag._ //val tpe = { - // val symdef$B2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTypeName("B"), NoPosition, DEFERRED | PARAM, false); - // val symdef$That2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTypeName("That"), NoPosition, DEFERRED | PARAM, false); - // val symdef$f2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTermName("f"), NoPosition, PARAM, false); - // val symdef$bf2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTermName("bf"), NoPosition, IMPLICIT | PARAM, false); + // val symdef$B2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TypeName("B"), NoPosition, DEFERRED | PARAM, false); + // val symdef$That2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TypeName("That"), NoPosition, DEFERRED | PARAM, false); + // val symdef$f2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TermName("f"), NoPosition, PARAM, false); + // val symdef$bf2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TermName("bf"), NoPosition, IMPLICIT | PARAM, false); // build.setTypeSignature(symdef$B2, TypeBounds(staticClass("scala.Nothing").asType.toTypeConstructor, staticClass("scala.Any").asType.toTypeConstructor)); // build.setTypeSignature(symdef$That2, TypeBounds(staticClass("scala.Nothing").asType.toTypeConstructor, staticClass("scala.Any").asType.toTypeConstructor)); // build.setTypeSignature(symdef$f2, TypeRef(ThisType(staticPackage("scala").asModule.moduleClass), staticClass("scala.Function1"), List(staticClass("scala.Int").asType.toTypeConstructor, TypeRef(NoPrefix, symdef$B2, List())))); diff --git a/test/files/run/macro-reify-unreify/Macros_1.scala b/test/files/run/macro-reify-unreify/Macros_1.scala index 9f04c13014..25ed352cca 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 ")), newTermName("$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-basic.check b/test/files/run/macro-repl-basic.check index 7deed4a878..46ea1f6405 100644 --- a/test/files/run/macro-repl-basic.check +++ b/test/files/run/macro-repl-basic.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> import language.experimental.macros import language.experimental.macros @@ -14,23 +12,23 @@ scala> scala> object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } } -defined module Impls +defined object Impls scala> object Macros { object Shmacros { @@ -40,7 +38,7 @@ scala> object Macros { }; class Macros { def quux(x: Int): Int = macro Impls.quux } -defined module Macros +defined object Macros defined class Macros scala> diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala index eae1febb3a..3c22c13dc7 100644 --- a/test/files/run/macro-repl-basic.scala +++ b/test/files/run/macro-repl-basic.scala @@ -8,19 +8,19 @@ object Test extends ReplTest { |object Impls { | def foo(c: Ctx)(x: c.Expr[Int]) = { | import c.universe._ - | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) | c.Expr[Int](body) | } | | def bar(c: Ctx)(x: c.Expr[Int]) = { | import c.universe._ - | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) | c.Expr[Int](body) | } | | def quux(c: Ctx)(x: c.Expr[Int]) = { | import c.universe._ - | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) | c.Expr[Int](body) | } |} diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check index 628a9146c4..9c35aad6b1 100644 --- a/test/files/run/macro-repl-dontexpand.check +++ b/test/files/run/macro-repl-dontexpand.check @@ -1,12 +1,10 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> def bar(c: scala.reflect.macros.Context) = ??? bar: (c: scala.reflect.macros.Context)Nothing scala> def foo = macro bar -foo: Any +defined term macro foo: Any scala> diff --git a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala index 5f3f61ca3f..8d7d3b5d3d 100644 --- a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala @@ -7,7 +7,7 @@ object Macros { val inscope = c.inferImplicitValue(c.mirror.staticClass("SourceLocation").toType) val outer = c.Expr[SourceLocation](if (!inscope.isEmpty) inscope else Literal(Constant(null))) - val Apply(fun, args) = c.enclosingImplicits(0)._2 + val Apply(fun, args) = c.enclosingImplicits(0).tree val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala index 535ec2ccf0..4c165ed1b8 100644 --- a/test/files/run/macro-sip19/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.Context object Macros { def impl(c: Context) = { import c.universe._ - val Apply(fun, args) = c.enclosingImplicits(0)._2 + val Apply(fun, args) = c.enclosingImplicits(0).tree val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check index dce976df02..ff96a34426 100644 --- a/test/files/run/macro-system-properties.check +++ b/test/files/run/macro-system-properties.check @@ -1,9 +1,7 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - -scala> import language.experimental._, reflect.macros.Context +scala> import language.experimental._, reflect.macros.Context import language.experimental._ import reflect.macros.Context @@ -13,14 +11,12 @@ scala> object GrabContext { def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } def grab() = macro impl } -defined module GrabContext +defined object GrabContext scala> object Test { class C(implicit a: Any) { GrabContext.grab } } -defined module Test +defined object Test scala> object Test { class C(implicit a: Any) { GrabContext.grab } } -defined module Test - -scala> +defined object Test scala> diff --git a/test/files/run/macro-def-path-dependent-a.check b/test/files/run/macro-term-declared-in-annotation.check index 7658ad2c24..7658ad2c24 100644 --- a/test/files/run/macro-def-path-dependent-a.check +++ b/test/files/run/macro-term-declared-in-annotation.check diff --git a/test/files/neg/macro-invalidsig-ctx-badvarargs.flags b/test/files/run/macro-term-declared-in-annotation.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-badvarargs.flags +++ b/test/files/run/macro-term-declared-in-annotation.flags diff --git a/test/files/run/macro-declared-in-annotation/Impls_1.scala b/test/files/run/macro-term-declared-in-annotation/Impls_1.scala index a11ee2907a..1ea06de679 100644 --- a/test/files/run/macro-declared-in-annotation/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-annotation/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) val body = Block(List(printPrefix), Literal(Constant("this is deprecated"))) c.Expr[String](body) } diff --git a/test/files/run/macro-declared-in-annotation/Macros_2.scala b/test/files/run/macro-term-declared-in-annotation/Macros_2.scala index 40d71c62fb..40d71c62fb 100644 --- a/test/files/run/macro-declared-in-annotation/Macros_2.scala +++ b/test/files/run/macro-term-declared-in-annotation/Macros_2.scala diff --git a/test/files/run/macro-declared-in-annotation/Test_3.scala b/test/files/run/macro-term-declared-in-annotation/Test_3.scala index 866487f028..866487f028 100644 --- a/test/files/run/macro-declared-in-annotation/Test_3.scala +++ b/test/files/run/macro-term-declared-in-annotation/Test_3.scala diff --git a/test/files/run/macro-declared-in-anonymous.check b/test/files/run/macro-term-declared-in-anonymous.check index 09b8d015a6..09b8d015a6 100644 --- a/test/files/run/macro-declared-in-anonymous.check +++ b/test/files/run/macro-term-declared-in-anonymous.check diff --git a/test/files/neg/macro-invalidsig-ctx-noctx.flags b/test/files/run/macro-term-declared-in-anonymous.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-noctx.flags +++ b/test/files/run/macro-term-declared-in-anonymous.flags diff --git a/test/files/run/macro-declared-in-class-object/Impls_1.scala b/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-class-object/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file 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 new file mode 100644 index 0000000000..88cd29ae4f --- /dev/null +++ b/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala @@ -0,0 +1,6 @@ +import scala.language.reflectiveCalls + +object Test extends App { + val macros = new { def foo = macro Impls.foo } + macros.foo +} diff --git a/test/files/run/macro-declared-in-block.check b/test/files/run/macro-term-declared-in-block.check index 5e687db8bf..5e687db8bf 100644 --- a/test/files/run/macro-declared-in-block.check +++ b/test/files/run/macro-term-declared-in-block.check diff --git a/test/files/neg/macro-invalidsig-implicit-params.flags b/test/files/run/macro-term-declared-in-block.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.flags +++ b/test/files/run/macro-term-declared-in-block.flags diff --git a/test/files/run/macro-declared-in-block/Impls_1.scala b/test/files/run/macro-term-declared-in-block/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-block/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-block/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-block/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala index 69088e24bc..69088e24bc 100644 --- a/test/files/run/macro-declared-in-block/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-class-class.check b/test/files/run/macro-term-declared-in-class-class.check index 47248d7af7..47248d7af7 100644 --- a/test/files/run/macro-declared-in-class-class.check +++ b/test/files/run/macro-term-declared-in-class-class.check diff --git a/test/files/neg/macro-invalidsig-params-badargc.flags b/test/files/run/macro-term-declared-in-class-class.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-badargc.flags +++ b/test/files/run/macro-term-declared-in-class-class.flags diff --git a/test/files/run/macro-declared-in-class-class/Impls_1.scala b/test/files/run/macro-term-declared-in-class-class/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-class-class/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-class-class/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala index 871857a97f..871857a97f 100644 --- a/test/files/run/macro-declared-in-class-class/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-class-object.check b/test/files/run/macro-term-declared-in-class-object.check index 35af59e40f..35af59e40f 100644 --- a/test/files/run/macro-declared-in-class-object.check +++ b/test/files/run/macro-term-declared-in-class-object.check diff --git a/test/files/neg/macro-invalidsig-params-badvarargs.flags b/test/files/run/macro-term-declared-in-class-object.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-badvarargs.flags +++ b/test/files/run/macro-term-declared-in-class-object.flags diff --git a/test/files/run/macro-declared-in-anonymous/Impls_1.scala b/test/files/run/macro-term-declared-in-class-object/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-anonymous/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-class-object/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala index 994f9fe935..994f9fe935 100644 --- a/test/files/run/macro-declared-in-class-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-class.check b/test/files/run/macro-term-declared-in-class.check index a1c1d7af8b..a1c1d7af8b 100644 --- a/test/files/run/macro-declared-in-class.check +++ b/test/files/run/macro-term-declared-in-class.check diff --git a/test/files/neg/macro-invalidsig-params-namemismatch.flags b/test/files/run/macro-term-declared-in-class.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-namemismatch.flags +++ b/test/files/run/macro-term-declared-in-class.flags diff --git a/test/files/run/macro-term-declared-in-class/Impls_1.scala b/test/files/run/macro-term-declared-in-class/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-class/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala index 1b9d13e775..1b9d13e775 100644 --- a/test/files/run/macro-declared-in-class/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-default-param.check b/test/files/run/macro-term-declared-in-default-param.check index 6decd7aa4d..6decd7aa4d 100644 --- a/test/files/run/macro-declared-in-default-param.check +++ b/test/files/run/macro-term-declared-in-default-param.check diff --git a/test/files/neg/macro-invalidsig-tparams-badtype.flags b/test/files/run/macro-term-declared-in-default-param.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-badtype.flags +++ b/test/files/run/macro-term-declared-in-default-param.flags diff --git a/test/files/run/macro-declared-in-default-param/Impls_1.scala b/test/files/run/macro-term-declared-in-default-param/Impls_1.scala index db1e5c7435..4380f40b04 100644 --- a/test/files/run/macro-declared-in-default-param/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-default-param/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) val body = Block(List(printPrefix), Literal(Constant("it works"))) c.Expr[String](body) } diff --git a/test/files/run/macro-declared-in-default-param/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala index 356029e63e..356029e63e 100644 --- a/test/files/run/macro-declared-in-default-param/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-implicit-class.check b/test/files/run/macro-term-declared-in-implicit-class.check index 5dc968c08c..5dc968c08c 100644 --- a/test/files/run/macro-declared-in-implicit-class.check +++ b/test/files/run/macro-term-declared-in-implicit-class.check diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-a.flags b/test/files/run/macro-term-declared-in-implicit-class.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-bounds-a.flags +++ b/test/files/run/macro-term-declared-in-implicit-class.flags diff --git a/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala index 837b306976..4c009cc367 100644 --- a/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala +++ b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala @@ -4,8 +4,8 @@ object Impls { def toOptionOfInt(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Ident(definitions.SomeModule), List(Select(Select(prefix.tree, newTermName("x")), newTermName("toInt"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Ident(definitions.SomeModule), List(Select(Select(prefix.tree, TermName("x")), TermName("toInt"))))) c.Expr[Option[Int]](body) } } diff --git a/test/files/run/macro-declared-in-implicit-class/Test_2.scala b/test/files/run/macro-term-declared-in-implicit-class/Test_2.scala index d0bc9cc38c..d0bc9cc38c 100644 --- a/test/files/run/macro-declared-in-implicit-class/Test_2.scala +++ b/test/files/run/macro-term-declared-in-implicit-class/Test_2.scala diff --git a/test/files/run/macro-declared-in-method.check b/test/files/run/macro-term-declared-in-method.check index 5e687db8bf..5e687db8bf 100644 --- a/test/files/run/macro-declared-in-method.check +++ b/test/files/run/macro-term-declared-in-method.check diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-b.flags b/test/files/run/macro-term-declared-in-method.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-bounds-b.flags +++ b/test/files/run/macro-term-declared-in-method.flags diff --git a/test/files/run/macro-term-declared-in-method/Impls_1.scala b/test/files/run/macro-term-declared-in-method/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-method/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-method/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala index ed5c8b7c43..ed5c8b7c43 100644 --- a/test/files/run/macro-declared-in-method/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-object-class.check b/test/files/run/macro-term-declared-in-object-class.check index 47248d7af7..47248d7af7 100644 --- a/test/files/run/macro-declared-in-object-class.check +++ b/test/files/run/macro-term-declared-in-object-class.check diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a.flags b/test/files/run/macro-term-declared-in-object-class.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a.flags +++ b/test/files/run/macro-term-declared-in-object-class.flags diff --git a/test/files/run/macro-term-declared-in-object-class/Impls_1.scala b/test/files/run/macro-term-declared-in-object-class/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-object-class/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala index 204deed61c..204deed61c 100644 --- a/test/files/run/macro-declared-in-object-class/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-object-object.check b/test/files/run/macro-term-declared-in-object-object.check index 35af59e40f..35af59e40f 100644 --- a/test/files/run/macro-declared-in-object-object.check +++ b/test/files/run/macro-term-declared-in-object-object.check diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b.flags b/test/files/run/macro-term-declared-in-object-object.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b.flags +++ b/test/files/run/macro-term-declared-in-object-object.flags diff --git a/test/files/run/macro-term-declared-in-object-object/Impls_1.scala b/test/files/run/macro-term-declared-in-object-object/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-object-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala index e261a50f3d..e261a50f3d 100644 --- a/test/files/run/macro-declared-in-object-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-object.check b/test/files/run/macro-term-declared-in-object.check index 4d955a96b1..4d955a96b1 100644 --- a/test/files/run/macro-declared-in-object.check +++ b/test/files/run/macro-term-declared-in-object.check diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c.flags b/test/files/run/macro-term-declared-in-object.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c.flags +++ b/test/files/run/macro-term-declared-in-object.flags diff --git a/test/files/run/macro-term-declared-in-object/Impls_1.scala b/test/files/run/macro-term-declared-in-object/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala index a5a4862ba0..a5a4862ba0 100644 --- a/test/files/run/macro-declared-in-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-package-object.check b/test/files/run/macro-term-declared-in-package-object.check index bc0069178d..bc0069178d 100644 --- a/test/files/run/macro-declared-in-package-object.check +++ b/test/files/run/macro-term-declared-in-package-object.check diff --git a/test/files/neg/macro-invalidusage-badbounds-a.flags b/test/files/run/macro-term-declared-in-package-object.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/macro-invalidusage-badbounds-a.flags +++ b/test/files/run/macro-term-declared-in-package-object.flags diff --git a/test/files/run/macro-term-declared-in-package-object/Impls_1.scala b/test/files/run/macro-term-declared-in-package-object/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-package-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala index 54a5962e80..54a5962e80 100644 --- a/test/files/run/macro-declared-in-package-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala diff --git a/test/files/run/macro-declared-in-refinement.check b/test/files/run/macro-term-declared-in-refinement.check index 09b8d015a6..09b8d015a6 100644 --- a/test/files/run/macro-declared-in-refinement.check +++ b/test/files/run/macro-term-declared-in-refinement.check diff --git a/test/files/run/macro-declared-in-annotation.flags b/test/files/run/macro-term-declared-in-refinement.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-annotation.flags +++ b/test/files/run/macro-term-declared-in-refinement.flags diff --git a/test/files/run/macro-term-declared-in-refinement/Impls_1.scala b/test/files/run/macro-term-declared-in-refinement/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-refinement/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala index f746c2da57..ff9a66d58a 100644 --- a/test/files/run/macro-declared-in-refinement/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala @@ -1,6 +1,9 @@ + +import scala.language.reflectiveCalls + class Base object Test extends App { val macros = new Base { def foo = macro Impls.foo } macros.foo -}
\ No newline at end of file +} diff --git a/test/files/run/macro-declared-in-trait.check b/test/files/run/macro-term-declared-in-trait.check index 0d70ac74f3..0f3756ddb6 100644 --- a/test/files/run/macro-declared-in-trait.check +++ b/test/files/run/macro-term-declared-in-trait.check @@ -1,6 +1,6 @@ prefix = Expr[Nothing]({ final class $anon extends AnyRef with Base { - def <init>(): anonymous class $anon = { + def <init>(): <$anon: Base> = { $anon.super.<init>(); () }; diff --git a/test/files/run/macro-declared-in-anonymous.flags b/test/files/run/macro-term-declared-in-trait.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-anonymous.flags +++ b/test/files/run/macro-term-declared-in-trait.flags diff --git a/test/files/run/macro-term-declared-in-trait/Impls_1.scala b/test/files/run/macro-term-declared-in-trait/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/files/run/macro-term-declared-in-trait/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala index f75906b636..f75906b636 100644 --- a/test/files/run/macro-declared-in-trait/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala diff --git a/test/files/run/macro-typecheck-implicitsdisabled.check b/test/files/run/macro-typecheck-implicitsdisabled.check index c4fa2c5c28..91d8fabd72 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled.check +++ b/test/files/run/macro-typecheck-implicitsdisabled.check @@ -1,2 +1,2 @@ -scala.this.Predef.any2ArrowAssoc[Int](1).->[Int](2) +scala.this.Predef.ArrowAssoc[Int](1).->[Int](2) scala.reflect.macros.TypecheckException: value -> is not a member of Int 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 633cb930fc..dbeb7efbc0 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def impl_with_implicits_enabled(c: Context) = { import c.universe._ - val tree1 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + val tree1 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withImplicitViewsDisabled = false) c.literal(ttree1.toString) } @@ -15,7 +15,7 @@ object Macros { import c.universe._ try { - val tree2 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + val tree2 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withImplicitViewsDisabled = true) c.literal(ttree2.toString) } catch { diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check index 29a881f8b1..e0e880ab66 100644 --- a/test/files/run/macro-typecheck-macrosdisabled.check +++ b/test/files/run/macro-typecheck-macrosdisabled.check @@ -7,7 +7,7 @@ $treecreator1.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.Literal.apply($u.Constant.apply(2)) @@ -20,7 +20,7 @@ $typecreator2.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.ConstantType.apply($u.Constant.apply(2)) 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 f693ad78cc..ff535fea8d 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -4,8 +4,8 @@ object Macros { def impl_with_macros_enabled(c: Context) = { import c.universe._ - val ru = Select(Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("package")), newTermName("universe")) - val tree1 = Apply(Select(ru, newTermName("reify")), List(Literal(Constant(2)))) + val 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) c.literal(ttree1.toString) } @@ -21,7 +21,7 @@ object Macros { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) c.literal(ttree2.toString) } diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check index 27d15d47af..347dfec1dc 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2.check +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -7,10 +7,10 @@ $treecreator1.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) } }; new $treecreator1() @@ -20,7 +20,7 @@ $typecreator2.super.<init>(); () }; - def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { + def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor)) 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 1dbf5a1a87..a96e0c53b6 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -4,8 +4,8 @@ object Macros { def impl_with_macros_enabled(c: Context) = { import c.universe._ - val ru = Select(Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("package")), newTermName("universe")) - val tree1 = Apply(Select(ru, newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val 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) c.literal(ttree1.toString) } @@ -21,7 +21,7 @@ object Macros { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + 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) c.literal(ttree2.toString) } diff --git a/test/files/run/manifests-new.scala b/test/files/run/manifests-new.scala index f1596dee81..8b42e3ca73 100644 --- a/test/files/run/manifests-new.scala +++ b/test/files/run/manifests-new.scala @@ -1,3 +1,6 @@ + + +import scala.language.{ higherKinds, postfixOps } import scala.reflect.runtime.universe._ object Test @@ -146,4 +149,4 @@ object Test } def main(args: Array[String]): Unit = runAllTests -}
\ No newline at end of file +} diff --git a/test/files/run/manifests-old.scala b/test/files/run/manifests-old.scala index 621689a254..d8b1e751d4 100644 --- a/test/files/run/manifests-old.scala +++ b/test/files/run/manifests-old.scala @@ -1,3 +1,6 @@ +import scala.language.{ higherKinds, postfixOps } + +@deprecated("Suppress warnings", since="2.11") object Test { object Variances extends Enumeration { @@ -144,4 +147,4 @@ object Test } def main(args: Array[String]): Unit = runAllTests -}
\ No newline at end of file +} diff --git a/test/files/run/mapConserve.scala b/test/files/run/mapConserve.scala index 013095b1de..d1d52f3107 100644 --- a/test/files/run/mapConserve.scala +++ b/test/files/run/mapConserve.scala @@ -1,11 +1,14 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import scala.annotation.tailrec import scala.collection.mutable.ListBuffer object Test { val maxListLength = 7 // up to 16, but larger is slower var testCount = 0 - - def checkStackOverflow() = { + + def checkStackOverflow() = { var xs: List[String] = Nil for (i <- 0 until 250000) xs = "X" :: xs @@ -47,7 +50,7 @@ object Test { // Behaves like existing mapConserve with respect to eq checkBehaviourUnchanged(data, data mapConserve lastHexDigit, data mapConserve lastHexDigit) } - + checkStackOverflow(); } -}
\ No newline at end of file +} diff --git a/test/files/run/mapValues.scala b/test/files/run/mapValues.scala index bd1794bc51..d3266bd18f 100644 --- a/test/files/run/mapValues.scala +++ b/test/files/run/mapValues.scala @@ -1,7 +1,7 @@ object Test { val m = Map(1 -> 1, 2 -> 2) val mv = (m mapValues identity) - 1 - + def main(args: Array[String]): Unit = { assert(mv.size == 1) } diff --git a/test/files/run/map_java_conversions.scala b/test/files/run/map_java_conversions.scala index 7714b2cc74..c007b3e0eb 100644 --- a/test/files/run/map_java_conversions.scala +++ b/test/files/run/map_java_conversions.scala @@ -4,53 +4,53 @@ object Test { - + def main(args: Array[String]) { import collection.JavaConversions._ - + test(new java.util.HashMap[String, String]) test(new java.util.Properties) testConcMap } - + def testConcMap { import collection.JavaConversions._ - + val concMap = new java.util.concurrent.ConcurrentHashMap[String, String] - + test(concMap) - val cmap = asScalaConcurrentMap(concMap) + val cmap = mapAsScalaConcurrentMap(concMap) cmap.putIfAbsent("absentKey", "absentValue") cmap.put("somekey", "somevalue") assert(cmap.remove("somekey", "somevalue") == true) assert(cmap.replace("absentKey", "newAbsentValue") == Some("absentValue")) assert(cmap.replace("absentKey", "newAbsentValue", ".......") == true) } - + def test(m: collection.mutable.Map[String, String]) { m.clear assert(m.size == 0) - + m.put("key", "value") assert(m.size == 1) - + assert(m.put("key", "anotherValue") == Some("value")) assert(m.put("key2", "value2") == None) assert(m.size == 2) - + m += (("key3", "value3")) assert(m.size == 3) - + m -= "key2" assert(m.size == 2) assert(m.nonEmpty) assert(m.remove("key") == Some("anotherValue")) - + m.clear for (i <- 0 until 10) m += (("key" + i, "value" + i)) for ((k, v) <- m) assert(k.startsWith("key")) } - + } diff --git a/test/files/run/matchbytes.scala b/test/files/run/matchbytes.scala index 7190886bab..f2cea06eb3 100644 --- a/test/files/run/matchbytes.scala +++ b/test/files/run/matchbytes.scala @@ -4,4 +4,4 @@ object Test extends App{ case 1 => println(1); case _ => println("????"); } -} +} diff --git a/test/files/run/matchintasany.scala b/test/files/run/matchintasany.scala index c6764b31b9..03f6ca2a84 100644 --- a/test/files/run/matchintasany.scala +++ b/test/files/run/matchintasany.scala @@ -5,4 +5,4 @@ object Test extends App{ case 1L => println(1); case _ => println("????"); } -} +} diff --git a/test/files/run/matchnull.scala b/test/files/run/matchnull.scala index cfb3049239..2cc8550d47 100644 --- a/test/files/run/matchnull.scala +++ b/test/files/run/matchnull.scala @@ -3,7 +3,7 @@ object Test def f1 = null match { case x: AnyRef => 1 case _ => -1 } def f2(x: Any) = x match { case 52 => 1 ; case null => -1 ; case _ => 0 } def f3(x: AnyRef) = x match { case x: String => 1 ; case List(_) => 0 ; case null => -1 ; case _ => -2 } - + def main(args: Array[String]): Unit = { println(f1) println(f2(null)) diff --git a/test/files/run/matchonseq.scala b/test/files/run/matchonseq.scala index 49b406a6ec..f6f320245a 100644 --- a/test/files/run/matchonseq.scala +++ b/test/files/run/matchonseq.scala @@ -1,8 +1,8 @@ -object Test extends App{ - Vector(1,2,3) match { - case head +: tail => println("It worked! head=" + head) +object Test extends App { + Vector(1,2,3) match { + case head +: tail => println("It worked! head=" + head) } - Vector(1,2,3) match { - case init :+ last => println("It worked! last=" + last) + Vector(1,2,3) match { + case init :+ last => println("It worked! last=" + last) } } diff --git a/test/files/run/memberpos.check b/test/files/run/memberpos.check new file mode 100644 index 0000000000..9e3a807f5a --- /dev/null +++ b/test/files/run/memberpos.check @@ -0,0 +1,11 @@ +newSource1.scala +2,4 class A +6,28 object A + 7,10 def bippy + 8 def hello + 11,27 class Dingo + 12,26 def foooooz + 22 val a +30 class B + 30 def f + diff --git a/test/files/run/memberpos.scala b/test/files/run/memberpos.scala new file mode 100644 index 0000000000..f2b79c0ec1 --- /dev/null +++ b/test/files/run/memberpos.scala @@ -0,0 +1,39 @@ +import scala.tools.partest._ + +// Simple sanity test for -Yshow-member-pos. +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp -Ystop-after:parser -Yshow-member-pos \"\" -d " + testOutput.path + override def show() = compile() + override def code = """ +class A(val a: Int = 1) { + +} + +object A { + def bippy = { + def hello = 55 + "" + hello + } + class Dingo { + def foooooz = /**** + + + + + + ****/ { + + + + val a = 1 + + + a + } + } +} + +class B { def f = 1 } + +""" +} diff --git a/test/files/run/misc.check b/test/files/run/misc.check index 9fa7b72d50..56116f8104 100644 --- a/test/files/run/misc.check +++ b/test/files/run/misc.check @@ -1,3 +1,27 @@ +misc.scala:46: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 42; + ^ +misc.scala:47: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 42l; + ^ +misc.scala:48: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 23.5f; + ^ +misc.scala:49: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 23.5; + ^ +misc.scala:50: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + "Hello"; + ^ +misc.scala:51: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 32 + 45; + ^ +misc.scala:62: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + x; + ^ +misc.scala:74: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 1 < 2; + ^ ### Hello ### 17 ### Bye diff --git a/test/files/run/misc.scala b/test/files/run/misc.scala index 139d2d70f7..2ae76bd968 100644 --- a/test/files/run/misc.scala +++ b/test/files/run/misc.scala @@ -60,7 +60,7 @@ object Test { Console.println; val x = 13; x; - // !!! why are DefDef replaced by Block(Tree[0])? we should use Empty! + // !!! why are DefDef replaced by Block(Tree[0])? we should use Empty! def f = 19; f; def f0() = 11; diff --git a/test/files/run/missingparams.scala b/test/files/run/missingparams.scala index e9b1d27d68..fbc4d2a4f7 100644 --- a/test/files/run/missingparams.scala +++ b/test/files/run/missingparams.scala @@ -6,8 +6,8 @@ final class Foo(val x: Int) { // test that the closure elimination is not wrongly replacing // 'that' by 'this' - def intersect(that: Foo) = - filter { dummy => + def intersect(that: Foo) = + filter { dummy => // x // dummy that.x > 0 } diff --git a/test/files/run/mutable-treeset.scala b/test/files/run/mutable-treeset.scala new file mode 100644 index 0000000000..100ab39965 --- /dev/null +++ b/test/files/run/mutable-treeset.scala @@ -0,0 +1,145 @@ +import scala.collection.mutable.TreeSet + +object Test extends App { + val list = List(6,5,4,3,2,1,1,2,3,4,5,6,6,5,4,3,2,1) + val distinct = list.distinct + val sorted = distinct.sorted + + // sublist stuff for a single level of slicing + val min = list.min + val max = list.max + val nonlist = ((min - 10) until (max + 20) filterNot list.contains).toList + val sublist = list filter {x => x >=(min + 1) && x < max} + val distinctSublist = sublist.distinct + val subnonlist = min :: max :: nonlist + val subsorted = distinctSublist.sorted + + // subsublist for a 2nd level of slicing + val almostmin = sublist.min + val almostmax = sublist.max + val subsublist = sublist filter {x => x >=(almostmin + 1) && x < almostmax} + val distinctSubsublist = subsublist.distinct + val subsubnonlist = almostmin :: almostmax :: subnonlist + val subsubsorted = distinctSubsublist.sorted + + def testSize { + def check(set : TreeSet[Int], list: List[Int]) { + assert(set.size == list.size, s"$set had size ${set.size} while $list had size ${list.size}") + } + + check(TreeSet[Int](), List[Int]()) + val set = TreeSet(list:_*) + check(set, distinct) + check(set.clone, distinct) + + val subset = set from (min + 1) until max + check(subset, distinctSublist) + check(subset.clone, distinctSublist) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, distinctSubsublist) + check(subsubset.clone, distinctSubsublist) + } + + def testContains { + def check(set : TreeSet[Int], list: List[Int], nonlist: List[Int]) { + assert(list forall set.apply, s"$set did not contain all elements of $list using apply") + assert(list forall set.contains, s"$set did not contain all elements of $list using contains") + assert(!(nonlist exists set.apply), s"$set had an element from $nonlist using apply") + assert(!(nonlist exists set.contains), s"$set had an element from $nonlist using contains") + } + + val set = TreeSet(list:_*) + check(set, list, nonlist) + check(set.clone, list, nonlist) + + val subset = set from (min + 1) until max + check(subset, sublist, subnonlist) + check(subset.clone, sublist, subnonlist) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, subsublist, subsubnonlist) + check(subsubset.clone, subsublist, subsubnonlist) + } + + def testAdd { + def check(set : TreeSet[Int], list: List[Int], nonlist: List[Int]) { + var builtList = List[Int]() + for (x <- list) { + set += x + builtList = (builtList :+ x).distinct.sorted filterNot nonlist.contains + assert(builtList forall set.apply, s"$set did not contain all elements of $builtList using apply") + assert(builtList.size == set.size, s"$set had size ${set.size} while $builtList had size ${builtList.size}") + } + assert(!(nonlist exists set.apply), s"$set had an element from $nonlist using apply") + assert(!(nonlist exists set.contains), s"$set had an element from $nonlist using contains") + } + + val set = TreeSet[Int]() + val clone = set.clone + val subset = set.clone from (min + 1) until max + val subclone = subset.clone + val subsubset = subset.clone from (almostmin + 1) until almostmax + val subsubclone = subsubset.clone + + check(set, list, nonlist) + check(clone, list, nonlist) + + check(subset, list, subnonlist) + check(subclone, list, subnonlist) + + check(subsubset, list, subsubnonlist) + check(subsubclone, list, subsubnonlist) + } + + def testRemove { + def check(set: TreeSet[Int], sorted: List[Int]) { + var builtList = sorted + for (x <- list) { + set remove x + builtList = builtList filterNot (_ == x) + assert(builtList forall set.apply, s"$set did not contain all elements of $builtList using apply") + assert(builtList.size == set.size, s"$set had size $set.size while $builtList had size $builtList.size") + } + } + val set = TreeSet(list:_*) + val clone = set.clone + val subset = set.clone from (min + 1) until max + val subclone = subset.clone + val subsubset = subset.clone from (almostmin + 1) until almostmax + val subsubclone = subsubset.clone + + check(set, sorted) + check(clone, sorted) + + check(subset, subsorted) + check(subclone, subsorted) + + check(subsubset, subsubsorted) + check(subsubclone, subsubsorted) + } + + def testIterator { + def check(set: TreeSet[Int], list: List[Int]) { + val it = set.iterator.toList + assert(it == list, s"$it did not equal $list") + } + val set = TreeSet(list: _*) + check(set, sorted) + check(set.clone, sorted) + + val subset = set from (min + 1) until max + check(subset, subsorted) + check(subset.clone, subsorted) + + val subsubset = subset from (almostmin + 1) until almostmax + check(subsubset, subsubsorted) + check(subsubset.clone, subsubsorted) + } + + testSize + testContains + testAdd + testRemove + testIterator +} diff --git a/test/files/run/name-based-patmat.check b/test/files/run/name-based-patmat.check new file mode 100644 index 0000000000..1cc605ea3d --- /dev/null +++ b/test/files/run/name-based-patmat.check @@ -0,0 +1,10 @@ +catdog +2 catdogs! A ha ha! +3 catdogs! A ha ha! +catdog +2 catdogs! A ha ha! +3 catdogs! A ha ha! +1 +1 +2 +3 diff --git a/test/files/run/name-based-patmat.scala b/test/files/run/name-based-patmat.scala new file mode 100644 index 0000000000..2c429c141f --- /dev/null +++ b/test/files/run/name-based-patmat.scala @@ -0,0 +1,75 @@ +final class MiniSome[T](val get: T) extends AnyVal { def isEmpty = false } + +package p1 { + class Triple(val x: Any) extends AnyRef with Product3[String, String, String] { + private def s = "" + x + override def canEqual(x: Any) = this eq x.asInstanceOf[AnyRef] + def isEmpty = false + def get = this + def _1 = s + def _2 = "2 " + s + "s! A ha ha!" + def _3 = "3 " + s + "s! A ha ha!" + + override def toString = s"Triple(${_1}, ${_2}, ${_3})" + } + + object Triple { + def unapply(x: Any): Triple = new Triple(x) + } +} + +package p2 { + class Triple(val x: Any) { + private def s = "" + x + def isEmpty = false + def get = this + def _1 = s + def _2 = "2 " + s + "s! A ha ha!" + def _3 = "3 " + s + "s! A ha ha!" + override def toString = s"Triple(${_1}, ${_2}, ${_3})" + } + + object Triple { + def unapply(x: Any): Triple = new Triple(x) + } +} + +package p3 { + case class Foo(x: Int, y: Int, zs: Int*) + + object Bar { + def f(x: Foo) = x match { + case Foo(5, 10, 15, 20, _*) => 1 + case Foo(5, 10, 15, _*) => 2 + case Foo(5, 10, _*) => 3 + case Foo(5, 10) => 4 // should warn unreachable + case _ => 5 + } + } +} + +object Test { + + // def f(x: Any) = x match { + // case p1.Foo(x, y, z) => println((x, y, z)) + // case x => println(x) + // } + + def main(args: Array[String]): Unit = { + "catdog" match { + case p1.Triple(x, y, z) => List(x, y, z) foreach println + case x => println("fail: " + x) + } + // TODO + "catdog" match { + case p2.Triple(x, y, z) => List(x, y, z) foreach println + case x => println("fail: " + x) + } + + println(p3.Bar.f(p3.Foo(5, 10, 15, 20, 25))) + println(p3.Bar.f(p3.Foo(5, 10, 15, 20))) + println(p3.Bar.f(p3.Foo(5, 10, 15))) + println(p3.Bar.f(p3.Foo(5, 10))) + // println(p3.Bar.f(p3.Foo(5))) + } +} diff --git a/test/files/run/names-defaults.check b/test/files/run/names-defaults.check index f253de71d6..0037822f3b 100644 --- a/test/files/run/names-defaults.check +++ b/test/files/run/names-defaults.check @@ -1,3 +1,7 @@ +names-defaults.scala:269: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + spawn(b = { val ttt = 1; ttt }, a = 0) + ^ +warning: there were 4 deprecation warning(s); re-run with -deprecation for details 1: @ get: $ get: 2 diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 220414f02a..05cd4a540c 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds, existentials } + object Test extends App { def get[T](x: T) = { println("get: "+ x); x } diff --git a/test/files/run/no-pickle-skolems.check b/test/files/run/no-pickle-skolems.check new file mode 100644 index 0000000000..d64066171a --- /dev/null +++ b/test/files/run/no-pickle-skolems.check @@ -0,0 +1 @@ +OK! diff --git a/test/files/run/no-pickle-skolems/Source_1.scala b/test/files/run/no-pickle-skolems/Source_1.scala new file mode 100644 index 0000000000..1b4cbfa788 --- /dev/null +++ b/test/files/run/no-pickle-skolems/Source_1.scala @@ -0,0 +1,5 @@ +package s + +trait Foo { def to[CC[X]](implicit cc: CC[Int]): Unit } + +class Bar extends Foo { def to[CC[X]](implicit cc: CC[Int]): Unit = ??? } diff --git a/test/files/run/no-pickle-skolems/Test_2.scala b/test/files/run/no-pickle-skolems/Test_2.scala new file mode 100644 index 0000000000..8fd6016aea --- /dev/null +++ b/test/files/run/no-pickle-skolems/Test_2.scala @@ -0,0 +1,39 @@ + +import scala.language.reflectiveCalls +import scala.reflect.runtime.universe._ + +object Test { + /** Collects symbols by the given name, even if they're not + * named CC. + */ + def collectSymbols[T: TypeTag](inMethod: TermName, name: String): List[String] = { + val m = typeOf[T] member inMethod typeSignatureIn typeOf[T] + var buf: List[Symbol] = Nil + var seen: Set[Symbol] = Set() + def id(s: Symbol): Int = s.asInstanceOf[{ def id: Int }].id + + def check(s: Symbol) { + if (!seen(s)) { + seen += s + if (s.name.toString == name) buf ::= s + } + } + def loop(t: Type) { + t match { + case TypeRef(pre, sym, args) => loop(pre) ; check(sym) ; args foreach loop + case PolyType(tparams, restpe) => tparams foreach { tp => check(tp) ; check(tp.owner) ; loop(tp.typeSignature) } ; loop(restpe) + case MethodType(params, restpe) => params foreach { p => check(p) ; loop(p.typeSignature) } ; loop(restpe) + case _ => + } + } + loop(m) + + buf.reverse.distinct map (s => s.name + "#" + id(s)) + } + + def main(args: Array[String]): Unit = { + val syms = collectSymbols[s.Bar]("to", "CC") + assert(syms.size == 1, syms) + println("OK!") + } +} diff --git a/test/files/run/nodebuffer-array.check b/test/files/run/nodebuffer-array.check deleted file mode 100644 index 49f8bfaf8d..0000000000 --- a/test/files/run/nodebuffer-array.check +++ /dev/null @@ -1,3 +0,0 @@ -<entry> - <elem>a</elem><elem>b</elem><elem>c</elem> - </entry> diff --git a/test/files/run/nodebuffer-array.scala b/test/files/run/nodebuffer-array.scala deleted file mode 100644 index 4e1ffe1e5e..0000000000 --- a/test/files/run/nodebuffer-array.scala +++ /dev/null @@ -1,15 +0,0 @@ -object Test { - - def f(s: String) = { - <entry> - { - for (item <- s split ',') yield - <elem>{ item }</elem> - } - </entry> - } - - def main(args: Array[String]): Unit = { - println(f("a,b,c")) - } -} diff --git a/test/files/run/null-and-intersect.scala b/test/files/run/null-and-intersect.scala index 1437fa4b25..7266dabe6d 100644 --- a/test/files/run/null-and-intersect.scala +++ b/test/files/run/null-and-intersect.scala @@ -2,7 +2,7 @@ object Test { trait Immortal class Bippy extends Immutable with Immortal class Boppy extends Immutable - + def f[T](x: Traversable[T]) = x match { case _: Map[_, _] => 3 case _: Seq[_] => 2 @@ -23,10 +23,10 @@ object Test { println(f(Seq(1))) println(f(Map(1 -> 2))) println(f(null)) - + println(g(new Bippy)) println(g(null)) - + println(h(new Bippy)) println(h(new Boppy)) println(h(null)) diff --git a/test/files/run/null-hash.scala b/test/files/run/null-hash.scala index abf15e8166..9b1f28b083 100644 --- a/test/files/run/null-hash.scala +++ b/test/files/run/null-hash.scala @@ -2,7 +2,7 @@ object Test { def f1 = List(5, 10, null: String).## def f2(x: Any) = x.## def f3 = ((55, "abc", null: List[Int])).## - + def main(args: Array[String]): Unit = { f1 f2(null) diff --git a/test/files/run/number-parsing.scala b/test/files/run/number-parsing.scala index 21551a3a07..ad1481063e 100644 --- a/test/files/run/number-parsing.scala +++ b/test/files/run/number-parsing.scala @@ -2,12 +2,12 @@ object Test { def numTests() = { val MinusZero = Float.box(-0.0f) val PlusZero = Float.box(0.0f) - + assert(PlusZero match { case MinusZero => false ; case _ => true }) assert(MinusZero match { case PlusZero => false ; case _ => true }) assert((MinusZero: scala.Float) == (PlusZero: scala.Float)) assert(!(MinusZero equals PlusZero)) - + List( -5f.max(2) , -5f max 2 , diff --git a/test/files/run/numbereq.scala b/test/files/run/numbereq.scala index a1f11da205..d50db6d049 100644 --- a/test/files/run/numbereq.scala +++ b/test/files/run/numbereq.scala @@ -13,13 +13,13 @@ object Test { if (x >= Byte.MinValue && x <= Byte.MaxValue) List(new java.lang.Byte(x.toByte)) else Nil, if (x >= Char.MinValue && x <= Char.MaxValue) List(new java.lang.Character(x.toChar)) else Nil ).flatten - + base ::: extras } def mkNumbers(x: BigInt): List[AnyRef] = { List( - List(BigDecimal(x, java.math.MathContext.UNLIMITED)), + List(BigDecimal(x, java.math.MathContext.UNLIMITED)), List(x), if (x.isValidDouble) List(new java.lang.Double(x.toDouble)) else Nil, if (x.isValidFloat) List(new java.lang.Float(x.toFloat)) else Nil, @@ -30,21 +30,21 @@ object Test { if (x.isValidChar) List(new java.lang.Character(x.toChar)) else Nil ).flatten } - + def main(args: Array[String]): Unit = { val ints = (0 to 15).toList map (Short.MinValue >> _) val ints2 = ints map (x => -x) val ints3 = ints map (_ + 1) val ints4 = ints2 map (_ - 1) - + val setneg1 = ints map mkNumbers val setneg2 = ints3 map mkNumbers val setpos1 = ints2 map mkNumbers val setpos2 = ints4 map mkNumbers val zero = mkNumbers(0) - - val sets = setneg1 ++ setneg2 ++ List(zero) ++ setpos1 ++ setpos2 - + + val sets = setneg1 ++ setneg2 ++ List(zero) ++ setpos1 ++ setpos2 + for (set <- sets ; x <- set ; y <- set) { // println("'%s' == '%s' (%s == %s) (%s == %s)".format(x, y, x.hashCode, y.hashCode, x.##, y.##)) assert(x == y, "%s/%s != %s/%s".format(x, x.getClass, y, y.getClass)) @@ -55,14 +55,14 @@ object Test { val bigInts2 = bigInts map (x => -x) val bigInts3 = bigInts map (_ + 1) val bigInts4 = bigInts2 map (_ - 1) - + val setneg1b = bigInts map mkNumbers val setneg2b = bigInts3 map mkNumbers val setpos1b = bigInts2 map mkNumbers val setpos2b = bigInts4 map mkNumbers val sets2 = setneg1 ++ setneg1b ++ setneg2 ++ setneg2b ++ List(zero) ++ setpos1 ++ setpos1b ++ setpos2 ++ setpos2b - + for (set <- sets2 ; x <- set ; y <- set) { // println("'%s' == '%s' (%s == %s) (%s == %s)".format(x, y, x.hashCode, y.hashCode, x.##, y.##)) assert(x == y, "%s/%s != %s/%s".format(x, x.getClass, y, y.getClass)) diff --git a/test/files/run/option-fold.scala b/test/files/run/option-fold.scala index d554ba4f9b..84e346ec79 100644 --- a/test/files/run/option-fold.scala +++ b/test/files/run/option-fold.scala @@ -2,18 +2,19 @@ object Test { sealed class A case object B extends A case class C(x: Int) extends A - + def f[T](x: Option[T]) = x.fold(List.empty[T])(List(_)) def g(x: Option[A]) = x.fold(-1) { case B => 0 case C(x) => x + case _ => ??? } def main(args: Array[String]): Unit = { - println(f(None)) - println(f(Some(5))) - println(g(None)) - println(g(Some(B))) - println(g(Some(C(1)))) + println(f(None)) //List() + println(f(Some(5))) //List(5) + println(g(None)) //-1 + println(g(Some(B))) //0 + println(g(Some(C(1)))) //1 } } diff --git a/test/files/run/origins.scala b/test/files/run/origins.scala index 0ad92297f5..6529351d3c 100644 --- a/test/files/run/origins.scala +++ b/test/files/run/origins.scala @@ -14,7 +14,7 @@ object Test { def f1() = 1 to 5 map boop def f2() = 1 to 10 map boop def f3() = 1 to 50 map boop - + def main(args: Array[String]): Unit = { f1() ; f2() ; f3() } diff --git a/test/files/run/packrat1.check b/test/files/run/packrat1.check deleted file mode 100644 index e9f797e1b6..0000000000 --- a/test/files/run/packrat1.check +++ /dev/null @@ -1,7 +0,0 @@ -1 -3 -5 -81 -4 -37 -9 diff --git a/test/files/run/packrat1.scala b/test/files/run/packrat1.scala deleted file mode 100644 index b5a4687378..0000000000 --- a/test/files/run/packrat1.scala +++ /dev/null @@ -1,47 +0,0 @@ -import scala.util.parsing.combinator._ - -import scala.util.parsing.combinator.syntactical.StandardTokenParsers -import scala.util.parsing.input._ -import scala.util.parsing.combinator.token._ - -import scala.collection.mutable.HashMap - -object Test extends App{ - import grammars._ - - val head = phrase(term) - - println(extractResult(head(new lexical.Scanner("1")))) - println(extractResult(head(new lexical.Scanner("1+2")))) - println(extractResult(head(new lexical.Scanner("9-4")))) - println(extractResult(head(new lexical.Scanner("9*9")))) - println(extractResult(head(new lexical.Scanner("8/2")))) - println(extractResult(head(new lexical.Scanner("4*9-0/7+9-8*1")))) - println(extractResult(head(new lexical.Scanner("(1+2)*3")))) -} - -object grammars extends StandardTokenParsers with PackratParsers{ - - def extractResult(r : ParseResult[_]) = r match { - case Success(a,_) => a - case NoSuccess(a,_) => a - } - - lexical.delimiters ++= List("+","-","*","/","(",")") - lexical.reserved ++= List("Hello","World") - - /**** - * term = term + fact | term - fact | fact - * fact = fact * num | fact / num | num - */ - - - val term: PackratParser[Int] = (term~("+"~>fact) ^^ {case x~y => x+y} - |term~("-"~>fact) ^^ {case x~y => x-y} - |fact) - - val fact: PackratParser[Int] = (fact~("*"~>numericLit) ^^ {case x~y => x*y.toInt} - |fact~("/"~>numericLit) ^^ {case x~y => x/y.toInt} - |"("~>term<~")" - |numericLit ^^ {_.toInt}) - } diff --git a/test/files/run/packrat2.check b/test/files/run/packrat2.check deleted file mode 100644 index 55a32ac58b..0000000000 --- a/test/files/run/packrat2.check +++ /dev/null @@ -1,7 +0,0 @@ -1 -3 -81 -43 -59 -188 -960 diff --git a/test/files/run/packrat2.scala b/test/files/run/packrat2.scala deleted file mode 100644 index f55021a6a8..0000000000 --- a/test/files/run/packrat2.scala +++ /dev/null @@ -1,57 +0,0 @@ -import scala.util.parsing.combinator._ - -import scala.util.parsing.combinator.syntactical.StandardTokenParsers -import scala.util.parsing.input._ -import scala.util.parsing.combinator.token._ - -import scala.collection.mutable.HashMap - -object Test extends App{ - import grammars2._ - - val head = phrase(exp) - - println(extractResult(head(new lexical.Scanner("1")))) - println(extractResult(head(new lexical.Scanner("1+2")))) - println(extractResult(head(new lexical.Scanner("9*9")))) - println(extractResult(head(new lexical.Scanner("4*9+7")))) - println(extractResult(head(new lexical.Scanner("4*9+7*2+3*3")))) - println(extractResult(head(new lexical.Scanner("4*9+7*2+3*3+9*5+7*6*2")))) - println(extractResult(head(new lexical.Scanner("4*(9+7)*(2+3)*3")))) - -} - -object grammars2 extends StandardTokenParsers with PackratParsers{ - - def extractResult(r : ParseResult[_]) = r match{ - case Success(a,_) => a - case NoSuccess(a,_) => a - } - - lexical.delimiters ++= List("+","-","*","/","(",")") - lexical.reserved ++= List("Hello","World") - - /* - * exp = sum | prod | num - * sum = exp ~ "+" ~ num - * prod = exp ~ "*" ~ num - */ - - val exp : PackratParser[Int] = sum | prod | numericLit ^^{_.toInt} | "("~>exp<~")" - val sum : PackratParser[Int] = exp~("+"~>exp) ^^ {case x~y => x+y} - val prod: PackratParser[Int] = exp~("*"~>(numericLit ^^{_.toInt} | exp)) ^^ {case x~y => x*y} - - - /* lexical.reserved ++= List("a","b", "c") - val a : PackratParser[Any] = numericLit^^{x => primeFactors(x.toInt)} - val b : PackratParser[Any] = memo("b") - val c : PackratParser[Any] = memo("c") - val AnBnCn : PackratParser[Any] = - parseButDontEat(repMany1(a,b))~not(b)~>rep1(a)~repMany1(b,c)// ^^{case x~y => x:::y} - //val c : PackratParser[Any] = parseButDontEat(a)~a~a - //println(c((new PackratReader(new lexical.Scanner("45 24"))))) - val r = new PackratReader(new lexical.Scanner("45 b c")) - println(AnBnCn(r)) - println(r.getCache.size) -*/ -} diff --git a/test/files/run/packrat3.check b/test/files/run/packrat3.check deleted file mode 100644 index 8c10626751..0000000000 --- a/test/files/run/packrat3.check +++ /dev/null @@ -1,7 +0,0 @@ -(((List(a, b)~())~List(a))~List(b, c)) -(((List(a, a, b, b)~())~List(a, a))~List(b, b, c, c)) -(((List(a, a, a, b, b, b)~())~List(a, a, a))~List(b, b, b, c, c, c)) -(((List(a, a, a, a, b, b, b, b)~())~List(a, a, a, a))~List(b, b, b, b, c, c, c, c)) -Expected failure -``b'' expected but `c' found -end of input diff --git a/test/files/run/packrat3.scala b/test/files/run/packrat3.scala deleted file mode 100644 index 216ef8f0af..0000000000 --- a/test/files/run/packrat3.scala +++ /dev/null @@ -1,51 +0,0 @@ -import scala.util.parsing.combinator._ - -import scala.util.parsing.combinator.syntactical.StandardTokenParsers -import scala.util.parsing.input._ -import scala.util.parsing.combinator.token._ - -import scala.collection.mutable.HashMap - -object Test { - def main(args: Array[String]): Unit = { - import grammars3._ - - val head = phrase(AnBnCn) - - println(extractResult(head(new lexical.Scanner("a b c")))) - println(extractResult(head(new lexical.Scanner("a a b b c c")))) - println(extractResult(head(new lexical.Scanner("a a a b b b c c c")))) - println(extractResult(head(new lexical.Scanner("a a a a b b b b c c c c")))) - - println(extractResult(AnBnCn(new PackratReader(new lexical.Scanner("a a a b b b b c c c c"))))) - println(extractResult(AnBnCn(new PackratReader(new lexical.Scanner("a a a a b b b c c c c"))))) - println(extractResult(AnBnCn(new PackratReader(new lexical.Scanner("a a a a b b b b c c c"))))) - } -} - -object grammars3 extends StandardTokenParsers with PackratParsers { - - def extractResult(r: ParseResult[_]) = r match { - case Success(a,_) => a - case NoSuccess(a,_) => a - } - - - lexical.reserved ++= List("a","b", "c") - val a: PackratParser[Any] = memo("a") - val b: PackratParser[Any] = memo("b") - val c: PackratParser[Any] = memo("c") - - val AnBnCn: PackratParser[Any] = - guard(repMany1(a,b) ~ not(b)) ~ rep1(a) ~ repMany1(b,c)// ^^{case x~y => x:::y} - - - private def repMany[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = - ( p~repMany(p,q)~q ^^ {case x~xs~y => x::xs:::(y::Nil)} - | success(Nil) - ) - - def repMany1[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = - p~opt(repMany(p,q))~q ^^ {case x~Some(xs)~y => x::xs:::(y::Nil)} - -} diff --git a/test/files/run/parmap-ops.scala b/test/files/run/parmap-ops.scala index f93bd7b77e..4274460c9d 100644 --- a/test/files/run/parmap-ops.scala +++ b/test/files/run/parmap-ops.scala @@ -1,10 +1,10 @@ import collection._ object Test { - + def main(args: Array[String]) { val gm: GenMap[Int, Int] = GenMap(0 -> 0, 1 -> 1).par - + // ops assert(gm.isDefinedAt(1)) assert(gm.contains(1)) @@ -21,11 +21,11 @@ object Test { } catch { case e: NoSuchElementException => // ok } - + assert(gm.filterKeys(_ % 2 == 0)(0) == 0) assert(gm.filterKeys(_ % 2 == 0).get(1) == None) assert(gm.mapValues(_ + 1)(0) == 1) - + // with defaults val pm = parallel.mutable.ParMap(0 -> 0, 1 -> 1) val dm = pm.withDefault(x => -x) @@ -37,12 +37,12 @@ object Test { assert(dm(3) == 3) assert(pm(3) == 3) assert(dm(4) == -4) - + val imdm = parallel.immutable.ParMap(0 -> 0, 1 -> 1).withDefault(x => -x) assert(imdm(0) == 0) assert(imdm(1) == 1) assert(imdm(2) == -2) assert(imdm.updated(2, 2) == parallel.ParMap(0 -> 0, 1 -> 1, 2 -> 2)) } - + } diff --git a/test/files/run/parserFilter.check b/test/files/run/parserFilter.check deleted file mode 100644 index be04454426..0000000000 --- a/test/files/run/parserFilter.check +++ /dev/null @@ -1,9 +0,0 @@ -[1.3] failure: Input doesn't match filter: false - -if false - ^ -[1.1] failure: Input doesn't match filter: not - -not true -^ -[1.8] parsed: (if~true) diff --git a/test/files/run/parserFilter.scala b/test/files/run/parserFilter.scala deleted file mode 100644 index d007d441f4..0000000000 --- a/test/files/run/parserFilter.scala +++ /dev/null @@ -1,15 +0,0 @@ -object Test extends scala.util.parsing.combinator.RegexParsers { - val keywords = Set("if", "false") - def word: Parser[String] = "\\w+".r - - def keyword: Parser[String] = word filter (keywords.contains) - def ident: Parser[String] = word filter(!keywords.contains(_)) - - def test = keyword ~ ident - - def main(args: Array[String]) { - println(parseAll(test, "if false")) - println(parseAll(test, "not true")) - println(parseAll(test, "if true")) - } -} diff --git a/test/files/run/parserForFilter.check b/test/files/run/parserForFilter.check deleted file mode 100644 index a53c147719..0000000000 --- a/test/files/run/parserForFilter.check +++ /dev/null @@ -1 +0,0 @@ -[1.13] parsed: (second,first) diff --git a/test/files/run/parserForFilter.scala b/test/files/run/parserForFilter.scala deleted file mode 100644 index 1bc44f8033..0000000000 --- a/test/files/run/parserForFilter.scala +++ /dev/null @@ -1,12 +0,0 @@ -object Test extends scala.util.parsing.combinator.RegexParsers { - def word: Parser[String] = "\\w+".r - - def twoWords = for { - (a ~ b) <- word ~ word - } yield (b, a) - - def main(args: Array[String]) { - println(parseAll(twoWords, "first second")) - } -} - diff --git a/test/files/run/parserJavaIdent.check b/test/files/run/parserJavaIdent.check deleted file mode 100644 index 597ddbee47..0000000000 --- a/test/files/run/parserJavaIdent.check +++ /dev/null @@ -1,26 +0,0 @@ -[1.7] parsed: simple -[1.8] parsed: with123 -[1.6] parsed: with$ -[1.10] parsed: withøßöèæ -[1.6] parsed: with_ -[1.6] parsed: _with -[1.1] failure: java identifier expected - -3start -^ -[1.1] failure: java identifier expected - --start -^ -[1.5] failure: java identifier expected - -with-s - ^ -[1.3] failure: java identifier expected - -we♥scala - ^ -[1.6] failure: java identifier expected - -with space - ^ diff --git a/test/files/run/parserJavaIdent.scala b/test/files/run/parserJavaIdent.scala deleted file mode 100644 index c068075e4e..0000000000 --- a/test/files/run/parserJavaIdent.scala +++ /dev/null @@ -1,26 +0,0 @@ -object Test extends scala.util.parsing.combinator.JavaTokenParsers { - - def test[A](s: String) { - val res = parseAll(ident, s) match { - case Failure(_, in) => Failure("java identifier expected", in) - case o => o - } - println(res) - } - - def main(args: Array[String]) { - // Happy tests - test("simple") - test("with123") - test("with$") - test("withøßöèæ") - test("with_") - test("_with") - // Sad tests - test("3start") - test("-start") - test("with-s") - test("we♥scala") - test("with space") - } -} diff --git a/test/files/run/parserNoSuccessMessage.check b/test/files/run/parserNoSuccessMessage.check deleted file mode 100644 index fe00d2fd3a..0000000000 --- a/test/files/run/parserNoSuccessMessage.check +++ /dev/null @@ -1,20 +0,0 @@ -[1.2] failure: string matching regex `\d+' expected but `x' found - --x - ^ -[1.1] failure: string matching regex `\d+' expected but `x' found - -x -^ -[1.3] parsed: (Some(-)~5) -[1.2] parsed: (None~5) -[1.2] error: Number expected! - --x - ^ -[1.1] error: Number expected! - -x -^ -[1.3] parsed: (Some(-)~5) -[1.2] parsed: (None~5) diff --git a/test/files/run/parserNoSuccessMessage.scala b/test/files/run/parserNoSuccessMessage.scala deleted file mode 100644 index 93aa252db0..0000000000 --- a/test/files/run/parserNoSuccessMessage.scala +++ /dev/null @@ -1,19 +0,0 @@ -object Test extends scala.util.parsing.combinator.RegexParsers { - def sign = "-" - def number = "\\d+".r - def p = sign.? ~ number withErrorMessage "Number expected!" - def q = sign.? ~! number withErrorMessage "Number expected!" - - def main(args: Array[String]) { - println(parseAll(p, "-x")) - println(parseAll(p, "x")) - println(parseAll(p, "-5")) - println(parseAll(p, "5")) - println(parseAll(q, "-x")) - println(parseAll(q, "x")) - println(parseAll(q, "-5")) - println(parseAll(q, "5")) - } -} - - diff --git a/test/files/run/patch-boundary.scala b/test/files/run/patch-boundary.scala index 8381956859..ed1a0e9fc1 100644 --- a/test/files/run/patch-boundary.scala +++ b/test/files/run/patch-boundary.scala @@ -1,8 +1,8 @@ object Test { def f = collection.mutable.ArrayBuffer(1, 2, 3, 4, 5, 6, 7, 8) def g = f.patch(4, List(1, 2), 10) - + def main(args: Array[String]): Unit = { - assert(g.size == 6) + assert(g.size == 6) } } diff --git a/test/files/run/patmat-behavior-2.check b/test/files/run/patmat-behavior-2.check new file mode 100644 index 0000000000..a928fe7918 --- /dev/null +++ b/test/files/run/patmat-behavior-2.check @@ -0,0 +1,24 @@ +f1(Foo(1)) == true +f1(Foo(1, 2)) == false +f1(Foo(1, 2, 3)) == false + +f2(Foo(1)) == false +f2(Foo(1, 2)) == true +f2(Foo(1, 2, 3)) == false + +f3(Foo(1)) == false +f3(Foo(1, 2)) == false +f3(Foo(1, 2, 3)) == true + +f1seq(Foo(1)) == true +f1seq(Foo(1, 2)) == true +f1seq(Foo(1, 2, 3)) == true + +f2seq(Foo(1)) == false +f2seq(Foo(1, 2)) == true +f2seq(Foo(1, 2, 3)) == true + +f3seq(Foo(1)) == false +f3seq(Foo(1, 2)) == false +f3seq(Foo(1, 2, 3)) == true + diff --git a/test/files/run/patmat-behavior-2.scala b/test/files/run/patmat-behavior-2.scala new file mode 100644 index 0000000000..b31f773772 --- /dev/null +++ b/test/files/run/patmat-behavior-2.scala @@ -0,0 +1,50 @@ +case class Foo(x: Int, ys: Int*) { + // We write our own toString because of SI-7735 + override def toString = (x +: ys).mkString("Foo(", ", ", ")") +} + +object Test { + def f1(x: Any) = x match { + case Foo(x) => true + case _ => false + } + def f2(x: Any) = x match { + case Foo(x, y) => true + case _ => false + } + def f3(x: Any) = x match { + case Foo(x, y, z) => true + case _ => false + } + def f1seq(x: Any) = x match { + case Foo(x, ys @ _*) => true + case _ => false + } + def f2seq(x: Any) = x match { + case Foo(x, y, zs @ _*) => true + case _ => false + } + def f3seq(x: Any) = x match { + case Foo(x, y, z, qs @ _*) => true + case _ => false + } + + val x1 = Foo(1) + val x2 = Foo(1, 2) + val x3 = Foo(1, 2, 3) + + val fs = List[Any => Boolean](f1, f2, f3) + val fseqs = List[Any => Boolean](f1seq, f2seq, f3seq) + val xs = List[Foo](x1, x2, x3) + + def main(args: Array[String]): Unit = { + for ((f, i) <- fs.zipWithIndex) { + xs foreach (x => println(s"f${i+1}($x) == ${f(x)}")) + println("") + } + for ((f, i) <- fseqs.zipWithIndex) { + xs foreach (x => println(s"f${i+1}seq($x) == ${f(x)}")) + println("") + } + } +} diff --git a/test/files/run/patmat-behavior.check b/test/files/run/patmat-behavior.check new file mode 100644 index 0000000000..273a1434fb --- /dev/null +++ b/test/files/run/patmat-behavior.check @@ -0,0 +1,90 @@ +patmat-behavior.scala:82: warning: fruitless type test: a value of type s.C00[A] cannot also be a s.C10[A] + def gd1[A](x: C00[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:82: warning: fruitless type test: a value of type s.C00[A] cannot also be a s.C20[A] + def gd1[A](x: C00[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:82: warning: fruitless type test: a value of type s.C00[A] cannot also be a s.C01[A] + def gd1[A](x: C00[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:82: warning: fruitless type test: a value of type s.C00[A] cannot also be a s.C11[A] + def gd1[A](x: C00[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:82: warning: fruitless type test: a value of type s.C00[A] cannot also be a s.C21[A] + def gd1[A](x: C00[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:83: warning: fruitless type test: a value of type s.C10[A] cannot also be a s.C00[A] + def gd2[A](x: C10[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:83: warning: fruitless type test: a value of type s.C10[A] cannot also be a s.C20[A] + def gd2[A](x: C10[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:83: warning: fruitless type test: a value of type s.C10[A] cannot also be a s.C01[A] + def gd2[A](x: C10[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:83: warning: fruitless type test: a value of type s.C10[A] cannot also be a s.C11[A] + def gd2[A](x: C10[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:83: warning: fruitless type test: a value of type s.C10[A] cannot also be a s.C21[A] + def gd2[A](x: C10[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:84: warning: fruitless type test: a value of type s.C20[A] cannot also be a s.C00[A] + def gd3[A](x: C20[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:84: warning: fruitless type test: a value of type s.C20[A] cannot also be a s.C10[A] + def gd3[A](x: C20[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:84: warning: fruitless type test: a value of type s.C20[A] cannot also be a s.C01[A] + def gd3[A](x: C20[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:84: warning: fruitless type test: a value of type s.C20[A] cannot also be a s.C11[A] + def gd3[A](x: C20[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:84: warning: fruitless type test: a value of type s.C20[A] cannot also be a s.C21[A] + def gd3[A](x: C20[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:85: warning: fruitless type test: a value of type s.C01[A] cannot also be a s.C00[A] + def gd4[A](x: C01[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:85: warning: fruitless type test: a value of type s.C01[A] cannot also be a s.C10[A] + def gd4[A](x: C01[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:85: warning: fruitless type test: a value of type s.C01[A] cannot also be a s.C20[A] + def gd4[A](x: C01[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:85: warning: fruitless type test: a value of type s.C01[A] cannot also be a s.C11[A] + def gd4[A](x: C01[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:85: warning: fruitless type test: a value of type s.C01[A] cannot also be a s.C21[A] + def gd4[A](x: C01[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:86: warning: fruitless type test: a value of type s.C11[A] cannot also be a s.C00[A] + def gd5[A](x: C11[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:86: warning: fruitless type test: a value of type s.C11[A] cannot also be a s.C10[A] + def gd5[A](x: C11[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:86: warning: fruitless type test: a value of type s.C11[A] cannot also be a s.C20[A] + def gd5[A](x: C11[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:86: warning: fruitless type test: a value of type s.C11[A] cannot also be a s.C01[A] + def gd5[A](x: C11[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:86: warning: fruitless type test: a value of type s.C11[A] cannot also be a s.C21[A] + def gd5[A](x: C11[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:87: warning: fruitless type test: a value of type s.C21[A] cannot also be a s.C00[A] + def gd6[A](x: C21[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:87: warning: fruitless type test: a value of type s.C21[A] cannot also be a s.C10[A] + def gd6[A](x: C21[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:87: warning: fruitless type test: a value of type s.C21[A] cannot also be a s.C20[A] + def gd6[A](x: C21[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:87: warning: fruitless type test: a value of type s.C21[A] cannot also be a s.C01[A] + def gd6[A](x: C21[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ +patmat-behavior.scala:87: warning: fruitless type test: a value of type s.C21[A] cannot also be a s.C11[A] + def gd6[A](x: C21[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + ^ diff --git a/test/files/run/patmat-behavior.scala b/test/files/run/patmat-behavior.scala new file mode 100644 index 0000000000..8b6370d796 --- /dev/null +++ b/test/files/run/patmat-behavior.scala @@ -0,0 +1,95 @@ +package s { + sealed trait C[+A] + + case class C00[+A]() extends C[A] + case class C10[+A](x: A) extends C[A] + case class C20[+A](x: A, y: A) extends C[A] + case class C01[+A](xs: A*) extends C[A] + case class C11[+A](x: A, ys: A*) extends C[A] + case class C21[+A](x: A, y: A, zs: A*) extends C[A] + + object E00 { def unapply[A](x: Any): Boolean = ??? } + object E10 { def unapply[A](x: Any): Option[A] = ??? } + object E20 { def unapply[A](x: Any): Option[(A, A)] = ??? } + object E01 { def unapplySeq[A](x: Any): Option[Seq[A]] = ??? } + object E11 { def unapplySeq[A](x: Any): Option[(A, Seq[A])] = ??? } + object E21 { def unapplySeq[A](x: Any): Option[(A, A, Seq[A])] = ??? } + + object F00 { def unapply[A](x: C[A]): Boolean = ??? } + object F10 { def unapply[A](x: C[A]): Option[A] = ??? } + object F20 { def unapply[A](x: C[A]): Option[(A, A)] = ??? } + object F01 { def unapplySeq[A](x: C[A]): Option[Seq[A]] = ??? } + object F11 { def unapplySeq[A](x: C[A]): Option[(A, Seq[A])] = ??? } + object F21 { def unapplySeq[A](x: C[A]): Option[(A, A, Seq[A])] = ??? } + + object G00 { def unapply[A](x: C00[A]): Boolean = ??? } + object G10 { def unapply[A](x: C10[A]): Option[A] = ??? } + object G20 { def unapply[A](x: C20[A]): Option[(A, A)] = ??? } + object G01 { def unapplySeq[A](x: C01[A]): Option[Seq[A]] = ??? } + object G11 { def unapplySeq[A](x: C11[A]): Option[(A, Seq[A])] = ??? } + object G21 { def unapplySeq[A](x: C21[A]): Option[(A, A, Seq[A])] = ??? } +} +import s._ + +package pos { + object Test { + def ga1(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } + def ga2(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } + def ga3(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } + def ga4(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } + def ga5(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } + def ga6(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } + + def gb1[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb2[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb3[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb4[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb5[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb6[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + + def gc1[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc2[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc3[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc4[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc5[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc6[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + + def gd1[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gd2[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gd3[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gd4[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gd5[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gd6[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + } +} + +package neg { + object Fail { + def gb1[A](x: C00[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb2[A](x: C10[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb3[A](x: C20[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb4[A](x: C01[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb5[A](x: C11[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + def gb6[A](x: C21[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs @ _*) => xs.head ; case E11(x, ys @ _*) => x ; case E21(x, y, zs @ _*) => x } + + def gc1[A](x: C00[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc2[A](x: C10[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc3[A](x: C20[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc4[A](x: C01[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc5[A](x: C11[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + def gc6[A](x: C21[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs @ _*) => xs.head ; case F11(x, ys @ _*) => x ; case F21(x, y, zs @ _*) => x } + + def gd1[A](x: C00[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + def gd2[A](x: C10[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + def gd3[A](x: C20[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + def gd4[A](x: C01[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + def gd5[A](x: C11[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + def gd6[A](x: C21[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs @ _*) => xs.head ; case G11(x, ys @ _*) => x ; case G21(x, y, zs @ _*) => x } + } +} + +object Test { + def main(args: Array[String]): Unit = { + + } +} diff --git a/test/files/run/patmat-bind-typed.check b/test/files/run/patmat-bind-typed.check new file mode 100644 index 0000000000..8baef1b4ab --- /dev/null +++ b/test/files/run/patmat-bind-typed.check @@ -0,0 +1 @@ +abc diff --git a/test/files/run/patmat-bind-typed.scala b/test/files/run/patmat-bind-typed.scala new file mode 100644 index 0000000000..10de921c51 --- /dev/null +++ b/test/files/run/patmat-bind-typed.scala @@ -0,0 +1,8 @@ +object Test { + def f(xs: List[Any]) = for (key @ (dummy: String) <- xs) yield key + + def main(args: Array[String]): Unit = { + f("abc" :: Nil) foreach println + f(5 :: Nil) foreach println + } +} diff --git a/test/files/run/patmat-exprs.scala b/test/files/run/patmat-exprs.scala index dfc78e2ca5..7ca5fd3063 100644 --- a/test/files/run/patmat-exprs.scala +++ b/test/files/run/patmat-exprs.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions } import runtime.ScalaRunTime object Test { @@ -37,7 +39,7 @@ trait Pattern { // // type Numeric[T] // import java.io.Serializable - // + // // implicit def compat27a[T](x: Iterable[T]) = new { // def iterator: Iterator[T] = x.elements // def sum: Int = 5 @@ -278,8 +280,8 @@ trait Pattern { case Mul(Mul(y, Const(z)), Const(x)) => Mul(const(num.mul(x, z)), y) case Const(x) if x == num.one => One[T] - case Const(x) if x == num.zero => Zero[T] - + case Const(x) if x == num.zero => Zero[T] + case Sub(x, Neg(y)) => Add(List(x, y)) case Sub(Neg(x), y) => Neg(Add(List(x, y))) case Neg(Neg(x)) => x @@ -576,4 +578,4 @@ trait Pattern { implicit def long2Constant[T](l: Long)(implicit num: NumericOps[T]): Leaf[T] = const(num.fromDouble(l.toDouble)) } -}
\ No newline at end of file +} diff --git a/test/files/run/patmat-finally.scala b/test/files/run/patmat-finally.scala index 6f769b30a0..dfea5ad176 100644 --- a/test/files/run/patmat-finally.scala +++ b/test/files/run/patmat-finally.scala @@ -21,5 +21,5 @@ object Test extends App { } bar(null, null) - x + x } diff --git a/test/files/run/patmat-seqs.scala b/test/files/run/patmat-seqs.scala index e23711697c..b5c47b4b4b 100644 --- a/test/files/run/patmat-seqs.scala +++ b/test/files/run/patmat-seqs.scala @@ -7,14 +7,14 @@ object Test { case Seq(_, _, _, _, _, x: String) => "ss6" case _ => "d" } - + def f2(x: Any) = x match { case Seq("a", "b", _*) => "s2" case Seq(1, _*) => "s1" case Seq(5, 6, 7, _*) => "s3" case _ => "d" } - + def main(args: Array[String]): Unit = { val xs1 = List( List(1,2,3), @@ -24,9 +24,9 @@ object Test { Seq(1, 2, 3, 4, 5, "abcd"), "abc" ) map f1 - + xs1 foreach println - + val xs2 = List( Seq(5, 6, 7), Seq(5, 6, 7, 8, 9), @@ -36,7 +36,7 @@ object Test { Nil, 5 ) map f2 - + xs2 foreach println } } diff --git a/test/files/run/patmat_unapp_abstype-new.check b/test/files/run/patmat_unapp_abstype-new.check index 42c54631d2..35447dbbfa 100644 --- a/test/files/run/patmat_unapp_abstype-new.check +++ b/test/files/run/patmat_unapp_abstype-new.check @@ -1,3 +1,9 @@ +patmat_unapp_abstype-new.scala:21: warning: abstract type pattern TypesUser.this.TypeRef is unchecked since it is eliminated by erasure + case TypeRef(x) => println("TypeRef") + ^ +patmat_unapp_abstype-new.scala:53: warning: abstract type pattern Intermed.this.Foo is unchecked since it is eliminated by erasure + case Foo(x) => println("Foo") + ^ TypeRef MethodType Bar diff --git a/test/files/run/patmat_unapp_abstype-new.scala b/test/files/run/patmat_unapp_abstype-new.scala index 1141177504..c2927bd124 100644 --- a/test/files/run/patmat_unapp_abstype-new.scala +++ b/test/files/run/patmat_unapp_abstype-new.scala @@ -18,7 +18,7 @@ trait TypesAPI { trait TypesUser extends TypesAPI { def shouldNotCrash(tp: Type): Unit = { tp match { - case TypeRef(x) => println("TypeRef") + case TypeRef(x) => println("TypeRef") case MethodType(x) => println("MethodType") case _ => println("none of the above") } @@ -27,7 +27,7 @@ trait TypesUser extends TypesAPI { trait TypesImpl extends TypesAPI { object TypeRef extends TypeRefExtractor // this will have a bridged unapply(x: Type) = unapply(x.asInstanceOf[TypeRef]) - case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef + case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef // --> the cast in the bridge will fail because the pattern matcher can't type test against the abstract types in TypesUser } diff --git a/test/files/run/patmat_unapp_abstype-old.check b/test/files/run/patmat_unapp_abstype-old.check deleted file mode 100644 index 72239d16cd..0000000000 --- a/test/files/run/patmat_unapp_abstype-old.check +++ /dev/null @@ -1,4 +0,0 @@ -TypeRef -none of the above -Bar -Foo diff --git a/test/files/run/patmat_unapp_abstype-old.flags b/test/files/run/patmat_unapp_abstype-old.flags deleted file mode 100644 index ba80cad69b..0000000000 --- a/test/files/run/patmat_unapp_abstype-old.flags +++ /dev/null @@ -1 +0,0 @@ --Xoldpatmat diff --git a/test/files/run/patmat_unapp_abstype-old.scala b/test/files/run/patmat_unapp_abstype-old.scala deleted file mode 100644 index 45496f08a2..0000000000 --- a/test/files/run/patmat_unapp_abstype-old.scala +++ /dev/null @@ -1,83 +0,0 @@ -// abstract types and extractors, oh my! -trait TypesAPI { - trait Type - - // an alternative fix (implemented in the virtual pattern matcher, is to replace the isInstanceOf by a manifest-based run-time test) - // that's what typeRefMani is for - type TypeRef <: Type //; implicit def typeRefMani: Manifest[TypeRef] - val TypeRef: TypeRefExtractor; trait TypeRefExtractor { - def apply(x: Int): TypeRef - def unapply(x: TypeRef): Option[(Int)] - } - - // just for illustration, should follow the same pattern as TypeRef - case class MethodType(n: Int) extends Type -} - -// user should not be exposed to the implementation -trait TypesUser extends TypesAPI { - def shouldNotCrash(tp: Type): Unit = { - tp match { - case TypeRef(x) => println("TypeRef") - // the above checks tp.isInstanceOf[TypeRef], which is erased to tp.isInstanceOf[Type] - // before calling TypeRef.unapply(tp), which will then crash unless tp.isInstanceOf[TypesImpl#TypeRef] (which is not implied by tp.isInstanceOf[Type]) - // tp.isInstanceOf[TypesImpl#TypeRef] is equivalent to classOf[TypesImpl#TypeRef].isAssignableFrom(tp.getClass) - // this is equivalent to manifest - // it is NOT equivalent to manifest[Type] <:< typeRefMani - case MethodType(x) => println("MethodType") - case _ => println("none of the above") - } - } -} - -trait TypesImpl extends TypesAPI { - object TypeRef extends TypeRefExtractor // this will have a bridged unapply(x: Type) = unapply(x.asInstanceOf[TypeRef]) - case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef - // --> the cast in the bridge will fail because the pattern matcher can't type test against the abstract types in TypesUser - //lazy val typeRefMani = manifest[TypeRef] -} - -trait Foos { - trait Bar - type Foo <: Bar - trait FooExtractor { - def unapply(foo: Foo): Option[Int] - } - val Foo: FooExtractor -} - -trait RealFoos extends Foos { - class Foo(val x: Int) extends Bar - object Foo extends FooExtractor { - def unapply(foo: Foo): Option[Int] = Some(foo.x) - } -} - -trait Intermed extends Foos { - def crash(bar: Bar): Unit = - bar match { - case Foo(x) => println("Foo") - case _ => println("Bar") - } -} - -object TestUnappStaticallyKnownSynthetic extends TypesImpl with TypesUser { - def test() = { - shouldNotCrash(TypeRef(10)) // should and does print "TypeRef" - // once #1697/#2337 are fixed, this should generate the correct output - shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher! - } -} - -object TestUnappDynamicSynth extends RealFoos with Intermed { - case class FooToo(n: Int) extends Bar - def test() = { - crash(FooToo(10)) - crash(new Foo(5)) - } -} - -object Test extends App { - TestUnappStaticallyKnownSynthetic.test() - TestUnappDynamicSynth.test() -} diff --git a/test/files/run/patmatnew.check b/test/files/run/patmatnew.check index e69de29bb2..56b8ac2f4f 100644 --- a/test/files/run/patmatnew.check +++ b/test/files/run/patmatnew.check @@ -0,0 +1,15 @@ +patmatnew.scala:351: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + case 1 => "OK" + ^ +patmatnew.scala:352: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + case 2 => assert(false); "KO" + ^ +patmatnew.scala:353: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + case 3 => assert(false); "KO" + ^ +patmatnew.scala:670: warning: This catches all Throwables. If this is really intended, use `case e : Throwable` to clear this warning. + case e => { + ^ +patmatnew.scala:489: warning: unreachable code + case _ if false => + ^ diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index a6f8199457..35b733d080 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -1,3 +1,6 @@ + +import scala.language.{ postfixOps } + object Test { def main(args: Array[String]) { @@ -251,7 +254,7 @@ object Test { } // (not regular) fancy guards / bug#644 - object TestSequence06 { + object TestSequence06 { case class A(i: Any) @@ -447,7 +450,7 @@ object Test { object Get extends Sync var ps: PartialFunction[Any, Any] = { - case Get(y) if y > 4 => // y gets a wildcard type for some reason?! hack + case Get(y) if y > 4 => // y gets a wildcard type for some reason?! hack } } def run() { diff --git a/test/files/run/pc-conversions.scala b/test/files/run/pc-conversions.scala index 60ee59c3c4..19fef355c8 100644 --- a/test/files/run/pc-conversions.scala +++ b/test/files/run/pc-conversions.scala @@ -1,15 +1,17 @@ - +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import collection._ // test conversions between collections object Test { - + def main(args: Array[String]) { testConversions } - + def testConversions { // seq conversions assertSeq(parallel.mutable.ParArray(1, 2, 3)) @@ -18,7 +20,7 @@ object Test { assertSeq(parallel.immutable.ParRange(1, 50, 1, false)) assertSeq(parallel.immutable.ParHashMap(1 -> 2, 2 -> 4)) assertSeq(parallel.immutable.ParHashSet(1, 2, 3)) - + // par conversions assertPar(Array(1, 2, 3)) assertPar(mutable.ArrayBuffer(1, 2, 3)) @@ -29,7 +31,7 @@ object Test { assertPar(immutable.Range(1, 50, 1)) assertPar(immutable.HashMap(1 -> 1, 2 -> 2)) assertPar(immutable.HashSet(1, 2, 3)) - + // par.to* and to*.par tests assertToPar(List(1 -> 1, 2 -> 2, 3 -> 3)) assertToPar(Stream(1 -> 1, 2 -> 2)) @@ -47,19 +49,19 @@ object Test { assertToPar(parallel.mutable.ParHashSet(1 -> 2)) assertToPar(parallel.immutable.ParHashMap(1 -> 2)) assertToPar(parallel.immutable.ParHashSet(1 -> 3)) - + assertToParWoMap(immutable.Range(1, 10, 2)) - + // seq and par again conversions) assertSeqPar(parallel.mutable.ParArray(1, 2, 3)) } - + def assertSeqPar[T](pc: parallel.ParIterable[T]) = pc.seq.par == pc - + def assertSeq[T](pc: parallel.ParIterable[T]) = assert(pc.seq == pc) - + def assertPar[T, P <: Parallel](xs: GenIterable[T]) = assert(xs == xs.par) - + def assertToPar[K, V](xs: GenTraversable[(K, V)]) { xs match { case _: Seq[_] => @@ -67,26 +69,26 @@ object Test { assert(xs.par.toIterable == xs) case _ => } - + assert(xs.toSeq.par == xs.toSeq) assert(xs.par.toSeq == xs.toSeq) - + assert(xs.toSet.par == xs.toSet) assert(xs.par.toSet == xs.toSet) - + assert(xs.toMap.par == xs.toMap) assert(xs.par.toMap == xs.toMap) } - + def assertToParWoMap[T](xs: GenSeq[T]) { assert(xs.toIterable.par == xs.toIterable) assert(xs.par.toIterable == xs.toIterable) - + assert(xs.toSeq.par == xs.toSeq) assert(xs.par.toSeq == xs.toSeq) - + assert(xs.toSet.par == xs.toSet) assert(xs.par.toSet == xs.toSet) } - + } diff --git a/test/files/run/pf-catch.scala b/test/files/run/pf-catch.scala index ba0781fe89..33982d0557 100644 --- a/test/files/run/pf-catch.scala +++ b/test/files/run/pf-catch.scala @@ -1,3 +1,5 @@ + +import scala.language.{ postfixOps } object Test { def shortName(x: AnyRef) = x.getClass.getName split '.' last type Handler[+T] = PartialFunction[Throwable, T] @@ -6,12 +8,12 @@ object Test { case x: java.util.NoSuchElementException => shortName(x) case x: java.lang.IllegalArgumentException => shortName(x) } - + def fn[T: Handler](body: => T): T = { try body catch implicitly[Handler[T]] } - + def f1 = { implicit val myHandler = standardHandler println(fn(Nil.head)) @@ -27,8 +29,8 @@ object Test { def main(args: Array[String]): Unit = { try f1 - catch { case x => println(shortName(x) + " slipped by.") } - + catch { case x: Throwable => println(shortName(x) + " slipped by.") } + f2 } } diff --git a/test/files/run/position-val-def.check b/test/files/run/position-val-def.check new file mode 100644 index 0000000000..a92c77c68c --- /dev/null +++ b/test/files/run/position-val-def.check @@ -0,0 +1,30 @@ +val x = 0 +[0:9]val x = [8:9]0 + +var x = 0 +[0:9]var x = [8:9]0 + +val x, y = 0 +[NoPosition]{ + [0:5]val x = [11]0; + [7:12]val y = [11:12]0; + [NoPosition]() +} + +var x, y = 0 +[NoPosition]{ + [0:5]var x = [11]0; + [7:12]var y = [11:12]0; + [NoPosition]() +} + +val (x, y) = 0 +[NoPosition]{ + <0:14><synthetic> <artifact> private[this] val x$1 = <4:14>[13:14][13:14]0: @[13]scala.unchecked match { + <4:10>case <4:10>[4]scala.Tuple2(<5:6>(x @ [5]_), <8:9>(y @ [8]_)) => <4:10><4:10>scala.Tuple2(<4:10>x, <4:10>y) + }; + [5:6]val x = [5]x$1._1; + [8:9]val y = [8]x$1._2; + [NoPosition]() +} + diff --git a/test/files/run/position-val-def.scala b/test/files/run/position-val-def.scala new file mode 100644 index 0000000000..62cb54acf8 --- /dev/null +++ b/test/files/run/position-val-def.scala @@ -0,0 +1,26 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test { + val toolbox = cm.mkToolBox(options = "-Yrangepos") + + def main(args: Array[String]) { + def test(expr: String) { + val t = toolbox.parse(expr) + println(expr) + println(show(t, printPositions = true)) + println() + } + val tests = """ + val x = 0 + var x = 0 + val x, y = 0 + var x, y = 0 + val (x, y) = 0 + """ + val exprs = tests.split("\\n").map(_.trim).filterNot(_.isEmpty) + exprs foreach test + } +} diff --git a/test/files/run/preinits.check b/test/files/run/preinits.check index 5584ab261e..e97a14b77f 100644 --- a/test/files/run/preinits.check +++ b/test/files/run/preinits.check @@ -1,3 +1,9 @@ +preinits.scala:2: warning: Implementation restriction: early definitions in traits are not initialized before the super class is initialized. +trait B extends { override val x = 1 } with A { println("B") } + ^ +preinits.scala:3: warning: Implementation restriction: early definitions in traits are not initialized before the super class is initialized. +trait C extends { override val x = 2 } with A + ^ A B 2 diff --git a/test/files/run/primitive-sigs-2-new.scala b/test/files/run/primitive-sigs-2-new.scala index cf6de9c81b..1f39667b18 100644 --- a/test/files/run/primitive-sigs-2-new.scala +++ b/test/files/run/primitive-sigs-2-new.scala @@ -1,3 +1,5 @@ + +import scala.language.{ postfixOps } import scala.reflect.{ClassTag, classTag} import java.{ lang => jl } @@ -29,4 +31,4 @@ object Test { println(new C f) c3m.sorted foreach println } -}
\ No newline at end of file +} diff --git a/test/files/run/primitive-sigs-2-old.scala b/test/files/run/primitive-sigs-2-old.scala index b7152f7e3d..16fe5ae555 100644 --- a/test/files/run/primitive-sigs-2-old.scala +++ b/test/files/run/primitive-sigs-2-old.scala @@ -1,3 +1,5 @@ + +import scala.language.{ postfixOps } import java.{ lang => jl } trait T[A] { @@ -25,7 +27,7 @@ object Test { val c1: Class[_] = classOf[T[_]] val c2: Class[_] = classOf[C] val c3: Class[_] = classOf[Arr] - + val c1m = c1.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString) val c2m = c2.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString) val c3m = c3.getDeclaredMethods.toList map (_.toGenericString) diff --git a/test/files/run/priorityQueue.scala b/test/files/run/priorityQueue.scala index edc0e32b02..327d8bf137 100644 --- a/test/files/run/priorityQueue.scala +++ b/test/files/run/priorityQueue.scala @@ -31,23 +31,23 @@ object Test { // val pq2 = new PriorityQueue[String] // val pq3 = new PriorityQueue[String] // val pq4 = new PriorityQueue[String] - + // val strings = (1 to 20).toList map (i => List.fill((Math.abs(nextInt % 20)) + 1)("x").mkString) - + // pq1 ++= strings // pq2 ++= strings.reverse // for (s <- strings) pq3 += s // for (s <- strings.reverse) pq4 += s - + // val pqs = List(pq1, pq2, pq3, pq4, pq1.clone, pq2.clone) - + // for (queue1 <- pqs ; queue2 <- pqs) { // val l1: List[String] = queue1.dequeueAll[String, List[String]] // val l2: List[String] = queue2.dequeueAll[String, List[String]] // assert(l1 == l2) // assert(queue1.max == queue2.max) // } - + // assertPriorityDestructive(pq1) // } @@ -83,7 +83,7 @@ object Test { // } // for (i <- 0 until 100) assert(intpq(i) == (99 - i)) // } - + // def testTails { // val pq = new PriorityQueue[Int] // for (i <- 0 until 10) pq += i * 4321 % 200 @@ -108,13 +108,13 @@ object Test { // prev = curr // } // } - + // def testInits { // val pq = new PriorityQueue[Long] // for (i <- 0 until 20) pq += (i + 313) * 111 % 300 - + // assert(pq.size == 20) - + // val initpq = pq.init // assert(initpq.size == 19) // assertPriorityDestructive(initpq) @@ -123,19 +123,19 @@ object Test { // def testFilters { // val pq = new PriorityQueue[String] // for (i <- 0 until 100) pq += "Some " + (i * 312 % 200) - + // val filpq = pq.filter(_.indexOf('0') != -1) // assertPriorityDestructive(filpq) // } // def testIntensiveEnqueueDequeue { // val pq = new PriorityQueue[Int] - + // testIntensive(1000, pq) // pq.clear // testIntensive(200, pq) // } - + // def testIntensive(sz: Int, pq: PriorityQueue[Int]) { // val lst = new collection.mutable.ArrayBuffer[Int] ++ (0 until sz) // val rand = new util.Random(7) @@ -153,7 +153,7 @@ object Test { // pq ++= (0 until 100) // val droppq = pq.drop(50) // assertPriority(droppq) - + // pq.clear // pq ++= droppq // assertPriorityDestructive(droppq) @@ -173,7 +173,7 @@ object Test { // // assertPriority(pq) // // pq.clear - + // // pq ++= (1 to 100) // // pq(5) = 200 // // assert(pq(0) == 200) @@ -204,7 +204,7 @@ object Test { // def testEquality { // val pq1 = new PriorityQueue[Int] // val pq2 = new PriorityQueue[Int] - + // pq1 ++= (0 until 50) // var i = 49 // while (i >= 0) { @@ -213,7 +213,7 @@ object Test { // } // assert(pq1 == pq2) // assertPriority(pq2) - + // pq1 += 100 // assert(pq1 != pq2) // pq2 += 100 @@ -230,7 +230,7 @@ object Test { // val pq = new PriorityQueue[Int] // pq ++= (0 until 100) // assert(pq.size == 100) - + // val (p1, p2) = pq.partition(_ < 50) // assertPriorityDestructive(p1) // assertPriorityDestructive(p2) @@ -252,13 +252,13 @@ object Test { // assert(pq.lastIndexWhere(_ == 9) == 0) // assert(pq.lastIndexOf(8) == 1) // assert(pq.lastIndexOf(7) == 2) - + // pq += 5 // pq += 9 // assert(pq.lastIndexOf(9) == 1) // assert(pq.lastIndexWhere(_ % 2 == 1) == 10) // assert(pq.lastIndexOf(5) == 6) - + // val lst = pq.reverseIterator.toList // for (i <- 0 until 5) assert(lst(i) == i) // assert(lst(5) == 5) @@ -268,13 +268,13 @@ object Test { // assert(lst(9) == 8) // assert(lst(10) == 9) // assert(lst(11) == 9) - + // pq.clear // assert(pq.reverseIterator.toList.isEmpty) - + // pq ++= (50 to 75) // assert(pq.lastIndexOf(70) == 5) - + // pq += 55 // pq += 70 // assert(pq.lastIndexOf(70) == 6) @@ -284,11 +284,11 @@ object Test { // assert(pq.lastIndexWhere(_ > 54, 21) == 21) // assert(pq.lastIndexWhere(_ > 69, 5) == 5) // } - + // def testReverse { // val pq = new PriorityQueue[(Int, Int)] // pq ++= (for (i <- 0 until 10) yield (i, i * i % 10)) - + // assert(pq.reverse.size == pq.reverseIterator.toList.size) // assert((pq.reverse zip pq.reverseIterator.toList).forall(p => p._1 == p._2)) // assert(pq.reverse.sameElements(pq.reverseIterator.toSeq)) @@ -296,19 +296,19 @@ object Test { // assert(pq.reverse(1)._1 == pq(8)._1) // assert(pq.reverse(4)._1 == pq(5)._1) // assert(pq.reverse(9)._1 == pq(0)._1) - + // pq += ((7, 7)) // pq += ((7, 9)) // pq += ((7, 8)) // assert(pq.reverse.reverse == pq) // assert(pq.reverse.lastIndexWhere(_._2 == 6) == 6) // assertPriorityDestructive(pq.reverse.reverse) - + // val iq = new PriorityQueue[Int] // iq ++= (0 until 50) // assert(iq.reverse == iq.reverseIterator.toSeq) // assert(iq.reverse.reverse == iq) - + // iq += 25 // iq += 40 // iq += 10 @@ -317,10 +317,10 @@ object Test { // assert(iq.reverse.lastIndexWhere(_ == 10) == 11) // assertPriorityDestructive(iq.reverse.reverse) // } - + // def testToList { // val pq = new PriorityQueue[Int] - + // pq += 1 // pq += 4 // pq += 0 @@ -330,16 +330,16 @@ object Test { // assert(pq.toList == pq) // assert(pq == List(5, 4, 3, 2, 1, 0)) // assert(pq.reverse == List(0, 1, 2, 3, 4, 5)) - + // pq.clear // for (i <- -50 until 50) pq += i // assert(pq.toList == pq) // assert(pq.toList == (-50 until 50).reverse) // } - + // def testForeach { // val pq = new PriorityQueue[Char] - + // pq += 't' // pq += 'o' // pq += 'b' @@ -351,7 +351,7 @@ object Test { // assert(sbf.toString == sbi.toString) // assert(sbf.toString == "ytob") // } - + } diff --git a/test/files/run/private-inline.check b/test/files/run/private-inline.check index 209e3ef4b6..3e44989521 100644 --- a/test/files/run/private-inline.check +++ b/test/files/run/private-inline.check @@ -1 +1,7 @@ +private-inline.scala:24: warning: Could not inline required method wrapper1 because callee contains exception handlers / finally clause, and is invoked with non-empty operand stack. + def f1b() = identity(wrapper1(5)) + ^ +private-inline.scala:29: warning: Could not inline required method wrapper2 because callee contains exception handlers / finally clause, and is invoked with non-empty operand stack. + def f2b() = identity(wrapper2(5)) + ^ 20 diff --git a/test/files/run/private-inline.flags b/test/files/run/private-inline.flags index eb4d19bcb9..00d3643fd4 100644 --- a/test/files/run/private-inline.flags +++ b/test/files/run/private-inline.flags @@ -1 +1 @@ --optimise
\ No newline at end of file +-optimise -Yinline-warnings diff --git a/test/files/run/private-inline.scala b/test/files/run/private-inline.scala index a62007779c..60fef9efca 100644 --- a/test/files/run/private-inline.scala +++ b/test/files/run/private-inline.scala @@ -2,7 +2,7 @@ final class A { private var x1 = false var x2 = false - + // manipulates private var @inline private def wrapper1[T](body: => T): T = { val saved = x1 @@ -17,35 +17,35 @@ final class A { try body finally x2 = saved } - + // not inlined def f1a() = wrapper1(5) // inlined! def f1b() = identity(wrapper1(5)) - + // not inlined def f2a() = wrapper2(5) // inlined! - def f2b() = identity(wrapper2(5)) + def f2b() = identity(wrapper2(5)) } object Test { def methodClasses = List("f1a", "f2a") map ("A$$anonfun$" + _ + "$1") - + def main(args: Array[String]): Unit = { val a = new A import a._ println(f1a() + f1b() + f2a() + f2b()) - + // Don't know how else to test this: all these should have been // inlined, so all should fail. methodClasses foreach { clazz => - + val foundClass = ( try Class.forName(clazz) - catch { case _ => null } + catch { case _: Throwable => null } ) - + assert(foundClass == null, foundClass) } } diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index bdf76ddce1..10d2ed5af7 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -1,31 +1,26 @@ - phase name id description - ---------- -- ----------- - parser 1 parse source into ASTs, perform simple desugaring - namer 2 resolve names, attach symbols to named trees - packageobjects 3 load package objects - typer 4 the meat and potatoes: type the trees - patmat 5 translate match expressions - superaccessors 6 add super accessors in traits and nested classes - extmethods 7 add extension methods for inline classes - pickler 8 serialize symbol tables - refchecks 9 reference/override checking, translate nested objects - uncurry 10 uncurry, translate function values to anonymous classes - tailcalls 11 replace tail calls by jumps - specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers, translate patterns - erasure 14 erase types, add interfaces for traits - posterasure 15 clean up erased inline classes - lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 17 move nested functions to top level - constructors 18 move field definitions into constructors - flatten 19 eliminate inner classes - mixin 20 mixin composition - cleanup 21 platform-specific cleanups, generate reflective calls - icode 22 generate portable intermediate code - inliner 23 optimization: do inlining -inlineExceptionHandlers 24 optimization: inline exception handlers - closelim 25 optimization: eliminate uncalled closures - dce 26 optimization: eliminate dead code - jvm 27 generate JVM bytecode - terminal 28 The last phase in the compiler chain - + phase name id description + ---------- -- ----------- + parser 1 parse source into ASTs, perform simple desugaring + namer 2 resolve names, attach symbols to named trees +packageobjects 3 load package objects + typer 4 the meat and potatoes: type the trees + patmat 5 translate match expressions +superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code + jvm 23 generate JVM bytecode + terminal 24 the last phase during a compilation run diff --git a/test/files/run/programmatic-main.scala b/test/files/run/programmatic-main.scala index 7bc5c5dfcf..542ac2781e 100644 --- a/test/files/run/programmatic-main.scala +++ b/test/files/run/programmatic-main.scala @@ -1,3 +1,5 @@ + +import scala.language.postfixOps import scala.tools.nsc._ import io.Path @@ -5,7 +7,7 @@ object Test { val cwd = Option(System.getProperty("partest.cwd")) getOrElse "." val basedir = Path(cwd).parent / "lib" path val baseargs = Array("-usejavacp", "-bootclasspath", basedir + "/scala-library.jar", "-cp", basedir + "/scala-compiler.jar") - + def main(args: Array[String]): Unit = { Console.withErr(Console.out) { Main process (baseargs ++ "-Xpluginsdir /does/not/exist/foo/quux -Xshow-phases".split(' ')) diff --git a/test/files/run/proxy.scala b/test/files/run/proxy.scala index ea222cb496..8a6385dc85 100644 --- a/test/files/run/proxy.scala +++ b/test/files/run/proxy.scala @@ -1,16 +1,16 @@ object Test extends App { val p = new Proxy { - def self = 2 + def self = 2 } println(p equals 1) println(p equals 2) println(p equals 3) println(p equals null) - + case class Bippy(a: String) extends Proxy { def self = a } - + val label = Bippy("bippy!") println(label == label) println(label == "bippy!") diff --git a/test/files/run/range-unit.scala b/test/files/run/range-unit.scala index ece0d9806c..d8ebc00e9c 100644 --- a/test/files/run/range-unit.scala +++ b/test/files/run/range-unit.scala @@ -6,14 +6,14 @@ object Test { ( (-3 to 3) ++ List(17, 127, Int.MaxValue, Int.MinValue + 1) ).distinct.sortBy(n => (math.abs(n), n)) ) :+ Int.MinValue - + // reducing output a little val endpoints = numbers filterNot Set(-3, -2, 2, 17, 127) - + def num(n: Int) = { val frommax = Int.MaxValue - n val frommin = Int.MinValue - n - + if (n > 0) { if (frommax == 0) "MAX" else if (frommax < 1000) "MAX-" + frommax @@ -25,7 +25,7 @@ object Test { else "" + n } } - + def run[T](body: => Range): List[Any] = { try { val r = body ; if (r.isEmpty) List(r.length) else List(num(r.length), num(r.head), num(r.last)) } catch { case e: IllegalArgumentException => List("---\n " + e) } diff --git a/test/files/run/range.scala b/test/files/run/range.scala index f08b2105d3..4637ab874d 100644 --- a/test/files/run/range.scala +++ b/test/files/run/range.scala @@ -6,7 +6,7 @@ object Test { range.foreach(buffer += _); assert(buffer.toList == range.iterator.toList, buffer.toList+"/"+range.iterator.toList) } - + def boundaryTests() = { // #4321 assert((Int.MinValue to Int.MaxValue by Int.MaxValue).size == 3) @@ -16,32 +16,43 @@ object Test { catch { case _: IllegalArgumentException => true } ) assert(caught) + // #7432 + val noElemAtMin = ( + try { (10 until 10).min ; false } + catch { case _: NoSuchElementException => true } + ) + assert(noElemAtMin) + val noElemAtMax = ( + try { (10 until 10).max ; false } + catch { case _: NoSuchElementException => true } + ) + assert(noElemAtMax) } - + case class GR[T](val x: T)(implicit val num: Integral[T]) { import num._ - + def negated = GR[T](-x) - + def gr1 = NumericRange(x, x, x) def gr2 = NumericRange.inclusive(x, x, x) def gr3 = NumericRange(x, x * fromInt(10), x) def gr4 = NumericRange.inclusive(x, x * fromInt(10), x) def gr5 = gr3.toList ::: negated.gr3.toList - + def check = { assert(gr1.isEmpty && !gr2.isEmpty) - assert(gr3.size == 9 && gr4.size == 10) + assert(gr3.size == 9 && gr4.size == 10) assert(gr5.sum == num.zero, gr5.toString) assert(!(gr3 contains (x * fromInt(10)))) assert((gr4 contains (x * fromInt(10)))) } } - + def main(args: Array[String]): Unit = { implicit val imp1 = Numeric.BigDecimalAsIfIntegral implicit val imp2 = Numeric.DoubleAsIfIntegral - + val _grs = List[GR[_]]( GR(BigDecimal(5.0)), GR(BigInt(5)), @@ -51,21 +62,21 @@ object Test { ) val grs = _grs ::: (_grs map (_.negated)) grs foreach (_.check) - + assert(NumericRange(1, 10, 1) sameElements (1 until 10)) assert(NumericRange.inclusive(1, 10, 1) sameElements (1 to 10)) assert(NumericRange.inclusive(1, 100, 3) sameElements (1 to 100 by 3)) - + // #2518 assert((3L to 7 by 2) sameElements List(3L, 5L, 7L)) - + rangeForeach(1 to 10); rangeForeach(1 until 10); rangeForeach(10 to 1 by -1); rangeForeach(10 until 1 by -1); rangeForeach(10 to 1 by -3); rangeForeach(10 until 1 by -3); - + // living on the edges boundaryTests() } diff --git a/test/files/run/records.scala b/test/files/run/records.scala index 96b0b4cb0f..f2b582b950 100644 --- a/test/files/run/records.scala +++ b/test/files/run/records.scala @@ -1,3 +1,6 @@ + +import scala.language.{ reflectiveCalls } + trait C { def f: Int } @@ -16,10 +19,10 @@ object Test { val y = new C { def f = 2 def g = " world" - } - + } + val z: T = y - + def main(args: Array[String]): Unit = { assert(x.f+z.f == 3) assert(x.g+z.g == "hello world") diff --git a/test/files/run/reflect-priv-ctor.check b/test/files/run/reflect-priv-ctor.check new file mode 100644 index 0000000000..a0fb1943b7 --- /dev/null +++ b/test/files/run/reflect-priv-ctor.check @@ -0,0 +1 @@ +privately constructed diff --git a/test/files/run/reflect-priv-ctor.scala b/test/files/run/reflect-priv-ctor.scala new file mode 100644 index 0000000000..9cb3e658cd --- /dev/null +++ b/test/files/run/reflect-priv-ctor.scala @@ -0,0 +1,22 @@ + +import language.postfixOps +import reflect.runtime._ +import universe._ + +object Test { + + class Foo private () { + override def toString = "privately constructed" + } + + def main(args: Array[String]): Unit = { + + //val foo = new Foo // no access + val klass = currentMirror reflectClass typeOf[Foo].typeSymbol.asClass + val init = typeOf[Foo].members find { case m: MethodSymbol => m.isConstructor case _ => false } get + val ctor = klass reflectConstructor init.asMethod + val foo = ctor() // no access? + Console println foo + } +} + diff --git a/test/files/run/reflection-allmirrors-tostring.scala b/test/files/run/reflection-allmirrors-tostring.scala index 73afff291c..41bab5ac0e 100644 --- a/test/files/run/reflection-allmirrors-tostring.scala +++ b/test/files/run/reflection-allmirrors-tostring.scala @@ -1,3 +1,5 @@ + +import scala.language.higherKinds import scala.reflect.runtime.universe._ class C { @@ -26,18 +28,18 @@ object Test extends App { println(cm.reflect(new C)) val im = cm.reflect(new C) - println(im.reflectField(typeOf[C].member(newTermName("f1")).asTerm)) - println(im.reflectField(typeOf[C].member(newTermName("f2")).asTerm)) - println(im.reflectMethod(typeOf[C].member(newTermName("m1")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m2")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m3")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m4")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m5")).asMethod)) - println(im.reflectClass(typeOf[C].member(newTypeName("C")).asClass)) - println(im.reflectModule(typeOf[C].member(newTermName("M")).asModule)) + println(im.reflectField(typeOf[C].member(TermName("f1")).asTerm)) + println(im.reflectField(typeOf[C].member(TermName("f2")).asTerm)) + println(im.reflectMethod(typeOf[C].member(TermName("m1")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m2")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m3")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m4")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m5")).asMethod)) + println(im.reflectClass(typeOf[C].member(TypeName("C")).asClass)) + println(im.reflectModule(typeOf[C].member(TermName("M")).asModule)) val c = cm.staticClass("C") - val cc = typeOf[C].member(newTypeName("C")).asClass + val cc = typeOf[C].member(TypeName("C")).asClass println(cm.reflectClass(c).reflectConstructor(c.typeSignature.member(nme.CONSTRUCTOR).asMethod)) println(im.reflectClass(cc).reflectConstructor(cc.typeSignature.member(nme.CONSTRUCTOR).asMethod)) -}
\ No newline at end of file +} diff --git a/test/files/run/reflection-enclosed-basic.scala b/test/files/run/reflection-enclosed-basic.scala index 1dcb6c2a27..7b9e0c20dc 100644 --- a/test/files/run/reflection-enclosed-basic.scala +++ b/test/files/run/reflection-enclosed-basic.scala @@ -12,7 +12,7 @@ private object B6 extends B2 { override def toString = "B6"; override def foo = object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } @@ -20,7 +20,7 @@ object Test extends App { def testNestedClass(name: String) = { val sym = cm.staticClass(name) println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) diff --git a/test/files/run/reflection-enclosed-inner-basic.scala b/test/files/run/reflection-enclosed-inner-basic.scala index 2b2c701993..c1cf9bc336 100644 --- a/test/files/run/reflection-enclosed-inner-basic.scala +++ b/test/files/run/reflection-enclosed-inner-basic.scala @@ -18,15 +18,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testInnerClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(new B).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -37,7 +37,7 @@ object Test extends App { testInnerClass("B2") def testInnerModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflect(new B).reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-inner-inner-basic.scala b/test/files/run/reflection-enclosed-inner-inner-basic.scala index 1b9e19d37d..8a73fac522 100644 --- a/test/files/run/reflection-enclosed-inner-inner-basic.scala +++ b/test/files/run/reflection-enclosed-inner-inner-basic.scala @@ -20,15 +20,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testInnerClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val outer1 = new B val outer2 = new outer1.BB val ctorMirror = cm.reflect(outer2).reflectClass(sym).reflectConstructor(ctor) @@ -41,7 +41,7 @@ object Test extends App { testInnerClass("B2") def testInnerModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val outer1 = new B val outer2 = new outer1.BB diff --git a/test/files/run/reflection-enclosed-inner-nested-basic.scala b/test/files/run/reflection-enclosed-inner-nested-basic.scala index 2800ee2548..6c2fc6df7a 100644 --- a/test/files/run/reflection-enclosed-inner-nested-basic.scala +++ b/test/files/run/reflection-enclosed-inner-nested-basic.scala @@ -21,15 +21,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testNestedClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(outer1.BB).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -40,7 +40,7 @@ object Test extends App { testNestedClass("B2") def testNestedModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflect(outer1.BB).reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-nested-basic.scala b/test/files/run/reflection-enclosed-nested-basic.scala index 8b740c2da2..180ac4ebee 100644 --- a/test/files/run/reflection-enclosed-nested-basic.scala +++ b/test/files/run/reflection-enclosed-nested-basic.scala @@ -18,15 +18,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testNestedClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -37,7 +37,7 @@ object Test extends App { testNestedClass("B2") def testNestedModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-nested-inner-basic.scala b/test/files/run/reflection-enclosed-nested-inner-basic.scala index 7466733d37..2558b8035a 100644 --- a/test/files/run/reflection-enclosed-nested-inner-basic.scala +++ b/test/files/run/reflection-enclosed-nested-inner-basic.scala @@ -20,15 +20,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testInnerClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(new B.BB).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -39,7 +39,7 @@ object Test extends App { testInnerClass("B2") def testInnerModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflect(new B.BB).reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-nested-nested-basic.scala b/test/files/run/reflection-enclosed-nested-nested-basic.scala index 8335ea482a..b4711c9a8c 100644 --- a/test/files/run/reflection-enclosed-nested-nested-basic.scala +++ b/test/files/run/reflection-enclosed-nested-nested-basic.scala @@ -20,15 +20,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testNestedClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -39,7 +39,7 @@ object Test extends App { testNestedClass("B2") def testNestedModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-equality.check b/test/files/run/reflection-equality.check index 65b525731f..3af3ad774d 100644 --- a/test/files/run/reflection-equality.check +++ b/test/files/run/reflection-equality.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> class X { def methodIntIntInt(x: Int, y: Int) = x+y } @@ -23,13 +21,13 @@ scala> val cs: ClassSymbol = im.symbol cs: reflect.runtime.universe.ClassSymbol = class X scala> val ts: Type = cs.typeSignature -ts: reflect.runtime.universe.Type = +ts: reflect.runtime.universe.Type = scala.AnyRef { def <init>(): X def methodIntIntInt(x: scala.Int,y: scala.Int): scala.Int } -scala> val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod +scala> val ms: MethodSymbol = ts.declaration(TermName("methodIntIntInt")).asMethod ms: reflect.runtime.universe.MethodSymbol = method methodIntIntInt scala> val MethodType( _, t1 ) = ms.typeSignature diff --git a/test/files/run/reflection-equality.scala b/test/files/run/reflection-equality.scala index 8fc82721e7..40f116bb53 100644 --- a/test/files/run/reflection-equality.scala +++ b/test/files/run/reflection-equality.scala @@ -11,7 +11,7 @@ object Test extends ReplTest { |def im: InstanceMirror = cm.reflect(new X) |val cs: ClassSymbol = im.symbol |val ts: Type = cs.typeSignature - |val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod + |val ms: MethodSymbol = ts.declaration(TermName("methodIntIntInt")).asMethod |val MethodType( _, t1 ) = ms.typeSignature |val t2 = typeOf[scala.Int] |t1 == t2 diff --git a/test/files/run/reflection-fieldmirror-accessorsareokay.scala b/test/files/run/reflection-fieldmirror-accessorsareokay.scala index 16354025f3..3926ab7835 100644 --- a/test/files/run/reflection-fieldmirror-accessorsareokay.scala +++ b/test/files/run/reflection-fieldmirror-accessorsareokay.scala @@ -24,6 +24,6 @@ object Test extends App { } } - test(cs.typeSignature.declaration(newTermName("x")).asTerm) - test(cs.typeSignature.declaration(newTermName("x_$eq")).asTerm) + test(cs.typeSignature.declaration(TermName("x")).asTerm) + test(cs.typeSignature.declaration(TermName("x_$eq")).asTerm) } diff --git a/test/files/run/reflection-fieldmirror-ctorparam.scala b/test/files/run/reflection-fieldmirror-ctorparam.scala index b9d50fe97b..608adad27b 100644 --- a/test/files/run/reflection-fieldmirror-ctorparam.scala +++ b/test/files/run/reflection-fieldmirror-ctorparam.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x")).asTerm + val f = cs.typeSignature.declaration(TermName("x")).asTerm try { val fm: FieldMirror = im.reflectField(f) println(fm.get) diff --git a/test/files/run/reflection-fieldmirror-getsetval.scala b/test/files/run/reflection-fieldmirror-getsetval.scala index 90221481d4..6a88dc3118 100644 --- a/test/files/run/reflection-fieldmirror-getsetval.scala +++ b/test/files/run/reflection-fieldmirror-getsetval.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm + val f = cs.typeSignature.declaration(TermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.get) fm.set(2) diff --git a/test/files/run/reflection-fieldmirror-getsetvar.scala b/test/files/run/reflection-fieldmirror-getsetvar.scala index abcf396dd1..52c13a73bb 100644 --- a/test/files/run/reflection-fieldmirror-getsetvar.scala +++ b/test/files/run/reflection-fieldmirror-getsetvar.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm + val f = cs.typeSignature.declaration(TermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.get) fm.set(2) diff --git a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala index 2b4a9bb55e..e070cdcfa3 100644 --- a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala +++ b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm + val f = cs.typeSignature.declaration(TermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.symbol.isVar) } diff --git a/test/files/run/reflection-fieldmirror-privatethis.scala b/test/files/run/reflection-fieldmirror-privatethis.scala index ab838dbb1b..89948772b1 100644 --- a/test/files/run/reflection-fieldmirror-privatethis.scala +++ b/test/files/run/reflection-fieldmirror-privatethis.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x")).asTerm + val f = cs.typeSignature.declaration(TermName("x")).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.symbol.isVar) println(fm.get) diff --git a/test/files/run/reflection-fieldsymbol-navigation.scala b/test/files/run/reflection-fieldsymbol-navigation.scala index 4448724988..33dc18a7e3 100644 --- a/test/files/run/reflection-fieldsymbol-navigation.scala +++ b/test/files/run/reflection-fieldsymbol-navigation.scala @@ -5,7 +5,7 @@ class C { } object Test extends App { - val x = typeOf[C].member(newTermName("x")).asTerm + val x = typeOf[C].member(TermName("x")).asTerm println(x) println(x.isVar) println(x.accessed) diff --git a/test/files/run/reflection-implClass.scala b/test/files/run/reflection-implClass.scala index b3c0081ccf..db211fd9a8 100644 --- a/test/files/run/reflection-implClass.scala +++ b/test/files/run/reflection-implClass.scala @@ -10,19 +10,19 @@ object Test extends App with Outer { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} - assert(cm.classSymbol(classTag[Foo].runtimeClass).typeSignature.declaration(newTermName("bar")).typeSignature == - cm.classSymbol(classTag[Bar].runtimeClass).typeSignature.declaration(newTermName("foo")).typeSignature) + assert(cm.classSymbol(classTag[Foo].runtimeClass).typeSignature.declaration(TermName("bar")).typeSignature == + cm.classSymbol(classTag[Bar].runtimeClass).typeSignature.declaration(TermName("foo")).typeSignature) val s1 = implClass(classTag[Foo].runtimeClass) assert(s1 != NoSymbol) assert(s1.typeSignature != NoType) assert(s1.companionSymbol.typeSignature != NoType) - assert(s1.companionSymbol.typeSignature.declaration(newTermName("bar")) != NoSymbol) + assert(s1.companionSymbol.typeSignature.declaration(TermName("bar")) != NoSymbol) val s2 = implClass(classTag[Bar].runtimeClass) assert(s2 != NoSymbol) assert(s2.typeSignature != NoType) assert(s2.companionSymbol.typeSignature != NoType) - assert(s2.companionSymbol.typeSignature.declaration(newTermName("foo")) != NoSymbol) + assert(s2.companionSymbol.typeSignature.declaration(TermName("foo")) != NoSymbol) def implClass(clazz: Class[_]) = { val implClass = Class.forName(clazz.getName + "$class") cm.classSymbol(implClass) diff --git a/test/files/run/reflection-implicit.scala b/test/files/run/reflection-implicit.scala index 0bcb0bc3a0..f2b3ba960c 100644 --- a/test/files/run/reflection-implicit.scala +++ b/test/files/run/reflection-implicit.scala @@ -1,3 +1,5 @@ + +import scala.language.implicitConversions import scala.reflect.runtime.universe._ class C { @@ -12,4 +14,4 @@ object Test extends App { val param = decls.find(_.name.toString == "d").get.asMethod.paramss.last.head param.typeSignature println(param.isImplicit) -}
\ No newline at end of file +} diff --git a/test/files/run/reflection-magicsymbols-invoke.scala b/test/files/run/reflection-magicsymbols-invoke.scala index 5f39370708..ff3992709f 100644 --- a/test/files/run/reflection-magicsymbols-invoke.scala +++ b/test/files/run/reflection-magicsymbols-invoke.scala @@ -28,7 +28,7 @@ object Test extends App { val ctor = tpe.declaration(nme.CONSTRUCTOR).asMethod cm.reflectClass(ctor.owner.asClass).reflectConstructor(ctor)(args: _*) } else { - val meth = tpe.declaration(newTermName(method).encodedName.toTermName).asMethod + val meth = tpe.declaration(TermName(method).encodedName.toTermName).asMethod cm.reflect(receiver).reflectMethod(meth)(args: _*) } }) @@ -54,7 +54,7 @@ object Test extends App { println("it's important to print the list of AnyVal's members") println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") typeOf[AnyVal].declarations.toList.sortBy(key).foreach(sym => println(key(sym))) - test(typeOf[AnyVal], null, "<init>") + test(typeOf[AnyVal], null, nme.CONSTRUCTOR.toString) test(typeOf[AnyVal], 2, "getClass") println("============\nAnyRef") diff --git a/test/files/run/reflection-magicsymbols-repl.check b/test/files/run/reflection-magicsymbols-repl.check index 2535e3f43d..46c21dfa00 100644 --- a/test/files/run/reflection-magicsymbols-repl.check +++ b/test/files/run/reflection-magicsymbols-repl.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ @@ -19,7 +17,7 @@ scala> class A { defined class A scala> def test(n: Int): Unit = { - val sig = typeOf[A] member newTermName("foo" + n) typeSignature + val sig = typeOf[A] member TermName("foo" + n) typeSignature val x = sig.asInstanceOf[MethodType].params.head println(x.typeSignature) } diff --git a/test/files/run/reflection-magicsymbols-repl.scala b/test/files/run/reflection-magicsymbols-repl.scala index 26127b8661..6a432c2664 100644 --- a/test/files/run/reflection-magicsymbols-repl.scala +++ b/test/files/run/reflection-magicsymbols-repl.scala @@ -14,7 +14,7 @@ object Test extends ReplTest { | def foo8(x: Singleton) = ??? |} |def test(n: Int): Unit = { - | val sig = typeOf[A] member newTermName("foo" + n) typeSignature + | val sig = typeOf[A] member TermName("foo" + n) typeSignature | val x = sig.asInstanceOf[MethodType].params.head | println(x.typeSignature) |} diff --git a/test/files/run/reflection-magicsymbols-vanilla.scala b/test/files/run/reflection-magicsymbols-vanilla.scala index 32819dcc46..2bde3d8874 100644 --- a/test/files/run/reflection-magicsymbols-vanilla.scala +++ b/test/files/run/reflection-magicsymbols-vanilla.scala @@ -1,3 +1,5 @@ +import scala.language.postfixOps + class A { def foo1(x: Int*) = ??? def foo2(x: => Int) = ??? @@ -12,7 +14,7 @@ class A { object Test extends App { import scala.reflect.runtime.universe._ def test(n: Int): Unit = { - val sig = typeOf[A] member newTermName("foo" + n) typeSignature + val sig = typeOf[A] member TermName("foo" + n) typeSignature val x = sig.asInstanceOf[MethodType].params.head println(x.typeSignature) } diff --git a/test/files/run/reflection-methodsymbol-params.scala b/test/files/run/reflection-methodsymbol-params.scala index 45b1f9628f..baad8d6b9b 100644 --- a/test/files/run/reflection-methodsymbol-params.scala +++ b/test/files/run/reflection-methodsymbol-params.scala @@ -13,12 +13,12 @@ class C { } object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.paramss) - println(typeOf[C].member(newTermName("x2")).asMethod.paramss) - println(typeOf[C].member(newTermName("x3")).asMethod.paramss) - println(typeOf[C].member(newTermName("x4")).asMethod.paramss) - println(typeOf[C].member(newTermName("y1")).asMethod.paramss) - println(typeOf[C].member(newTermName("y2")).asMethod.paramss) - println(typeOf[C].member(newTermName("y3")).asMethod.paramss) - println(typeOf[C].member(newTermName("y4")).asMethod.paramss) + println(typeOf[C].member(TermName("x1")).asMethod.paramss) + println(typeOf[C].member(TermName("x2")).asMethod.paramss) + println(typeOf[C].member(TermName("x3")).asMethod.paramss) + println(typeOf[C].member(TermName("x4")).asMethod.paramss) + println(typeOf[C].member(TermName("y1")).asMethod.paramss) + println(typeOf[C].member(TermName("y2")).asMethod.paramss) + println(typeOf[C].member(TermName("y3")).asMethod.paramss) + println(typeOf[C].member(TermName("y4")).asMethod.paramss) }
\ No newline at end of file diff --git a/test/files/run/reflection-methodsymbol-returntype.scala b/test/files/run/reflection-methodsymbol-returntype.scala index 392754dbe4..74a9e5dac0 100644 --- a/test/files/run/reflection-methodsymbol-returntype.scala +++ b/test/files/run/reflection-methodsymbol-returntype.scala @@ -13,12 +13,12 @@ class C { } object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.returnType) - println(typeOf[C].member(newTermName("x2")).asMethod.returnType) - println(typeOf[C].member(newTermName("x3")).asMethod.returnType) - println(typeOf[C].member(newTermName("x4")).asMethod.returnType) - println(typeOf[C].member(newTermName("y1")).asMethod.returnType) - println(typeOf[C].member(newTermName("y2")).asMethod.returnType) - println(typeOf[C].member(newTermName("y3")).asMethod.returnType) - println(typeOf[C].member(newTermName("y4")).asMethod.returnType) + println(typeOf[C].member(TermName("x1")).asMethod.returnType) + println(typeOf[C].member(TermName("x2")).asMethod.returnType) + println(typeOf[C].member(TermName("x3")).asMethod.returnType) + println(typeOf[C].member(TermName("x4")).asMethod.returnType) + println(typeOf[C].member(TermName("y1")).asMethod.returnType) + println(typeOf[C].member(TermName("y2")).asMethod.returnType) + println(typeOf[C].member(TermName("y3")).asMethod.returnType) + println(typeOf[C].member(TermName("y4")).asMethod.returnType) }
\ No newline at end of file diff --git a/test/files/run/reflection-methodsymbol-typeparams.scala b/test/files/run/reflection-methodsymbol-typeparams.scala index bb0a3c3aec..56d37ebeaa 100644 --- a/test/files/run/reflection-methodsymbol-typeparams.scala +++ b/test/files/run/reflection-methodsymbol-typeparams.scala @@ -13,12 +13,12 @@ class C { } object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.typeParams) - println(typeOf[C].member(newTermName("x2")).asMethod.typeParams) - println(typeOf[C].member(newTermName("x3")).asMethod.typeParams) - println(typeOf[C].member(newTermName("x4")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y1")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y2")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y3")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y4")).asMethod.typeParams) + println(typeOf[C].member(TermName("x1")).asMethod.typeParams) + println(typeOf[C].member(TermName("x2")).asMethod.typeParams) + println(typeOf[C].member(TermName("x3")).asMethod.typeParams) + println(typeOf[C].member(TermName("x4")).asMethod.typeParams) + println(typeOf[C].member(TermName("y1")).asMethod.typeParams) + println(typeOf[C].member(TermName("y2")).asMethod.typeParams) + println(typeOf[C].member(TermName("y3")).asMethod.typeParams) + println(typeOf[C].member(TermName("y4")).asMethod.typeParams) }
\ No newline at end of file diff --git a/test/files/run/reflection-repl-classes.check b/test/files/run/reflection-repl-classes.check index 2dd96a93bf..874fed2d7c 100644 --- a/test/files/run/reflection-repl-classes.check +++ b/test/files/run/reflection-repl-classes.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> class A defined class A @@ -19,10 +17,10 @@ scala> object defs { val cm = reflect.runtime.currentMirror val u = cm.universe val im = cm.reflect(new B) - val method = im.symbol.typeSignature.member(u.newTermName("foo")).asMethod + val method = im.symbol.typeSignature.member(u.TermName("foo")).asMethod val mm = im.reflectMethod(method) } -defined module defs +defined object defs scala> import defs._ import defs._ diff --git a/test/files/run/reflection-repl-classes.scala b/test/files/run/reflection-repl-classes.scala index 80e332cde3..4bfb980498 100644 --- a/test/files/run/reflection-repl-classes.scala +++ b/test/files/run/reflection-repl-classes.scala @@ -12,7 +12,7 @@ object Test extends ReplTest { | val cm = reflect.runtime.currentMirror | val u = cm.universe | val im = cm.reflect(new B) - | val method = im.symbol.typeSignature.member(u.newTermName("foo")).asMethod + | val method = im.symbol.typeSignature.member(u.TermName("foo")).asMethod | val mm = im.reflectMethod(method) |} |import defs._ diff --git a/test/files/run/reflection-repl-elementary.check b/test/files/run/reflection-repl-elementary.check index d9133f7e3e..4a223e8a24 100644 --- a/test/files/run/reflection-repl-elementary.check +++ b/test/files/run/reflection-repl-elementary.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> scala.reflect.runtime.universe.typeOf[List[Nothing]] res0: reflect.runtime.universe.Type = scala.List[Nothing] diff --git a/test/files/run/reflection-sanitychecks.scala b/test/files/run/reflection-sanitychecks.scala index f817f23731..6d3daff1f7 100644 --- a/test/files/run/reflection-sanitychecks.scala +++ b/test/files/run/reflection-sanitychecks.scala @@ -32,14 +32,14 @@ object Test extends App { def test(tpe: Type): Unit = { def failsafe(action: => Any): Any = try action catch { case ex: Throwable => ex.toString } println(s"=========members of ${tpe.typeSymbol.name} in a mirror of D=========") - println("field #1: " + failsafe(im.reflectField(tpe.member(newTermName("foo")).asTerm).get)) - println("method #1: " + failsafe(im.reflectMethod(tpe.member(newTermName("bar")).asMethod)())) - println("field #2: " + failsafe(im.reflectField(tpe.member(newTermName("quux")).asTerm).get)) - println("method #2: " + failsafe(im.reflectMethod(tpe.member(newTermName("baz")).asMethod)())) - println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("bar")).asMethod)())) - println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("<init>")).asMethod)())) - println("class: " + failsafe(im.reflectClass(tpe.member(newTypeName("C")).asClass).reflectConstructor(typeOf[C].member(newTypeName("C")).asClass.typeSignature.member(newTermName("<init>")).asMethod)())) - println("object: " + failsafe(im.reflectModule(tpe.member(newTermName("O")).asModule).instance)) + println("field #1: " + failsafe(im.reflectField(tpe.member(TermName("foo")).asTerm).get)) + println("method #1: " + failsafe(im.reflectMethod(tpe.member(TermName("bar")).asMethod)())) + println("field #2: " + failsafe(im.reflectField(tpe.member(TermName("quux")).asTerm).get)) + println("method #2: " + failsafe(im.reflectMethod(tpe.member(TermName("baz")).asMethod)())) + println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(TermName("bar")).asMethod)())) + println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(TermName("<init>")).asMethod)())) + println("class: " + failsafe(im.reflectClass(tpe.member(TypeName("C")).asClass).reflectConstructor(typeOf[C].member(TypeName("C")).asClass.typeSignature.member(nme.CONSTRUCTOR).asMethod)())) + println("object: " + failsafe(im.reflectModule(tpe.member(TermName("O")).asModule).instance)) println() } diff --git a/test/files/run/reflection-valueclasses-derived.scala b/test/files/run/reflection-valueclasses-derived.scala index 6b08f987ba..8d25e2929c 100644 --- a/test/files/run/reflection-valueclasses-derived.scala +++ b/test/files/run/reflection-valueclasses-derived.scala @@ -6,7 +6,7 @@ class C(val x: Int) extends AnyVal { } object Test extends App { - println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("foo")).asMethod)(2)) - println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("getClass")).asMethod)()) - println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("toString")).asMethod)()) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(TermName("foo")).asMethod)(2)) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(TermName("getClass")).asMethod)()) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(TermName("toString")).asMethod)()) }
\ No newline at end of file diff --git a/test/files/run/reflection-valueclasses-magic.scala b/test/files/run/reflection-valueclasses-magic.scala index c4a26e460a..33d4634397 100644 --- a/test/files/run/reflection-valueclasses-magic.scala +++ b/test/files/run/reflection-valueclasses-magic.scala @@ -44,7 +44,7 @@ object Test extends App { val realex = scala.ExceptionUtils.unwrapThrowable(ex) println(realex.getClass + ": " + realex.getMessage) } - val meth = tpe.declaration(newTermName(method).encodedName.toTermName) + val meth = tpe.declaration(TermName(method).encodedName.toTermName) val testees = if (meth.isMethod) List(meth.asMethod) else meth.asTerm.alternatives.map(_.asMethod) testees foreach (testee => { val convertedArgs = args.zipWithIndex.map { case (arg, i) => convert(arg, testee.paramss.flatten.apply(i).typeSignature) } diff --git a/test/files/run/reflection-valueclasses-standard.scala b/test/files/run/reflection-valueclasses-standard.scala index 18a3d1fa04..b6b5a2ede2 100644 --- a/test/files/run/reflection-valueclasses-standard.scala +++ b/test/files/run/reflection-valueclasses-standard.scala @@ -5,8 +5,8 @@ import scala.reflect.{ClassTag, classTag} object Test extends App { def test[T: ClassTag: TypeTag](x: T) = { println(s"========${classTag[T].runtimeClass}========") - println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("getClass")).asMethod)()) - println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("toString")).asMethod)()) + println(cm.reflect(x).reflectMethod(typeOf[T].member(TermName("getClass")).asMethod)()) + println(cm.reflect(x).reflectMethod(typeOf[T].member(TermName("toString")).asMethod)()) } test(2.toByte) diff --git a/test/files/run/reify-aliases.check b/test/files/run/reify-aliases.check index aa846b9bc6..da784227af 100644 --- a/test/files/run/reify-aliases.check +++ b/test/files/run/reify-aliases.check @@ -1 +1 @@ -TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()) +TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) diff --git a/test/files/run/reify-each-node-type.check b/test/files/run/reify-each-node-type.check new file mode 100644 index 0000000000..afc65add7a --- /dev/null +++ b/test/files/run/reify-each-node-type.check @@ -0,0 +1,35 @@ + 1 s Ident + 2 r.List Select + 3 r.List.apply() Apply + 4 r.List.apply(1) Literal + 5 r.List.apply[Int]() TypeApply + 6 (1: Int) Typed + 7 (null: r.List[Int]) AppliedTypeTree + 8 { (); () } Block + 9 { val x: Int = 0; () } ValDef +10 { val x = 0; () } TypeTree +11 if (true) () else () If +12 { def f: Unit = (); () } DefDef +13 { def m = NN.super.q; () } Super +14 { abstract trait A extends AnyRef; () } ClassDef Template +15 { def f(x: Any): Unit = (); () } EmptyTree +16 (null: r.D with r.E) CompoundTypeTree +17 { type T = Int; () } TypeDef +18 { type CC[T <: r.D] = r.C[T]; () } TypeBoundsTree +19 try { 0 } finally Predef.println("") Try +20 ((x: Int) => x) Function +21 { var v = 1; v = 2 } Assign +22 { class A extends AnyRef { def <init>() = { super.<init>(); This +23 new r.List[Int]() New +24 0: @unchecked Annotated +25 (null: r.Outer#Inner) SelectFromTypeTree +26 (null: Nil.type) SingletonTypeTree +27 (null: T forSome { type T }) ExistentialTypeTree +28 { import r.{A, B=>C}; () } Import +29 { def f: Int = return 0; () } Return +30 { object x extends AnyRef { def <init>() = { super.<init>(); ModuleDef +31 throw new Exception() Throw +32 0 match { case _ => 0 } Match CaseDef +33 0 match { case (1| 2) => 0 } Alternative +34 NN.q match { case (x @ r.List) => 0 } Bind +35 NN.q match { case r.UnSeq(1, (_)*) => 0 } Star diff --git a/test/files/run/reify-each-node-type.scala b/test/files/run/reify-each-node-type.scala new file mode 100644 index 0000000000..425061f955 --- /dev/null +++ b/test/files/run/reify-each-node-type.scala @@ -0,0 +1,110 @@ + +import scala.language.{ existentials, postfixOps } +import scala.reflect.runtime.universe._ + +object r { + class A + class B + class List[+A] + object List { def apply[A](xs: A*): List[A] = new List[A] } + object Nil extends List[Nothing] + + trait OuterP[A] { + trait Inner + trait InnerP[B] + } + trait Outer { + trait Inner + trait InnerP[B] + } + object Un { def unapply(x: Any) = Some(5) } + object UnSeq { def unapplySeq(x: Any) = Some(Seq(5)) } + class C[T] + class D + trait E + + trait SN { + def q: Any = null + } +} + +object s { + import r._ + + trait NN extends SN { + def act[T](expr: Expr[T]): Unit + + act(reify { s /* Ident */ }) + act(reify { r.List /* Select */ }) + act(reify { List() /* Apply */ }) + act(reify { List(1) /* Literal */ }) + act(reify { List[Int]() /* TypeApply */ }) + act(reify { 1: Int /* Typed */ }) + act(reify { null: List[Int] /* AppliedTypeTree */ }) + act(reify { () ; () /* Block */ }) + act(reify { val x: Int = 0 /* ValDef */ }) + act(reify { val x = 0 /* TypeTree */ }) + act(reify { if (true) () /* If */ }) + act(reify { def f { } /* DefDef */ }) + act(reify { def m = super.q /* Super */ }) + act(reify { trait A /* ClassDef Template */ }) + act(reify { def f(x: Any) { } /* EmptyTree */ }) + act(reify { null: D with E /* CompoundTypeTree */ }) + act(reify { type T = Int /* TypeDef */ }) + act(reify { type CC[T <: D] = C[T] /* TypeBoundsTree */ }) + act(reify { try 0 finally println("") /* Try */ }) + act(reify { (x: Int) => x /* Function */ }) + act(reify { var v = 1 ; v = 2 /* Assign */ }) + act(reify { class A() { def this(x: A) = this() } /* This */ }) + act(reify { new List[Int] /* New */ }) + act(reify { 0: @unchecked /* Annotated */ }) + act(reify { null: Outer#Inner /* SelectFromTypeTree */ }) + act(reify { null: Nil.type /* SingletonTypeTree */ }) + act(reify { null: (T forSome { type T }) /* ExistentialTypeTree */ }) + act(reify { import r.{ A, B => C }; /* Import */ }) + act(reify { def f: Int = return 0 /* Return */ }) + act(reify { object x /* ModuleDef */ }) + act(reify { throw new java.lang.Exception /* Throw */ }) + act(reify { 0 match { case _ => 0 } /* Match CaseDef */ }) + act(reify { 0 match { case 1 | 2 => 0 } /* Alternative */ }) + act(reify { q match { case x @ List => 0 } /* Bind */ }) + act(reify { q match { case UnSeq(1, _*) => 0 } /* Star */ }) + + // ``unexpected: bound type that doesn't have a tpe: Ident(newTypeName("Int"))'' + // act(reify { r.List[T forSome { type T <: Int }]() }) // Was crashing , no longer + // + // error: exception during macro expansion: + // scala.MatchError: collection.this.Seq.unapplySeq[A] (of class scala.reflect.internal.Trees$TypeApply) + // at scala.reflect.reify.phases.Reshape$$anon$1.extractExtractor$1(Reshape.scala:73) + // at scala.reflect.reify.phases.Reshape$$anon$1.transform(Reshape.scala:82) + // at scala.reflect.reify.phases.Reshape$$anon$1.transform(Reshape.scala:24) + // at scala.reflect.internal.Trees$class.itransform(Trees.scala:1290) + // + // act(reify { r.List[Any]() match { case Seq(1, _*) => 1 } } ) + + // act(reify { List[OuterP[Int]#InnerP[Byte]]() }) + // + // SI-7243 + // + // test/files/run/reify-each-node-type.scala:85: error: Cannot materialize r.List.apply[r.OuterP[Int]#InnerP[Byte]]() as { ... } because: + // scala.reflect.macros.TypecheckException: value TypeTreeWithDeferredRefCheck is not a member of type parameter U + // act(reify { List[OuterP[Int]#InnerP[Byte]]() }) + // ^ + // one error found + } +} + +object Test { + var idx = 0 + val seen = scala.collection.mutable.Set[String]() + + object N extends s.NN { + def act[T](expr: Expr[T]): Unit = { + idx += 1 + val ts = expr.tree filter (_ => true) map (_.getClass.getName split "[.$]" last) filterNot seen distinct; + println("%2d %60s %s".format(idx, expr.tree.toString.replaceAll("""\s+""", " ").take(60), ts mkString " ")) + seen ++= ts + } + } + def main(args: Array[String]): Unit = N +} diff --git a/test/files/run/reify-repl-fail-gracefully.check b/test/files/run/reify-repl-fail-gracefully.check index 1b0f3f2162..29ccee3cc6 100644 --- a/test/files/run/reify-repl-fail-gracefully.check +++ b/test/files/run/reify-repl-fail-gracefully.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> import language.experimental.macros import language.experimental.macros @@ -12,10 +10,8 @@ import scala.reflect.runtime.universe._ scala> scala> reify -<console>:12: error: macros cannot be partially applied +<console>:12: error: too few argument lists for macro invocation reify ^ scala> - -scala> diff --git a/test/files/run/reify_ann1a.check b/test/files/run/reify_ann1a.check index 99a966f38b..71841ff83b 100644 --- a/test/files/run/reify_ann1a.check +++ b/test/files/run/reify_ann1a.check @@ -1,5 +1,5 @@ { - @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T >: Nothing <: Any] extends AnyRef { + @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T] extends AnyRef { @new ann(List.apply("3a")) @new ann(List.apply("3b")) <paramaccessor> private[this] val x: T @ann(List.apply("4a")) @ann(List.apply("4b")) = _; def <init>(@new ann(List.apply("3a")) @new ann(List.apply("3b")) x: T @ann(List.apply("4a")) @ann(List.apply("4b"))) = { super.<init>(); diff --git a/test/files/run/reify_ann1b.check b/test/files/run/reify_ann1b.check index 6a5f32a492..a046dafeab 100644 --- a/test/files/run/reify_ann1b.check +++ b/test/files/run/reify_ann1b.check @@ -1,5 +1,10 @@ +reify_ann1b.scala:6: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class ann(bar: String) extends annotation.ClassfileAnnotation + ^ { - @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T >: Nothing <: Any] extends AnyRef { + @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T] extends AnyRef { @new ann(bar = "3a") @new ann(bar = "3b") <paramaccessor> private[this] val x: T @ann(bar = "4a") @ann(bar = "4b") = _; def <init>(@new ann(bar = "3a") @new ann(bar = "3b") x: T @ann(bar = "4a") @ann(bar = "4b")) = { super.<init>(); diff --git a/test/files/run/reify_ann2a.check b/test/files/run/reify_ann2a.check index ccbcb4c31e..a26fa42045 100644 --- a/test/files/run/reify_ann2a.check +++ b/test/files/run/reify_ann2a.check @@ -6,7 +6,7 @@ () } }; - @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T >: Nothing <: Any] extends AnyRef { + @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T] extends AnyRef { @new ann(List.apply("3a")) @new ann(List.apply("3b")) <paramaccessor> private[this] val x: T @ann(List.apply("4a")) @ann(List.apply("4b")) = _; def <init>(@new ann(List.apply("3a")) @new ann(List.apply("3b")) x: T @ann(List.apply("4a")) @ann(List.apply("4b"))) = { super.<init>(); diff --git a/test/files/run/reify_ann3.check b/test/files/run/reify_ann3.check index 8caceb2696..d4cf660758 100644 --- a/test/files/run/reify_ann3.check +++ b/test/files/run/reify_ann3.check @@ -1,5 +1,5 @@ { - class Tree[A >: Nothing <: Any, B >: Nothing <: Any] extends AnyRef { + class Tree[A, B] extends AnyRef { @new inline @getter() final <paramaccessor> val key: A = _; def <init>(key: A) = { super.<init>(); diff --git a/test/files/run/reify_classfileann_a.check b/test/files/run/reify_classfileann_a.check index 0c919020a8..51f255b232 100644 --- a/test/files/run/reify_classfileann_a.check +++ b/test/files/run/reify_classfileann_a.check @@ -1,3 +1,8 @@ +reify_classfileann_a.scala:6: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation + ^ { @new ann(bar = "1", quux = Array("2", "3"), baz = new ann(bar = "4")) class C extends AnyRef { def <init>() = { diff --git a/test/files/run/reify_classfileann_b.check b/test/files/run/reify_classfileann_b.check index c204fa8dc0..05f2e5bfc6 100644 --- a/test/files/run/reify_classfileann_b.check +++ b/test/files/run/reify_classfileann_b.check @@ -1,3 +1,8 @@ +reify_classfileann_b.scala:6: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends annotation.ClassfileAnnotation + ^ { class C extends AnyRef { def <init>() = { diff --git a/test/files/run/reify_closure8b.check b/test/files/run/reify_closure8b.check index 5a7863ff15..5d48d3ab36 100644 --- a/test/files/run/reify_closure8b.check +++ b/test/files/run/reify_closure8b.check @@ -1,3 +1,3 @@ -scala.tools.reflect.ToolBoxError: reflective compilation has failed: +scala.tools.reflect.ToolBoxError: reflective compilation has failed: value y is not a member of Test.Foo diff --git a/test/files/run/reify_copypaste1.scala b/test/files/run/reify_copypaste1.scala index c597b7af19..cf813182ae 100644 --- a/test/files/run/reify_copypaste1.scala +++ b/test/files/run/reify_copypaste1.scala @@ -9,10 +9,10 @@ object Test extends App { val output = new java.io.ByteArrayOutputStream() System.setOut(new java.io.PrintStream(output)) val toolBox = currentMirror.mkToolBox(options = "-Yreify-copypaste") - val reify = Select(Select(Select(Select(Ident(ScalaPackage), newTermName("reflect")), newTermName("runtime")), newTermName("universe")), newTermName("reify")) - val reifee = Block(List(ValDef(Modifiers(LAZY), newTermName("x"), TypeTree(), Apply(Ident(ListModule), List(Literal(Constant(1)), Literal(Constant(2)))))), Ident(newTermName("x"))) + val reify = Select(Select(Select(Select(Ident(ScalaPackage), TermName("reflect")), TermName("runtime")), TermName("universe")), TermName("reify")) + val reifee = Block(List(ValDef(Modifiers(LAZY), TermName("x"), TypeTree(), Apply(Ident(ListModule), List(Literal(Constant(1)), Literal(Constant(2)))))), Ident(TermName("x"))) toolBox.eval(Apply(reify, List(reifee))) - val Block(List(tpeCopypaste), exprCopypaste @ ModuleDef(_, _, Template(_, _, (_ :: stats) :+ expr))) = toolBox.parse(output.toString()) + val Block(List(tpeCopypaste, exprCopypaste @ ModuleDef(_, _, Template(_, _, (_ :: stats) :+ expr))), Literal(Constant(()))) = toolBox.parse(output.toString()) output.reset() toolBox.eval(Block(stats, expr)) stdout.println(output.toString) diff --git a/test/files/run/reify_extendbuiltins.scala b/test/files/run/reify_extendbuiltins.scala index a2d546579d..46d5b7e55e 100644 --- a/test/files/run/reify_extendbuiltins.scala +++ b/test/files/run/reify_extendbuiltins.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions, postfixOps } import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval @@ -12,4 +14,4 @@ object Test extends App { println("10! = " + (10!)) }.eval -}
\ No newline at end of file +} diff --git a/test/pending/run/reify_implicits-new.check b/test/files/run/reify_implicits-new.check index e3aeb20f6b..e3aeb20f6b 100644 --- a/test/pending/run/reify_implicits-new.check +++ b/test/files/run/reify_implicits-new.check diff --git a/test/pending/run/reify_implicits-new.scala b/test/files/run/reify_implicits-new.scala index 42a1deef26..1d90d907ea 100644 --- a/test/pending/run/reify_implicits-new.scala +++ b/test/files/run/reify_implicits-new.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions, reflectiveCalls } import scala.reflect.{ClassTag, classTag} import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval @@ -13,4 +15,4 @@ object Test extends App { val x = Array(2, 3, 1, 4) println("x = "+ x.sort((x: Int, y: Int) => x < y).toList) }.eval -}
\ No newline at end of file +} diff --git a/test/pending/run/reify_implicits-old.check b/test/files/run/reify_implicits-old.check index e3aeb20f6b..e3aeb20f6b 100644 --- a/test/pending/run/reify_implicits-old.check +++ b/test/files/run/reify_implicits-old.check diff --git a/test/pending/run/reify_implicits-old.scala b/test/files/run/reify_implicits-old.scala index 8ff256d2d4..a4e90488e5 100644 --- a/test/pending/run/reify_implicits-old.scala +++ b/test/files/run/reify_implicits-old.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions, reflectiveCalls } import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval @@ -12,4 +14,4 @@ object Test extends App { val x = Array(2, 3, 1, 4) println("x = "+ x.sort((x: Int, y: Int) => x < y).toList) }.eval -}
\ No newline at end of file +} diff --git a/test/files/run/reify_lazyevaluation.scala b/test/files/run/reify_lazyevaluation.scala index 5b310d95f7..3f2530ddee 100644 --- a/test/files/run/reify_lazyevaluation.scala +++ b/test/files/run/reify_lazyevaluation.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions } import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval diff --git a/test/files/run/reify_lazyunit.check b/test/files/run/reify_lazyunit.check index 1b46c909be..579ecfe8aa 100644 --- a/test/files/run/reify_lazyunit.check +++ b/test/files/run/reify_lazyunit.check @@ -1,3 +1,6 @@ +reify_lazyunit.scala:6: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + lazy val x = { 0; println("12")} + ^ 12 one two diff --git a/test/files/run/reify_newimpl_11.check b/test/files/run/reify_newimpl_11.check index 2f5cb581e6..c019c6db2d 100644 --- a/test/files/run/reify_newimpl_11.check +++ b/test/files/run/reify_newimpl_11.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_11.scala:6:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_11.scala:6:11 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_13.check b/test/files/run/reify_newimpl_13.check index d518cd7b84..13e3c9af1e 100644 --- a/test/files/run/reify_newimpl_13.check +++ b/test/files/run/reify_newimpl_13.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_13.scala:7:13). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_13.scala:7:13 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_19.check b/test/files/run/reify_newimpl_19.check index 8b8652f92c..c749d4f106 100644 --- a/test/files/run/reify_newimpl_19.check +++ b/test/files/run/reify_newimpl_19.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_19.scala:7:10). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_19.scala:7:10 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_22.check b/test/files/run/reify_newimpl_22.check index dcb3e2889b..1432d10127 100644 --- a/test/files/run/reify_newimpl_22.check +++ b/test/files/run/reify_newimpl_22.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ @@ -19,11 +17,9 @@ scala> { } println(code.eval) } -<console>:15: free term: Ident(newTermName("x")) defined by res0 in <console>:14:21 +<console>:15: free term: Ident(TermName("x")) defined by res0 in <console>:14:21 val code = reify { ^ 2 scala> - -scala> diff --git a/test/files/run/reify_newimpl_23.check b/test/files/run/reify_newimpl_23.check index 882124657e..217f0a98c7 100644 --- a/test/files/run/reify_newimpl_23.check +++ b/test/files/run/reify_newimpl_23.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ @@ -18,11 +16,9 @@ scala> def foo[T]{ } println(code.eval) } -<console>:13: free type: Ident(newTypeName("T")) defined by foo in <console>:12:16 +<console>:13: free type: Ident(TypeName("T")) defined by foo in <console>:12:16 val code = reify { ^ foo: [T]=> Unit scala> - -scala> diff --git a/test/files/run/reify_newimpl_25.check b/test/files/run/reify_newimpl_25.check index d1028b94c7..93ad69defa 100644 --- a/test/files/run/reify_newimpl_25.check +++ b/test/files/run/reify_newimpl_25.check @@ -1,19 +1,15 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> { import scala.reflect.runtime.universe._ val x = "2" val tt = implicitly[TypeTag[x.type]] println(tt) } -<console>:11: free term: Ident(newTermName("x")) defined by res0 in <console>:10:21 +<console>:11: free term: Ident(TermName("x")) defined by res0 in <console>:10:21 val tt = implicitly[TypeTag[x.type]] ^ TypeTag[x.type] scala> - -scala> diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check index 347f6365aa..8e0ad87bf2 100644 --- a/test/files/run/reify_newimpl_26.check +++ b/test/files/run/reify_newimpl_26.check @@ -1,14 +1,12 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> def foo[T]{ import scala.reflect.runtime.universe._ val tt = implicitly[WeakTypeTag[List[T]]] println(tt) } -<console>:9: free type: Ident(newTypeName("T")) defined by foo in <console>:7:16 +<console>:9: free type: Ident(TypeName("T")) defined by foo in <console>:7:16 val tt = implicitly[WeakTypeTag[List[T]]] ^ foo: [T]=> Unit @@ -17,5 +15,3 @@ scala> foo[Int] WeakTypeTag[scala.List[T]] scala> - -scala> diff --git a/test/files/run/reify_newimpl_30.check b/test/files/run/reify_newimpl_30.check index 29baac911e..7557c750a6 100644 --- a/test/files/run/reify_newimpl_30.check +++ b/test/files/run/reify_newimpl_30.check @@ -1,2 +1,4 @@ -reflective toolbox has failed: -unresolved free type variables (namely: C defined by <local Test> in reify_newimpl_30.scala:7:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +reflective toolbox failed due to unresolved free type variables: + C defined by <local Test> in reify_newimpl_30.scala:7:11 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_35.check b/test/files/run/reify_newimpl_35.check index 52aaa171e0..f884d2c0d0 100644 --- a/test/files/run/reify_newimpl_35.check +++ b/test/files/run/reify_newimpl_35.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ @@ -13,5 +11,3 @@ scala> println(foo) Expr[List[Nothing]](Nil) scala> - -scala> diff --git a/test/files/run/reify_printf.check b/test/files/run/reify_printf.check index e69de29bb2..3b18e512db 100644 --- a/test/files/run/reify_printf.check +++ b/test/files/run/reify_printf.check @@ -0,0 +1 @@ +hello world diff --git a/test/files/run/reify_printf.scala b/test/files/run/reify_printf.scala index 272856b962..c4ade79837 100644 --- a/test/files/run/reify_printf.scala +++ b/test/files/run/reify_printf.scala @@ -9,13 +9,13 @@ import scala.reflect.internal.Types import scala.util.matching.Regex object Test extends App { - val output = new ByteArrayOutputStream() - Console.setOut(new PrintStream(output)) + //val output = new ByteArrayOutputStream() + //Console.setOut(new PrintStream(output)) val toolbox = cm.mkToolBox() val tree = tree_printf(reify("hello %s").tree, reify("world").tree) val evaluated = toolbox.eval(tree) - assert(output.toString() == "hello world", output.toString() +" == hello world") + //assert(output.toString() == "hello world", output.toString() +" == hello world") /* // upd. Oh, good old times, our very-very first experiments with macros :) @@ -23,7 +23,7 @@ object Test extends App { */ var i = 0 - def gensym(name: String) = { i += 1; newTermName(name + i) } + def gensym(name: String) = { i += 1; TermName(name + i) } def createTempValDef( value : Tree, tpe : Type ) : (Option[Tree],Tree) = { val local = gensym("temp") @@ -59,13 +59,13 @@ object Test extends App { Apply( Select( Select( - Ident( newTermName("scala") ) - , newTermName("Predef") + Ident( TermName("scala") ) + , TermName("Predef") ) - , newTermName("print") + , TermName("print") ) , List(ref) ): Tree Block((evals ++ prints).toList, Literal(Constant(()))) } -}
\ No newline at end of file +} diff --git a/test/files/run/reify_this.scala b/test/files/run/reify_this.scala index ecbf394bba..c385da6360 100644 --- a/test/files/run/reify_this.scala +++ b/test/files/run/reify_this.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval -trait Eval { +trait Transvaal { def eval(tree: Expr[_]) = tree.eval } -object Test extends App with Eval { +object Test extends App with Transvaal { // select a value from package eval(reify{println("foo")}) eval(reify{println((new Object).toString == (new Object).toString)}) @@ -17,4 +17,4 @@ object Test extends App with Eval { // select a value from module val x = 2 eval(reify{println(x)}) -}
\ No newline at end of file +} diff --git a/test/files/run/repl-assign.check b/test/files/run/repl-assign.check index c6b0458f04..bdc7793c37 100644 --- a/test/files/run/repl-assign.check +++ b/test/files/run/repl-assign.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> var x = 10 x: Int = 10 @@ -16,5 +14,3 @@ scala> y = 13 y: Int = 13 scala> - -scala> diff --git a/test/files/run/repl-backticks.check b/test/files/run/repl-backticks.check deleted file mode 100644 index c0561abd7c..0000000000 --- a/test/files/run/repl-backticks.check +++ /dev/null @@ -1,2 +0,0 @@ -import java.lang.Thread.`yield` -import scala.`package`.Throwable diff --git a/test/files/run/repl-backticks.scala b/test/files/run/repl-backticks.scala deleted file mode 100644 index 5eaa1ec4c1..0000000000 --- a/test/files/run/repl-backticks.scala +++ /dev/null @@ -1,18 +0,0 @@ -import scala.tools.nsc._ - -object Test { - val testCode = <code> - import java.lang.Thread.`yield` - import scala.`package`.Throwable - - `yield` - </code>.text - - def main(args: Array[String]) = { - val settings = new Settings() - settings.classpath.value = System.getProperty("java.class.path") - val repl = new interpreter.IMain(settings) - repl.interpret(testCode) - } -} - diff --git a/test/files/run/repl-bare-expr.check b/test/files/run/repl-bare-expr.check index 8b6434e986..97ae208ff4 100644 --- a/test/files/run/repl-bare-expr.check +++ b/test/files/run/repl-bare-expr.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> 2 ; 3 <console>:7: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses 2 ;; @@ -31,7 +29,7 @@ scala> 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Mooo <console>:7: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { ^ -defined module Cow +defined object Cow defined class Moo bippy: Int res2: Int = 105 @@ -39,7 +37,7 @@ res2: Int = 105 scala> scala> object Bovine { var x: List[_] = null } ; case class Ruminant(x: Int) ; bippy * bippy * bippy -defined module Bovine +defined object Bovine defined class Ruminant res3: Int = 216 @@ -50,5 +48,3 @@ scala> Bovine.x res4: List[Any] = List(Ruminant(5), Cow, Moooooo) scala> - -scala> diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 0cb18e989a..1f6d3e2b39 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -1,14 +1,11 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> :type List[1, 2, 3] <console>:1: error: identifier expected but integer literal found. List[1, 2, 3] ^ - scala> :type List(1, 2, 3) List[Int] @@ -41,12 +38,11 @@ Int scala> :type protected lazy val f = 5 <console>:5: error: lazy value f cannot be accessed in object $iw Access to protected value f not permitted because - enclosing object $eval in package $line13 is not a subclass of + enclosing object $eval in package $line13 is not a subclass of object $iw where target is defined - lazy val $result = `f` + lazy val $result = f ^ - scala> :type def f = 5 => Int @@ -81,8 +77,8 @@ TypeRef( ) TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] - + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + ) args = List( TypeRef(TypeSymbol(final abstract class Int extends AnyVal)) @@ -103,7 +99,7 @@ PolyType( resultType = TypeRef( TypeSymbol( abstract trait Set[A] extends Iterable[A] with Set[A] with GenericSetTemplate[A,scala.collection.immutable.Set] with SetLike[A,scala.collection.immutable.Set[A]] with Parallelizable[A,scala.collection.parallel.immutable.ParSet[A]] - + ) args = List(TypeRef(TypeSymbol(abstract class Any extends ))) ) @@ -148,8 +144,8 @@ TypeRef( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] - + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + ) args = List( TypeRef( @@ -181,8 +177,8 @@ PolyType( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] - + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + ) args = List(TypeParamTypeRef(TypeParam(T <: AnyVal))) ) @@ -204,8 +200,8 @@ PolyType( params = List(TermSymbol(x: T), TermSymbol(y: List[U])) resultType = TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] - + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + ) args = List(TypeParamTypeRef(TypeParam(U >: T))) ) @@ -223,5 +219,3 @@ scala> :type println("side effect!") Unit scala> - -scala> diff --git a/test/files/run/repl-empty-package.check b/test/files/run/repl-empty-package.check new file mode 100644 index 0000000000..ecf79c2c6d --- /dev/null +++ b/test/files/run/repl-empty-package.check @@ -0,0 +1,7 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> println(Bippy.bippy) +bippy! + +scala> diff --git a/test/files/run/repl-empty-package/s_1.scala b/test/files/run/repl-empty-package/s_1.scala new file mode 100644 index 0000000000..b59d16b338 --- /dev/null +++ b/test/files/run/repl-empty-package/s_1.scala @@ -0,0 +1,3 @@ +object Bippy { + def bippy = "bippy!" +} diff --git a/test/files/run/repl-empty-package/s_2.scala b/test/files/run/repl-empty-package/s_2.scala new file mode 100644 index 0000000000..512e6dd382 --- /dev/null +++ b/test/files/run/repl-empty-package/s_2.scala @@ -0,0 +1,5 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = "println(Bippy.bippy)" +} diff --git a/test/files/run/repl-javap-app.check b/test/files/run/repl-javap-app.check new file mode 100644 index 0000000000..490860585c --- /dev/null +++ b/test/files/run/repl-javap-app.check @@ -0,0 +1,38 @@ +#partest java6 +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :javap -app MyApp$ +public final void delayedEndpoint$MyApp$1(); + Code: + Stack=2, Locals=1, Args_size=1 + 0: getstatic #61; //Field scala/Console$.MODULE$:Lscala/Console$; + 3: ldc #63; //String Hello, delayed world. + 5: invokevirtual #67; //Method scala/Console$.println:(Ljava/lang/Object;)V + 8: return + LocalVariableTable: + Start Length Slot Name Signature + 0 9 0 this LMyApp$; + +scala> +#partest !java6 +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :javap -app MyApp$ + public final void delayedEndpoint$MyApp$1(); + flags: ACC_PUBLIC, ACC_FINAL + Code: + stack=2, locals=1, args_size=1 + 0: getstatic #61 // Field scala/Console$.MODULE$:Lscala/Console$; + 3: ldc #63 // String Hello, delayed world. + 5: invokevirtual #67 // Method scala/Console$.println:(Ljava/lang/Object;)V + 8: return + LocalVariableTable: + Start Length Slot Name Signature + 0 9 0 this LMyApp$; + LineNumberTable: + line 5: 0 +} + +scala> diff --git a/test/files/run/repl-javap-app.scala b/test/files/run/repl-javap-app.scala new file mode 100644 index 0000000000..be04920be1 --- /dev/null +++ b/test/files/run/repl-javap-app.scala @@ -0,0 +1,10 @@ + +import scala.tools.partest.ReplTest + +object MyApp extends App { + Console println "Hello, delayed world." +} + +object Test extends ReplTest { + def code = ":javap -app MyApp$" +} diff --git a/test/files/run/repl-javap-def.scala b/test/files/run/repl-javap-def.scala new file mode 100644 index 0000000000..dbd769613a --- /dev/null +++ b/test/files/run/repl-javap-def.scala @@ -0,0 +1,17 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |def f = 7 + |:javap -public -raw f + """.stripMargin + + // it should find f wrapped in repl skins. replstiltskin. + override def yah(res: Seq[String]) = { + // replstiltskin: what be my name? + val keywords = List("public", "class", "line") + def isLineClass(s: String) = keywords forall (s contains _) + def filtered = res filter isLineClass + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap-fun.scala b/test/files/run/repl-javap-fun.scala new file mode 100644 index 0000000000..5c9a6b7691 --- /dev/null +++ b/test/files/run/repl-javap-fun.scala @@ -0,0 +1,16 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | List(1,2,3) filter (_ % 2 != 0) map (_ * 2) + |} + |:javap -fun Betty + """.stripMargin + + // two anonfuns of Betty + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class Betty") + 2 == filtered.size + } +} diff --git a/test/files/run/repl-javap-mem.scala b/test/files/run/repl-javap-mem.scala new file mode 100644 index 0000000000..8db30e835c --- /dev/null +++ b/test/files/run/repl-javap-mem.scala @@ -0,0 +1,19 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | val ds = List(1,2,3) filter (_ % 2 == 0) map (_ * 3) + | def m(vs: List[Int]) = vs filter (_ % 2 != 0) map (_ * 2) + |} + |:javap Betty#m + """.stripMargin + + // filter for requested method member + override def yah(res: Seq[String]) = { + // cheaply, methods end in arg list + val p = """.*m\(.*\);""".r + def filtered = res filter (_ match { case p() => true case _ => false }) + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap-memfun.scala b/test/files/run/repl-javap-memfun.scala new file mode 100644 index 0000000000..d2b4243c8b --- /dev/null +++ b/test/files/run/repl-javap-memfun.scala @@ -0,0 +1,18 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | List(1,2,3) count (_ % 2 != 0) + | def f = List(1,2,3) filter (_ % 2 != 0) map (_ * 2) + | def g = List(1,2,3) filter (_ % 2 == 0) map (_ * 3) map (_ + 1) + |} + |:javap -fun Betty#g + """.stripMargin + + // three anonfuns of Betty#g + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class Betty") + 3 == filtered.size + } +} diff --git a/test/files/run/repl-javap-more-fun.scala b/test/files/run/repl-javap-more-fun.scala new file mode 100644 index 0000000000..e603faf75a --- /dev/null +++ b/test/files/run/repl-javap-more-fun.scala @@ -0,0 +1,17 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | val ds = List(1,2,3) filter (_ % 2 == 0) map (_ * 3) + | def m(vs: List[Int]) = vs filter (_ % 2 != 0) map (_ * 2) + |} + |:javap -fun Betty + """.stripMargin + + // two anonfuns of Betty + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class Betty") + 4 == filtered.size + } +} diff --git a/test/files/run/repl-javap-outdir-funs/foo_1.scala b/test/files/run/repl-javap-outdir-funs/foo_1.scala new file mode 100644 index 0000000000..9b98e94733 --- /dev/null +++ b/test/files/run/repl-javap-outdir-funs/foo_1.scala @@ -0,0 +1,6 @@ + +package disktest + +class Foo { + def m(vs: List[Int]) = vs map (_ + 1) +} diff --git a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala new file mode 100644 index 0000000000..6c6fe2d515 --- /dev/null +++ b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala @@ -0,0 +1,17 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |:javap -fun disktest/Foo.class + """.stripMargin + + override def yah(res: Seq[String]) = + // It's currently unknown why this test fails on Avian with + // “Failed: No anonfuns found.”, skip it for now. See SI-7630. + if (scala.tools.partest.utils.Properties.isAvian) + true + else { + def filtered = res filter (_ contains "public final class disktest.Foo") + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap-outdir/foo_1.scala b/test/files/run/repl-javap-outdir/foo_1.scala new file mode 100644 index 0000000000..9b98e94733 --- /dev/null +++ b/test/files/run/repl-javap-outdir/foo_1.scala @@ -0,0 +1,6 @@ + +package disktest + +class Foo { + def m(vs: List[Int]) = vs map (_ + 1) +} diff --git a/test/files/run/repl-javap-outdir/run-repl_7.scala b/test/files/run/repl-javap-outdir/run-repl_7.scala new file mode 100644 index 0000000000..dc2c5719ff --- /dev/null +++ b/test/files/run/repl-javap-outdir/run-repl_7.scala @@ -0,0 +1,12 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |:javap disktest/Foo.class + """.stripMargin + + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public class disktest.Foo") + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap.scala b/test/files/run/repl-javap.scala new file mode 100644 index 0000000000..7a19852d4e --- /dev/null +++ b/test/files/run/repl-javap.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |case class Betty(i: Int) { def next = Betty(i+1) } + |:javap Betty + """.stripMargin + + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public class Betty") + 1 == filtered.size + } +} diff --git a/test/files/run/repl-out-dir.check b/test/files/run/repl-out-dir.check new file mode 100644 index 0000000000..3e51c63155 --- /dev/null +++ b/test/files/run/repl-out-dir.check @@ -0,0 +1,49 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> case class Bippy(x: Int) +defined class Bippy + +scala> val x = Bippy(1) +x: Bippy = Bippy(1) + +scala> $intp.showDirectory +repl-out-dir-run.obj + $line1 + $eval$.class + $eval.class + $line2 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$.class + $read$.class + $read.class + $line3 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$$iw$Bippy$.class + $read$$iw$$iw$Bippy.class + $read$$iw$.class + $read$.class + $read.class + $line4 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$.class + $read$.class + $read.class + $line5 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$.class + $read$.class + $read.class + $repl_$init.class + Test$.class + Test.class + +scala> diff --git a/test/files/run/repl-out-dir.scala b/test/files/run/repl-out-dir.scala new file mode 100644 index 0000000000..33c823aa2d --- /dev/null +++ b/test/files/run/repl-out-dir.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.ReplTest +import scala.tools.nsc.Settings + +object Test extends ReplTest { + override def extraSettings = s"-Yrepl-outdir ${testOutput.path}" + + def code = s""" +case class Bippy(x: Int) +val x = Bippy(1) +$$intp.showDirectory + """ + +} diff --git a/test/files/run/repl-paste-2.check b/test/files/run/repl-paste-2.check index 203b020f2c..ab3809a2e0 100644 --- a/test/files/run/repl-paste-2.check +++ b/test/files/run/repl-paste-2.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> scala> 999l // Detected repl transcript paste: ctrl-D to finish. @@ -31,7 +29,6 @@ res9: Int = 6 scala> x.length + res5 res10: Int = 12 - // Replaying 8 commands from transcript. scala> 999l diff --git a/test/files/run/repl-paste-3.check b/test/files/run/repl-paste-3.check index 2b4c941c33..8fae61792e 100644 --- a/test/files/run/repl-paste-3.check +++ b/test/files/run/repl-paste-3.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> println(3) 3 @@ -10,5 +8,3 @@ scala> List(1,2) res1: List[Int] = List(1, 2) scala> - -scala> diff --git a/test/files/run/repl-paste-4.pastie b/test/files/run/repl-paste-4.pastie new file mode 100644 index 0000000000..853a66f6a4 --- /dev/null +++ b/test/files/run/repl-paste-4.pastie @@ -0,0 +1,4 @@ + +// if we are truly companions, I can see your foo +class Foo { private val foo = 7 } +object Foo { def apply(f: Foo) = f.foo } diff --git a/test/files/run/repl-paste-4.scala b/test/files/run/repl-paste-4.scala new file mode 100644 index 0000000000..0060dc1ff6 --- /dev/null +++ b/test/files/run/repl-paste-4.scala @@ -0,0 +1,20 @@ + +import scala.tools.partest.SessionTest + +object Test extends SessionTest { + def session = +s"""|Type in expressions to have them evaluated. + |Type :help for more information. + | + |scala> :paste $pastie + |Pasting file $pastie... + |defined class Foo + |defined object Foo + | + |scala> Foo(new Foo) + |res0: Int = 7 + | + |scala> """ + def pastie = testPath changeExtension "pastie" +} + diff --git a/test/files/run/repl-paste-raw.pastie b/test/files/run/repl-paste-raw.pastie new file mode 100644 index 0000000000..f13b4bcf8b --- /dev/null +++ b/test/files/run/repl-paste-raw.pastie @@ -0,0 +1,8 @@ + +// a raw paste is not a script +// hence it can be packaged + +package brown_paper + +// these are a few of my favorite things +case class Gift (hasString: Boolean) diff --git a/test/files/run/repl-paste-raw.scala b/test/files/run/repl-paste-raw.scala new file mode 100644 index 0000000000..2953796f99 --- /dev/null +++ b/test/files/run/repl-paste-raw.scala @@ -0,0 +1,20 @@ + +import scala.tools.partest.SessionTest + +object Test extends SessionTest { + def session = +s"""|Type in expressions to have them evaluated. + |Type :help for more information. + | + |scala> :paste -raw $pastie + |Pasting file $pastie... + | + |scala> val favoriteThing = brown_paper.Gift(true) + |favoriteThing: brown_paper.Gift = Gift(true) + | + |scala> favoriteThing.hasString + |res0: Boolean = true + | + |scala> """ + def pastie = testPath changeExtension "pastie" +} diff --git a/test/files/run/repl-paste.check b/test/files/run/repl-paste.check index d3e171fbfb..97f177ddc4 100644 --- a/test/files/run/repl-paste.check +++ b/test/files/run/repl-paste.check @@ -17,11 +17,10 @@ object Dingus val x = (new Dingus).y - // Exiting paste mode, now interpreting. defined class Dingus -defined module Dingus +defined object Dingus x: Int = 110 scala> diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 9d63ecde94..d6a0d8c931 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -14,13 +14,14 @@ scala> global.emptyValDef // "it is imported twice in the same scope by ..." res0: $r.global.emptyValDef.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags +warning: there were 1 feature warning(s); re-run with -feature for details tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence res1: $r.global.Type = (i: Int)scala.util.Random scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl -m: $r.treedsl.global.Match = +m: $r.treedsl.global.Match = 10 match { case 5 => false case _ => true diff --git a/test/files/run/repl-reset.check b/test/files/run/repl-reset.check index 7256b851bb..c6e147977a 100644 --- a/test/files/run/repl-reset.check +++ b/test/files/run/repl-reset.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> val x1 = 1 x1: Int = 1 @@ -51,5 +49,3 @@ scala> { new BippyBungus ; x1 } res2: Int = 4 scala> - -scala> diff --git a/test/files/run/repl-save.check b/test/files/run/repl-save.check new file mode 100644 index 0000000000..5f928688d0 --- /dev/null +++ b/test/files/run/repl-save.check @@ -0,0 +1,3 @@ +val i = 7 +val j = 8 +i * j diff --git a/test/files/run/repl-save.scala b/test/files/run/repl-save.scala new file mode 100644 index 0000000000..4539790b1a --- /dev/null +++ b/test/files/run/repl-save.scala @@ -0,0 +1,25 @@ +import scala.tools.partest.SessionTest + +object Test extends SessionTest { + def session = +s"""|Type in expressions to have them evaluated. + |Type :help for more information. + | + |scala> val i = 7 + |i: Int = 7 + | + |scala> val j = 8 + |j: Int = 8 + | + |scala> i * j + |res0: Int = 56 + | + |scala> :save $saveto + | + |scala> """ + def saveto = testOutput / "session.repl" + override def show() = { + super.show() + Console print saveto.toFile.slurp + } +} diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check new file mode 100644 index 0000000000..2a143a1777 --- /dev/null +++ b/test/files/run/repl-term-macros.check @@ -0,0 +1,40 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> import scala.reflect.macros.Context +import scala.reflect.macros.Context + +scala> import language.experimental.macros +import language.experimental.macros + +scala> + +scala> def impl1(c: Context) = c.literalUnit +impl1: (c: scala.reflect.macros.Context)c.Expr[Unit] + +scala> def foo1 = macro impl1 +defined term macro foo1: Unit + +scala> foo1 + +scala> + +scala> def impl2(c: Context)() = c.literalUnit +impl2: (c: scala.reflect.macros.Context)()c.Expr[Unit] + +scala> def foo2() = macro impl2 +defined term macro foo2: ()Unit + +scala> foo2() + +scala> + +scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = c.literalUnit +impl3: (c: scala.reflect.macros.Context)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit] + +scala> def foo3(x: Int)(y: Int) = macro impl3 +defined term macro foo3: (x: Int)(y: Int)Unit + +scala> foo3(2)(3) + +scala> diff --git a/test/files/run/repl-term-macros.scala b/test/files/run/repl-term-macros.scala new file mode 100644 index 0000000000..f826259be9 --- /dev/null +++ b/test/files/run/repl-term-macros.scala @@ -0,0 +1,20 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + import scala.reflect.macros.Context +import language.experimental.macros + +def impl1(c: Context) = c.literalUnit +def foo1 = macro impl1 +foo1 + +def impl2(c: Context)() = c.literalUnit +def foo2() = macro impl2 +foo2() + +def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = c.literalUnit +def foo3(x: Int)(y: Int) = macro impl3 +foo3(2)(3) + """ +}
\ No newline at end of file diff --git a/test/files/run/repl-transcript.check b/test/files/run/repl-transcript.check index 6d22353882..49891af900 100644 --- a/test/files/run/repl-transcript.check +++ b/test/files/run/repl-transcript.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> scala> class Bippity // Detected repl transcript paste: ctrl-D to finish. @@ -19,7 +17,6 @@ scala> 1 to 100 map (_ + 1) res6: scala.collection.immutable.IndexedSeq[Int] = Vector(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101) scala> res6.sum + res5 - // Replaying 5 commands from transcript. scala> class Bippity diff --git a/test/files/run/repl-trim-stack-trace.scala b/test/files/run/repl-trim-stack-trace.scala new file mode 100644 index 0000000000..483659146a --- /dev/null +++ b/test/files/run/repl-trim-stack-trace.scala @@ -0,0 +1,45 @@ + +import scala.tools.partest.{ SessionTest, Welcoming } + +// SI-7740 +object Test extends SessionTest with Welcoming { + def session = +"""Welcome to Scala +Type in expressions to have them evaluated. +Type :help for more information. + +scala> def f = throw new Exception("Uh-oh") +f: Nothing + +scala> f +java.lang.Exception: Uh-oh + at .f(<console>:7) + ... 69 elided + +scala> def f = throw new Exception("") +f: Nothing + +scala> f +java.lang.Exception: + at .f(<console>:7) + ... 69 elided + +scala> def f = throw new Exception +f: Nothing + +scala> f +java.lang.Exception + at .f(<console>:7) + ... 69 elided + +scala> """ + + // normalize the "elided" lines because the frame count depends on test context + lazy val elided = """(\s+\.{3} )\d+( elided)""".r + override def normalize(line: String) = line match { + case welcome(w) => w + case elided(ellipsis, suffix) => s"$ellipsis???$suffix" + case s => s + } + override def expected = super.expected map normalize +} diff --git a/test/files/run/repl-type-verbose.check b/test/files/run/repl-type-verbose.check index 989c0735b0..e37754a060 100644 --- a/test/files/run/repl-type-verbose.check +++ b/test/files/run/repl-type-verbose.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> // verbose! scala> :type -v def f = 5 @@ -165,7 +163,7 @@ PolyType( normalize = TypeRef( TypeSymbol( abstract trait Ordering[T] extends Comparator[T] with PartialOrdering[T] with Serializable - + ) args = List(TypeParamTypeRef(TypeParam(T))) ) @@ -190,5 +188,3 @@ PolyType( ) scala> - -scala> diff --git a/test/files/run/resetattrs-this.scala b/test/files/run/resetattrs-this.scala index 12afa3d712..2a55437273 100644 --- a/test/files/run/resetattrs-this.scala +++ b/test/files/run/resetattrs-this.scala @@ -4,8 +4,8 @@ import scala.tools.reflect.ToolBox object Test extends App { val tb = cm.mkToolBox() - val tree = Select(This(cm.staticPackage("scala").moduleClass), newTermName("Predef")) + val tree = Select(This(cm.staticPackage("scala").moduleClass), TermName("Predef")) val ttree = tb.typeCheck(tree) val rttree = tb.resetAllAttrs(ttree) println(tb.eval(rttree) == Predef) -}
\ No newline at end of file +} diff --git a/test/files/run/richs.check b/test/files/run/richs.check index a970a814b1..02a98b376d 100644 --- a/test/files/run/richs.check +++ b/test/files/run/richs.check @@ -1,3 +1,4 @@ +warning: there were 2 deprecation warning(s); re-run with -deprecation for details RichCharTest1: true diff --git a/test/files/run/richs.scala b/test/files/run/richs.scala index 5ee573673d..4b5345757c 100644 --- a/test/files/run/richs.scala +++ b/test/files/run/richs.scala @@ -11,8 +11,8 @@ trait RichTest { val cn = this.getClass().getName() cn.substring(0, cn.length-1) } - def length[A](it: Iterator[A]) = it.toList length - def length[A](it: Iterable[A]) = it.toList length + def length[A](it: Iterator[A]) = it.toList.length + def length[A](it: Iterable[A]) = it.toList.length def run: Unit } object RichCharTest1 extends RichTest { diff --git a/test/files/run/run-bug4840.scala b/test/files/run/run-bug4840.scala index 5f98bc9f4b..dda280fd17 100644 --- a/test/files/run/run-bug4840.scala +++ b/test/files/run/run-bug4840.scala @@ -1,6 +1,6 @@ object Test { def g(x: Boolean): Option[String] = if (x) Some("booya") else None - + def f1() = { for (x <- g(true)) yield { g(false) match { @@ -9,11 +9,11 @@ object Test { } } } - + def f2() = { for (x <- g(true) ; y <- g(true) ; z <- g(true)) yield { for (x <- g(true) ; y <- g(true) ; z <- g(true)) yield { - g(true) map { _ => + g(true) map { _ => (null: Any) match { case Some(x: Int) => x case _ => 5 @@ -21,7 +21,7 @@ object Test { } } } - } + } def main(args: Array[String]): Unit = { println(f1()) diff --git a/test/files/run/runtime-richChar.scala b/test/files/run/runtime-richChar.scala index cf18a1d302..dceb70e74d 100644 --- a/test/files/run/runtime-richChar.scala +++ b/test/files/run/runtime-richChar.scala @@ -5,19 +5,19 @@ object Test extends App { else println(name + " failed: " + expected + " differs from " + got) } - + testSeq("'a' to 'c'", List('a', 'b', 'c'), 'a' to 'c') testSeq("'a' until 'c'", List('a', 'b'), 'a' until 'c') - + testSeq("'a' to 'b'", List('a', 'b'), 'a' to 'b') testSeq("'a' until 'b'", List('a'), 'a' until 'b') - + testSeq("'a' to 'a'", List('a'), 'a' to 'a') testSeq("'a' until 'a'", List(), 'a' until 'a') - + testSeq("'b' to 'a'", List(), 'b' to 'a') testSeq("'b' until 'a'", List(), 'b' until 'a') - + testSeq("'c' to 'a'", List(), 'c' to 'a') testSeq("'c' until 'a'", List(), 'c' until 'a') } diff --git a/test/files/run/runtime.check b/test/files/run/runtime.check index 990a087da0..d613c9bd42 100644 --- a/test/files/run/runtime.check +++ b/test/files/run/runtime.check @@ -1,3 +1,9 @@ +runtime.scala:141: warning: comparing values of types Null and Null using `eq' will always yield true + check(true , null eq null, null ne null); + ^ +runtime.scala:141: warning: comparing values of types Null and Null using `ne' will always yield false + check(true , null eq null, null ne null); + ^ <<< Test0 [false,true] [0,1,2] diff --git a/test/files/run/runtime.scala b/test/files/run/runtime.scala index 2dcb41fb50..89348b294d 100644 --- a/test/files/run/runtime.scala +++ b/test/files/run/runtime.scala @@ -125,7 +125,7 @@ object Test2Test { object Test3Test { - class Foo { override def equals(that: Any) = error("abort"); } + class Foo { override def equals(that: Any) = sys.error("abort"); } def check(expected: Boolean, actual1: Boolean, actual2: Boolean): Unit = Console.println( @@ -171,7 +171,7 @@ object Test { try { test; } catch { - case exception => { + case exception: Throwable => { //val name: String = Thread.currentThread().getName(); Console.print("Exception in thread \"" + name + "\" " + exception); Console.println; diff --git a/test/files/run/scan.scala b/test/files/run/scan.scala index f056c77ba1..47e0a7d976 100644 --- a/test/files/run/scan.scala +++ b/test/files/run/scan.scala @@ -6,17 +6,17 @@ object Test { def main(args: Array[String]) { val lst = List(1, 2, 3, 4, 5) - + assert(lst.scanLeft(0)(_ + _) == List(0, 1, 3, 6, 10, 15)) assert(lst.scanRight(0)(_ + _) == List(15, 14, 12, 9, 5, 0)) - + val emp = List[Int]() assert(emp.scanLeft(0)(_ + _) == List(0)) assert(emp.scanRight(0)(_ + _) == List(0)) - + val stream = Stream(1, 2, 3, 4, 5) assert(stream.scanLeft(0)(_ + _) == Stream(0, 1, 3, 6, 10, 15)) - + assert(Stream.from(1).scanLeft(0)(_ + _).take(5) == Stream(0, 1, 3, 6, 10)) } diff --git a/test/files/run/search.check b/test/files/run/search.check new file mode 100644 index 0000000000..a885696509 --- /dev/null +++ b/test/files/run/search.check @@ -0,0 +1,6 @@ +Found(2) +Found(4) +InsertionPoint(9) +Found(2) +Found(4) +InsertionPoint(9) diff --git a/test/files/run/search.scala b/test/files/run/search.scala new file mode 100644 index 0000000000..ed7fed54a7 --- /dev/null +++ b/test/files/run/search.scala @@ -0,0 +1,14 @@ +object Test extends App { + import scala.collection.{LinearSeq, IndexedSeq} + import scala.collection.Searching.search + + val ls = LinearSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13) + println(ls.search(3)) + println(ls.search(5, 3, 8)) + println(ls.search(12)) + + val is = IndexedSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13) + println(is.search(3)) + println(is.search(5, 3, 8)) + println(is.search(12)) +} diff --git a/test/files/run/seqlike-kmp.scala b/test/files/run/seqlike-kmp.scala index 514990cfa2..af39fda9af 100644 --- a/test/files/run/seqlike-kmp.scala +++ b/test/files/run/seqlike-kmp.scala @@ -2,7 +2,7 @@ object Test { val source = 0 to 99 val idxes = (-1 to 2) ++ (97 to 100) def str(xs: Seq[Int]) = xs.mkString("(", ", ", ")") - + def f(tgt: Seq[Int]) = { println("indexOfSlice") // the first index `>= from` such that... @@ -17,11 +17,11 @@ object Test { println(" %s with idx <= %d = %d".format(str(tgt), x, res)) } } - + def g(idx: Int, len: Int) = { f(source.slice(idx, idx + len)) } - + def main(args: Array[String]): Unit = { g(97, 1) g(97, 2) diff --git a/test/files/run/sequenceComparisons.scala b/test/files/run/sequenceComparisons.scala index 5d7958bc7e..613b37f45a 100644 --- a/test/files/run/sequenceComparisons.scala +++ b/test/files/run/sequenceComparisons.scala @@ -2,12 +2,12 @@ import scala.collection.{ mutable, immutable } import collection.{ Seq, Traversable } object Test { - // TODO: + // TODO: // // SeqProxy // SeqForwarder // the commented out ones in seqMakers - + val seqMakers = List[List[Int] => Seq[Int]]( // scala.Array(_: _*), mutable.ArrayBuffer(_: _*), @@ -23,13 +23,13 @@ object Test { immutable.Seq(_: _*), mutable.Seq(_: _*), immutable.Stack(_: _*), - // mutable.Stack(_: _*), + // mutable.Stack(_: _*), immutable.IndexedSeq(_: _*), // was Vector //mutable.Vector(_: _*), immutable.List(_: _*), immutable.Stream(_: _*) ) - + abstract class Data[T] { val seq: Seq[T] private def seqList = seq.toList @@ -45,50 +45,50 @@ object Test { } lazy val eqeq = Method(_ == _, (List(seqList), List(Nil, seqList drop 1, seqList ::: seqList)), "%s == %s") - + val startsWithInputs: Inputs lazy val startsWith = Method(_ startsWith _, startsWithInputs, "%s startsWith %s") - + val endsWithInputs: Inputs lazy val endsWith = Method(_ endsWith _, endsWithInputs, "%s endsWith %s") val indexOfSliceInputs: Inputs private def subseqTest(s1: Seq[T], s2: Seq[T]) = (s1 indexOfSlice s2) != -1 lazy val indexOfSlice = Method(subseqTest _, indexOfSliceInputs, "(%s indexOfSlice %s) != -1") - + val sameElementsInputs: Inputs lazy val sameElements = Method(_ sameElements _, sameElementsInputs, "%s sameElements %s") - + def methodList = List(eqeq, startsWith, endsWith, indexOfSlice, sameElements) } - + object test1 extends Data[Int] { val seq = List(1,2,3,4,5) - + val startsWithInputs = ( List(Nil, List(1), List(1,2), seq), List(List(1,2,3,4,6), seq ::: List(5), List(0)) ) - + val endsWithInputs = ( List(Nil, List(5), List(4,5), seq), List(0 :: seq, List(5,2,3,4,5), List(3,4), List(5,6)) ) - + val indexOfSliceInputs = ( List(Nil, List(1), List(3), List(5), List(1,2), List(2,3,4), List(4,5), seq), List(List(1,2,3,5), List(6), List(5,4,3,2,1), List(2,1)) ) - + val sameElementsInputs = ( List(List(1,2,3,4,5)), - List(Nil, List(1), List(1,2), List(2,3,4), List(2,3,4,5), List(2,3,4,5,1), List(1,2,3,5,4), seq reverse) + List(Nil, List(1), List(1,2), List(2,3,4), List(2,3,4,5), List(2,3,4,5,1), List(1,2,3,5,4), seq.reverse) ) } - + val failures = new mutable.ListBuffer[String] var testCount = 0 - + def assertOne(op1: Any, op2: Any, res: Boolean, str: String) { testCount += 1 val resStr = str.format(op1, op2) @@ -97,25 +97,25 @@ object Test { failures += ("FAIL: " + resStr) // assert(res, resStr) } - + def runSeqs() = { for (s1f <- seqMakers ; s2f <- seqMakers ; testData <- List(test1)) { import testData._ val scrut = s1f(seq) - + for (Method(f, (trueList, falseList), descr) <- methodList) { for (s <- trueList; rhs = s2f(s)) assertOne(scrut, rhs, f(scrut, rhs), descr) - + for (s <- falseList; rhs = s2f(s)) assertOne(scrut, rhs, !f(scrut, rhs), "!(" + descr + ")") } } } - + def main(args: Array[String]) { runSeqs() - + assert(failures.isEmpty, failures mkString "\n") } } diff --git a/test/files/run/serialize-stream.scala b/test/files/run/serialize-stream.scala index e424d5b629..3ab9f2df34 100644 --- a/test/files/run/serialize-stream.scala +++ b/test/files/run/serialize-stream.scala @@ -5,13 +5,13 @@ object Test { val bos = new java.io.ByteArrayOutputStream() val oos = new java.io.ObjectOutputStream(bos) oos.writeObject(s) - + val ois = new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(bos.toByteArray)) val obj = ois.readObject() println(obj) println(obj.asInstanceOf[Seq[T]].toList) } - + def main(args: Array[String]) { ser(Stream(1, 2, 3)) ser(Stream(1)) diff --git a/test/files/run/settings-parse.check b/test/files/run/settings-parse.check new file mode 100644 index 0000000000..18145c9100 --- /dev/null +++ b/test/files/run/settings-parse.check @@ -0,0 +1,566 @@ +0) List(-cp, ) ==> Settings { + -d = . + -classpath = "" +} + +1) List(-cp, , ) ==> Settings { + -d = . + -classpath = "" +} + +2) List(, -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +3) List(-cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +4) List(-cp, , , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +5) List(-cp, , -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +6) List(, -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +7) List(-cp, , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +8) List(-cp, , , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +9) List(-cp, , -deprecation, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +10) List(-cp, , -deprecation, foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +11) List(, -cp, , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +12) List(-cp, , foo.scala) ==> Settings { + -d = . + -classpath = "" +} + +13) List(-cp, , , foo.scala) ==> Settings { + -d = . + -classpath = "" +} + +14) List(-cp, , foo.scala, ) ==> Settings { + -d = . + -classpath = "" +} + +15) List(, -cp, , foo.scala) ==> Settings { + -d = . + -classpath = "" +} + +16) List(-cp, , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +17) List(-cp, , , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +18) List(-cp, , foo.scala, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +19) List(-cp, , foo.scala, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +20) List(, -cp, , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +21) List(-deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +22) List(, -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +23) List(-deprecation, -cp, , ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +24) List(-deprecation, , -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +25) List(-deprecation, -cp, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +26) List(, -deprecation, -cp, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +27) List(-deprecation, -cp, , , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +28) List(-deprecation, -cp, , foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +29) List(-deprecation, , -cp, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +30) List(-deprecation, foo.scala, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +31) List(, -deprecation, foo.scala, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +32) List(-deprecation, , foo.scala, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +33) List(-deprecation, foo.scala, -cp, , ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +34) List(-deprecation, foo.scala, , -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +35) List(foo.scala, -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +36) List(, foo.scala, -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +37) List(foo.scala, -cp, , ) ==> Settings { + -d = . + -classpath = "" +} + +38) List(foo.scala, , -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +39) List(foo.scala, -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +40) List(, foo.scala, -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +41) List(foo.scala, -cp, , , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +42) List(foo.scala, -cp, , -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +43) List(foo.scala, , -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +44) List(foo.scala, -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +45) List(, foo.scala, -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +46) List(foo.scala, , -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +47) List(foo.scala, -deprecation, -cp, , ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +48) List(foo.scala, -deprecation, , -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +0) List(-cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +1) List(-cp, /tmp:/bippy, ) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +2) List(, -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +3) List(-cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +4) List(-cp, /tmp:/bippy, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +5) List(-cp, /tmp:/bippy, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +6) List(, -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +7) List(-cp, /tmp:/bippy, -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +8) List(-cp, /tmp:/bippy, , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +9) List(-cp, /tmp:/bippy, -deprecation, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +10) List(-cp, /tmp:/bippy, -deprecation, foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +11) List(, -cp, /tmp:/bippy, -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +12) List(-cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +13) List(-cp, /tmp:/bippy, , foo.scala) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +14) List(-cp, /tmp:/bippy, foo.scala, ) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +15) List(, -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +16) List(-cp, /tmp:/bippy, foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +17) List(-cp, /tmp:/bippy, , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +18) List(-cp, /tmp:/bippy, foo.scala, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +19) List(-cp, /tmp:/bippy, foo.scala, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +20) List(, -cp, /tmp:/bippy, foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +21) List(-deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +22) List(, -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +23) List(-deprecation, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +24) List(-deprecation, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +25) List(-deprecation, -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +26) List(, -deprecation, -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +27) List(-deprecation, -cp, /tmp:/bippy, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +28) List(-deprecation, -cp, /tmp:/bippy, foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +29) List(-deprecation, , -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +30) List(-deprecation, foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +31) List(, -deprecation, foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +32) List(-deprecation, , foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +33) List(-deprecation, foo.scala, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +34) List(-deprecation, foo.scala, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +35) List(foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +36) List(, foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +37) List(foo.scala, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +38) List(foo.scala, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +39) List(foo.scala, -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +40) List(, foo.scala, -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +41) List(foo.scala, -cp, /tmp:/bippy, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +42) List(foo.scala, -cp, /tmp:/bippy, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +43) List(foo.scala, , -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +44) List(foo.scala, -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +45) List(, foo.scala, -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +46) List(foo.scala, , -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +47) List(foo.scala, -deprecation, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +48) List(foo.scala, -deprecation, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + diff --git a/test/files/run/settings-parse.scala b/test/files/run/settings-parse.scala new file mode 100644 index 0000000000..2754feb972 --- /dev/null +++ b/test/files/run/settings-parse.scala @@ -0,0 +1,29 @@ + +import scala.language.postfixOps +import scala.tools.nsc._ + +object Test { + val tokens = List("", "-deprecation", "foo.scala") + val subsets = tokens.toSet.subsets.toList + val permutations0 = subsets.flatMap(_.toList.permutations).distinct + + def runWithCp(cp: String) = { + val permutations = permutations0 flatMap ("-cp CPTOKEN" :: _ permutations) + + for ((p, i) <- permutations.distinct.sortBy(_ mkString "").zipWithIndex) { + val args = p flatMap (_ split "\\s+") map (x => if (x == "CPTOKEN") cp else x) + val s = new settings.MutableSettings(println) + val (ok, residual) = s.processArguments(args, processAll = true) + + val expected = args filter (_ == "foo.scala") + assert(residual == expected, residual) + assert(ok, args) + println(s"$i) $args ==> $s") + } + } + + def main(args0: Array[String]): Unit = { + runWithCp("") + runWithCp("/tmp:/bippy") + } +} diff --git a/test/files/run/shortClass.check b/test/files/run/shortClass.check new file mode 100644 index 0000000000..fbdb725cca --- /dev/null +++ b/test/files/run/shortClass.check @@ -0,0 +1,10 @@ +bippity.bop.Foo +bippity.bop.Foo$Bar +bippity.bop.Foo$Bar$ +Test$$anon$1 +Test$$anon$2 +Foo +Bar +Bar$ +Foo with DingDongBippy +Bar with DingDongBippy diff --git a/test/files/run/shortClass.scala b/test/files/run/shortClass.scala new file mode 100644 index 0000000000..b7bb016896 --- /dev/null +++ b/test/files/run/shortClass.scala @@ -0,0 +1,24 @@ +import scala.reflect.internal.util._ + +package bippity { + trait DingDongBippy + + package bop { + class Foo { + class Bar + object Bar + } + } +} + +object Test { + import bippity._ + import bop._ + + def main(args: Array[String]): Unit = { + val f = new Foo + val instances = List(f, new f.Bar, f.Bar, new Foo with DingDongBippy, new f.Bar with DingDongBippy) + instances map (_.getClass.getName) foreach println + instances map shortClassOfInstance foreach println + } +} diff --git a/test/files/run/showraw_aliases.check b/test/files/run/showraw_aliases.check index aebd354031..d6a198b1cb 100644 --- a/test/files/run/showraw_aliases.check +++ b/test/files/run/showraw_aliases.check @@ -1,2 +1,2 @@ -Block(List(Import(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), List(ImportSelector(newTermName("universe"), <offset>, newTermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), scala.reflect.runtime.package), [newTermName("universe") aka newTermName("ru")])) -Block(List(Import(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), List(ImportSelector(newTermName("universe"), <offset>, newTermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), scala.reflect.runtime.package#<id>), [newTermName("universe")#<id> aka newTermName("ru")])) +Block(List(Import(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), List(ImportSelector(TermName("universe"), <offset>, TermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), scala.reflect.runtime.package), [TermName("universe") aka TermName("ru")])) +Block(List(Import(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), List(ImportSelector(TermName("universe"), <offset>, TermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), scala.reflect.runtime.package#<id>), [TermName("universe")#<id> aka TermName("ru")])) diff --git a/test/files/run/showraw_mods.check b/test/files/run/showraw_mods.check index 7fca027614..3ec868542d 100644 --- a/test/files/run/showraw_mods.check +++ b/test/files/run/showraw_mods.check @@ -1 +1 @@ -Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), newTypeName("C"), List(), Template(List(Ident(newTypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), newTermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), newTermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), newTermName("y"), TypeTree(), Select(This(newTypeName("C")), newTermName("x"))), ValDef(Modifiers(LAZY), newTermName("z"), TypeTree(), Select(This(newTypeName("C")), newTermName("y"))))))), Literal(Constant(()))) +Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), TypeName("C"), List(), Template(List(Ident(TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), TermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), TermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), TermName("y"), TypeTree(), Select(This(TypeName("C")), TermName("x"))), ValDef(Modifiers(LAZY), TermName("z"), TypeTree(), Select(This(TypeName("C")), TermName("y"))))))), Literal(Constant(()))) diff --git a/test/files/run/showraw_tree.check b/test/files/run/showraw_tree.check index b71018d4fe..eb74bd8b2b 100644 --- a/test/files/run/showraw_tree.check +++ b/test/files/run/showraw_tree.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), newTypeName("String")), Select(Ident(scala.Predef), newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), newTypeName("String")), Select(Ident(scala.Predef), newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_ids.check b/test/files/run/showraw_tree_ids.check index 5835ffa6de..7e0149a3c1 100644 --- a/test/files/run/showraw_tree_ids.check +++ b/test/files/run/showraw_tree_ids.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), newTypeName("String")), Select(Ident(scala.Predef#<id>), newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), newTypeName("String")), Select(Ident(scala.Predef#<id>), newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), TypeName("String")), Select(Ident(scala.Predef#<id>), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), TypeName("String")), Select(Ident(scala.Predef#<id>), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_kinds.check b/test/files/run/showraw_tree_kinds.check index c4d66856d4..577f447ae4 100644 --- a/test/files/run/showraw_tree_kinds.check +++ b/test/files/run/showraw_tree_kinds.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), newTypeName("String")), Select(Ident(scala.Predef#MOD), newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), newTypeName("String")), Select(Ident(scala.Predef#MOD), newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), TypeName("String")), Select(Ident(scala.Predef#MOD), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), TypeName("String")), Select(Ident(scala.Predef#MOD), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_types_ids.check b/test/files/run/showraw_tree_types_ids.check index fccb81d8df..6a73d77436 100644 --- a/test/files/run/showraw_tree_types_ids.check +++ b/test/files/run/showraw_tree_types_ids.check @@ -1,12 +1,12 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), newTypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), newTypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) -[1] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) +[1] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List())))) [3] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List()) -[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()) +[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()) [5] SingleType(ThisType(scala#<id>), scala.Predef#<id>) -Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), newTypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), newTypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) -[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()) +Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) +[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()) [5] SingleType(ThisType(scala#<id>), scala.Predef#<id>) -[6] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()))) -[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), newTypeName("String")#<id>, List())))) +[6] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()))) +[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List())))) [8] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List()) diff --git a/test/files/run/showraw_tree_types_typed.check b/test/files/run/showraw_tree_types_typed.check index f3e0f8c5f6..cf63ecb586 100644 --- a/test/files/run/showraw_tree_types_typed.check +++ b/test/files/run/showraw_tree_types_typed.check @@ -1,12 +1,12 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), newTypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), newTypeName("String"))))))), nme.CONSTRUCTOR), List()) -[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))))))), nme.CONSTRUCTOR), List()) +[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List())))) [3] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List()) -[4] TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()) +[4] TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) [5] SingleType(ThisType(scala), scala.Predef) -Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), newTypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), newTypeName("String"))))))), nme.CONSTRUCTOR), List()) -[4] TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()) +Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))))))), nme.CONSTRUCTOR), List()) +[4] TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) [5] SingleType(ThisType(scala), scala.Predef) -[6] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()))) -[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List())))) +[6] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()))) +[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List())))) [8] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List()) diff --git a/test/files/run/showraw_tree_types_untyped.check b/test/files/run/showraw_tree_types_untyped.check index b71018d4fe..eb74bd8b2b 100644 --- a/test/files/run/showraw_tree_types_untyped.check +++ b/test/files/run/showraw_tree_types_untyped.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), newTypeName("String")), Select(Ident(scala.Predef), newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), newTypeName("String")), Select(Ident(scala.Predef), newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_ultimate.check b/test/files/run/showraw_tree_ultimate.check index a6286ba754..63f72de50b 100644 --- a/test/files/run/showraw_tree_ultimate.check +++ b/test/files/run/showraw_tree_ultimate.check @@ -1,12 +1,12 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#PCTOR), List()) -[1] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#PCTOR), List()) +[1] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List())))) [3] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List()) -[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()) +[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()) [5] SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD) -Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#CTOR), List()) -[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()) +Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#CTOR), List()) +[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()) [5] SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD) -[6] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()))) -[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), newTypeName("String")#<id>#TPE, List())))) +[6] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()))) +[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List())))) [8] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List()) diff --git a/test/files/run/si5045.scala b/test/files/run/si5045.scala index e198b101f3..b0c3a4ddc4 100644 --- a/test/files/run/si5045.scala +++ b/test/files/run/si5045.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + object Test extends App { import scala.util.matching.{ Regex, UnanchoredRegex } diff --git a/test/files/run/slice-strings.scala b/test/files/run/slice-strings.scala index 23085866f5..129314387a 100644 --- a/test/files/run/slice-strings.scala +++ b/test/files/run/slice-strings.scala @@ -1,7 +1,7 @@ -object Test { +object Test { def cmp(x1: String) = { val x2 = x1.toList - + -10 to 10 foreach { i => assert(x1.take(i) == x2.take(i).mkString) assert(x1.drop(i) == x2.drop(i).mkString) @@ -12,7 +12,7 @@ object Test { assert(x1.slice(idx1, idx2) == x2.slice(idx1, idx2).mkString) } } - + def main(args: Array[String]): Unit = { cmp("abcde") } diff --git a/test/files/run/slices.scala b/test/files/run/slices.scala index e31ea4046f..107b8e658a 100644 --- a/test/files/run/slices.scala +++ b/test/files/run/slices.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + object Test extends App { // lists diff --git a/test/files/run/sm-interpolator.scala b/test/files/run/sm-interpolator.scala index 7f7b9f061a..b99daa2a8b 100644 --- a/test/files/run/sm-interpolator.scala +++ b/test/files/run/sm-interpolator.scala @@ -1,14 +1,14 @@ object Test extends App { import scala.reflect.internal.util.StringContextStripMarginOps - def check(actual: Any, expected: Any) = if (actual != expected) sys.error(s"expected: [$expected], actual: [$actual])") + def check(actual: Any, expected: Any) = if (actual != expected) sys.error(s"\nexpected:\n$expected\n\nactual:\n$actual") val bar = "|\n ||" check( - sm"""|ab + sm"""|ab |de |${bar} | ${1}""", - "ab \nde\n|\n || | 1") + "ab\nde\n|\n || | 1") check( sm"|", diff --git a/test/files/run/spec-nlreturn.scala b/test/files/run/spec-nlreturn.scala index ec5e7229d3..5ab1747856 100644 --- a/test/files/run/spec-nlreturn.scala +++ b/test/files/run/spec-nlreturn.scala @@ -1,10 +1,11 @@ + object Test { def f(): Int = { try { - val g = 1 to 10 map { i => return 16 ; i } sum; + val g = (1 to 10 map { i => return 16 ; i }).sum g } - catch { case x: runtime.NonLocalReturnControl[_] => + catch { case x: runtime.NonLocalReturnControl[_] => println(x.getClass.getName) x.value.asInstanceOf[Int] } diff --git a/test/files/run/streamWithFilter.scala b/test/files/run/streamWithFilter.scala index 7f8f9a09d2..cb919d4f55 100644 --- a/test/files/run/streamWithFilter.scala +++ b/test/files/run/streamWithFilter.scala @@ -4,7 +4,7 @@ object Test { def isBuzz(x: Int) = x % 5 == 0 // next line will run forever if withFilter isn't doing its thing. val fizzbuzzes = for (n <- nums ; if isFizz(n) ; if isBuzz(n)) yield n - + def main(args: Array[String]): Unit = { fizzbuzzes take 5 foreach println } diff --git a/test/files/run/stream_flatmap_odds.scala b/test/files/run/stream_flatmap_odds.scala index 6fb202ca68..1935253595 100644 --- a/test/files/run/stream_flatmap_odds.scala +++ b/test/files/run/stream_flatmap_odds.scala @@ -1,4 +1,4 @@ object Test extends App { lazy val odds: Stream[Int] = Stream(1) append ( odds flatMap {x => Stream(x + 2)} ) - println(odds take 42 force) + Console println (odds take 42).force } diff --git a/test/files/run/stream_length.check b/test/files/run/stream_length.check index 9906de773c..e4350aa741 100644 --- a/test/files/run/stream_length.check +++ b/test/files/run/stream_length.check @@ -1 +1,5 @@ +#partest !avian Length: 970299 +#partest avian +!!!TEST SKIPPED!!! +See SI-7600 for further information. diff --git a/test/files/run/stream_length.scala b/test/files/run/stream_length.scala index 2808fbc495..33929f4b57 100644 --- a/test/files/run/stream_length.scala +++ b/test/files/run/stream_length.scala @@ -10,6 +10,10 @@ object Test { } def main(args: Array[String]) { - println("Length: " + walk(3, "---").length) + if (scala.tools.partest.utils.Properties.isAvian) { + println("!!!TEST SKIPPED!!!") + println("See SI-7600 for further information.") + } else + println("Length: " + walk(3, "---").length) } } diff --git a/test/files/run/streams.scala b/test/files/run/streams.scala index 03b2622edd..350e103eab 100644 --- a/test/files/run/streams.scala +++ b/test/files/run/streams.scala @@ -41,7 +41,7 @@ object Test extends App { def powers(x: Int) = if ((x&(x-1)) == 0) Some(x) else None println(s3.flatMap(powers).reverse.head) - // large enough to generate StackOverflows (on most systems) + // large enough to generate StackOverflows (on most systems) // unless the following methods are tail call optimized. val size = 100000 diff --git a/test/files/run/string-extractor.check b/test/files/run/string-extractor.check new file mode 100644 index 0000000000..47f3722c86 --- /dev/null +++ b/test/files/run/string-extractor.check @@ -0,0 +1,9 @@ +by +BY +oTheClown +nope +1: ob +2: obby +2: OBBY +3: BOBO +3: TomTomTheClown diff --git a/test/files/run/string-extractor.scala b/test/files/run/string-extractor.scala new file mode 100644 index 0000000000..c0fe911ff3 --- /dev/null +++ b/test/files/run/string-extractor.scala @@ -0,0 +1,60 @@ +final class StringExtract(val s: String) extends AnyVal { + def isEmpty = (s eq null) || (s == "") + def get = this + def length = s.length + def lengthCompare(n: Int) = s.length compare n + def apply(idx: Int): Char = s charAt idx + def head: Char = s charAt 0 + def tail: String = s drop 1 + def drop(n: Int): StringExtract = new StringExtract(s drop n) + + override def toString = s +} + +final class ThreeStringExtract(val s: String) extends AnyVal { + def isEmpty = (s eq null) || (s == "") + def get: (List[Int], Double, ThreeStringExtract) = ((s.length :: Nil, s.length.toDouble, this)) + def length = s.length + def lengthCompare(n: Int) = s.length compare n + def apply(idx: Int): Char = s charAt idx + def head: Char = s charAt 0 + def tail: String = s drop 1 + def drop(n: Int): ThreeStringExtract = new ThreeStringExtract(s drop n) + + override def toString = s +} + + +object Bippy { + def unapplySeq(x: Any): StringExtract = new StringExtract("" + x) +} +object TripleBippy { + def unapplySeq(x: Any): ThreeStringExtract = new ThreeStringExtract("" + x) +} + +object Test { + def f(x: Any) = x match { + case Bippy('B' | 'b', 'O' | 'o', 'B' | 'b', xs @ _*) => xs + case _ => "nope" + } + + def g(x: Any): String = x match { + case TripleBippy(3 :: Nil, 3.0, 'b', chars @ _*) => "1: " + chars + case TripleBippy(5 :: Nil, 5.0, 'b' | 'B', chars @ _*) => "2: " + chars + case TripleBippy(_, _, chars @ _*) => "3: " + chars + case _ => "nope" + } + + def main(args: Array[String]): Unit = { + println(f("Bobby")) + println(f("BOBBY")) + println(f("BoBoTheClown")) + println(f("TomTomTheClown")) + + println(g("bob")) + println(g("bobby")) + println(g("BOBBY")) + println(g("BOBO")) + println(g("TomTomTheClown")) + } +} diff --git a/test/files/run/stringbuilder-drop.scala b/test/files/run/stringbuilder-drop.scala index a9e5a71762..422fb2bc7c 100644 --- a/test/files/run/stringbuilder-drop.scala +++ b/test/files/run/stringbuilder-drop.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - val s = (new StringBuilder ++= "hello world") dropRight 1 toString; - assert(s == "hello worl") + val s = (new StringBuilder ++= "hello world") dropRight 1 + assert("" + s == "hello worl") } } diff --git a/test/files/run/stringbuilder.scala b/test/files/run/stringbuilder.scala index ef85fc02a6..a98f9cf37d 100644 --- a/test/files/run/stringbuilder.scala +++ b/test/files/run/stringbuilder.scala @@ -1,21 +1,24 @@ + +import scala.language.reflectiveCalls + object Test extends App { val str = "ABCDEFGHIJKLMABCDEFGHIJKLM" val surrogateStr = "an old Turkic letter: \uD803\uDC22" - - type SB = { + + type SB = { def indexOf(str: String): Int def indexOf(str: String, fromIndex: Int): Int def lastIndexOf(str: String): Int def lastIndexOf(str: String, fromIndex: Int): Int } - + import scala.collection.mutable.{ StringBuilder => ScalaStringBuilder } import java.lang.{ StringBuilder => JavaStringBuilder } - + val sbScala = new ScalaStringBuilder() append str val sbJava = new JavaStringBuilder() append str val sbs: List[SB] = List[SB](sbScala, sbJava) - + def sameAnswers(f: (SB) => Int) = assert(f(sbScala) == f(sbJava)) sameAnswers(_.indexOf("")) @@ -31,10 +34,10 @@ object Test extends App { sameAnswers(_.lastIndexOf("QZV")) sameAnswers(_.lastIndexOf("GHI", 22)) sameAnswers(_.lastIndexOf("KLM", 22)) - + // testing that the "reverse" implementation avoids reversing surrogate pairs - val jsb = new JavaStringBuilder(surrogateStr) reverse - val ssb = new ScalaStringBuilder(surrogateStr) reverseContents ; - + val jsb = new JavaStringBuilder(surrogateStr).reverse + val ssb = new ScalaStringBuilder(surrogateStr).reverseContents + assert(jsb.toString == ssb.toString) } diff --git a/test/files/run/stringinterpolation_macro-run.scala b/test/files/run/stringinterpolation_macro-run.scala index 9c59c334f8..1138cd0860 100644 --- a/test/files/run/stringinterpolation_macro-run.scala +++ b/test/files/run/stringinterpolation_macro-run.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ object Test extends App { // 'b' / 'B' (category: general) diff --git a/test/files/run/structural.scala b/test/files/run/structural.scala index 36af8c4bfc..7da104ca6e 100644 --- a/test/files/run/structural.scala +++ b/test/files/run/structural.scala @@ -1,18 +1,21 @@ + +import scala.language.{ reflectiveCalls } + object test1 { - + val o1 = new Object { override def toString = "ohone" } val o2 = new Object { override def toString = "ohtwo" } - + val t1 = new Tata("tieone") val t2 = new Tata("tietwo") - + class Tata(name: String) { override def toString = name def tatMe = "oy" } - + class Titi extends Tata("titi") - + object Rec { val a = 1 val b = 2 @@ -41,7 +44,7 @@ object test1 { val y: Tata = null def z(t: Tata) = () } - + type rt = Object { val a: Int; val c: String; @@ -65,7 +68,7 @@ object test1 { var v: Int val y: Tata } - + def l (r: rt) { println(" 1. " + r.c) println(" 2. " + r.a + 1) @@ -94,33 +97,33 @@ object test1 { println("25. " + r.y) println("26. " + r.e(null)) } - + /*def ma[T](r: Object{def e(x: T): T; val x: T}) { println("30. " + r.e(r.x)) // static error }*/ - + def mb(r: Object { def e[T](x: T): T }) { println("31. " + r.e[Int](4)) // while this is ok } - + def m1(r: Object { def z(x: Tata): Unit }) { println("32. " + r.z(new Titi)) // while this is ok } - + def m2[T](r: Object { def e(x: Tata): T; val x: Tata }) { println("33. " + r.e(r.x)) // and this too } - + class Rec3[T] { def e(x: T): T = x } - + def m3[T](r: Rec3[T], x: T) { println("33. " + r.e(x)) // and this too } - + Rec.g(11) - + this.l(Rec) this.mb(new Object{def e[T](x: T): T = x}) this.m1(Rec) @@ -132,7 +135,7 @@ object test2 { class C extends { def f() { println("1") } } val x1 = new C x1.f() - + abstract class D extends { def f() } val x2 = new D { def f() { println("2") } } x2.f() @@ -152,45 +155,45 @@ object test2 { object test3 { - case class Exc extends Exception - + case class Exc() extends Exception + object Rec { def f = throw Exc() } - + def m(r: { def f: Nothing }) = try { r.f } catch { case e: Exc => println("caught") - case e => println(e) + case e: Throwable => println(e) } - + m(Rec) - + } object test4 { class A - + val aar = Array(new A, new A, new A) val nar = Array(1, 2) - + def f(p: {def size: Int}) = println(p.size) //def g[T <: {def size: Int}](p: T) = println(p.size) // open issue //def h[T <% {def size: Int}](p: T) = println(p.size) // open issue - + f(aar) f(nar) - + //g(aar) //g(nar) - + //h(aar) //h(nar) - + } object Test extends App { diff --git a/test/files/run/synchronized.check b/test/files/run/synchronized.check index dd9f4ef424..6e99739633 100644 --- a/test/files/run/synchronized.check +++ b/test/files/run/synchronized.check @@ -1,3 +1,4 @@ +warning: there were 14 inliner warning(s); re-run with -Yinline-warnings for details .|. c1.f1: OK .|. c1.fi: OK .|... c1.fv: OK diff --git a/test/files/run/synchronized.flags b/test/files/run/synchronized.flags index 1182725e86..49d036a887 100644 --- a/test/files/run/synchronized.flags +++ b/test/files/run/synchronized.flags @@ -1 +1 @@ --optimize
\ No newline at end of file +-optimize diff --git a/test/files/run/sysprops.scala b/test/files/run/sysprops.scala index 4d98e2cdd0..bdad677221 100644 --- a/test/files/run/sysprops.scala +++ b/test/files/run/sysprops.scala @@ -3,16 +3,16 @@ import sys._ /** Basic sys.Prop test. */ object Test { val key = "ding.dong.doobie" - + def bool() = { val prop = BooleanProp.valueIsTrue(key) assert(prop.key == key) - + prop.clear() assert(!prop.value) assert(!prop.isSet) assert(prop.get != null) - + prop set "dingus" assert(prop.get == "dingus") assert(!prop.value) @@ -32,7 +32,7 @@ object Test { prop.set("523") assert(prop.value == 523) prop.set("DingusInt") - + try { println(prop.value) ; assert(false, "should not get here") } catch { case _: Exception => () } } @@ -41,7 +41,7 @@ object Test { prop.set("55.0") assert(prop.value == 55.0) } - + def main(args: Array[String]): Unit = { bool() int() diff --git a/test/files/run/t0017.scala b/test/files/run/t0017.scala index e976f453d8..245cbb7e42 100644 --- a/test/files/run/t0017.scala +++ b/test/files/run/t0017.scala @@ -7,7 +7,7 @@ def transpose[A](arr: Array[Array[A]]) = { var my_arr = Array(Array(1,2),Array(3,4)) -for (i <- Array.range(0, my_arr(0).length)) yield +for (i <- Array.range(0, my_arr(0).length)) yield for (row <- my_arr) yield row(i) val transposed = transpose(my_arr) diff --git a/test/files/run/t0091.check b/test/files/run/t0091.check index 7ed6ff82de..fd3c81a4d7 100644 --- a/test/files/run/t0091.check +++ b/test/files/run/t0091.check @@ -1 +1,2 @@ 5 +5 diff --git a/test/files/run/t0091.scala b/test/files/run/t0091.scala index eaddde0dbf..45235eb77b 100644 --- a/test/files/run/t0091.scala +++ b/test/files/run/t0091.scala @@ -4,10 +4,13 @@ object C extends B { object m extends A { def x = 5 } } object Test { - // The type annotation here is necessary, otherwise - // the compiler would reference C$m$ directly. - def o : B = C - def main(argv : Array[String]) : Unit = { - println(o.m.x) - } + // The type annotation here is necessary, otherwise + // the compiler would reference C$m$ directly. + def o1 : B = C + def o2 = C + + def main(argv : Array[String]) : Unit = { + println(o1.m.x) + println(o2.m.x) + } } diff --git a/test/files/run/t0325.scala b/test/files/run/t0325.scala index 92331ab05f..a126a3a204 100644 --- a/test/files/run/t0325.scala +++ b/test/files/run/t0325.scala @@ -7,7 +7,7 @@ case class RS(self: String) { } def split(separator: Char): Array[String] = self.split(escape(separator)) - + def split(separators: Array[Char]): Array[String] = { val re = separators.foldLeft("[")(_+escape(_)) + "]" self.split(re) @@ -24,10 +24,10 @@ object Test { else println(ret) } catch { - case e@_ => println(which + " failed with " + e.getClass) + case e: Throwable => println(which + " failed with " + e.getClass) } } - + def main(args: Array[String]) { val badChars = "?*{+([\\^.$" @@ -46,8 +46,8 @@ object Test { for ((c,str) <- badCases) test(("a"+c+"b").split(str.toArray),"RichString split(\""+ str + "\")") println - + for ((c,str) <- badCases) - test(RS("a"+c+"b").split(str.toArray),"RS split(\""+ str + "\")") + test(RS("a"+c+"b").split(str.toArray),"RS split(\""+ str + "\")") } } diff --git a/test/files/run/t0421-old.scala b/test/files/run/t0421-old.scala index 8d51013924..dde89bc542 100644 --- a/test/files/run/t0421-old.scala +++ b/test/files/run/t0421-old.scala @@ -1,4 +1,6 @@ // ticket #421 + +@deprecated("Suppress warnings", since="2.11") object Test extends App { def transpose[A: ClassManifest](xss: Array[Array[A]]) = { @@ -7,17 +9,17 @@ object Test extends App { } def scalprod(xs: Array[Double], ys: Array[Double]) = { - var acc = 0.0 - for ((x, y) <- xs zip ys) acc = acc + x * y + var acc = 0.0 + for ((x, y) <- xs zip ys) acc = acc + x * y acc } def matmul(xss: Array[Array[Double]], yss: Array[Array[Double]]) = { - val ysst = transpose(yss) + val ysst = transpose(yss) val ysst1: Array[Array[Double]] = yss.transpose assert(ysst.deep == ysst1.deep) for (xs <- xss) yield - for (yst <- ysst) yield + for (yst <- ysst) yield scalprod(xs, yst) } @@ -25,6 +27,6 @@ object Test extends App { println(transpose(a1).deep.mkString("[", ",", "]")) println(matmul(Array(Array(2, 3)), Array(Array(5), Array(7))).deep.mkString("[", ",", "]")) - + println(matmul(Array(Array(4)), Array(Array(6, 8))).deep.mkString("[", ",", "]")) } diff --git a/test/files/run/t0432.scala b/test/files/run/t0432.scala index 8ba9015d81..b860a0874f 100644 --- a/test/files/run/t0432.scala +++ b/test/files/run/t0432.scala @@ -1,3 +1,6 @@ + +import scala.language.reflectiveCalls + object Test { type valueType = { def value: this.type } diff --git a/test/files/run/t0486.check b/test/files/run/t0486.check deleted file mode 100644 index dd1ec28223..0000000000 --- a/test/files/run/t0486.check +++ /dev/null @@ -1,8 +0,0 @@ -<wsdl:definitions name="service1" xmlns:tns="target1"> - </wsdl:definitions> -<wsdl:definitions name="service2" xmlns:tns="target2"> - </wsdl:definitions> -<wsdl:definitions name="service3" xmlns:tns="target3"> - </wsdl:definitions> -<wsdl:definitions name="service4" xmlns:tns="target4"> - </wsdl:definitions> diff --git a/test/files/run/t0486.scala b/test/files/run/t0486.scala deleted file mode 100644 index d3ed8f4225..0000000000 --- a/test/files/run/t0486.scala +++ /dev/null @@ -1,24 +0,0 @@ -object Test extends App { - import scala.xml._ - - def wsdlTemplate1(serviceName: String): Node = - <wsdl:definitions name={serviceName} xmlns:tns = { "target1" } > - </wsdl:definitions>; - - def wsdlTemplate2(serviceName: String, targetNamespace: String): Node = - <wsdl:definitions name={serviceName} xmlns:tns = { targetNamespace } > - </wsdl:definitions>; - - def wsdlTemplate3(serviceName: String): Node = - <wsdl:definitions name={serviceName} xmlns:tns = { Text("target3") } > - </wsdl:definitions>; - - def wsdlTemplate4(serviceName: String, targetNamespace: () => String): Node = - <wsdl:definitions name={serviceName} xmlns:tns = { targetNamespace() } > - </wsdl:definitions>; - - println(wsdlTemplate1("service1")) - println(wsdlTemplate2("service2", "target2")) - println(wsdlTemplate3("service3")) - println(wsdlTemplate4("service4", () => "target4")) -} diff --git a/test/files/run/t0508.scala b/test/files/run/t0508.scala index 0f4325e629..2283c46c36 100644 --- a/test/files/run/t0508.scala +++ b/test/files/run/t0508.scala @@ -9,5 +9,5 @@ object Test extends App { } } - foo(Foo.unapply, Foo("this might be fun", 10)) + foo(Foo.unapply, Foo("this might be fun", 10)) } diff --git a/test/files/run/t0528.scala b/test/files/run/t0528.scala index a76f602ed3..68a9975173 100644 --- a/test/files/run/t0528.scala +++ b/test/files/run/t0528.scala @@ -1,3 +1,5 @@ + +import scala.language.{ existentials } trait Sequ[A] { def toArray: Array[T forSome {type T <: A}] } diff --git a/test/files/run/t0631.scala b/test/files/run/t0631.scala index 5bceab6193..c401ed31cb 100644 --- a/test/files/run/t0631.scala +++ b/test/files/run/t0631.scala @@ -1,5 +1,5 @@ object Test extends App { - class Foo { + class Foo { override def equals(that: Any) = { println("Foo.equals called") super.equals(that) diff --git a/test/files/run/t0663.check b/test/files/run/t0663.check deleted file mode 100755 index dd9be2af70..0000000000 --- a/test/files/run/t0663.check +++ /dev/null @@ -1 +0,0 @@ -<feed/> diff --git a/test/files/run/t0663.scala b/test/files/run/t0663.scala deleted file mode 100644 index dd0326d4e3..0000000000 --- a/test/files/run/t0663.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends App { - val src = scala.io.Source.fromString("<?xml version='1.0' encoding='UTF-8'?><feed/>") - val parser = xml.parsing.ConstructingParser.fromSource(src, true) - println(parser.document) -} - diff --git a/test/files/run/t0677-old.scala b/test/files/run/t0677-old.scala index 6c8a3a7e99..8d4c3ee060 100644 --- a/test/files/run/t0677-old.scala +++ b/test/files/run/t0677-old.scala @@ -1,5 +1,8 @@ + + +@deprecated("Suppress warnings", since="2.11") object Test extends App { - class X[T: ClassManifest] { + class X[T: ClassManifest] { val a = Array.ofDim[T](3, 4) } val x = new X[String] diff --git a/test/files/run/t0700.check b/test/files/run/t0700.check deleted file mode 100644 index b4eabbab1a..0000000000 --- a/test/files/run/t0700.check +++ /dev/null @@ -1,2 +0,0 @@ -[3.2] parsed: List(2, 2, 2) -[3.2] parsed: List(2, 2, 2) diff --git a/test/files/run/t0700.scala b/test/files/run/t0700.scala deleted file mode 100644 index 5a7180528c..0000000000 --- a/test/files/run/t0700.scala +++ /dev/null @@ -1,24 +0,0 @@ -import java.io.{File,StringReader} - -import scala.util.parsing.combinator.Parsers -import scala.util.parsing.input.{CharArrayReader, StreamReader} - -class TestParsers extends Parsers { - type Elem = Char - - def p: Parser[List[Int]] = rep(p1 | p2) - def p1: Parser[Int] = 'a' ~ nl ~ 'b' ~ nl ^^^ 1 - def p2: Parser[Int] = 'a' ~ nl ^^^ 2 - def nl: Parser[Int] = rep(accept('\n') | accept('\r')) ^^^ 0 -} - -object Test { - def main(args: Array[String]): Unit = { - val tstParsers = new TestParsers - val s = "a\na\na" - val r1 = new CharArrayReader(s.toCharArray()) - val r2 = StreamReader(new StringReader(s)) - println(tstParsers.p(r1)) - println(tstParsers.p(r2)) - } -} diff --git a/test/files/run/t0807.scala b/test/files/run/t0807.scala index 1a1add6b3a..1e2a26664a 100644 --- a/test/files/run/t0807.scala +++ b/test/files/run/t0807.scala @@ -1,5 +1,5 @@ trait A -trait B extends A { val x = println("early") } +trait B extends A { val x = println("early") } object Test extends App { new B {} } diff --git a/test/files/run/t0883.scala b/test/files/run/t0883.scala index adde95197b..c8ed06dbfe 100644 --- a/test/files/run/t0883.scala +++ b/test/files/run/t0883.scala @@ -1,14 +1,14 @@ object Foo { def apply(x: String) = new Foo(x) } class Foo(name: String) case object Bar extends Foo("Bar") -case class Baz() extends Foo("Baz") +case class Baz() extends Foo("Baz") object Test extends App { - Foo("Bar") match { - case Bar => println("What?") + Foo("Bar") match { + case Bar => println("What?") case _ => println("OK") } - Foo("Baz") match { - case Baz() => println("What?") + Foo("Baz") match { + case Baz() => println("What?") case _ => println("OK") - } + } } diff --git a/test/files/run/t1005.scala b/test/files/run/t1005.scala index 60129bcc51..562e2e4c6d 100644 --- a/test/files/run/t1005.scala +++ b/test/files/run/t1005.scala @@ -1,19 +1,20 @@ +import scala.language.postfixOps object Test { class Foo[T](x : Array[AnyRef]) { def bar = x.asInstanceOf[Array[T]] } class Bar[T](x : Array[T]) { def bar = x.asInstanceOf[Array[AnyRef]] } object FromMono{ - def main(args : Array[String]) = (new Foo[AnyRef](Array[AnyRef]("Halp!"))).bar + def mainer(args : Array[String]) = (new Foo[AnyRef](Array[AnyRef]("Halp!"))).bar } object FromPoly{ - def main(args : Array[String]) = (new Bar[AnyRef](Array[AnyRef]("Halp!"))).bar + def mainer(args : Array[String]) = (new Bar[AnyRef](Array[AnyRef]("Halp!"))).bar } - + def main(args: Array[String]): Unit = { - println(FromMono main null mkString) - println(FromPoly main null mkString) + println(FromMono mainer null mkString) + println(FromPoly mainer null mkString) } } diff --git a/test/files/run/t1042.scala b/test/files/run/t1042.scala index 1f39fff24a..302ff31053 100644 --- a/test/files/run/t1042.scala +++ b/test/files/run/t1042.scala @@ -6,7 +6,7 @@ abstract class A { case class B() extends A { // overloaded version is implemented, causing toString not to be implemented? - def toString(sb: StringBuilder): StringBuilder = error("") + def toString(sb: StringBuilder): StringBuilder = sys.error("") } object Test extends App { diff --git a/test/files/run/t107.check b/test/files/run/t107.check new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/test/files/run/t107.check @@ -0,0 +1 @@ +1 diff --git a/test/files/run/t107.scala b/test/files/run/t107.scala new file mode 100644 index 0000000000..ab1b289882 --- /dev/null +++ b/test/files/run/t107.scala @@ -0,0 +1,8 @@ +object Test { + def main(args : Array[String]) : Unit = { + var hash : Long = 0 + val bytes = Array(1.toByte, 2.toByte, 3.toByte) + hash += bytes(0) + Console.println(hash) + } +}
\ No newline at end of file diff --git a/test/files/run/t1079.check b/test/files/run/t1079.check deleted file mode 100644 index c508d5366f..0000000000 --- a/test/files/run/t1079.check +++ /dev/null @@ -1 +0,0 @@ -false diff --git a/test/files/run/t1079.scala b/test/files/run/t1079.scala deleted file mode 100644 index ce435d254b..0000000000 --- a/test/files/run/t1079.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends App { - println(<t user:tag=""/> == <t user:tag="X"/>) -} diff --git a/test/files/run/t1100.check b/test/files/run/t1100.check deleted file mode 100644 index d3a49a47df..0000000000 --- a/test/files/run/t1100.check +++ /dev/null @@ -1,4 +0,0 @@ -[1.4] error: errors are propagated - -aaab - ^ diff --git a/test/files/run/t1100.scala b/test/files/run/t1100.scala deleted file mode 100644 index 6b95fd6ecb..0000000000 --- a/test/files/run/t1100.scala +++ /dev/null @@ -1,17 +0,0 @@ -import scala.util.parsing.combinator.Parsers -import scala.util.parsing.input.CharSequenceReader - -class TestParsers extends Parsers { - type Elem = Char - - def p: Parser[List[Char]] = rep1(p1) - def p1: Parser[Char] = accept('a') | err("errors are propagated") -} - -object Test { - def main(args: Array[String]): Unit = { - val tstParsers = new TestParsers - val s = new CharSequenceReader("aaab") - println(tstParsers.p(s)) - } -} diff --git a/test/files/run/t1110.scala b/test/files/run/t1110.scala index 824643868c..81917789c8 100644 --- a/test/files/run/t1110.scala +++ b/test/files/run/t1110.scala @@ -1,8 +1,12 @@ + + +import scala.language.{ reflectiveCalls } + class Stuff { def zoop(p: Any{def &(q: Int): Int}) = p & 7 def floop = new { def & = "Hello" } - assert((floop &) == "Hello") + assert((floop.&) == "Hello") assert(zoop(10) == 2) } diff --git a/test/files/run/t1141.scala b/test/files/run/t1141.scala index ee4f2e7fd2..732c57943c 100644 --- a/test/files/run/t1141.scala +++ b/test/files/run/t1141.scala @@ -1,7 +1,11 @@ + + +import scala.language.reflectiveCalls + object Test extends App { val foo = new { def apply(args : String*) = args foreach println } - + foo("var", "args") } diff --git a/test/files/run/t1167.scala b/test/files/run/t1167.scala index c2ec4cff4e..3dd0a30c00 100644 --- a/test/files/run/t1167.scala +++ b/test/files/run/t1167.scala @@ -10,17 +10,17 @@ trait Test1 { /* getName * Returns the binary name of the class if this class object represents a - * reference type that is not an array type. + * reference type that is not an array type. * getSimpleName * Returns the simple name of the underlying class as given in the source * code. Returns an empty string if the underlying class is anonymous. */ abstract class Foo { override def toString = getClass.getSimpleName - + abstract class Bar { override def toString = getClass.getSimpleName - } + } } object Test extends App { diff --git a/test/files/run/t1195-new.scala b/test/files/run/t1195-new.scala index 0f62b140c9..4f068c7d42 100644 --- a/test/files/run/t1195-new.scala +++ b/test/files/run/t1195-new.scala @@ -1,3 +1,5 @@ + +import scala.language.{ existentials } import scala.reflect.runtime.universe._ object Test { @@ -25,4 +27,4 @@ class A1[T] { class B1[U] { def f = { case class D(x: Int) extends A1[String] ; new D(5) } } -}
\ No newline at end of file +} diff --git a/test/files/run/t1195-old.scala b/test/files/run/t1195-old.scala index b46a3b70f5..f80734c228 100644 --- a/test/files/run/t1195-old.scala +++ b/test/files/run/t1195-old.scala @@ -1,3 +1,6 @@ + +import scala.language.{ existentials } + object Test { def f() = { case class Bar(x: Int); Bar } def g() = { case class Bar(x: Int); Bar(5) } diff --git a/test/files/run/t1220.scala b/test/files/run/t1220.scala index 0ba188d02d..75e0ea07e8 100644 --- a/test/files/run/t1220.scala +++ b/test/files/run/t1220.scala @@ -1,7 +1,7 @@ object Test extends App { class QSRichIterable[A](self: Iterable[A]) { - def filterMap[R](f: PartialFunction[A,R]) = + def filterMap[R](f: PartialFunction[A,R]) = self filter (f.isDefinedAt) map f } diff --git a/test/files/run/t1300.scala b/test/files/run/t1300.scala index ce2f80eb4e..aa3580e33c 100644 --- a/test/files/run/t1300.scala +++ b/test/files/run/t1300.scala @@ -4,10 +4,10 @@ object Test extends App // val a1 = x1.toArray[Any] val a2 = Array('a','b','c','d').toArray[Any] val a3 = Array("e","f","g","h").toArray[Any] - + Array.copy(a3, 0, a1, 0, 4) Array.copy(a2, 0, a3, 0, 4) Array.copy(a2, 0, a1, 0, 4) - + println(a1.mkString + a2.mkString + a3.mkString) } diff --git a/test/files/run/t1309.scala b/test/files/run/t1309.scala index b6a75fe6ae..84963549a2 100644 --- a/test/files/run/t1309.scala +++ b/test/files/run/t1309.scala @@ -1,6 +1,6 @@ object Test { def f(ras: => IndexedSeq[Byte]): IndexedSeq[Byte] = ras - + def main(args: Array[String]): Unit = { f(new Array[Byte](0)) } diff --git a/test/files/run/t1323.scala b/test/files/run/t1323.scala index 8209b85219..94b51bd2a4 100644 --- a/test/files/run/t1323.scala +++ b/test/files/run/t1323.scala @@ -3,9 +3,9 @@ object Test extends App { println(" 2:" + List(1,2,3,4).indexOfSlice(List(1,2))) // 0 println(" 3:" + List(1,2,3,4).indexOfSlice(List(2,3))) // 1 println(" 4:" + List(1,2,3,4).indexOfSlice(List(3,4))) // 2 - println(" 5:" + List(1,2,3,4).indexOfSlice(List(4,5))) // -1 + println(" 5:" + List(1,2,3,4).indexOfSlice(List(4,5))) // -1 println(" 6:" + List(1,2,3,4).indexOfSlice(List(2,4))) // -1 - println(" 7:" + List(1,2,3,4).indexOfSlice(List(4,3))) // -1 + println(" 7:" + List(1,2,3,4).indexOfSlice(List(4,3))) // -1 println(" 8:" + List(1,2,3,4).indexOfSlice(List(1,3))) // -1 println(" 9:" + List(1,2,3,4).indexOfSlice(List(1,3))) // -1 println("10:" + List(1,2,3,4).indexOfSlice(List(1,2,3,4))) // 0 diff --git a/test/files/run/t1333.scala b/test/files/run/t1333.scala index 514b4ffc8a..1696629cbb 100644 --- a/test/files/run/t1333.scala +++ b/test/files/run/t1333.scala @@ -1,11 +1,11 @@ object Test { case class A(x: Int)(y: Int)(z: String) - + def f(x: Any) = x match { case A(x) => x case _ => -1 } - + def main(args: Array[String]): Unit = { println(f(A(10)(20)("abc"))) println(f(A(-10)(20)("abc"))) diff --git a/test/files/run/t1368.check b/test/files/run/t1368.check new file mode 100644 index 0000000000..581e8a4039 --- /dev/null +++ b/test/files/run/t1368.check @@ -0,0 +1,3 @@ +t1368.scala:7: warning: Reference to uninitialized value blurp + def go3 = (new AnyRef with Happy with Sad { override val status = blurp ; val blurp = "happysad" }).status + ^ diff --git a/test/files/run/t1423.scala b/test/files/run/t1423.scala index 44c6653287..073483aeee 100644 --- a/test/files/run/t1423.scala +++ b/test/files/run/t1423.scala @@ -5,4 +5,4 @@ object Test extends App{ case 1L => println(1); case _ => println("????"); } -} +} diff --git a/test/files/run/t1427.check b/test/files/run/t1427.check new file mode 100644 index 0000000000..11a3d2f4a9 --- /dev/null +++ b/test/files/run/t1427.check @@ -0,0 +1,3 @@ +t1427.scala:6: warning: abstract type X in type pattern Bob[_[_] <: Any] is unchecked since it is eliminated by erasure + case x: (Bob[X] forSome { type X[_] }) => true + ^ diff --git a/test/files/run/t1427.scala b/test/files/run/t1427.scala index 21bd71ffef..4b8057ffe8 100644 --- a/test/files/run/t1427.scala +++ b/test/files/run/t1427.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds } + class Bob[K[_]] { def foo(other: Any) = other match { case x: (Bob[X] forSome { type X[_] }) => true @@ -9,7 +12,7 @@ object Test { def main(args: Array[String]): Unit = { val x = new Bob[List] val results = List(x, new Bob[Set], 55) map (x foo _) - + assert(results == List(true, true, false)) } } diff --git a/test/files/run/t1430/Bar_1.java b/test/files/run/t1430/Bar_1.java index 4db2eafcbd..e49b6becb2 100644 --- a/test/files/run/t1430/Bar_1.java +++ b/test/files/run/t1430/Bar_1.java @@ -2,7 +2,7 @@ package j; interface Foo { public void foo(); -} +} public interface Bar_1 extends Foo { public void bar(); -} +} diff --git a/test/files/run/t1430/Test_2.scala b/test/files/run/t1430/Test_2.scala index 7af65de5cd..278d9c7fd3 100644 --- a/test/files/run/t1430/Test_2.scala +++ b/test/files/run/t1430/Test_2.scala @@ -6,7 +6,7 @@ package s { class Baz(x: j.Bar_1) { x.foo override def toString = "Baz" - } + } } object Test { diff --git a/test/files/run/t1500.check b/test/files/run/t1500.check deleted file mode 100644 index 94a169333b..0000000000 --- a/test/files/run/t1500.check +++ /dev/null @@ -1,3 +0,0 @@ -defined class posingAs -resolve: [A, B](x: A @posingAs[B])B -x: Any = 7 diff --git a/test/files/run/t1500.scala b/test/files/run/t1500.scala deleted file mode 100644 index ab132b724f..0000000000 --- a/test/files/run/t1500.scala +++ /dev/null @@ -1,46 +0,0 @@ -import scala.tools.nsc._ - -object Test { - - /** - * Type inference overlooks constraints posed by type parameters in annotations on types. - */ - - val testCode = <code> - - class posingAs[A] extends annotation.TypeConstraint - - def resolve[A,B](x: A @posingAs[B]): B = x.asInstanceOf[B] - - val x = resolve(7: @posingAs[Any]) - - </code>.text - - def main(args: Array[String]) = { - - val settings = new Settings() - settings.classpath.value = System.getProperty("java.class.path") - val tool = new interpreter.IMain(settings) - val global = tool.compiler - - import global._ - import definitions._ - - object checker extends AnnotationChecker { - - /** Check annotations to decide whether tpe1 <:< tpe2 */ - def annotationsConform(tpe1: Type, tpe2: Type): Boolean = { - - tpe1.annotations.forall(a1 => tpe2.annotations.forall(a2 => a1.atp <:< a2.atp)) - - } - } - - global.addAnnotationChecker(checker) - - tool.interpret(testCode) - - } - -} - diff --git a/test/files/run/t1501.check b/test/files/run/t1501.check deleted file mode 100644 index f0fa9112a5..0000000000 --- a/test/files/run/t1501.check +++ /dev/null @@ -1,3 +0,0 @@ -defined class xyz -loopWhile: [T](cond: => Boolean)(body: => Unit @xyz[T])Unit @xyz[T] -test: ()Unit @xyz[Int] diff --git a/test/files/run/t1501.scala b/test/files/run/t1501.scala deleted file mode 100644 index aba206bc7a..0000000000 --- a/test/files/run/t1501.scala +++ /dev/null @@ -1,56 +0,0 @@ -import scala.tools.nsc._ - -object Test { - - /** - * ... - */ - - val testCode = <code> - - class xyz[A] extends annotation.TypeConstraint - - def loopWhile[T](cond: =>Boolean)(body: =>(Unit @xyz[T])): Unit @ xyz[T] = {{ - if (cond) {{ - body - loopWhile[T](cond)(body) - }} - }} - - def test() = {{ - var x = 7 - loopWhile(x != 0) {{ - x = x - 1 - (): @xyz[Int] - }} - }} - - </code>.text - - def main(args: Array[String]) = { - val settings = new Settings() - settings.classpath.value = System.getProperty("java.class.path") - val tool = new interpreter.IMain(settings) - val global = tool.compiler - - import global._ - import definitions._ - - object checker extends AnnotationChecker { - - /** Check annotations to decide whether tpe1 <:< tpe2 */ - def annotationsConform(tpe1: Type, tpe2: Type): Boolean = { - - tpe1.annotations.forall(a1 => tpe2.annotations.forall(a2 => a1.atp <:< a2.atp)) - - } - } - - global.addAnnotationChecker(checker) - - tool.interpret(testCode) - - } - -} - diff --git a/test/files/run/t1505.scala b/test/files/run/t1505.scala index a246e8a35b..4afbb99ef7 100644 --- a/test/files/run/t1505.scala +++ b/test/files/run/t1505.scala @@ -1,5 +1,3 @@ -object P extends Enumeration(0, "A", "B", "C") { val A, B, C = Value } - object Q extends Enumeration { val A = Value("A") val B = Value("B") @@ -11,9 +9,14 @@ object R extends Enumeration { } object Test extends App { - assert(P(0) == P.withName("A")) - assert(P.C == P.withName("C")) - assert(Q(0) == Q.withName("A")) assert(Q.C == Q.withName("C")) + + assert(R(0) == R.withName("A")) + assert(R.C == R.withName("C")) + + var failed = false + try { Q.withName("x") } catch { case _: NoSuchElementException => failed = true } + assert(failed) + } diff --git a/test/files/run/t153.scala b/test/files/run/t153.scala index 82492fdbe6..3fdb423865 100644 --- a/test/files/run/t153.scala +++ b/test/files/run/t153.scala @@ -1,5 +1,5 @@ object Test extends App { def powers(x: Int) = if ((x&(x-1))==0) Some(x) else None val res = (Stream.range(1, 500000) flatMap powers).reverse - println(res take 42 force) + println((res take 42).force) } diff --git a/test/files/run/t1537.scala b/test/files/run/t1537.scala index ddbfb29ac4..1dce501990 100644 --- a/test/files/run/t1537.scala +++ b/test/files/run/t1537.scala @@ -4,15 +4,15 @@ trait Syntax { trait Evaluation { val syntax: Syntax - + def equalInTrait = this.syntax.Foo == this.syntax.Foo } object Test extends Evaluation with App { - object syntax extends Syntax + object syntax extends Syntax def equalInObject = this.syntax.Foo == this.syntax.Foo - + println(equalInTrait) println(equalInObject) } diff --git a/test/files/run/t1591.scala b/test/files/run/t1591.scala index bd43f0b23d..6dd9605042 100644 --- a/test/files/run/t1591.scala +++ b/test/files/run/t1591.scala @@ -1,8 +1,8 @@ abstract class A { - + lazy val lazyBar = bar - - object bar { + + object bar { val foo = 12 } diff --git a/test/files/run/t1620.check b/test/files/run/t1620.check deleted file mode 100755 index afa1e6acd5..0000000000 --- a/test/files/run/t1620.check +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<!DOCTYPE foo PUBLIC "-//Foo Corp//DTD 1.0//EN" "foo.dtd"> -<foo/> -<?xml version='1.0' encoding='utf-8'?> -<!DOCTYPE foo PUBLIC "-//Foo Corp//DTD 1.0//EN"> -<foo/> diff --git a/test/files/run/t1620.scala b/test/files/run/t1620.scala deleted file mode 100644 index e8ea06eb5f..0000000000 --- a/test/files/run/t1620.scala +++ /dev/null @@ -1,16 +0,0 @@ -import java.io.PrintWriter -import scala.xml.XML -import scala.xml.dtd.{DocType, PublicID} - -object Test extends App { - val dt = DocType("foo", PublicID("-//Foo Corp//DTD 1.0//EN", "foo.dtd"), Seq()) - val pw = new PrintWriter(System.out) - XML.write(pw, <foo/>, "utf-8", true, dt) - pw.println() - pw.flush() - - val dt2 = DocType("foo", PublicID("-//Foo Corp//DTD 1.0//EN", null), Seq()) - XML.write(pw, <foo/>, "utf-8", true, dt2) - pw.println() - pw.flush() -} diff --git a/test/files/run/t1718.scala b/test/files/run/t1718.scala index 358bd1be5a..d1b19c38cd 100644 --- a/test/files/run/t1718.scala +++ b/test/files/run/t1718.scala @@ -1,10 +1,10 @@ object Test extends App{ - def matchesNull[T](mightBeNull: Array[T]): Boolean = mightBeNull match { + def matchesNull[T](mightBeNull: Array[T]): Boolean = mightBeNull match { case null => true case x => false } val nullArray: Array[String] = null - println(matchesNull(nullArray)) + println(matchesNull(nullArray)) } diff --git a/test/files/run/t1766.scala b/test/files/run/t1766.scala index 2afd883755..ff81da3f8e 100644 --- a/test/files/run/t1766.scala +++ b/test/files/run/t1766.scala @@ -1,16 +1,19 @@ + +import scala.language.{ reflectiveCalls } + object Test extends App { - + class C(s: String) { - + def this(i: Int) = this("bar") - + def f = { val v: { def n: Int } = new { val n = 3 } v.n } - + } - + new C("foo").f - + } diff --git a/test/files/run/t1773.scala b/test/files/run/t1773.scala deleted file mode 100644 index c50b62512f..0000000000 --- a/test/files/run/t1773.scala +++ /dev/null @@ -1,12 +0,0 @@ -object Test extends App -{ - val xs = List( - <a></a>, - <a/>, - <a>{ xml.NodeSeq.Empty }</a>, - <a>{""}</a>, - <a>{ if (true) "" else "I like turtles" }</a> - ) - - for (x1 <- xs; x2 <- xs) assert (x1 xml_== x2) -} diff --git a/test/files/run/t1829.scala b/test/files/run/t1829.scala index 7c39d33ae9..8240527424 100644 --- a/test/files/run/t1829.scala +++ b/test/files/run/t1829.scala @@ -1,6 +1,6 @@ object Test{ def main(args : Array[String]){ - import scala.collection.immutable._ + import scala.collection.immutable._ assert(IntMap.empty == HashMap.empty); assert(HashMap.empty == IntMap.empty); assert(LongMap.empty == HashMap.empty); diff --git a/test/files/run/t1909.check b/test/files/run/t1909.check new file mode 100644 index 0000000000..7d25be60fd --- /dev/null +++ b/test/files/run/t1909.check @@ -0,0 +1,3 @@ +t1909.scala:7: warning: A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled. + def this(p: String) = this(try 0) + ^ diff --git a/test/files/pos/t1909.scala b/test/files/run/t1909.scala index 01213f62a3..8ead7bacf2 100644 --- a/test/files/pos/t1909.scala +++ b/test/files/run/t1909.scala @@ -6,3 +6,7 @@ class Ticket1909 { def this(value: Int) = this() def this(p: String) = this(try 0) } + +object Test extends App { + new Ticket1909("") +} diff --git a/test/files/pos/t1909b-pos.scala b/test/files/run/t1909b.scala index b914bee366..89b2af57dc 100644 --- a/test/files/pos/t1909b-pos.scala +++ b/test/files/run/t1909b.scala @@ -3,4 +3,7 @@ class Ticket1909 (x: Int) { def bar() = 5 bar }) -}
\ No newline at end of file +} +object Test extends App { + new Ticket1909() +} diff --git a/test/files/run/t1909c.scala b/test/files/run/t1909c.scala new file mode 100644 index 0000000000..87c0eb08b5 --- /dev/null +++ b/test/files/run/t1909c.scala @@ -0,0 +1,9 @@ +class Base(a: Any) + +// java.lang.VerifyError: (class: Sub, method: <init> signature: ()V) Expecting to find object/array on stack +// at Test$.<init>(t1909c.scala) +class Sub() extends Base({ def bippy = 5; bippy }) + +object Test extends App { + new Sub() +} diff --git a/test/files/run/t1987.scala b/test/files/run/t1987.scala index 4c278ec6a0..de869edea0 100644 --- a/test/files/run/t1987.scala +++ b/test/files/run/t1987.scala @@ -5,7 +5,7 @@ package foo { package object bar { def duh(n: Long) = println("long") def duh(n: Double) = println("double") - + def duh2(n: Double) = println("double") def duh2(n: Long) = println("long") } @@ -16,7 +16,7 @@ package foo { bip.bar.duh(33L) duh(33d) bip.bar.duh(33d) - + duh2(33L) bip.bar.duh2(33L) duh2(33d) @@ -35,7 +35,7 @@ package bip { def duh2(n: Double) = println("double") def duh2(n: Long) = println("long") } - + package object bar extends Duh with Duh2 { } package bar { object Main { @@ -44,7 +44,7 @@ package bip { bip.bar.duh(33L) duh(33d) bip.bar.duh(33d) - + duh2(33L) bip.bar.duh2(33L) duh2(33d) diff --git a/test/files/run/t2029.scala b/test/files/run/t2029.scala index 1cbe97a350..32b04f0b47 100644 --- a/test/files/run/t2029.scala +++ b/test/files/run/t2029.scala @@ -3,10 +3,10 @@ object Test{ import scala.collection.immutable.TreeSet; val mainSet = TreeSet(1 to 5 :_*) - + var compareCalled = false; val smallerSet = TreeSet(2 to 4 :_*)(Ordering[Int].reverse) - + println(mainSet.mkString(",")) println(smallerSet.mkString(",")) println(smallerSet.subsetOf(mainSet)); diff --git a/test/files/run/t2074_2.scala b/test/files/run/t2074_2.scala index 1f59e0b8a1..4624170f89 100644 --- a/test/files/run/t2074_2.scala +++ b/test/files/run/t2074_2.scala @@ -12,7 +12,7 @@ object Test { def iterator = underlying.iterator } val w = IndexedSeq(1, 2, 3).view - + def main(args: Array[String]): Unit = { println(v) println(w) diff --git a/test/files/run/t2087-and-2400.scala b/test/files/run/t2087-and-2400.scala index 93cd633ffb..19a5df26e3 100644 --- a/test/files/run/t2087-and-2400.scala +++ b/test/files/run/t2087-and-2400.scala @@ -3,14 +3,14 @@ object Test def negativeCharMaker = new (Short => Char) { def apply(x: Short) = x.toChar } def main(args: Array[String]): Unit = { // throws exception if -100 gets to Character.valueOf - val x = negativeCharMaker(-100) - + val x = negativeCharMaker(-100) + // chars are unsigned, they should never be equal to negative values assert((-100).toShort != (-100).toChar) assert((-100).toChar != (-100).toShort) assert((-100).toChar != (-100).toByte) assert((-100).toByte != (-100).toChar) - + // BoxesRunTime must agree as well assert(((-100).toShort: Any) != (-100).toChar) assert(((-100).toChar: Any) != (-100).toShort) diff --git a/test/files/run/t2106.check b/test/files/run/t2106.check new file mode 100644 index 0000000000..b14e9d1c41 --- /dev/null +++ b/test/files/run/t2106.check @@ -0,0 +1,3 @@ +t2106.scala:7: warning: Could not inline required method foo because access level required by callee not matched by caller. + def main(args: Array[String]): Unit = x.foo + ^ diff --git a/test/files/run/t2106.flags b/test/files/run/t2106.flags index eb4d19bcb9..00d3643fd4 100644 --- a/test/files/run/t2106.flags +++ b/test/files/run/t2106.flags @@ -1 +1 @@ --optimise
\ No newline at end of file +-optimise -Yinline-warnings diff --git a/test/files/run/t2106.scala b/test/files/run/t2106.scala index e8124dabab..55b89da805 100644 --- a/test/files/run/t2106.scala +++ b/test/files/run/t2106.scala @@ -4,5 +4,5 @@ class A extends Cloneable { object Test { val x = new A - def main(args: Array[String]) = x.foo + def main(args: Array[String]): Unit = x.foo } diff --git a/test/files/run/t2124.check b/test/files/run/t2124.check deleted file mode 100755 index 51b40469aa..0000000000 --- a/test/files/run/t2124.check +++ /dev/null @@ -1 +0,0 @@ -<p><lost/><q/></p> diff --git a/test/files/run/t2124.scala b/test/files/run/t2124.scala deleted file mode 100644 index a4fd654d76..0000000000 --- a/test/files/run/t2124.scala +++ /dev/null @@ -1,25 +0,0 @@ -import scala.xml._ - -import scala.xml.transform._ - -object Test { - val sampleXml = <p><lost/><t><s><r></r></s></t></p> - - def main(args: scala.Array[String]) { - - println(new RuleTransformer(new RewriteRule { - - override def transform(n: Node): NodeSeq = { - val result = n match { - case <t>{_*}</t> => <q/> - - case n => n - - } -// println ("Rewriting '" +n+ "' to: '" + result+ "'") - - result - } - }).transform(sampleXml)) - } -} diff --git a/test/files/run/t2125.check b/test/files/run/t2125.check deleted file mode 100755 index 51b40469aa..0000000000 --- a/test/files/run/t2125.check +++ /dev/null @@ -1 +0,0 @@ -<p><lost/><q/></p> diff --git a/test/files/run/t2125.scala b/test/files/run/t2125.scala deleted file mode 100644 index a10ed9827b..0000000000 --- a/test/files/run/t2125.scala +++ /dev/null @@ -1,25 +0,0 @@ -import scala.xml._ - -import scala.xml.transform._ - -object Test { - - val sampleXml = <xml:group><p><lost/><t><s><r></r></s></t></p></xml:group> - - def main(args: scala.Array[String]) { - println(new RuleTransformer(new RewriteRule { - - override def transform(n: Node): NodeSeq = { - - val result = n match { - - case <t>{_*}</t> => <q/> - - case n => n - } -// println ("Rewriting '" +n+ "' to: '" + result+ "'") - result - } - }).transform(sampleXml)) - } -} diff --git a/test/files/run/t2251.check b/test/files/run/t2251.check new file mode 100644 index 0000000000..55ad2a5857 --- /dev/null +++ b/test/files/run/t2251.check @@ -0,0 +1 @@ +Set(List(List(C), Stream(D, ?))) diff --git a/test/files/run/t2251.scala b/test/files/run/t2251.scala new file mode 100644 index 0000000000..00c5619b49 --- /dev/null +++ b/test/files/run/t2251.scala @@ -0,0 +1,19 @@ +class A +trait B[T <: B[T]] extends A +class C extends B[C] { override def toString = "C" } +class D extends B[D] { override def toString = "D" } + +class E { + val ys = List(List(new C), Stream(new D)) +} + +object Test { + def trav = List(List(), Stream()) + + def main(args: Array[String]): Unit = { + val f = (new E).ys _ + var xs: Set[List[_ <: Seq[B[_]]]] = Set() + xs += f() + println(xs) + } +} diff --git a/test/files/run/t2251b.check b/test/files/run/t2251b.check new file mode 100644 index 0000000000..4231fc6ea6 --- /dev/null +++ b/test/files/run/t2251b.check @@ -0,0 +1,11 @@ +TypeTag[List[scala.collection.immutable.LinearSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with java.io.Serializable]] +TypeTag[List[scala.collection.immutable.Iterable[B[_ >: F with E with D with C <: B[_ >: F with E with D with C <: A]]] with F with Int => Any]] +TypeTag[List[scala.collection.immutable.Seq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with Serializable]] +TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[scala.collection.Map[_ >: F with C <: B[_ >: F with C <: B[_ >: F with C <: A]], B[_ >: G with D <: B[_ >: G with D <: A]]]]] +TypeTag[List[scala.collection.AbstractSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with scala.collection.LinearSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with java.io.Serializable]] +TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] diff --git a/test/files/run/t2251b.scala b/test/files/run/t2251b.scala new file mode 100644 index 0000000000..b67b3aec1e --- /dev/null +++ b/test/files/run/t2251b.scala @@ -0,0 +1,48 @@ +class A +trait B[T <: B[T]] extends A +class B1[T <: B1[T]] extends B[T] +class C extends B[C] { override def toString = "C" } +class D extends B[D] { override def toString = "D" } +class E extends B[E] { override def toString = "E" } +class F extends B[F] { override def toString = "F" } +class G extends B1[G] { override def toString = "G" } + +object Test { + import scala.collection.{ mutable, immutable } + import scala.collection.immutable.{ Vector } + import scala.reflect.runtime.universe._ + def what[T: TypeTag](x: T) = println(typeTag[T]) + + def main(args: Array[String]): Unit = { + what(List(List(new C), Stream(new D))) + what(List(List(new C), Stream(new D), Vector(new E), Set(new F))) + what(List(immutable.Vector(new C), Stream(new D))) + what(List(collection.Set(new F), mutable.Set(new G))) + what(List(collection.Set(new F), immutable.Set(new G))) + what(List(mutable.Set(new F), immutable.Set(new G))) + what(List(mutable.Seq(new F), immutable.Seq(new G))) + what(List(mutable.Map(new C -> new D), immutable.Map(new F -> new G))) + what(List(mutable.MutableList(new F), immutable.List(new G))) + what(List(mutable.Seq(new F), collection.Seq(new G))) + what(List(mutable.LinearSeq(new F), collection.IndexedSeq(new G))) + } +} + + +// class D extends B[D] { override def toString = "D" } + + +// class E { +// val ys = List(List(new C), Stream(new D)) +// } + +// object Test { +// def trav = List(List(), Stream()) + +// def main(args: Array[String]): Unit = { +// val f = (new E).ys _ +// var xs: Set[List[_ <: Seq[B[_]]]] = Set() +// xs += f() +// println(xs) +// } +// } diff --git a/test/files/run/t2276.check b/test/files/run/t2276.check deleted file mode 100644 index 95f51c8e29..0000000000 --- a/test/files/run/t2276.check +++ /dev/null @@ -1,8 +0,0 @@ -<root> - <subnode> - <version>2</version> - </subnode> - <contents> - <version>2</version> - </contents> - </root> diff --git a/test/files/run/t2276.scala b/test/files/run/t2276.scala deleted file mode 100644 index f0404e5fab..0000000000 --- a/test/files/run/t2276.scala +++ /dev/null @@ -1,24 +0,0 @@ -import scala.xml._ -import scala.xml.transform._ - -object Test extends App { - val inputXml : Node = - <root> - <subnode> - <version>1</version> - </subnode> - <contents> - <version>1</version> - </contents> - </root> - - object t1 extends RewriteRule { - override def transform(n: Node): Seq[Node] = n match { - case <version>{x}</version> if x.toString.toInt < 4 => <version>{x.toString.toInt+1}</version> - case other => other - } - } - - val ruleTransformer = new RuleTransformer(t1) - println(ruleTransformer(inputXml)) -} diff --git a/test/files/run/t2296c/Action.java b/test/files/run/t2296c/Action.java index 50ba9a4de1..4a6b69a5b8 100644 --- a/test/files/run/t2296c/Action.java +++ b/test/files/run/t2296c/Action.java @@ -8,7 +8,7 @@ public abstract class Action { public Action(Global glob0) { m_glob = glob0; } - + public Action() { this(null); } diff --git a/test/files/run/t2308a.scala b/test/files/run/t2308a.scala index abb568064a..d1144db37d 100644 --- a/test/files/run/t2308a.scala +++ b/test/files/run/t2308a.scala @@ -1,7 +1,9 @@ + +import scala.language.{ higherKinds } object Test { trait T[M[_]] - + def f1 = classOf[T[X] forSome { type X[_] } ] - + def main(args: Array[String]): Unit = println(f1) } diff --git a/test/pending/run/t2318.check b/test/files/run/t2318.check index a486f1ac47..a486f1ac47 100644 --- a/test/pending/run/t2318.check +++ b/test/files/run/t2318.check diff --git a/test/pending/run/t2318.scala b/test/files/run/t2318.scala index e42cbb9680..b638c433f5 100644 --- a/test/pending/run/t2318.scala +++ b/test/files/run/t2318.scala @@ -1,21 +1,24 @@ import java.security._ +import scala.language.{ reflectiveCalls } + object Test { trait Bar { def bar: Unit } - + object Mgr extends SecurityManager { override def checkPermission(perm: Permission) = perm match { case _: java.lang.RuntimePermission => () case _: java.io.FilePermission => () - case x: java.security.AccessControlException if x.getName contains ".networkaddress." => () // generality ftw + case x: java.security.SecurityPermission if x.getName contains ".networkaddress." => () // generality ftw + case x: java.util.PropertyPermission if x.getName == "sun.net.inetaddr.ttl" => () case _ => super.checkPermission(perm) } } - + def t1() = { val p = Runtime.getRuntime().exec("ls"); type Destroyable = { def destroy() : Unit } - def doDestroy( obj : Destroyable ) : Unit = obj.destroy(); + def doDestroy( obj : Destroyable ) : Unit = obj.destroy(); doDestroy( p ); } def t2() = { @@ -27,12 +30,12 @@ object Test { val structural = b.asInstanceOf[{ def bar: Unit }] structural.bar } - + def main(args: Array[String]) { // figuring this will otherwise break on windows try t1() catch { case _: java.io.IOException => () } - + t2() } } diff --git a/test/files/run/t2333.scala b/test/files/run/t2333.scala index da43386572..7dc7a92df2 100644 --- a/test/files/run/t2333.scala +++ b/test/files/run/t2333.scala @@ -1,7 +1,7 @@ class A { def whatever() { lazy val a = 1 - lazy val b = try { 2 } catch { case _ => 0 } + lazy val b = try { 2 } catch { case _: Throwable => 0 } a b @@ -13,4 +13,4 @@ object Test { val a = new A a.whatever } -}
\ No newline at end of file +} diff --git a/test/files/run/t2337.scala b/test/files/run/t2337.scala index 86a372ce56..edb574cba4 100644 --- a/test/files/run/t2337.scala +++ b/test/files/run/t2337.scala @@ -10,7 +10,7 @@ object Test { // throw new Exception("Unsupported compare " + first + "; " + second) } } - + def main(args: Array[String]): Unit = { println("Both Int", -1, compare(0, 1)) println("Both Float", 1, compare(1.0, 0.0)) diff --git a/test/files/run/t2354.scala b/test/files/run/t2354.scala deleted file mode 100644 index 5419911ac3..0000000000 --- a/test/files/run/t2354.scala +++ /dev/null @@ -1,17 +0,0 @@ -import scala.xml.parsing._ -import scala.io.Source - -object Test -{ - val xml_good = "<title><![CDATA[Hello [tag]]]></title>" - val xml_bad = "<title><![CDATA[Hello [tag] ]]></title>" - - val parser1 = ConstructingParser.fromSource(Source.fromString(xml_good),false) - val parser2 = ConstructingParser.fromSource(Source.fromString(xml_bad),false) - - def main(args: Array[String]): Unit = { - parser1.document - parser2.document - } -} - diff --git a/test/files/run/t2417.scala b/test/files/run/t2417.scala index 2d0bc2d405..8d1527e2d6 100644 --- a/test/files/run/t2417.scala +++ b/test/files/run/t2417.scala @@ -1,6 +1,6 @@ // #2417 object Test { - + def parallel(numThreads: Int)(block: => Unit) { var failure: Throwable = null val threads = Array.tabulate(numThreads)(i => new Thread { @@ -8,7 +8,7 @@ object Test { try { block } catch { - case x => failure = x + case x: Throwable => failure = x } } }) @@ -16,7 +16,7 @@ object Test { for (t <- threads) t.join if (failure != null) println("FAILURE: " + failure) } - + def testSet(initialSize: Int, numThreads: Int, passes: Int) { val orig = Set.empty ++ (1 to initialSize) parallel(numThreads) { @@ -32,7 +32,7 @@ object Test { } } } - + def testMap(initialSize: Int, numThreads: Int, passes: Int) { val orig = Map.empty ++ ((1 to initialSize) map ((_,"v"))) parallel(numThreads) { @@ -48,28 +48,28 @@ object Test { } } } - + def main(args: Array[String]) { println("testing small Map that doesn't promote to HashMap...") testMap(4, 2, 1000000) println() - + println("testing single-threaded HashMap use...") testMap(5, 1, 1000000) println() - + println("testing HashMap.size from multiple threads...") testMap(5, 2, 1000000) println() - + println("testing small Set that doesn't promote to HashSet...") testSet(4, 2, 1000000) println() - + println("testing single-threaded HashSet use...") testSet(5, 1, 1000000) println() - + println("testing HashSet.size from multiple threads...") testSet(5, 2, 1000000) println() diff --git a/test/files/run/t2464/Annotated.java b/test/files/run/t2464/Annotated.java new file mode 100644 index 0000000000..d022f9852c --- /dev/null +++ b/test/files/run/t2464/Annotated.java @@ -0,0 +1,5 @@ +package test; + +@Connect(loadStyle = Connect.LoadStyle.EAGER) +public class Annotated { +} diff --git a/test/files/run/t2464/Connect.java b/test/files/run/t2464/Connect.java new file mode 100644 index 0000000000..59349f94c8 --- /dev/null +++ b/test/files/run/t2464/Connect.java @@ -0,0 +1,20 @@ +package test; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Connect { + + LoadStyle loadStyle() default LoadStyle.EAGER; + + public enum LoadStyle { + EAGER, + DEFERRED, + LAZY + } +} diff --git a/test/files/run/t2464/Test.scala b/test/files/run/t2464/Test.scala new file mode 100644 index 0000000000..90e1a03c17 --- /dev/null +++ b/test/files/run/t2464/Test.scala @@ -0,0 +1,35 @@ +import scala.reflect.io.Streamable +import scala.tools.asm.{ClassWriter, ClassReader} +import scala.tools.asm.tree.ClassNode +import scala.tools.partest._ +import scala.tools.partest.BytecodeTest.modifyClassFile +import java.io.{FileOutputStream, FileInputStream, File} + +object Test extends DirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def app = """ + object O { + new test.Annotated + } + """ + + def show(): Unit = { + compileCode(app) + modifyClassFile(new File(testOutput.toFile, "test/Annotated.class")) { + (cn: ClassNode) => + // As investigated https://issues.scala-lang.org/browse/SI-2464?focusedCommentId=64521&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-64521 + // classfiles in the wild sometimes lack the required InnerClass attribute for nested enums that + // are referenced in an annotation. I don't know what compiler or bytecode processor leaves things + // that way, but this test makes sure we don't crash. + cn.innerClasses.clear() + cn + } + compileCode(app) + } +} diff --git a/test/files/run/t2512.scala b/test/files/run/t2512.scala index de20af5e72..8166839a9a 100644 --- a/test/files/run/t2512.scala +++ b/test/files/run/t2512.scala @@ -3,11 +3,11 @@ import scala.tools.nsc.util.HashSet object Test { val runs = 10000 class Bop - + def main(args: Array[String]): Unit = { val set: HashSet[Bop] = HashSet("Bop", 16) (1 to runs).toList foreach (_ => set addEntry new Bop) - + assert(runs == set.size && set.size == set.iterator.length) } } diff --git a/test/files/run/t2514.scala b/test/files/run/t2514.scala index 21c4afb472..0bf716e8bb 100644 --- a/test/files/run/t2514.scala +++ b/test/files/run/t2514.scala @@ -1,7 +1,11 @@ + + +import scala.language.{ implicitConversions, postfixOps, reflectiveCalls } + object Test { implicit def x[A](a: A) = new { def xx = a } - + def main(args: Array[String]): Unit = { val r1 = 12 xx; val r2 = 12.xx @@ -9,7 +13,7 @@ object Test val r4 = 12.xx + 12.xx val r5 = 12.`xx` + 12.xx val r6 = 12.3.`xx` + 12.xx - + assert(r5 == 24) } -}
\ No newline at end of file +} diff --git a/test/files/run/t2526.scala b/test/files/run/t2526.scala index d37185535f..53f3059135 100644 --- a/test/files/run/t2526.scala +++ b/test/files/run/t2526.scala @@ -4,18 +4,18 @@ */ object Test { import collection._ - + def main(args: Array[String]) { val m = new mutable.HashMap[String, String] - + /* Use non hash-based structure for verification */ val keys = List("a", "b", "c", "d", "e") val valueSuffix = "value" val values = keys.map(_ + valueSuffix) val entries = keys.zip(values) - + for (k <- keys) m(k) = k + valueSuffix - + assertForeach(keys, m.keySet.iterator) assertForeach(keys, m.keysIterator) assertForeach(keys, m.keySet) @@ -25,7 +25,7 @@ object Test { assertForeach(entries, m) } - + /* Checks foreach of `actual` goes over all the elements in `expected` */ private def assertForeach[E](expected: Traversable[E], actual: Iterator[E]): Unit = { val notYetFound = new mutable.ArrayBuffer[E]() ++= expected @@ -35,12 +35,12 @@ object Test { } assert(notYetFound.size == 0, "mutable.HashMap.foreach should have iterated over: " + notYetFound) } - - /* + + /* * Checks foreach of `actual` goes over all the elements in `expected` * We duplicate the method above because there is no common inteface between Traversable and * Iterator and we want to avoid converting between collections to ensure that we test what - * we mean to test. + * we mean to test. */ private def assertForeach[E](expected: Traversable[E], actual: Traversable[E]): Unit = { val notYetFound = new mutable.ArrayBuffer[E]() ++= expected diff --git a/test/files/run/t2552.scala b/test/files/run/t2552.scala index 17dcac596b..0c6b4f005b 100644 --- a/test/files/run/t2552.scala +++ b/test/files/run/t2552.scala @@ -2,11 +2,11 @@ object Test extends App { def testTakeWhile = { val numbers = Iterator.range(0, 50) val zeroTo9 = numbers.takeWhile(x => { println("p(" + x + ")"); x < 10 } ) - + zeroTo9.foreach(println _) - + val zeroTo1 = Iterator.range(0, 20).takeWhile(x => { println("p(" + x + ")"); x < 2 } ) - + println(zeroTo1.hasNext) println(zeroTo1.hasNext) println(zeroTo1.next) @@ -15,16 +15,16 @@ object Test extends App { println(zeroTo1.hasNext) println(zeroTo1.hasNext) } - + def testFilter = { val predicate = (x: Int) => { println("p(" + x + ")"); x % 2 == 0 } - + val evens = Iterator.range(0, 10).filter(predicate) - + println(evens.hasNext) println(evens.hasNext) println(evens.next) - + evens.foreach(println _) } diff --git a/test/files/run/t2577.check b/test/files/run/t2577.check new file mode 100644 index 0000000000..4a584e4989 --- /dev/null +++ b/test/files/run/t2577.check @@ -0,0 +1 @@ +Nothing diff --git a/test/files/run/t2577.scala b/test/files/run/t2577.scala new file mode 100644 index 0000000000..6d836a3996 --- /dev/null +++ b/test/files/run/t2577.scala @@ -0,0 +1,17 @@ +case class annot[T]() extends scala.annotation.StaticAnnotation + +// type inference should infer @annot[Nothing] instead of @annot[T] +// note the T is not in scope here! +class Foo[@annot U] + +object Test { + import scala.reflect.runtime.universe._ + val x = new Foo + + def main(args: Array[String]): Unit = { + val targ = typeOf[x.type].widen match { + case TypeRef(_, _, arg :: _) => arg + } + println(targ) + } +} diff --git a/test/files/run/t2594_tcpoly.scala b/test/files/run/t2594_tcpoly.scala index e759ca8b0f..a9d26693f9 100644 --- a/test/files/run/t2594_tcpoly.scala +++ b/test/files/run/t2594_tcpoly.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds } + trait Monad[M[_]] { def foo[A](a: M[A]): M[A] } @@ -15,4 +18,4 @@ object Test { } def main(as: Array[String]) { BarMonad[Int] foo (new Bar[Int, Int]) } -}
\ No newline at end of file +} diff --git a/test/files/run/t2636.scala b/test/files/run/t2636.scala index 3271f79ffc..2f55c8ad5a 100644 --- a/test/files/run/t2636.scala +++ b/test/files/run/t2636.scala @@ -1,30 +1,33 @@ + +import scala.language.{ reflectiveCalls } + object Test { type Foo = { def update(x: Int, value: String): Unit } type Foo2 = { def update(x: Int, value: String): Int } type Foo3 = { def update(x: Int, value: String): Array[Int] } - + def alen() = { type L1 = { def length: Int } def len(p: L1) = p.length val x: L1 = Array(1,2,3) len(x) } - + type A1 = { def apply(x: Int): String } def arrApply(a: A1, x: Int) = a(x) - + def main(args: Array[String]): Unit = { val arr = new Array[String](3) val p1: Foo = arr def a1 = p1(0) = "b" val p2: Foo2 = new { def update(x: Int, value: String) = { p1(1) = "o" ; 1 } } - def a2 = p2(0) = "c" - + def a2 = p2(0) = "c" + val p3: Foo3 = new { def update(x: Int, value: String) = { p1(2) = "b" ; Array(1) } } def a3 = p3(10) = "hi mom" - + a1 ; a2 ; a3 ; assert(arr.mkString == "bob") @@ -32,4 +35,4 @@ object Test assert(arrApply(arr, 1) == "o") assert(arrApply(new { def apply(x: Int) = "tom" }, -100) == "tom") } -}
\ No newline at end of file +} diff --git a/test/files/run/t266.scala b/test/files/run/t266.scala index 1fd6dab185..20a29dabbb 100644 --- a/test/files/run/t266.scala +++ b/test/files/run/t266.scala @@ -2,9 +2,9 @@ trait O { self: Test.type => - + Nil foreach identity - + def f = (1 to 10).toList map identity } diff --git a/test/files/run/t2721.check b/test/files/run/t2721.check deleted file mode 100644 index 2bd7656b36..0000000000 --- a/test/files/run/t2721.check +++ /dev/null @@ -1,2 +0,0 @@ -root:-rootVal-sub:-subVal- -root:-rootVal-sub:-subVal- diff --git a/test/files/run/t2721.scala b/test/files/run/t2721.scala deleted file mode 100644 index 93af884a60..0000000000 --- a/test/files/run/t2721.scala +++ /dev/null @@ -1,12 +0,0 @@ -object Test -{ - val xml1 = <root xmlns:ns="nsUri" ns:at="rootVal"><sub ns:at="subVal"/></root> - val xml2= scala.xml.XML.loadString("""<root xmlns:ns="nsUri" ns:at="rootVal"><sub ns:at="subVal"/></root>""") - - def backslashSearch(x: xml.Elem) = "root:-"+(x \ "@{nsUri}at") +"-sub:-"+(x \ "sub" \ "@{nsUri}at") +"-" - - def main(args: Array[String]): Unit = { - println(backslashSearch(xml1)) - println(backslashSearch(xml2)) - } -} diff --git a/test/files/run/t2755.scala b/test/files/run/t2755.scala index c279ecc24e..8d10b56734 100644 --- a/test/files/run/t2755.scala +++ b/test/files/run/t2755.scala @@ -28,7 +28,7 @@ object Test { case x: Array[_] => 6 case _ => 7 } - + def main(args: Array[String]): Unit = { println(f1(Array(1, 2, 3))) @@ -38,7 +38,7 @@ object Test { println(f1(new Array[Any](10))) // should match as Array[AnyRef] println(f1(Array(1L))) println(f1(null)) - + println(f2(Array(1, 2, 3))) println(f2(Array(1.0, -2.0, 3.0, 1.0))) println(f2(Array(1.0f, 2.0f, 3.0f, -3.0f))) @@ -46,7 +46,7 @@ object Test { println(f2(new Array[Any](10))) // should match as Array[AnyRef] println(f2(Array(1L))) println(f2(null)) - + println(f3(Array(1, 2, 3))) println(f3(Array(1.0, -2.0, 3.0, 1.0))) println(f3(Array(1.0f, 2.0f, 3.0f, -3.0f))) diff --git a/test/files/run/t2800.scala b/test/files/run/t2800.scala index cc6fb30bbc..84d1de0507 100644 --- a/test/files/run/t2800.scala +++ b/test/files/run/t2800.scala @@ -3,20 +3,20 @@ object Test { def f2 = (5: Any) match { case List(x @ _*) => x ; case _ => false } def f3 = (Nil: Any) match { case List(x @ _*) => x ; case _ => false } def f4 = (Array(1): Any) match { case List(x @ _*) => x ; case _ => false } - + def f5 = ("": Any) match { case Array(x @ _*) => x ; case _ => false } def f6 = (5: Any) match { case Array(x @ _*) => x ; case _ => false } def f7 = (Nil: Any) match { case Array(x @ _*) => x ; case _ => false } def f8 = (Array(1): Any) match { case Array(x @ _*) => x ; case _ => false } - + def f9 = ("": Any) match { case x @ List(_*) => x ; case _ => false } def f10 = ("": Any) match { case List(_*) => true ; case _ => false } def f11 = (Nil: Any) match { case List(_*) => true ; case _ => false } def f12 = ("": Any) match { case x @ Array(_*) => x ; case _ => false } def f13 = ("": Any) match { case Array(_*) => true ; case _ => false } def f14 = (Nil: Any) match { case Array(_*) => true ; case _ => false } - - + + def main(args: Array[String]): Unit = { println(f1) println(f2) diff --git a/test/files/run/t2818.scala b/test/files/run/t2818.scala index 19b67cbc88..746cdfb049 100644 --- a/test/files/run/t2818.scala +++ b/test/files/run/t2818.scala @@ -1,6 +1,6 @@ object Test extends App { println((List.range(1L, 15L) :\ 0L) (_ + _)) println((List.range(1L, 1000000L) :\ 0L) (_ + _)) - println((List.fill(5)(1) :\ 1) (_ - _)) - println((List.fill(1000000)(1) :\ 1) (_ - _)) + println((List.fill(5)(1) :\ 1) (_ - _)) + println((List.fill(1000000)(1) :\ 1) (_ - _)) } diff --git a/test/files/run/t2849.scala b/test/files/run/t2849.scala index 0995f64010..cadf605ae0 100644 --- a/test/files/run/t2849.scala +++ b/test/files/run/t2849.scala @@ -16,9 +16,9 @@ object Test { def ticketExample { var big = 100000 - + var aSortedSet: SortedSet[Int] = TreeSet(big) - + for (i <- 1 until N) { aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1)) big -= 1 @@ -42,7 +42,7 @@ object Test { } } } - + } diff --git a/test/files/run/t2867.scala b/test/files/run/t2867.scala index 0d30f95f8d..25e55eaecd 100644 --- a/test/files/run/t2867.scala +++ b/test/files/run/t2867.scala @@ -1,6 +1,6 @@ object Test { - case class A(l: List[_]*) - + case class A(l: List[_]*) + def main(args: Array[String]): Unit = { /** Kind of sneaking a slightly different test in here as well as * testing 2867. How subversive. @@ -9,7 +9,7 @@ object Test { val xs2 = List(1.0, 2.0, 3.0) val xs3 = List[Any](1.0f, 2.0f, 3.0f) val xs4 = List[Byte](1, 2, 3) - + assert(A(List(xs1, xs2)) == A(List(xs3, xs4))) } } diff --git a/test/files/run/t2873.check b/test/files/run/t2873.check index 9198280f61..209b679c07 100644 --- a/test/files/run/t2873.check +++ b/test/files/run/t2873.check @@ -1 +1 @@ -scala.collection.immutable.RedBlack<A>.Empty$ +RedBlack<A>.Empty$ diff --git a/test/files/run/t2873.scala b/test/files/run/t2873.scala index 8d48a8dbb4..3a3cc59b46 100644 --- a/test/files/run/t2873.scala +++ b/test/files/run/t2873.scala @@ -1,5 +1,10 @@ +abstract class RedBlack[A] extends Serializable { + abstract class Tree[+B] extends Serializable + case object Empty extends Tree[Nothing] +} + object Test { def main(args: Array[String]): Unit = { - println(classOf[scala.collection.immutable.RedBlack[_]].getMethod("Empty").getGenericReturnType) + println(classOf[RedBlack[_]].getMethod("Empty").getGenericReturnType) } } diff --git a/test/files/run/t2886.check b/test/files/run/t2886.check index a70f9935ed..61e36948bd 100644 --- a/test/files/run/t2886.check +++ b/test/files/run/t2886.check @@ -1,5 +1,5 @@ ((x: Predef.String) => { - val x$1 = x; - val x$2 = x; + <artifact> val x$1 = x; + <artifact> val x$2 = x; Test.this.test(x$2, x$1) }) diff --git a/test/files/run/t2958.scala b/test/files/run/t2958.scala index b9563a1b77..dcd24ecc36 100644 --- a/test/files/run/t2958.scala +++ b/test/files/run/t2958.scala @@ -2,14 +2,14 @@ object Test { def f(args: Array[String]) = args match { case Array("-p", prefix, from, to) => prefix + from + to - + case Array(from, to) => from + to case _ => "default" } - + def main(args: Array[String]) { assert(f(Array("1", "2")) == "12") } diff --git a/test/files/run/t3026.scala b/test/files/run/t3026.scala index 0231c7bcd1..22dde9cc03 100755 --- a/test/files/run/t3026.scala +++ b/test/files/run/t3026.scala @@ -3,6 +3,6 @@ object Test { case object RED extends Colour case object YELLOW extends Colour val items = Array(RED, YELLOW) - + def main(args: Array[String]): Unit = items foreach println } diff --git a/test/files/run/t3038.scala b/test/files/run/t3038.scala index 986fc982e7..7eb69f7fb5 100644 --- a/test/files/run/t3038.scala +++ b/test/files/run/t3038.scala @@ -2,18 +2,18 @@ class A { private lazy val a1 = "a1" object B private lazy val a2 = "a2" - + @transient lazy val a3 = "a3" @transient private lazy val a4 = "a4" @transient lazy val a5 = "a5" @transient private lazy val a6 = "a6" - + final val a7 = "a7" private final val a8 = "a8" @transient final val a9 = "a9" - - + + def run = { @@ -27,13 +27,13 @@ class A { println(a7) println(a8) println(a9) - } + } } class C extends A { private lazy val c1 = "c1" lazy val c2 = "c2" - + private lazy val c3 = "c3" @transient lazy val c4 = "c4" @@ -41,7 +41,7 @@ class C extends A { @transient lazy val c6 = "c6" @transient private lazy val c7 = "c7" lazy val c8 = "c8" - + final val c9 = "c9" private final val c10 = "c10" diff --git a/test/files/run/t3038c/A_1.scala b/test/files/run/t3038c/A_1.scala index 14579fcf67..91564e3021 100644 --- a/test/files/run/t3038c/A_1.scala +++ b/test/files/run/t3038c/A_1.scala @@ -59,7 +59,7 @@ class A { lazy val a57 = 58 lazy val a58 = 59 lazy val a59 = 60 - private lazy val a60 = 61 + private lazy val a60 = 61 private lazy val a61 = 62 private lazy val a62 = 63 private lazy val a63 = 64 @@ -69,7 +69,7 @@ class A { private lazy val a67 = 68 private lazy val a68 = 69 private lazy val a69 = 70 - + def run = { println(List(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, diff --git a/test/files/run/t3038d.scala b/test/files/run/t3038d.scala index 6cd2d83776..44fb047b0b 100644 --- a/test/files/run/t3038d.scala +++ b/test/files/run/t3038d.scala @@ -16,19 +16,17 @@ trait Foo { } } - -@serializable -class Bar extends Foo { +class Bar extends Foo with Serializable { @transient protected var first: Any = null def size = a @transient var second: Any = null - - def checkMember { first } - + + def checkMember { if (first == null) print("") } + private def writeObject(out: java.io.ObjectOutputStream) { serializeTo(out) } - + private def readObject(in: java.io.ObjectInputStream) { first = null init(in) @@ -40,7 +38,7 @@ object Test { val in = new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(bytes)) in.readObject.asInstanceOf[A] } - + private def toBytes(o: AnyRef): Array[Byte] = { val bos = new java.io.ByteArrayOutputStream val out = new java.io.ObjectOutputStream(bos) @@ -49,7 +47,7 @@ object Test { bos.toByteArray } - + def main(args: Array[String]) { val a1 = new Bar() val serialized:Array[Byte] = toBytes(a1) diff --git a/test/files/run/t3050.scala b/test/files/run/t3050.scala index ca9d91e191..160f8b664b 100644 --- a/test/files/run/t3050.scala +++ b/test/files/run/t3050.scala @@ -1,9 +1,9 @@ object Test { def main(args: Array[String]): Unit = { - val x = + val x = try { ("": Any) match { case List(_*) => true } } - catch { case _ => false } - + catch { case _: Throwable => false } + assert(!x) } } diff --git a/test/files/run/t3112.scala b/test/files/run/t3112.scala index 88677fa09e..eb8eec6327 100644 --- a/test/files/run/t3112.scala +++ b/test/files/run/t3112.scala @@ -7,5 +7,5 @@ object Test { println((Vector() ++ (0 until 32)) takeRight 0) // works println((Vector() ++ (0 until 33)) takeRight 0) // error } - + }
\ No newline at end of file diff --git a/test/files/run/t3150.scala b/test/files/run/t3150.scala index 8acdb50354..034703b5f7 100644 --- a/test/files/run/t3150.scala +++ b/test/files/run/t3150.scala @@ -1,7 +1,7 @@ object Test { case object Bob { override def equals(other: Any) = true } def f(x: Any) = x match { case Bob => Bob } - + def main(args: Array[String]): Unit = { assert(f(Bob) eq Bob) assert(f(0) eq Bob) diff --git a/test/files/run/t3158.scala b/test/files/run/t3158.scala index 2261b5cd81..c824b62e96 100644 --- a/test/files/run/t3158.scala +++ b/test/files/run/t3158.scala @@ -1,6 +1,6 @@ object Test { def main(args: Array[String]) { - println(args.map(_ => foo _).deep) + println(args.map(_ => foo _).deep) } def foo(xs: String*) { diff --git a/test/files/run/t3175.scala b/test/files/run/t3175.scala index aff2e67d0d..ea56ded229 100644 --- a/test/files/run/t3175.scala +++ b/test/files/run/t3175.scala @@ -1,51 +1,54 @@ /** A bit down the road this test will examine * the bytecode. */ + +import scala.language.reflectiveCalls + object Test { def len(x:{ def length: Int }) = x.length def f1(x:{ def apply(x: Int): Long }) = x(0) def f2(x:{ def apply(x: Int): Byte }) = x(0) def f3(x:{ def apply(x: Int): String }) = x(0).length - + def f4(x:{ def update(x: Int, y: Long): Unit }, y: Long) = x(0) = y def f5(x:{ def update(x: Int, y: Byte): Unit }, y: Byte) = x(0) = y def f6(x:{ def update(x: Int, y: String): Unit }, y: String) = x(0) = y - + def f7(x: { def length: Any }) = x.length - + def f8(x: { def apply(x: Int): Any }) = x(0) def f9(x: { def apply(x: Int): Int }) = x(0) def f10(x: { def apply(x: Int): Long }) = x(0) - + // update has some interesting special cases def f11(x:{ def update(x: Int, y: Long): Any }, y: Long) = x(0) = y - def f12(x:{ def update(x: Int, y: String): AnyVal }, y: String) = x(0) = y + def f12(x:{ def update(x: Int, y: String): AnyVal }, y: String) = x(0) = y def f13(x:{ def update(x: Int, y: String): AnyRef }, y: String) = x(0) = y - + // doesn't work yet, see #3197 // def fclone(x:{ def clone(): AnyRef }) = x.clone() - + def main(args: Array[String]): Unit = { val longs = Array(5L) val bytes = Array(5: Byte) val strs = Array("abcde", "fghjij") - + println(len(Array(1,2,3)) + len(Array(4.0,5.0f)) + len(Array("abc", 5)) + len("bop")) println(f1(longs) + f2(bytes) + f3(strs)) - + f4(longs, 1) f5(bytes, 1) f6(strs, "a") - + println(f1(longs) + f2(bytes) + f3(strs)) - + println(f7(Array(1,2,3))) println(f7("def")) - + println(f8(Array(5))) println(f9(Array(5))) println(f10(Array(5))) - + f11(longs, 100L) f12(strs, "jabooboo") println(longs(0)) diff --git a/test/files/run/t3232.scala b/test/files/run/t3232.scala index feff7e7089..900a1f5dba 100644 --- a/test/files/run/t3232.scala +++ b/test/files/run/t3232.scala @@ -4,18 +4,18 @@ object Test { val r2 = 1 to Int.MaxValue val r3 = Int.MinValue to -2 val r4 = Int.MinValue until -1 - + // some exceptional conditions val e1 = () => (0 to Int.MaxValue).length val e2 = () => (5 until 5).last - + def main(args: Array[String]): Unit = { List(r1, r2, r3, r4) foreach (x => assert(x.length == Int.MaxValue)) - + // exception required List(e1, e2) foreach { f => try { f() ; assert(false) } - catch { case _ => () } + catch { case _: Throwable => () } } } } diff --git a/test/files/run/t3242.scala b/test/files/run/t3242.scala index f8defaa5cd..0a449d51f9 100644 --- a/test/files/run/t3242.scala +++ b/test/files/run/t3242.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds } + object Test { def benchmarkA(num: Int) { diff --git a/test/files/run/t3269.scala b/test/files/run/t3269.scala index 6fe727111c..17e42cdb0e 100644 --- a/test/files/run/t3269.scala +++ b/test/files/run/t3269.scala @@ -4,6 +4,6 @@ object Test { println(it.next) it.hasNext it.hasNext - it.hasNext + it.hasNext } } diff --git a/test/files/run/t3273.scala b/test/files/run/t3273.scala index a4dfc4b30c..379a8a29c1 100644 --- a/test/files/run/t3273.scala +++ b/test/files/run/t3273.scala @@ -1,7 +1,7 @@ object Test { val num1: Stream[Int] = 1 #:: num1.map(_ + 1) val num2: Stream[Int] = 1 #:: num2.iterator.map(_ + 1).toStream - + def main(args: Array[String]): Unit = { val x1 = (num1 take 10).toList val x2 = (num2 take 10).toList diff --git a/test/files/run/t3326.scala b/test/files/run/t3326.scala index f70cb01504..4ac7ef9138 100644 --- a/test/files/run/t3326.scala +++ b/test/files/run/t3326.scala @@ -10,7 +10,7 @@ import scala.math.Ordering * * There are 2 `++` overloads - a generic one in traversables and * a map-specific one in `MapLike` - which knows about the ordering. - * + * * The problem here is that the expected return type for the expression * in which `++` appears drives the decision of the overload that needs * to be taken. @@ -18,36 +18,36 @@ import scala.math.Ordering * `SortedMap`, but `immutable.Map` instead. * This is why `collection.SortedMap` used to resort to the generic * `TraversableLike.++` which knows nothing about the ordering. - * + * * To avoid `collection.SortedMap`s resort to the more generic `TraverableLike.++`, * we override the `MapLike.++` overload in `collection.SortedMap` to return * the proper type `SortedMap`. */ object Test { - + def main(args: Array[String]) { testCollectionSorted() testImmutableSorted() } - + def testCollectionSorted() { import collection._ val order = implicitly[Ordering[Int]].reverse var m1: SortedMap[Int, String] = SortedMap.empty[Int, String](order) var m2: SortedMap[Int, String] = SortedMap.empty[Int, String](order) - + m1 += (1 -> "World") m1 += (2 -> "Hello") - + m2 += (4 -> "Bar") m2 += (5 -> "Foo") - + val m3: SortedMap[Int, String] = m1 ++ m2 - + println(m1) println(m2) println(m3) - + println(m1 + (3 -> "?")) } @@ -56,19 +56,19 @@ object Test { val order = implicitly[Ordering[Int]].reverse var m1: SortedMap[Int, String] = SortedMap.empty[Int, String](order) var m2: SortedMap[Int, String] = SortedMap.empty[Int, String](order) - + m1 += (1 -> "World") m1 += (2 -> "Hello") - + m2 += (4 -> "Bar") m2 += (5 -> "Foo") - + val m3: SortedMap[Int, String] = m1 ++ m2 - + println(m1) println(m2) println(m3) - + println(m1 + (3 -> "?")) } } diff --git a/test/files/run/t3361.scala b/test/files/run/t3361.scala index 7fbc6777f2..d49bcbc905 100644 --- a/test/files/run/t3361.scala +++ b/test/files/run/t3361.scala @@ -40,7 +40,7 @@ object Test extends App { def insert_1 { val ten = DoubleLinkedList(1 to 10: _*) ten.append(DoubleLinkedList(11)) - + // Post-insert size test require(11 == ten.size) // Post-insert data test @@ -57,7 +57,7 @@ object Test extends App { DoubleLinkedList().insert(ten) } catch { case _: IllegalArgumentException => require(true) - case _ => require(false) + case _: Throwable => require(false) } val zero = DoubleLinkedList(0) zero.insert(ten) @@ -87,7 +87,7 @@ object Test extends App { DoubleLinkedList().append(ten) } catch { case _: IllegalArgumentException => require(true) - case _ => require(false) + case _: Throwable => require(false) } val zero = DoubleLinkedList(0) zero.append(ten) diff --git a/test/files/run/t3376.check b/test/files/run/t3376.check index 3a1d7d581b..cc6949d326 100644 --- a/test/files/run/t3376.check +++ b/test/files/run/t3376.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> class M[@specialized T] { override def toString = "mmm" } defined class M diff --git a/test/files/run/t3395.scala b/test/files/run/t3395.scala index 01cc431871..b4990a1716 100644 --- a/test/files/run/t3395.scala +++ b/test/files/run/t3395.scala @@ -1,11 +1,11 @@ object Test { def main(args: Array[String]): Unit = { - Seq("") match { + Seq("") match { case Seq("") => println("abc") case Seq(_, _, x) => println(x) } - - Seq(1, 2, "def") match { + + Seq(1, 2, "def") match { case Seq("") => println("abc") case Seq(_, _, x) => println(x) } diff --git a/test/files/run/t3397.scala b/test/files/run/t3397.scala index 243fe766de..2c8cbed3ab 100644 --- a/test/files/run/t3397.scala +++ b/test/files/run/t3397.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { val x = Seq(Set(1,2,3),Set(4,5,6),Set(7,8,9)).transpose - + () } } diff --git a/test/files/run/t3425.check b/test/files/run/t3425.check new file mode 100644 index 0000000000..5be779bd74 --- /dev/null +++ b/test/files/run/t3425.check @@ -0,0 +1,4 @@ +123 +456 +789 +789 diff --git a/test/files/run/t3425.scala b/test/files/run/t3425.scala new file mode 100644 index 0000000000..c61d1071a5 --- /dev/null +++ b/test/files/run/t3425.scala @@ -0,0 +1,41 @@ +import scala.language.reflectiveCalls +object Other { + abstract class Foo { + type R1 <: { def x: Any } + type R2 <: R1 { def x: Int } + + def f(x: R2) = x.x + } + + abstract class Bar { + trait R0 { def x: Any } + type R1 <: R0 { def x: AnyVal } + type R2 <: R1 { def x: Int } + + def f(x: R2) = x.x + } +} +object Test { + trait A + trait B + def x(a: (A { val y: Int }) with B { val y: Int }) = a.y + + class C extends A with B { + val y = 456 + } + + class Bippy { def x: Int = 789 } + + def main(args: Array[String]): Unit = { + println(x(new A with B { val y = 123 })) + println(x(new C)) + + { val foo = new Other.Foo { type R1 = Bippy ; type R2 = Bippy } + println(foo.f(new Bippy)) + } + { val bar = new Other.Bar { type R1 = Bippy with R0 ; type R2 = R1 } + println(bar.f(new Bippy with bar.R0)) + } + } +} + diff --git a/test/files/run/t3425b.check b/test/files/run/t3425b.check new file mode 100644 index 0000000000..5d34c43de3 --- /dev/null +++ b/test/files/run/t3425b.check @@ -0,0 +1,152 @@ +==== Direct Calls ==== + +Any{val y: P} with C{val y: P} +Any{val y: P} with C{val y: Q} +Any{val y: P} with C{val y: R forSome { type R <: P with Q }} +Any{val y: Q} with C{val y: P} +Any{val y: Q} with C{val y: Q} +Any{val y: Q} with C{val y: R forSome { type R <: P with Q }} +Any{val y: R forSome { type R <: P with Q }} with C{val y: P} +Any{val y: R forSome { type R <: P with Q }} with C{val y: Q} +Any{val y: R forSome { type R <: P with Q }} with C{val y: R forSome { type R <: P with Q }} +A{val y: P} with C{val y: P} +A{val y: P} with C{val y: Q} +A{val y: P} with C{val y: R forSome { type R <: P with Q }} +A{val y: Q} with C{val y: P} +A{val y: Q} with C{val y: Q} +A{val y: Q} with C{val y: R forSome { type R <: P with Q }} +A{val y: R forSome { type R <: P with Q }} with C{val y: P} +A{val y: R forSome { type R <: P with Q }} with C{val y: Q} +A{val y: R forSome { type R <: P with Q }} with C{val y: R forSome { type R <: P with Q }} +B{val y: P} with C{val y: P} +B{val y: P} with C{val y: Q} +B{val y: P} with C{val y: R forSome { type R <: P with Q }} +B{val y: Q} with C{val y: P} +B{val y: Q} with C{val y: Q} +B{val y: Q} with C{val y: R forSome { type R <: P with Q }} +B{val y: R forSome { type R <: P with Q }} with C{val y: P} +B{val y: R forSome { type R <: P with Q }} with C{val y: Q} +B{val y: R forSome { type R <: P with Q }} with C{val y: R forSome { type R <: P with Q }} +C{val y: P} with C{val y: P} +C{val y: P} with C{val y: Q} +C{val y: P} with C{val y: R forSome { type R <: P with Q }} +C{val y: Q} with C{val y: P} +C{val y: Q} with C{val y: Q} +C{val y: Q} with C{val y: R forSome { type R <: P with Q }} +C{val y: R forSome { type R <: P with Q }} with C{val y: P} +C{val y: R forSome { type R <: P with Q }} with C{val y: Q} +C{val y: R forSome { type R <: P with Q }} with C{val y: R forSome { type R <: P with Q }} + + +==== Reflective Calls ==== + +Any{val y: P} with Any{val y: P} +Any{val y: P} with Any{val y: Q} +Any{val y: P} with Any{val y: R forSome { type R <: P with Q }} +Any{val y: P} with A{val y: P} +Any{val y: P} with A{val y: Q} +Any{val y: P} with A{val y: R forSome { type R <: P with Q }} +Any{val y: P} with B{val y: P} +Any{val y: P} with B{val y: Q} +Any{val y: P} with B{val y: R forSome { type R <: P with Q }} +Any{val y: Q} with Any{val y: P} +Any{val y: Q} with Any{val y: Q} +Any{val y: Q} with Any{val y: R forSome { type R <: P with Q }} +Any{val y: Q} with A{val y: P} +Any{val y: Q} with A{val y: Q} +Any{val y: Q} with A{val y: R forSome { type R <: P with Q }} +Any{val y: Q} with B{val y: P} +Any{val y: Q} with B{val y: Q} +Any{val y: Q} with B{val y: R forSome { type R <: P with Q }} +Any{val y: R forSome { type R <: P with Q }} with Any{val y: P} +Any{val y: R forSome { type R <: P with Q }} with Any{val y: Q} +Any{val y: R forSome { type R <: P with Q }} with Any{val y: R forSome { type R <: P with Q }} +Any{val y: R forSome { type R <: P with Q }} with A{val y: P} +Any{val y: R forSome { type R <: P with Q }} with A{val y: Q} +Any{val y: R forSome { type R <: P with Q }} with A{val y: R forSome { type R <: P with Q }} +Any{val y: R forSome { type R <: P with Q }} with B{val y: P} +Any{val y: R forSome { type R <: P with Q }} with B{val y: Q} +Any{val y: R forSome { type R <: P with Q }} with B{val y: R forSome { type R <: P with Q }} +A{val y: P} with Any{val y: P} +A{val y: P} with Any{val y: Q} +A{val y: P} with Any{val y: R forSome { type R <: P with Q }} +A{val y: P} with A{val y: P} +A{val y: P} with A{val y: Q} +A{val y: P} with A{val y: R forSome { type R <: P with Q }} +A{val y: P} with B{val y: P} +A{val y: P} with B{val y: Q} +A{val y: P} with B{val y: R forSome { type R <: P with Q }} +A{val y: Q} with Any{val y: P} +A{val y: Q} with Any{val y: Q} +A{val y: Q} with Any{val y: R forSome { type R <: P with Q }} +A{val y: Q} with A{val y: P} +A{val y: Q} with A{val y: Q} +A{val y: Q} with A{val y: R forSome { type R <: P with Q }} +A{val y: Q} with B{val y: P} +A{val y: Q} with B{val y: Q} +A{val y: Q} with B{val y: R forSome { type R <: P with Q }} +A{val y: R forSome { type R <: P with Q }} with Any{val y: P} +A{val y: R forSome { type R <: P with Q }} with Any{val y: Q} +A{val y: R forSome { type R <: P with Q }} with Any{val y: R forSome { type R <: P with Q }} +A{val y: R forSome { type R <: P with Q }} with A{val y: P} +A{val y: R forSome { type R <: P with Q }} with A{val y: Q} +A{val y: R forSome { type R <: P with Q }} with A{val y: R forSome { type R <: P with Q }} +A{val y: R forSome { type R <: P with Q }} with B{val y: P} +A{val y: R forSome { type R <: P with Q }} with B{val y: Q} +A{val y: R forSome { type R <: P with Q }} with B{val y: R forSome { type R <: P with Q }} +B{val y: P} with Any{val y: P} +B{val y: P} with Any{val y: Q} +B{val y: P} with Any{val y: R forSome { type R <: P with Q }} +B{val y: P} with A{val y: P} +B{val y: P} with A{val y: Q} +B{val y: P} with A{val y: R forSome { type R <: P with Q }} +B{val y: P} with B{val y: P} +B{val y: P} with B{val y: Q} +B{val y: P} with B{val y: R forSome { type R <: P with Q }} +B{val y: Q} with Any{val y: P} +B{val y: Q} with Any{val y: Q} +B{val y: Q} with Any{val y: R forSome { type R <: P with Q }} +B{val y: Q} with A{val y: P} +B{val y: Q} with A{val y: Q} +B{val y: Q} with A{val y: R forSome { type R <: P with Q }} +B{val y: Q} with B{val y: P} +B{val y: Q} with B{val y: Q} +B{val y: Q} with B{val y: R forSome { type R <: P with Q }} +B{val y: R forSome { type R <: P with Q }} with Any{val y: P} +B{val y: R forSome { type R <: P with Q }} with Any{val y: Q} +B{val y: R forSome { type R <: P with Q }} with Any{val y: R forSome { type R <: P with Q }} +B{val y: R forSome { type R <: P with Q }} with A{val y: P} +B{val y: R forSome { type R <: P with Q }} with A{val y: Q} +B{val y: R forSome { type R <: P with Q }} with A{val y: R forSome { type R <: P with Q }} +B{val y: R forSome { type R <: P with Q }} with B{val y: P} +B{val y: R forSome { type R <: P with Q }} with B{val y: Q} +B{val y: R forSome { type R <: P with Q }} with B{val y: R forSome { type R <: P with Q }} +C{val y: P} with Any{val y: P} +C{val y: P} with Any{val y: Q} +C{val y: P} with Any{val y: R forSome { type R <: P with Q }} +C{val y: P} with A{val y: P} +C{val y: P} with A{val y: Q} +C{val y: P} with A{val y: R forSome { type R <: P with Q }} +C{val y: P} with B{val y: P} +C{val y: P} with B{val y: Q} +C{val y: P} with B{val y: R forSome { type R <: P with Q }} +C{val y: Q} with Any{val y: P} +C{val y: Q} with Any{val y: Q} +C{val y: Q} with Any{val y: R forSome { type R <: P with Q }} +C{val y: Q} with A{val y: P} +C{val y: Q} with A{val y: Q} +C{val y: Q} with A{val y: R forSome { type R <: P with Q }} +C{val y: Q} with B{val y: P} +C{val y: Q} with B{val y: Q} +C{val y: Q} with B{val y: R forSome { type R <: P with Q }} +C{val y: R forSome { type R <: P with Q }} with Any{val y: P} +C{val y: R forSome { type R <: P with Q }} with Any{val y: Q} +C{val y: R forSome { type R <: P with Q }} with Any{val y: R forSome { type R <: P with Q }} +C{val y: R forSome { type R <: P with Q }} with A{val y: P} +C{val y: R forSome { type R <: P with Q }} with A{val y: Q} +C{val y: R forSome { type R <: P with Q }} with A{val y: R forSome { type R <: P with Q }} +C{val y: R forSome { type R <: P with Q }} with B{val y: P} +C{val y: R forSome { type R <: P with Q }} with B{val y: Q} +C{val y: R forSome { type R <: P with Q }} with B{val y: R forSome { type R <: P with Q }} + + diff --git a/test/files/run/t3425b/Base_1.scala b/test/files/run/t3425b/Base_1.scala new file mode 100644 index 0000000000..5a660a89b2 --- /dev/null +++ b/test/files/run/t3425b/Base_1.scala @@ -0,0 +1,89 @@ +trait P { def reflected: Boolean } +trait Q { def reflected: Boolean } +class PQ(val reflected: Boolean) extends P with Q { } + +trait A +trait B +trait C { val y: P } +class ABC extends A with B with C { + private def reflected = ( + Thread.currentThread.getStackTrace + takeWhile (_.getMethodName != "main") + exists (_.toString contains "sun.reflect.") + ) + lazy val y: PQ = new PQ(reflected) +} + +/*** The source used to generate the second file + Not otherwise used in the test except that compiling + it helps make sure it still compiles. + +****/ + +object Gen { + case class Tp(outer: String, elem: String) { + override def toString = s"$outer { val y: $elem }" + } + case class Pair(tp1: Tp, tp2: Tp) { + def expr = s"((new ABC): $tp)" + def tp = s"($tp1) with ($tp2)" + } + val traits = Vector("Any", "A", "B", "C") map ("%6s" format _) + val types = Vector("P", "Q", "R forSome { type R <: P with Q }") + val allTypes = for (c <- traits ; tp <- types) yield Tp(c, tp) + val pairs = allTypes flatMap (t1 => allTypes map (t2 => Pair(t1, t2))) + val indices = pairs.indices + + def aliases(idx: Int) = { + val p = pairs(idx) + import p._ + List( + s"type R1_$idx = $tp", + s"type R2_$idx = R1_$idx { val y: (${tp1.elem}) with (${tp2.elem}) }" + ) + } + + def mkMethodContent(pre: String)(f: Int => String) = + indices map (i => s"def $pre$i${f(i)}") mkString "\n " + + def content = List( + indices flatMap aliases mkString "\n ", + mkMethodContent("f")(i => s" = { val x = ${pairs(i).expr} ; x.y.reflected -> whatis(x).toString }"), + mkMethodContent("g")(i => s"""(x: R1_$i) = x.y"""), + mkMethodContent("h")(i => s"""(x: R2_$i) = x.y""") + ) mkString "\n " + + def fCalls = indices map ("f" + _) mkString ("\n ", ",\n ", "\n ") + + def main(args: Array[String]): Unit = { + // One cannot attain proper appreciation for the inadequacies of + // string interpolation without becoming one with the newline. + val nl = "\\n" + + println(s""" + |import scala.reflect.runtime.universe._ + |import scala.language._ + | + |object Test { + | def whatis[T: TypeTag](x: T) = typeOf[T] + | def sshow(label: String, xs: Traversable[Any]) { + | println("==== " + label + " ====$nl") + | xs.toList.map("" + _).sorted foreach println + | println("$nl") + | } + | + | $content + | lazy val fcalls = List($fCalls) + | + | def main(args: Array[String]) { + | sshow("Direct Calls", fcalls collect { case (false, n) => n }) + | sshow("Reflective Calls", fcalls collect { case (true, n) => n }) + | // For a good time try printing this - have to fix bugs in + | // reflection before that's going to be a good idea + | // println(typeOf[Test.type].typeSymbol.asClass.typeSignature) + | } + |} + """.stripMargin.trim + ) + } +} diff --git a/test/files/run/t3425b/Generated_2.scala b/test/files/run/t3425b/Generated_2.scala new file mode 100644 index 0000000000..f1699636f6 --- /dev/null +++ b/test/files/run/t3425b/Generated_2.scala @@ -0,0 +1,886 @@ +import scala.reflect.runtime.universe._ +import scala.language._ + +object Test { + def whatis[T: TypeTag](x: T) = typeOf[T] + def sshow(label: String, xs: Traversable[Any]) { + println("==== " + label + " ====\n") + xs.toList.map("" + _).sorted foreach println + println("\n") + } + + type R1_0 = ( Any { val y: P }) with ( Any { val y: P }) + type R2_0 = R1_0 { val y: (P) with (P) } + type R1_1 = ( Any { val y: P }) with ( Any { val y: Q }) + type R2_1 = R1_1 { val y: (P) with (Q) } + type R1_2 = ( Any { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_2 = R1_2 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_3 = ( Any { val y: P }) with ( A { val y: P }) + type R2_3 = R1_3 { val y: (P) with (P) } + type R1_4 = ( Any { val y: P }) with ( A { val y: Q }) + type R2_4 = R1_4 { val y: (P) with (Q) } + type R1_5 = ( Any { val y: P }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_5 = R1_5 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_6 = ( Any { val y: P }) with ( B { val y: P }) + type R2_6 = R1_6 { val y: (P) with (P) } + type R1_7 = ( Any { val y: P }) with ( B { val y: Q }) + type R2_7 = R1_7 { val y: (P) with (Q) } + type R1_8 = ( Any { val y: P }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_8 = R1_8 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_9 = ( Any { val y: P }) with ( C { val y: P }) + type R2_9 = R1_9 { val y: (P) with (P) } + type R1_10 = ( Any { val y: P }) with ( C { val y: Q }) + type R2_10 = R1_10 { val y: (P) with (Q) } + type R1_11 = ( Any { val y: P }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_11 = R1_11 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_12 = ( Any { val y: Q }) with ( Any { val y: P }) + type R2_12 = R1_12 { val y: (Q) with (P) } + type R1_13 = ( Any { val y: Q }) with ( Any { val y: Q }) + type R2_13 = R1_13 { val y: (Q) with (Q) } + type R1_14 = ( Any { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_14 = R1_14 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_15 = ( Any { val y: Q }) with ( A { val y: P }) + type R2_15 = R1_15 { val y: (Q) with (P) } + type R1_16 = ( Any { val y: Q }) with ( A { val y: Q }) + type R2_16 = R1_16 { val y: (Q) with (Q) } + type R1_17 = ( Any { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_17 = R1_17 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_18 = ( Any { val y: Q }) with ( B { val y: P }) + type R2_18 = R1_18 { val y: (Q) with (P) } + type R1_19 = ( Any { val y: Q }) with ( B { val y: Q }) + type R2_19 = R1_19 { val y: (Q) with (Q) } + type R1_20 = ( Any { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_20 = R1_20 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_21 = ( Any { val y: Q }) with ( C { val y: P }) + type R2_21 = R1_21 { val y: (Q) with (P) } + type R1_22 = ( Any { val y: Q }) with ( C { val y: Q }) + type R2_22 = R1_22 { val y: (Q) with (Q) } + type R1_23 = ( Any { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_23 = R1_23 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_24 = ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P }) + type R2_24 = R1_24 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_25 = ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q }) + type R2_25 = R1_25 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_26 = ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_26 = R1_26 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_27 = ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: P }) + type R2_27 = R1_27 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_28 = ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q }) + type R2_28 = R1_28 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_29 = ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_29 = R1_29 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_30 = ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: P }) + type R2_30 = R1_30 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_31 = ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q }) + type R2_31 = R1_31 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_32 = ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_32 = R1_32 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_33 = ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: P }) + type R2_33 = R1_33 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_34 = ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q }) + type R2_34 = R1_34 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_35 = ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_35 = R1_35 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_36 = ( A { val y: P }) with ( Any { val y: P }) + type R2_36 = R1_36 { val y: (P) with (P) } + type R1_37 = ( A { val y: P }) with ( Any { val y: Q }) + type R2_37 = R1_37 { val y: (P) with (Q) } + type R1_38 = ( A { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_38 = R1_38 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_39 = ( A { val y: P }) with ( A { val y: P }) + type R2_39 = R1_39 { val y: (P) with (P) } + type R1_40 = ( A { val y: P }) with ( A { val y: Q }) + type R2_40 = R1_40 { val y: (P) with (Q) } + type R1_41 = ( A { val y: P }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_41 = R1_41 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_42 = ( A { val y: P }) with ( B { val y: P }) + type R2_42 = R1_42 { val y: (P) with (P) } + type R1_43 = ( A { val y: P }) with ( B { val y: Q }) + type R2_43 = R1_43 { val y: (P) with (Q) } + type R1_44 = ( A { val y: P }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_44 = R1_44 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_45 = ( A { val y: P }) with ( C { val y: P }) + type R2_45 = R1_45 { val y: (P) with (P) } + type R1_46 = ( A { val y: P }) with ( C { val y: Q }) + type R2_46 = R1_46 { val y: (P) with (Q) } + type R1_47 = ( A { val y: P }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_47 = R1_47 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_48 = ( A { val y: Q }) with ( Any { val y: P }) + type R2_48 = R1_48 { val y: (Q) with (P) } + type R1_49 = ( A { val y: Q }) with ( Any { val y: Q }) + type R2_49 = R1_49 { val y: (Q) with (Q) } + type R1_50 = ( A { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_50 = R1_50 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_51 = ( A { val y: Q }) with ( A { val y: P }) + type R2_51 = R1_51 { val y: (Q) with (P) } + type R1_52 = ( A { val y: Q }) with ( A { val y: Q }) + type R2_52 = R1_52 { val y: (Q) with (Q) } + type R1_53 = ( A { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_53 = R1_53 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_54 = ( A { val y: Q }) with ( B { val y: P }) + type R2_54 = R1_54 { val y: (Q) with (P) } + type R1_55 = ( A { val y: Q }) with ( B { val y: Q }) + type R2_55 = R1_55 { val y: (Q) with (Q) } + type R1_56 = ( A { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_56 = R1_56 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_57 = ( A { val y: Q }) with ( C { val y: P }) + type R2_57 = R1_57 { val y: (Q) with (P) } + type R1_58 = ( A { val y: Q }) with ( C { val y: Q }) + type R2_58 = R1_58 { val y: (Q) with (Q) } + type R1_59 = ( A { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_59 = R1_59 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_60 = ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P }) + type R2_60 = R1_60 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_61 = ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q }) + type R2_61 = R1_61 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_62 = ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_62 = R1_62 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_63 = ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: P }) + type R2_63 = R1_63 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_64 = ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q }) + type R2_64 = R1_64 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_65 = ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_65 = R1_65 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_66 = ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: P }) + type R2_66 = R1_66 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_67 = ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q }) + type R2_67 = R1_67 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_68 = ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_68 = R1_68 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_69 = ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: P }) + type R2_69 = R1_69 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_70 = ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q }) + type R2_70 = R1_70 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_71 = ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_71 = R1_71 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_72 = ( B { val y: P }) with ( Any { val y: P }) + type R2_72 = R1_72 { val y: (P) with (P) } + type R1_73 = ( B { val y: P }) with ( Any { val y: Q }) + type R2_73 = R1_73 { val y: (P) with (Q) } + type R1_74 = ( B { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_74 = R1_74 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_75 = ( B { val y: P }) with ( A { val y: P }) + type R2_75 = R1_75 { val y: (P) with (P) } + type R1_76 = ( B { val y: P }) with ( A { val y: Q }) + type R2_76 = R1_76 { val y: (P) with (Q) } + type R1_77 = ( B { val y: P }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_77 = R1_77 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_78 = ( B { val y: P }) with ( B { val y: P }) + type R2_78 = R1_78 { val y: (P) with (P) } + type R1_79 = ( B { val y: P }) with ( B { val y: Q }) + type R2_79 = R1_79 { val y: (P) with (Q) } + type R1_80 = ( B { val y: P }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_80 = R1_80 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_81 = ( B { val y: P }) with ( C { val y: P }) + type R2_81 = R1_81 { val y: (P) with (P) } + type R1_82 = ( B { val y: P }) with ( C { val y: Q }) + type R2_82 = R1_82 { val y: (P) with (Q) } + type R1_83 = ( B { val y: P }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_83 = R1_83 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_84 = ( B { val y: Q }) with ( Any { val y: P }) + type R2_84 = R1_84 { val y: (Q) with (P) } + type R1_85 = ( B { val y: Q }) with ( Any { val y: Q }) + type R2_85 = R1_85 { val y: (Q) with (Q) } + type R1_86 = ( B { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_86 = R1_86 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_87 = ( B { val y: Q }) with ( A { val y: P }) + type R2_87 = R1_87 { val y: (Q) with (P) } + type R1_88 = ( B { val y: Q }) with ( A { val y: Q }) + type R2_88 = R1_88 { val y: (Q) with (Q) } + type R1_89 = ( B { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_89 = R1_89 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_90 = ( B { val y: Q }) with ( B { val y: P }) + type R2_90 = R1_90 { val y: (Q) with (P) } + type R1_91 = ( B { val y: Q }) with ( B { val y: Q }) + type R2_91 = R1_91 { val y: (Q) with (Q) } + type R1_92 = ( B { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_92 = R1_92 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_93 = ( B { val y: Q }) with ( C { val y: P }) + type R2_93 = R1_93 { val y: (Q) with (P) } + type R1_94 = ( B { val y: Q }) with ( C { val y: Q }) + type R2_94 = R1_94 { val y: (Q) with (Q) } + type R1_95 = ( B { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_95 = R1_95 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_96 = ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P }) + type R2_96 = R1_96 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_97 = ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q }) + type R2_97 = R1_97 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_98 = ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_98 = R1_98 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_99 = ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: P }) + type R2_99 = R1_99 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_100 = ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q }) + type R2_100 = R1_100 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_101 = ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_101 = R1_101 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_102 = ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: P }) + type R2_102 = R1_102 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_103 = ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q }) + type R2_103 = R1_103 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_104 = ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_104 = R1_104 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_105 = ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: P }) + type R2_105 = R1_105 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_106 = ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q }) + type R2_106 = R1_106 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_107 = ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_107 = R1_107 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_108 = ( C { val y: P }) with ( Any { val y: P }) + type R2_108 = R1_108 { val y: (P) with (P) } + type R1_109 = ( C { val y: P }) with ( Any { val y: Q }) + type R2_109 = R1_109 { val y: (P) with (Q) } + type R1_110 = ( C { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_110 = R1_110 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_111 = ( C { val y: P }) with ( A { val y: P }) + type R2_111 = R1_111 { val y: (P) with (P) } + type R1_112 = ( C { val y: P }) with ( A { val y: Q }) + type R2_112 = R1_112 { val y: (P) with (Q) } + type R1_113 = ( C { val y: P }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_113 = R1_113 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_114 = ( C { val y: P }) with ( B { val y: P }) + type R2_114 = R1_114 { val y: (P) with (P) } + type R1_115 = ( C { val y: P }) with ( B { val y: Q }) + type R2_115 = R1_115 { val y: (P) with (Q) } + type R1_116 = ( C { val y: P }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_116 = R1_116 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_117 = ( C { val y: P }) with ( C { val y: P }) + type R2_117 = R1_117 { val y: (P) with (P) } + type R1_118 = ( C { val y: P }) with ( C { val y: Q }) + type R2_118 = R1_118 { val y: (P) with (Q) } + type R1_119 = ( C { val y: P }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_119 = R1_119 { val y: (P) with (R forSome { type R <: P with Q }) } + type R1_120 = ( C { val y: Q }) with ( Any { val y: P }) + type R2_120 = R1_120 { val y: (Q) with (P) } + type R1_121 = ( C { val y: Q }) with ( Any { val y: Q }) + type R2_121 = R1_121 { val y: (Q) with (Q) } + type R1_122 = ( C { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_122 = R1_122 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_123 = ( C { val y: Q }) with ( A { val y: P }) + type R2_123 = R1_123 { val y: (Q) with (P) } + type R1_124 = ( C { val y: Q }) with ( A { val y: Q }) + type R2_124 = R1_124 { val y: (Q) with (Q) } + type R1_125 = ( C { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_125 = R1_125 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_126 = ( C { val y: Q }) with ( B { val y: P }) + type R2_126 = R1_126 { val y: (Q) with (P) } + type R1_127 = ( C { val y: Q }) with ( B { val y: Q }) + type R2_127 = R1_127 { val y: (Q) with (Q) } + type R1_128 = ( C { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_128 = R1_128 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_129 = ( C { val y: Q }) with ( C { val y: P }) + type R2_129 = R1_129 { val y: (Q) with (P) } + type R1_130 = ( C { val y: Q }) with ( C { val y: Q }) + type R2_130 = R1_130 { val y: (Q) with (Q) } + type R1_131 = ( C { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_131 = R1_131 { val y: (Q) with (R forSome { type R <: P with Q }) } + type R1_132 = ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P }) + type R2_132 = R1_132 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_133 = ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q }) + type R2_133 = R1_133 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_134 = ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } }) + type R2_134 = R1_134 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_135 = ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: P }) + type R2_135 = R1_135 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_136 = ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q }) + type R2_136 = R1_136 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_137 = ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } }) + type R2_137 = R1_137 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_138 = ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: P }) + type R2_138 = R1_138 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_139 = ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q }) + type R2_139 = R1_139 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_140 = ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } }) + type R2_140 = R1_140 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + type R1_141 = ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: P }) + type R2_141 = R1_141 { val y: (R forSome { type R <: P with Q }) with (P) } + type R1_142 = ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q }) + type R2_142 = R1_142 { val y: (R forSome { type R <: P with Q }) with (Q) } + type R1_143 = ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } }) + type R2_143 = R1_143 { val y: (R forSome { type R <: P with Q }) with (R forSome { type R <: P with Q }) } + def f0 = { val x = ((new ABC): ( Any { val y: P }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f1 = { val x = ((new ABC): ( Any { val y: P }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f2 = { val x = ((new ABC): ( Any { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f3 = { val x = ((new ABC): ( Any { val y: P }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f4 = { val x = ((new ABC): ( Any { val y: P }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f5 = { val x = ((new ABC): ( Any { val y: P }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f6 = { val x = ((new ABC): ( Any { val y: P }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f7 = { val x = ((new ABC): ( Any { val y: P }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f8 = { val x = ((new ABC): ( Any { val y: P }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f9 = { val x = ((new ABC): ( Any { val y: P }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f10 = { val x = ((new ABC): ( Any { val y: P }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f11 = { val x = ((new ABC): ( Any { val y: P }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f12 = { val x = ((new ABC): ( Any { val y: Q }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f13 = { val x = ((new ABC): ( Any { val y: Q }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f14 = { val x = ((new ABC): ( Any { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f15 = { val x = ((new ABC): ( Any { val y: Q }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f16 = { val x = ((new ABC): ( Any { val y: Q }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f17 = { val x = ((new ABC): ( Any { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f18 = { val x = ((new ABC): ( Any { val y: Q }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f19 = { val x = ((new ABC): ( Any { val y: Q }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f20 = { val x = ((new ABC): ( Any { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f21 = { val x = ((new ABC): ( Any { val y: Q }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f22 = { val x = ((new ABC): ( Any { val y: Q }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f23 = { val x = ((new ABC): ( Any { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f24 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f25 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f26 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f27 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f28 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f29 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f30 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f31 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f32 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f33 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f34 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f35 = { val x = ((new ABC): ( Any { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f36 = { val x = ((new ABC): ( A { val y: P }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f37 = { val x = ((new ABC): ( A { val y: P }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f38 = { val x = ((new ABC): ( A { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f39 = { val x = ((new ABC): ( A { val y: P }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f40 = { val x = ((new ABC): ( A { val y: P }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f41 = { val x = ((new ABC): ( A { val y: P }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f42 = { val x = ((new ABC): ( A { val y: P }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f43 = { val x = ((new ABC): ( A { val y: P }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f44 = { val x = ((new ABC): ( A { val y: P }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f45 = { val x = ((new ABC): ( A { val y: P }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f46 = { val x = ((new ABC): ( A { val y: P }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f47 = { val x = ((new ABC): ( A { val y: P }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f48 = { val x = ((new ABC): ( A { val y: Q }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f49 = { val x = ((new ABC): ( A { val y: Q }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f50 = { val x = ((new ABC): ( A { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f51 = { val x = ((new ABC): ( A { val y: Q }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f52 = { val x = ((new ABC): ( A { val y: Q }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f53 = { val x = ((new ABC): ( A { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f54 = { val x = ((new ABC): ( A { val y: Q }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f55 = { val x = ((new ABC): ( A { val y: Q }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f56 = { val x = ((new ABC): ( A { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f57 = { val x = ((new ABC): ( A { val y: Q }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f58 = { val x = ((new ABC): ( A { val y: Q }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f59 = { val x = ((new ABC): ( A { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f60 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f61 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f62 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f63 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f64 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f65 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f66 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f67 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f68 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f69 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f70 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f71 = { val x = ((new ABC): ( A { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f72 = { val x = ((new ABC): ( B { val y: P }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f73 = { val x = ((new ABC): ( B { val y: P }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f74 = { val x = ((new ABC): ( B { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f75 = { val x = ((new ABC): ( B { val y: P }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f76 = { val x = ((new ABC): ( B { val y: P }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f77 = { val x = ((new ABC): ( B { val y: P }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f78 = { val x = ((new ABC): ( B { val y: P }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f79 = { val x = ((new ABC): ( B { val y: P }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f80 = { val x = ((new ABC): ( B { val y: P }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f81 = { val x = ((new ABC): ( B { val y: P }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f82 = { val x = ((new ABC): ( B { val y: P }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f83 = { val x = ((new ABC): ( B { val y: P }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f84 = { val x = ((new ABC): ( B { val y: Q }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f85 = { val x = ((new ABC): ( B { val y: Q }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f86 = { val x = ((new ABC): ( B { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f87 = { val x = ((new ABC): ( B { val y: Q }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f88 = { val x = ((new ABC): ( B { val y: Q }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f89 = { val x = ((new ABC): ( B { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f90 = { val x = ((new ABC): ( B { val y: Q }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f91 = { val x = ((new ABC): ( B { val y: Q }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f92 = { val x = ((new ABC): ( B { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f93 = { val x = ((new ABC): ( B { val y: Q }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f94 = { val x = ((new ABC): ( B { val y: Q }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f95 = { val x = ((new ABC): ( B { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f96 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f97 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f98 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f99 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f100 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f101 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f102 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f103 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f104 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f105 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f106 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f107 = { val x = ((new ABC): ( B { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f108 = { val x = ((new ABC): ( C { val y: P }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f109 = { val x = ((new ABC): ( C { val y: P }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f110 = { val x = ((new ABC): ( C { val y: P }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f111 = { val x = ((new ABC): ( C { val y: P }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f112 = { val x = ((new ABC): ( C { val y: P }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f113 = { val x = ((new ABC): ( C { val y: P }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f114 = { val x = ((new ABC): ( C { val y: P }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f115 = { val x = ((new ABC): ( C { val y: P }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f116 = { val x = ((new ABC): ( C { val y: P }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f117 = { val x = ((new ABC): ( C { val y: P }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f118 = { val x = ((new ABC): ( C { val y: P }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f119 = { val x = ((new ABC): ( C { val y: P }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f120 = { val x = ((new ABC): ( C { val y: Q }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f121 = { val x = ((new ABC): ( C { val y: Q }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f122 = { val x = ((new ABC): ( C { val y: Q }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f123 = { val x = ((new ABC): ( C { val y: Q }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f124 = { val x = ((new ABC): ( C { val y: Q }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f125 = { val x = ((new ABC): ( C { val y: Q }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f126 = { val x = ((new ABC): ( C { val y: Q }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f127 = { val x = ((new ABC): ( C { val y: Q }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f128 = { val x = ((new ABC): ( C { val y: Q }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f129 = { val x = ((new ABC): ( C { val y: Q }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f130 = { val x = ((new ABC): ( C { val y: Q }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f131 = { val x = ((new ABC): ( C { val y: Q }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f132 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f133 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f134 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( Any { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f135 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f136 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f137 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( A { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f138 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f139 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f140 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( B { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def f141 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: P })) ; x.y.reflected -> whatis(x).toString } + def f142 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: Q })) ; x.y.reflected -> whatis(x).toString } + def f143 = { val x = ((new ABC): ( C { val y: R forSome { type R <: P with Q } }) with ( C { val y: R forSome { type R <: P with Q } })) ; x.y.reflected -> whatis(x).toString } + def g0(x: R1_0) = x.y + def g1(x: R1_1) = x.y + def g2(x: R1_2) = x.y + def g3(x: R1_3) = x.y + def g4(x: R1_4) = x.y + def g5(x: R1_5) = x.y + def g6(x: R1_6) = x.y + def g7(x: R1_7) = x.y + def g8(x: R1_8) = x.y + def g9(x: R1_9) = x.y + def g10(x: R1_10) = x.y + def g11(x: R1_11) = x.y + def g12(x: R1_12) = x.y + def g13(x: R1_13) = x.y + def g14(x: R1_14) = x.y + def g15(x: R1_15) = x.y + def g16(x: R1_16) = x.y + def g17(x: R1_17) = x.y + def g18(x: R1_18) = x.y + def g19(x: R1_19) = x.y + def g20(x: R1_20) = x.y + def g21(x: R1_21) = x.y + def g22(x: R1_22) = x.y + def g23(x: R1_23) = x.y + def g24(x: R1_24) = x.y + def g25(x: R1_25) = x.y + def g26(x: R1_26) = x.y + def g27(x: R1_27) = x.y + def g28(x: R1_28) = x.y + def g29(x: R1_29) = x.y + def g30(x: R1_30) = x.y + def g31(x: R1_31) = x.y + def g32(x: R1_32) = x.y + def g33(x: R1_33) = x.y + def g34(x: R1_34) = x.y + def g35(x: R1_35) = x.y + def g36(x: R1_36) = x.y + def g37(x: R1_37) = x.y + def g38(x: R1_38) = x.y + def g39(x: R1_39) = x.y + def g40(x: R1_40) = x.y + def g41(x: R1_41) = x.y + def g42(x: R1_42) = x.y + def g43(x: R1_43) = x.y + def g44(x: R1_44) = x.y + def g45(x: R1_45) = x.y + def g46(x: R1_46) = x.y + def g47(x: R1_47) = x.y + def g48(x: R1_48) = x.y + def g49(x: R1_49) = x.y + def g50(x: R1_50) = x.y + def g51(x: R1_51) = x.y + def g52(x: R1_52) = x.y + def g53(x: R1_53) = x.y + def g54(x: R1_54) = x.y + def g55(x: R1_55) = x.y + def g56(x: R1_56) = x.y + def g57(x: R1_57) = x.y + def g58(x: R1_58) = x.y + def g59(x: R1_59) = x.y + def g60(x: R1_60) = x.y + def g61(x: R1_61) = x.y + def g62(x: R1_62) = x.y + def g63(x: R1_63) = x.y + def g64(x: R1_64) = x.y + def g65(x: R1_65) = x.y + def g66(x: R1_66) = x.y + def g67(x: R1_67) = x.y + def g68(x: R1_68) = x.y + def g69(x: R1_69) = x.y + def g70(x: R1_70) = x.y + def g71(x: R1_71) = x.y + def g72(x: R1_72) = x.y + def g73(x: R1_73) = x.y + def g74(x: R1_74) = x.y + def g75(x: R1_75) = x.y + def g76(x: R1_76) = x.y + def g77(x: R1_77) = x.y + def g78(x: R1_78) = x.y + def g79(x: R1_79) = x.y + def g80(x: R1_80) = x.y + def g81(x: R1_81) = x.y + def g82(x: R1_82) = x.y + def g83(x: R1_83) = x.y + def g84(x: R1_84) = x.y + def g85(x: R1_85) = x.y + def g86(x: R1_86) = x.y + def g87(x: R1_87) = x.y + def g88(x: R1_88) = x.y + def g89(x: R1_89) = x.y + def g90(x: R1_90) = x.y + def g91(x: R1_91) = x.y + def g92(x: R1_92) = x.y + def g93(x: R1_93) = x.y + def g94(x: R1_94) = x.y + def g95(x: R1_95) = x.y + def g96(x: R1_96) = x.y + def g97(x: R1_97) = x.y + def g98(x: R1_98) = x.y + def g99(x: R1_99) = x.y + def g100(x: R1_100) = x.y + def g101(x: R1_101) = x.y + def g102(x: R1_102) = x.y + def g103(x: R1_103) = x.y + def g104(x: R1_104) = x.y + def g105(x: R1_105) = x.y + def g106(x: R1_106) = x.y + def g107(x: R1_107) = x.y + def g108(x: R1_108) = x.y + def g109(x: R1_109) = x.y + def g110(x: R1_110) = x.y + def g111(x: R1_111) = x.y + def g112(x: R1_112) = x.y + def g113(x: R1_113) = x.y + def g114(x: R1_114) = x.y + def g115(x: R1_115) = x.y + def g116(x: R1_116) = x.y + def g117(x: R1_117) = x.y + def g118(x: R1_118) = x.y + def g119(x: R1_119) = x.y + def g120(x: R1_120) = x.y + def g121(x: R1_121) = x.y + def g122(x: R1_122) = x.y + def g123(x: R1_123) = x.y + def g124(x: R1_124) = x.y + def g125(x: R1_125) = x.y + def g126(x: R1_126) = x.y + def g127(x: R1_127) = x.y + def g128(x: R1_128) = x.y + def g129(x: R1_129) = x.y + def g130(x: R1_130) = x.y + def g131(x: R1_131) = x.y + def g132(x: R1_132) = x.y + def g133(x: R1_133) = x.y + def g134(x: R1_134) = x.y + def g135(x: R1_135) = x.y + def g136(x: R1_136) = x.y + def g137(x: R1_137) = x.y + def g138(x: R1_138) = x.y + def g139(x: R1_139) = x.y + def g140(x: R1_140) = x.y + def g141(x: R1_141) = x.y + def g142(x: R1_142) = x.y + def g143(x: R1_143) = x.y + def h0(x: R2_0) = x.y + def h1(x: R2_1) = x.y + def h2(x: R2_2) = x.y + def h3(x: R2_3) = x.y + def h4(x: R2_4) = x.y + def h5(x: R2_5) = x.y + def h6(x: R2_6) = x.y + def h7(x: R2_7) = x.y + def h8(x: R2_8) = x.y + def h9(x: R2_9) = x.y + def h10(x: R2_10) = x.y + def h11(x: R2_11) = x.y + def h12(x: R2_12) = x.y + def h13(x: R2_13) = x.y + def h14(x: R2_14) = x.y + def h15(x: R2_15) = x.y + def h16(x: R2_16) = x.y + def h17(x: R2_17) = x.y + def h18(x: R2_18) = x.y + def h19(x: R2_19) = x.y + def h20(x: R2_20) = x.y + def h21(x: R2_21) = x.y + def h22(x: R2_22) = x.y + def h23(x: R2_23) = x.y + def h24(x: R2_24) = x.y + def h25(x: R2_25) = x.y + def h26(x: R2_26) = x.y + def h27(x: R2_27) = x.y + def h28(x: R2_28) = x.y + def h29(x: R2_29) = x.y + def h30(x: R2_30) = x.y + def h31(x: R2_31) = x.y + def h32(x: R2_32) = x.y + def h33(x: R2_33) = x.y + def h34(x: R2_34) = x.y + def h35(x: R2_35) = x.y + def h36(x: R2_36) = x.y + def h37(x: R2_37) = x.y + def h38(x: R2_38) = x.y + def h39(x: R2_39) = x.y + def h40(x: R2_40) = x.y + def h41(x: R2_41) = x.y + def h42(x: R2_42) = x.y + def h43(x: R2_43) = x.y + def h44(x: R2_44) = x.y + def h45(x: R2_45) = x.y + def h46(x: R2_46) = x.y + def h47(x: R2_47) = x.y + def h48(x: R2_48) = x.y + def h49(x: R2_49) = x.y + def h50(x: R2_50) = x.y + def h51(x: R2_51) = x.y + def h52(x: R2_52) = x.y + def h53(x: R2_53) = x.y + def h54(x: R2_54) = x.y + def h55(x: R2_55) = x.y + def h56(x: R2_56) = x.y + def h57(x: R2_57) = x.y + def h58(x: R2_58) = x.y + def h59(x: R2_59) = x.y + def h60(x: R2_60) = x.y + def h61(x: R2_61) = x.y + def h62(x: R2_62) = x.y + def h63(x: R2_63) = x.y + def h64(x: R2_64) = x.y + def h65(x: R2_65) = x.y + def h66(x: R2_66) = x.y + def h67(x: R2_67) = x.y + def h68(x: R2_68) = x.y + def h69(x: R2_69) = x.y + def h70(x: R2_70) = x.y + def h71(x: R2_71) = x.y + def h72(x: R2_72) = x.y + def h73(x: R2_73) = x.y + def h74(x: R2_74) = x.y + def h75(x: R2_75) = x.y + def h76(x: R2_76) = x.y + def h77(x: R2_77) = x.y + def h78(x: R2_78) = x.y + def h79(x: R2_79) = x.y + def h80(x: R2_80) = x.y + def h81(x: R2_81) = x.y + def h82(x: R2_82) = x.y + def h83(x: R2_83) = x.y + def h84(x: R2_84) = x.y + def h85(x: R2_85) = x.y + def h86(x: R2_86) = x.y + def h87(x: R2_87) = x.y + def h88(x: R2_88) = x.y + def h89(x: R2_89) = x.y + def h90(x: R2_90) = x.y + def h91(x: R2_91) = x.y + def h92(x: R2_92) = x.y + def h93(x: R2_93) = x.y + def h94(x: R2_94) = x.y + def h95(x: R2_95) = x.y + def h96(x: R2_96) = x.y + def h97(x: R2_97) = x.y + def h98(x: R2_98) = x.y + def h99(x: R2_99) = x.y + def h100(x: R2_100) = x.y + def h101(x: R2_101) = x.y + def h102(x: R2_102) = x.y + def h103(x: R2_103) = x.y + def h104(x: R2_104) = x.y + def h105(x: R2_105) = x.y + def h106(x: R2_106) = x.y + def h107(x: R2_107) = x.y + def h108(x: R2_108) = x.y + def h109(x: R2_109) = x.y + def h110(x: R2_110) = x.y + def h111(x: R2_111) = x.y + def h112(x: R2_112) = x.y + def h113(x: R2_113) = x.y + def h114(x: R2_114) = x.y + def h115(x: R2_115) = x.y + def h116(x: R2_116) = x.y + def h117(x: R2_117) = x.y + def h118(x: R2_118) = x.y + def h119(x: R2_119) = x.y + def h120(x: R2_120) = x.y + def h121(x: R2_121) = x.y + def h122(x: R2_122) = x.y + def h123(x: R2_123) = x.y + def h124(x: R2_124) = x.y + def h125(x: R2_125) = x.y + def h126(x: R2_126) = x.y + def h127(x: R2_127) = x.y + def h128(x: R2_128) = x.y + def h129(x: R2_129) = x.y + def h130(x: R2_130) = x.y + def h131(x: R2_131) = x.y + def h132(x: R2_132) = x.y + def h133(x: R2_133) = x.y + def h134(x: R2_134) = x.y + def h135(x: R2_135) = x.y + def h136(x: R2_136) = x.y + def h137(x: R2_137) = x.y + def h138(x: R2_138) = x.y + def h139(x: R2_139) = x.y + def h140(x: R2_140) = x.y + def h141(x: R2_141) = x.y + def h142(x: R2_142) = x.y + def h143(x: R2_143) = x.y + lazy val fcalls = List( + f0, + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, + f9, + f10, + f11, + f12, + f13, + f14, + f15, + f16, + f17, + f18, + f19, + f20, + f21, + f22, + f23, + f24, + f25, + f26, + f27, + f28, + f29, + f30, + f31, + f32, + f33, + f34, + f35, + f36, + f37, + f38, + f39, + f40, + f41, + f42, + f43, + f44, + f45, + f46, + f47, + f48, + f49, + f50, + f51, + f52, + f53, + f54, + f55, + f56, + f57, + f58, + f59, + f60, + f61, + f62, + f63, + f64, + f65, + f66, + f67, + f68, + f69, + f70, + f71, + f72, + f73, + f74, + f75, + f76, + f77, + f78, + f79, + f80, + f81, + f82, + f83, + f84, + f85, + f86, + f87, + f88, + f89, + f90, + f91, + f92, + f93, + f94, + f95, + f96, + f97, + f98, + f99, + f100, + f101, + f102, + f103, + f104, + f105, + f106, + f107, + f108, + f109, + f110, + f111, + f112, + f113, + f114, + f115, + f116, + f117, + f118, + f119, + f120, + f121, + f122, + f123, + f124, + f125, + f126, + f127, + f128, + f129, + f130, + f131, + f132, + f133, + f134, + f135, + f136, + f137, + f138, + f139, + f140, + f141, + f142, + f143 + ) + + def main(args: Array[String]) { + sshow("Direct Calls", fcalls collect { case (false, n) => n }) + sshow("Reflective Calls", fcalls collect { case (true, n) => n }) + // For a good time try printing this - have to fix bugs in + // reflection before that's going to be a good idea + // println(typeOf[Test.type].typeSymbol.asClass.typeSignature) + } +} diff --git a/test/files/run/t3488.check b/test/files/run/t3488.check index 0d66ea1aee..314dfc7838 100644 --- a/test/files/run/t3488.check +++ b/test/files/run/t3488.check @@ -1,2 +1,8 @@ +t3488.scala:4: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + println(foo { val List(_*)=List(0); 1 } ()) + ^ +t3488.scala:5: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + println(foo { val List(_*)=List(0); 1 } (1)) + ^ 0 1 diff --git a/test/files/run/t3488.scala b/test/files/run/t3488.scala index 20a1400dce..a8cfa9b808 100644 --- a/test/files/run/t3488.scala +++ b/test/files/run/t3488.scala @@ -1,6 +1,6 @@ object Test extends App { def foo(p: => Unit)(x:Int = 0) = x - + println(foo { val List(_*)=List(0); 1 } ()) println(foo { val List(_*)=List(0); 1 } (1)) } diff --git a/test/files/run/t3493.scala b/test/files/run/t3493.scala index b0b7589cfd..aafe7a3a4a 100644 --- a/test/files/run/t3493.scala +++ b/test/files/run/t3493.scala @@ -3,7 +3,7 @@ object Test { - + def main(args: Array[String]) { import scala.collection.immutable._ val x = TreeSet("a", "b", "c", "d") @@ -11,5 +11,5 @@ object Test { assert(x2.toString == "TreeSet(a, b, c, d, e)") assert(x2.toString == runtime.ScalaRunTime.stringOf(x2).trim) } - + } diff --git a/test/files/run/t3496.scala b/test/files/run/t3496.scala index 80a4e6bd86..e1aa032ab1 100644 --- a/test/files/run/t3496.scala +++ b/test/files/run/t3496.scala @@ -4,12 +4,12 @@ // ticket #3496 object Test { - + def main(args: Array[String]) { val s = Stream.from(1) s.take(5) s.drop(5) s.splitAt(5) } - + } diff --git a/test/files/run/t3502.scala b/test/files/run/t3502.scala index 9492b2d4d4..cc78e54c86 100644 --- a/test/files/run/t3502.scala +++ b/test/files/run/t3502.scala @@ -5,7 +5,7 @@ // ticket #3502 object Test { - + object GeneratePrimeFactorsLazy extends (Int => List[Int]) { override def apply(n:Int) = { val s = Stream.range(2, n / 2).filter(n % _ == 0) @@ -13,12 +13,12 @@ object Test { s.headOption.map(x => x :: apply(n / x)).getOrElse(List(n)) } } - + def main(args:Array[String]) { // a prime number //val num = 623456789 val num = 2796203 assert(GeneratePrimeFactorsLazy(num) == List(num)) } - + } diff --git a/test/files/run/t3507-new.scala b/test/files/run/t3507-new.scala index f045755b8f..bd16849e8a 100644 --- a/test/files/run/t3507-new.scala +++ b/test/files/run/t3507-new.scala @@ -1,3 +1,5 @@ + +import scala.language.{ existentials } import scala.reflect.runtime.universe._ class A { @@ -14,4 +16,4 @@ object Test extends App { def mani[T: TypeTag](x: T) = println(typeOf[T]) mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier // --> _1 is not in scope here -}
\ No newline at end of file +} diff --git a/test/files/run/t3509.scala b/test/files/run/t3509.scala index 7ec150eb01..76f8d6016e 100644 --- a/test/files/run/t3509.scala +++ b/test/files/run/t3509.scala @@ -1,7 +1,7 @@ object Test { - class Foo(final var i:Int) - + class Foo(final var i:Int) + def main(args : Array[String]) : Unit = { val foo = new Foo(0) foo.i += 1 diff --git a/test/files/run/t3511.scala b/test/files/run/t3511.scala index 9b4d581462..30757b1a66 100644 --- a/test/files/run/t3511.scala +++ b/test/files/run/t3511.scala @@ -6,31 +6,31 @@ import scala.collection.immutable._ // ticket #3511 object Test { - + def main(args: Array[String]) { assert(Stream.from(0).view.force.take(5) == List(0, 1, 2, 3, 4)) - + val s = Stream.from(0) val smap = s.view.map(_ * 2).force.take(5) assert(smap == List(0, 2, 4, 6, 8)) - + val sfilter = s.view.filter(_ % 2 == 0).force.take(5) assert(sfilter == List(0, 2, 4, 6, 8)) - + val sflatmap = s.view.flatMap(n => List(n, n * 2)).force.take(6) assert(sflatmap == List(0, 0, 1, 2, 2, 4)) - + val stakewhile = s.view.takeWhile(_ < 10).force assert(stakewhile == List.range(0, 10)) - + val szip = s.view.zip(s.map(_ / 2)).force.take(5) assert(szip == List((0, 0), (1, 0), (2, 1), (3, 1), (4, 2))) - + val szipall = s.view.zipAll(List(0, 1, 2), 0, 0).force.take(5) assert(szipall == List((0, 0), (1, 1), (2, 2), (3, 0), (4, 0))) - + val spatch = s.view.patch(1, List(5, 5, 5), 5).force.take(5) assert(spatch == List(0, 5, 5, 5, 6)) } - + } diff --git a/test/files/run/t3516.scala b/test/files/run/t3516.scala index 82a97f27de..aa302ce85a 100644 --- a/test/files/run/t3516.scala +++ b/test/files/run/t3516.scala @@ -1,7 +1,7 @@ object Test { def mkIterator = (1 to 5).iterator map (x => { println(x) ; x }) def mkInfinite = Iterator continually { println(1) ; 1 } - + def main(args: Array[String]): Unit = { // Stream is strict in its head so we should see 1 from each of them. val s1 = mkIterator.toStream diff --git a/test/files/run/t3518.scala b/test/files/run/t3518.scala index 36ca9daaa2..033cc19548 100644 --- a/test/files/run/t3518.scala +++ b/test/files/run/t3518.scala @@ -4,7 +4,7 @@ object Test { val r3 = 10.0 to 1.0 by -0.5 val r4 = 1.0 until 1.0 by 1.0 val r5 = 1 to 100 by 2 - + def main(args: Array[String]): Unit = { assert(r3 forall (r1 contains _)) assert(r1 forall (r3 contains _)) diff --git a/test/files/run/t3529.scala b/test/files/run/t3529.scala index bb82424bf6..a5977d0a6c 100644 --- a/test/files/run/t3529.scala +++ b/test/files/run/t3529.scala @@ -1,3 +1,4 @@ +import scala.language.postfixOps object Test { def main(args: Array[String]): Unit = { assert(1 to 10 drop 10 isEmpty) diff --git a/test/files/run/t3530.scala b/test/files/run/t3530.scala index 3fedc66dbe..f6f7fb4229 100644 --- a/test/files/run/t3530.scala +++ b/test/files/run/t3530.scala @@ -5,7 +5,7 @@ object Test { case xs @ List(_*) => "list: " + xs.length case _ => "not a list" }) - + def f2[T](x: List[T]) = println(x match { case List(_, _) => "two" case List(_, _, _) => "three" @@ -21,9 +21,9 @@ object Test { f(Nil) f(List(1,2,3,4,5)) f(null) - + println - + f2(List(1, 2)) f2(List('a', 'b', 'c')) f2(List('a', 'b', 'c', 'd')) diff --git a/test/files/run/t3540.scala b/test/files/run/t3540.scala index 4eb3de780b..5ffacb5dff 100644 --- a/test/files/run/t3540.scala +++ b/test/files/run/t3540.scala @@ -2,6 +2,6 @@ object Test { def main(args: Array[String]): Unit = { assert(List.iterate(List(1,2,3), 4)(_.tail).last.isEmpty) assert(Stream.iterate(Stream(1,2,3), 4)(_.tail).last.isEmpty) - assert(Array.iterate(Array(1,2,3), 4)(_.tail).last.isEmpty) + assert(Array.iterate(Array(1,2,3), 4)(_.tail).last.isEmpty) } } diff --git a/test/files/run/t3563.scala b/test/files/run/t3563.scala index 2a80ef412a..8abbb60803 100644 --- a/test/files/run/t3563.scala +++ b/test/files/run/t3563.scala @@ -5,17 +5,17 @@ // ticket #3563 object Test { - + def main(args: Array[String]) { var sum = 0 val setseq = Set(1, 2, 3, 4).toSeq setseq.map( n => { sum += n; n * n }).head assert(sum == 10) - + sum = 0 val mapseq = Map(1 -> 1, 2 -> 2, 3 -> 3, 4 -> 4).toSeq mapseq.map( n => { sum += n._1; (n._1 + n._1, n._2 * n._2) }).head assert(sum == 10) } - + } diff --git a/test/files/run/t3569.scala b/test/files/run/t3569.scala index 4699aeaab3..91d437e0e3 100644 --- a/test/files/run/t3569.scala +++ b/test/files/run/t3569.scala @@ -1,9 +1,9 @@ object Test { final val bippy1 = 1 final lazy val bippy2 = 2 - + lazy val lv = scala.util.Random.nextInt() - + class X(final var x: Int) { final var var1: Int = 0 final private var var2: Int = 0 @@ -12,20 +12,20 @@ object Test { final val val1: Int = 1 final private val val2: Int = 1 final private[this] val val3: Int = 1 - + final lazy val lval1: Int = 2 final private lazy val lval2: Int = 2 final private[this] lazy val lval3: Int = 2 } case class Y(final var x: Int, final private var y: Int, final val z1: Int, final private val z2: Int) { } - + def f = new X(0).x += 1 def main(args: Array[String]) { f val s = new X(0) s.x += 1 println(s.x) - + (classOf[X].getDeclaredFields map ("" + _)).sorted foreach println (classOf[Y].getDeclaredFields map ("" + _)).sorted foreach println } diff --git a/test/files/run/t3575.scala b/test/files/run/t3575.scala index 7ede65b00c..ef83e84f14 100644 --- a/test/files/run/t3575.scala +++ b/test/files/run/t3575.scala @@ -46,7 +46,7 @@ object Test { println(TwoShort(12, "Hello").getClass().getName()); println(TwoShort("Hello", 12).getClass().getName()); println(TwoShort(12, 12).getClass().getName()); - + println(TwoMinimal("Hello", "World").getClass().getName()); println(TwoMinimal(12, "Hello").getClass().getName()); println(TwoMinimal("Hello", 12).getClass().getName()); diff --git a/test/files/run/t3580.scala b/test/files/run/t3580.scala index ac9f81ab9e..50ff6c4551 100644 --- a/test/files/run/t3580.scala +++ b/test/files/run/t3580.scala @@ -4,14 +4,14 @@ object Test { - + class Empty extends Traversable[Nothing] { def foreach[U](f: Nothing => U) {} } - + def main(args: Array[String]) { val t = new Empty t.toStream } - + } diff --git a/test/files/run/t3603.scala b/test/files/run/t3603.scala index a0821a2a45..a89cb7080a 100644 --- a/test/files/run/t3603.scala +++ b/test/files/run/t3603.scala @@ -2,17 +2,17 @@ object Test { - + def main(args: Array[String]) { import collection.immutable._ - + val intmap = IntMap(1 -> 1, 2 -> 2) val intres = intmap.map { case (a, b) => (a, b.toString) } assert(intres.isInstanceOf[IntMap[_]]) - + val longmap = LongMap(1L -> 1, 2L -> 2) val longres = longmap.map { case (a, b) => (a, b.toString) } assert(longres.isInstanceOf[LongMap[_]]) } - + } diff --git a/test/files/run/t3613.scala b/test/files/run/t3613.scala index 171a6a21aa..1293f62c0f 100644 --- a/test/files/run/t3613.scala +++ b/test/files/run/t3613.scala @@ -1,7 +1,7 @@ class Boopy { private val s = new Schnuck def observer : PartialFunction[ Any, Unit ] = s.observer - + private class Schnuck extends javax.swing.AbstractListModel { model => val observer : PartialFunction[ Any, Unit ] = { @@ -10,13 +10,13 @@ class Boopy { def getSize = 0 def getElementAt( idx: Int ) = ??? } - + } object Test { def main(args: Array[String]): Unit = { val x = new Boopy val o = x.observer - o( "Boopy" ) // --> throws runtime error + o( "Boopy" ) // --> throws runtime error } } diff --git a/test/files/run/t3619.scala b/test/files/run/t3619.scala index 46324b4d69..3f4c56ea53 100644 --- a/test/files/run/t3619.scala +++ b/test/files/run/t3619.scala @@ -17,7 +17,7 @@ object Test extends App { } } */ - + new Meh } diff --git a/test/files/run/t363.scala b/test/files/run/t363.scala index 5f3f30a098..c747be2ec9 100644 --- a/test/files/run/t363.scala +++ b/test/files/run/t363.scala @@ -3,7 +3,7 @@ object Test { println("I love the smell of (Array[String])Unit in the morning.") } } - + class Test { def kurtz() = "We must kill them. We must incinerate them." } diff --git a/test/files/run/t3647.scala b/test/files/run/t3647.scala index 434a13f414..a970e887f6 100644 --- a/test/files/run/t3647.scala +++ b/test/files/run/t3647.scala @@ -13,10 +13,10 @@ object Test { "line4" ).iterator) assert(ps.filter(_ == '\n').size == 3) - + val ps1 = PagedSeq.fromLines(List("Ok").iterator) assert(ps1.filter(_ == '\n').size == 0) - + val eps = PagedSeq.fromLines(List().iterator) assert(eps.filter(_ == '\n').size == 0) } diff --git a/test/files/run/t3651.scala b/test/files/run/t3651.scala index 49ae173249..3a6dda0de3 100644 --- a/test/files/run/t3651.scala +++ b/test/files/run/t3651.scala @@ -5,6 +5,6 @@ class LongKlass( override val a: Long ) extends Klass[Long](a) object Test { def main(args: Array[String]) { val lk = new LongKlass(10) - lk.a + val a = lk.a } } diff --git a/test/files/run/t3667.check b/test/files/run/t3667.check index bbe5d1bc48..6375c88997 100644 --- a/test/files/run/t3667.check +++ b/test/files/run/t3667.check @@ -1,6 +1,3 @@ -1 -2 -3 4 2 3 diff --git a/test/files/run/t3667.scala b/test/files/run/t3667.scala index f30d57ce3a..ada09d5886 100644 --- a/test/files/run/t3667.scala +++ b/test/files/run/t3667.scala @@ -1,27 +1,9 @@ object Test { def main(args: Array[String]) { - val o1 = new Outer1 - val o2 = new Outer2 - val o3 = new Outer3 val o4 = new Outer4 val o5 = new Outer5 val o6 = new Outer6 - println(1) - ser(new o1.Inner(1)) - o1.Inner // make sure the Inner$module field of the Outer1 instance is initialized! - ser(new o1.Inner(1)) - - println(2) - ser(new o2.Inner(1)) - o2.Inner - ser(new o2.Inner(1)) - - println(3) - ser(new o3.Inner(1)) - o3.Inner - ser(new o3.Inner(1)) - println(4) ser(new o4.Inner(1)) o4.Inner @@ -54,23 +36,6 @@ object Test { } -@serializable -class Outer1 { - @serializable - class Inner(x: Int = 1) -} - -@serializable -class Outer2 { - case class Inner(x: Int = 1) -} - -@serializable -class Outer3 { - case class Inner(x: Int) -} - - class Outer4 extends Serializable { class Inner(x: Int = 1) extends Serializable } diff --git a/test/files/run/t3702.scala b/test/files/run/t3702.scala index 021abcb625..0cdafd90b6 100644 --- a/test/files/run/t3702.scala +++ b/test/files/run/t3702.scala @@ -3,7 +3,7 @@ object Test { case 5 :: _ => () case List(from) => from } - + def main(args: Array[String]): Unit = { println(foo(5 :: Nil, List(1,2,3))) println(foo(6 :: Nil, List(1,2,3))) diff --git a/test/files/run/t3705.scala b/test/files/run/t3705.scala deleted file mode 100644 index fcc020f28c..0000000000 --- a/test/files/run/t3705.scala +++ /dev/null @@ -1,17 +0,0 @@ -// package foo - -import scala.xml._ -object Test { - def updateNodes(ns: Seq[Node]): Seq[Node] = - for(subnode <- ns) yield subnode match { - case <d>{_}</d> if true => <d>abc</d> - case Elem(prefix, label, attribs, scope, children @ _*) => - Elem(prefix, label, attribs, scope, updateNodes(children) : _*) - case other => other - } - def main(args: Array[String]): Unit = { - updateNodes(<b />) - - } -} - diff --git a/test/files/run/t3714.scala b/test/files/run/t3714.scala index c344b40f1f..2d600f97f1 100644 --- a/test/files/run/t3714.scala +++ b/test/files/run/t3714.scala @@ -21,7 +21,7 @@ object Test { case BreakImpl(x) => x case _ => -1 } - + def main(args: Array[String]) { val break = BreakImpl(22) // assert(f1(break) == 22) diff --git a/test/files/run/t3719.scala b/test/files/run/t3719.scala index 4649f11bb1..01dc205545 100644 --- a/test/files/run/t3719.scala +++ b/test/files/run/t3719.scala @@ -1,7 +1,7 @@ object Days extends Enumeration { type Day = DayValue val Mon, Tue, Wed, Thu, Fri, Sat, Sun = new DayValue // DayValue - + protected class DayValue extends Val { def isWeekday: Boolean = this match { @@ -21,7 +21,7 @@ object Test extends App { val d: Day = Mon d.toString } - + def nameOfTue(): String = { import Days._ val d: Day = Tue diff --git a/test/files/run/t3758-old.scala b/test/files/run/t3758-old.scala index f00254afee..d5e4a6cc1c 100644 --- a/test/files/run/t3758-old.scala +++ b/test/files/run/t3758-old.scala @@ -1,3 +1,5 @@ + +@deprecated("Suppress warnings", since="2.11") object Test { def main(args: Array[String]): Unit = { assert(classManifest[Array[String]].typeArguments contains classManifest[String]) @@ -7,4 +9,4 @@ object Test { assert(manifest[Array[Int]].typeArguments contains manifest[Int]) assert(manifest[Array[Float]].typeArguments contains manifest[Float]) } -}
\ No newline at end of file +} diff --git a/test/files/run/t3822.scala b/test/files/run/t3822.scala index eaf0a145d3..c35804035e 100644 --- a/test/files/run/t3822.scala +++ b/test/files/run/t3822.scala @@ -1,17 +1,17 @@ import scala.collection.{ mutable, immutable, generic } import immutable.ListSet -object Test { +object Test { def main(args: Array[String]): Unit = { val xs = ListSet(-100000 to 100001: _*) - + assert(xs.size == 200002) assert(xs.sum == 100001) - + val ys = ListSet[Int]() val ys1 = (1 to 12).grouped(3).foldLeft(ys)(_ ++ _) val ys2 = (1 to 12).foldLeft(ys)(_ + _) - + assert(ys1 == ys2) } } diff --git a/test/files/run/t3829.scala b/test/files/run/t3829.scala index e3d8c56882..780a6a95b7 100644 --- a/test/files/run/t3829.scala +++ b/test/files/run/t3829.scala @@ -1,11 +1,11 @@ // ticket #3829 object Test { import collection.{ mutable, immutable } - + def main(args: Array[String]) { val map = immutable.Map(1 -> 2, 3 -> 4) assert(map.get(0) == None) - + // Since r24255 defaultMap.get(x) returns None rather than // using the default, so these mostly use apply. val defmap = map.withDefaultValue(-1) @@ -19,10 +19,10 @@ object Test { assert((defmap - 1)(0) == -1) assert((defmap - 1)(1) == -1) assert((defmap - 1)(3) == 4) - + val mutmap = mutable.Map(1 -> 2, 2 -> 3) assert(mutmap.get(0) == None) - + val defmutmap = mutmap.withDefaultValue(-1) assert(defmutmap(0) == -1) assert(defmutmap(3) == -1) @@ -36,5 +36,5 @@ object Test { assert(defmutmap(1) == 2) assert(mutmap(1) == 2) } - + } diff --git a/test/files/run/t3832.scala b/test/files/run/t3832.scala new file mode 100644 index 0000000000..ac44358bc7 --- /dev/null +++ b/test/files/run/t3832.scala @@ -0,0 +1,17 @@ +class t3832 { + def this(un: Int) = { + this() + def bippy = this + () + } + def this(un: Boolean) = { + this() + def boppy = () => this + () + } +} + +object Test extends App { + new t3832(0) + new t3832(true) +} diff --git a/test/files/run/t3835.scala b/test/files/run/t3835.scala index c120a61f6e..766b6ddc2e 100644 --- a/test/files/run/t3835.scala +++ b/test/files/run/t3835.scala @@ -1,6 +1,6 @@ object Test extends App { // work around optimizer bug SI-5672 -- generates wrong bytecode for switches in arguments - // virtpatmat happily emits a switch for a one-case switch, whereas -Xoldpatmat did not + // virtpatmat happily emits a switch for a one-case switch // this is not the focus of this test, hence the temporary workaround def a = (1, 2, 3) match { case (r, \u03b8, \u03c6) => r + \u03b8 + \u03c6 } println(a) diff --git a/test/files/run/t3855.scala b/test/files/run/t3855.scala index e55714201f..d10aab5383 100644 --- a/test/files/run/t3855.scala +++ b/test/files/run/t3855.scala @@ -1,13 +1,13 @@ object Test { def byval[A](a: => A) = a def closure[A](f: () => A) = f() - + def f1(s: String) = { - var n = try { s.toInt } catch { case _ => 1 } + var n = try { s.toInt } catch { case _: Throwable => 1 } byval(n) } def f2(s: String) = { - var n = try { s.toInt } catch { case _ => 1 } + var n = try { s.toInt } catch { case _: Throwable => 1 } closure(() => n) } diff --git a/test/files/run/t3877.scala b/test/files/run/t3877.scala index ce1e9283a7..5710e982a0 100644 --- a/test/files/run/t3877.scala +++ b/test/files/run/t3877.scala @@ -11,7 +11,7 @@ object Test { println("test1: " + d) } } - + def test2 { var d = 2 var i = 0 @@ -25,7 +25,7 @@ object Test { return } } - + def test3 { var d = 2 var i = 0 @@ -34,9 +34,9 @@ object Test { d = b i += 1 println("test3: " + d) - } while (d < LIMIT && i < LIMIT) + } while (d < LIMIT && i < LIMIT) } - + def test4 { var d = 2 var i = 0 @@ -47,9 +47,9 @@ object Test { println("test4: " + d) if (d >= LIMIT || i >= LIMIT) return - } while (true) + } while (true) } - + def test5 { var d = 2 var i = 0 @@ -58,7 +58,7 @@ object Test { d = b i += 1 println("test5.1: " + d) - + var e = 2 var j = 0 while (e < LIMIT && j < LIMIT) { @@ -69,7 +69,7 @@ object Test { } } } - + def main(args: Array[String]) { test1 diff --git a/test/files/run/t3886.scala b/test/files/run/t3886.scala deleted file mode 100644 index 1e8e7ad252..0000000000 --- a/test/files/run/t3886.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Test { - def main(args: Array[String]) { - assert( <k a="1" b="2"/> == <k a="1" b="2"/> ) - assert( <k a="1" b="2"/> != <k a="1" b="3"/> ) - assert( <k a="1" b="2"/> != <k a="2" b="2"/> ) - - assert( <k a="1" b="2"/> != <k/> ) - assert( <k a="1" b="2"/> != <k a="1"/> ) - assert( <k a="1" b="2"/> != <k b="2"/> ) - } -} diff --git a/test/files/run/t3887.scala b/test/files/run/t3887.scala index 81fa7a917e..16ce983efc 100644 --- a/test/files/run/t3887.scala +++ b/test/files/run/t3887.scala @@ -13,4 +13,4 @@ object Test { val option1: (Int, String) = (1, "abc") -} +} diff --git a/test/files/run/t3888.check b/test/files/run/t3888.check new file mode 100644 index 0000000000..844ca54682 --- /dev/null +++ b/test/files/run/t3888.check @@ -0,0 +1 @@ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details diff --git a/test/files/run/t3888.scala b/test/files/run/t3888.scala index e0f1453b1d..19771041fc 100644 --- a/test/files/run/t3888.scala +++ b/test/files/run/t3888.scala @@ -1,15 +1,18 @@ + +// in a match, which notion of equals prevails? +// extending Tuple doesn't seem to be at issue here. object Test { val T1 = new P private[this] val T2 = T1 - def m1 = + def m1 = (1, 2) match { case T1 => true case _ => false } - def m2 = + def m2 = (1, 2) match { case T2 => true case _ => false @@ -23,4 +26,4 @@ object Test { class P extends Pair(1, 1) { override def equals(x: Any) = true -}
\ No newline at end of file +} diff --git a/test/pending/run/t3897.check b/test/files/run/t3897.check index 244b83716f..244b83716f 100644 --- a/test/pending/run/t3897.check +++ b/test/files/run/t3897.check diff --git a/test/pending/run/t3897/J_2.java b/test/files/run/t3897/J_2.java index 178412dc92..a4c9a98fb1 100644 --- a/test/pending/run/t3897/J_2.java +++ b/test/files/run/t3897/J_2.java @@ -7,7 +7,7 @@ public class J_2 { String name = fields[i].getName(); if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { } else System.out.println("(" + name + "," + fields[i].getGenericType() + ")"); - } + } } public void f2(Class<?> clazz) { Method[] methods = clazz.getDeclaredMethods(); @@ -15,7 +15,7 @@ public class J_2 { String name = methods[i].getName(); if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { } else System.out.println("(" + name + "," + methods[i].getGenericReturnType() + ")"); - } + } } public void javaRun() { diff --git a/test/pending/run/t3897/a_1.scala b/test/files/run/t3897/a_1.scala index 4da959e2ac..4da959e2ac 100644 --- a/test/pending/run/t3897/a_1.scala +++ b/test/files/run/t3897/a_1.scala diff --git a/test/pending/run/t3897/a_2.scala b/test/files/run/t3897/a_2.scala index 4d9e59ef05..7a161fcbe4 100644 --- a/test/pending/run/t3897/a_2.scala +++ b/test/files/run/t3897/a_2.scala @@ -1,12 +1,12 @@ object Test { def f1(clazz: Class[_]) = ( - clazz.getDeclaredFields.toList + clazz.getDeclaredFields.toList . filterNot (_.getName contains "bitmap$") . map (f => (f.getName, f.getGenericType)) . foreach (println) ) def f2(clazz: Class[_]) = ( - clazz.getDeclaredMethods.toList + clazz.getDeclaredMethods.toList . filterNot (_.getName contains "bitmap$") . map (f => (f.getName, f.getGenericReturnType)) . foreach (println) @@ -17,7 +17,7 @@ object Test { f2(classOf[One]) f1(classOf[Two]) f2(classOf[Two]) - + new J_2().javaRun } } diff --git a/test/files/run/t3932.scala b/test/files/run/t3932.scala index 51fc16d6ea..f577ef8315 100644 --- a/test/files/run/t3932.scala +++ b/test/files/run/t3932.scala @@ -23,10 +23,10 @@ object Test { def main(args: Array[String]): Unit = { println(O1.g1) println(O1.g2) - + println(O2.g1) println(O2.g2) - + val o3 = new O3() println(o3.g1) println(o3.g2) diff --git a/test/files/run/t3935.scala b/test/files/run/t3935.scala index c66b1b0599..fa1bbf8d3f 100644 --- a/test/files/run/t3935.scala +++ b/test/files/run/t3935.scala @@ -9,7 +9,7 @@ object Test { try { assert(q.front != null) } catch { - case _ => + case _: Throwable => } } } diff --git a/test/files/run/t3964.scala b/test/files/run/t3964.scala index 80ba361a20..9b46cdb298 100644 --- a/test/files/run/t3964.scala +++ b/test/files/run/t3964.scala @@ -1,13 +1,16 @@ + +import scala.language.implicitConversions + object Test { - class Base + class Base object Bob extends Base class Foo { def bippy = 42 } class Oof { def bippy = -21 } - + // I am more specific than you implicit def f1(x: Bob.type): Foo = new Foo implicit def f2(x: Base): Oof = new Oof - + def main(args: Array[String]): Unit = { // this would of course print an unambiguous 42 println(Bob.bippy) diff --git a/test/files/run/t3970.scala b/test/files/run/t3970.scala index f8c763bc85..35b5ce6e1b 100644 --- a/test/files/run/t3970.scala +++ b/test/files/run/t3970.scala @@ -9,11 +9,11 @@ object Test { def main(args: Array[String]) { val dl = DoubleLinkedList[Int]() dl.remove() - + val dl2 = DoubleLinkedList[Int](1, 2, 3) dl2.next.remove() assert(dl2 == DoubleLinkedList(1, 3)) - + val dl3 = DoubleLinkedList[Int](1, 2, 3) assert(dl3.drop(1) == DoubleLinkedList(2, 3)) assert(dl3.drop(1).prev == null) diff --git a/test/files/run/t3980.scala b/test/files/run/t3980.scala index 4e693eba9b..c140176ce4 100644 --- a/test/files/run/t3980.scala +++ b/test/files/run/t3980.scala @@ -2,7 +2,7 @@ object A { def run1 { lazy val x: Unit = {(); println("once")} x - x + x } def run2 { lazy val y: Int = 2 diff --git a/test/files/run/t3984.scala b/test/files/run/t3984.scala index 9a2e00a2a8..0747b0ee25 100644 --- a/test/files/run/t3984.scala +++ b/test/files/run/t3984.scala @@ -36,7 +36,7 @@ object MapBug { im = im + ((ih,ih)) mm = mm + ((ih,ih)) } - assert(im == mm) + assert(im == mm) val x = IH(6,4) im = im - x mm = mm - x diff --git a/test/files/run/t4013.scala b/test/files/run/t4013.scala index da7fbc5b3f..7060559317 100644 --- a/test/files/run/t4013.scala +++ b/test/files/run/t4013.scala @@ -5,12 +5,12 @@ trait Base[B] { } -class Suba[@specialized B](override val data: Array[B]) extends Base[B] { +class Suba[@specialized B](override val data: Array[B]) extends Base[B] { assert(data != null) } -class Subopt[@specialized B](override val data: Option[B]) extends Base[B] { +class Subopt[@specialized B](override val data: Option[B]) extends Base[B] { assert(data != null) } diff --git a/test/files/run/t4013b.scala b/test/files/run/t4013b.scala index f17eaea3d3..1262e261f5 100644 --- a/test/files/run/t4013b.scala +++ b/test/files/run/t4013b.scala @@ -8,7 +8,7 @@ trait Base[B] { class M[@specialized(Int) A] -class Sub3[@specialized(Int) B](override val data: M[B]) extends Base[B] { +class Sub3[@specialized(Int) B](override val data: M[B]) extends Base[B] { assert(data != null) } diff --git a/test/files/run/t4023.check b/test/files/run/t4023.check new file mode 100644 index 0000000000..05f867c397 --- /dev/null +++ b/test/files/run/t4023.check @@ -0,0 +1,21 @@ +Try 1: (6 classes) +class Test$C$B1 +class Test$C$B2 +class Test$C$B3$ +class Test$C$B4$ +class Test$C$B5$ +class Test$C$B6$ +Try 2: (6 classes) +class Test$C$B1 +class Test$C$B2 +class Test$C$B3$ +class Test$C$B4$ +class Test$C$B5$ +class Test$C$B6$ +Try 3: (6 classes) +class Test$C$B1 +class Test$C$B2 +class Test$C$B3$ +class Test$C$B4$ +class Test$C$B5$ +class Test$C$B6$ diff --git a/test/files/run/t4023.scala b/test/files/run/t4023.scala new file mode 100644 index 0000000000..518b58382a --- /dev/null +++ b/test/files/run/t4023.scala @@ -0,0 +1,34 @@ +object Test { + object C { + class B1 + private class B2 + object B3 + private object B4 + object B5 extends B1 + private object B6 extends B2 + + val classes1 = this.getClass.getDeclaredClasses + val classes2 = C.getClass .getDeclaredClasses + val classes3 = getClass .getDeclaredClasses + } + + // sortBy(_.getName) introduces additional classes which we don't want to see in C, + // so we call sortBy outside of C. + object TestHelper { + val valuesTry1 = C.classes1.sortBy(_.getName) + val valuesTry2 = C.classes2.sortBy(_.getName) + val valuesTry3 = C.classes3.sortBy(_.getName) + } + + def main(args: Array[String]) { + println("Try 1: (" + TestHelper.valuesTry1.length + " classes)") + TestHelper.valuesTry1.foreach(println) + println("Try 2: (" + TestHelper.valuesTry2.length + " classes)") + TestHelper.valuesTry2.foreach(println) + println("Try 3: (" + TestHelper.valuesTry3.length + " classes)") + TestHelper.valuesTry3.foreach(println) + } + + +} + diff --git a/test/files/run/t4024.scala b/test/files/run/t4024.scala index 7c62a3fc6e..f48410915d 100644 --- a/test/files/run/t4024.scala +++ b/test/files/run/t4024.scala @@ -1,9 +1,9 @@ object Test extends App { - val x = "abc" + val x = "abc" val m = x.getClass.getMethod("toString") - + assert(m.invoke(x, (Nil: List[AnyRef]): _*) == "abc") Test2.main(Array()) diff --git a/test/files/run/t4025.check b/test/files/run/t4025.check index 6715003cb6..2d4f644c5a 100644 --- a/test/files/run/t4025.check +++ b/test/files/run/t4025.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> class Color(val red: Int) defined class Color diff --git a/test/files/run/t4027.scala b/test/files/run/t4027.scala index d70ca0cc3a..585c5c8b37 100644 --- a/test/files/run/t4027.scala +++ b/test/files/run/t4027.scala @@ -7,7 +7,7 @@ import collection._ * Mapping, filtering, etc. on these views should return sorted maps again. */ object Test extends App { - + val sortedmap = SortedMap(1 -> false, 2 -> true, 3 -> false, 4 -> true) println(sortedmap.filterKeys(_ % 2 == 0): SortedMap[Int, Boolean]) println(sortedmap.mapValues(_ + "!"): SortedMap[Int, String]) @@ -15,7 +15,7 @@ object Test extends App { println(sortedmap.mapValues(_ + "!").map(t => (t._1, t._2.toString.length)): SortedMap[Int, Int]) println(sortedmap.filterKeys(_ % 2 == 0).filter(t => t._1 < 2): SortedMap[Int, Boolean]) println(sortedmap.mapValues(_ + "!").filter(t => t._1 < 2): SortedMap[Int, String]) - + val immsortedmap = immutable.SortedMap(1 -> false, 2 -> true, 3 -> false, 4 -> true) println(immsortedmap.filterKeys(_ % 2 == 0): immutable.SortedMap[Int, Boolean]) println(immsortedmap.mapValues(_ + "!"): immutable.SortedMap[Int, String]) @@ -23,5 +23,5 @@ object Test extends App { println(immsortedmap.mapValues(_ + "!").map(t => (t._1, t._2.toString.length)): immutable.SortedMap[Int, Int]) println(immsortedmap.filterKeys(_ % 2 == 0).filter(t => t._1 < 2): immutable.SortedMap[Int, Boolean]) println(immsortedmap.mapValues(_ + "!").filter(t => t._1 < 2): immutable.SortedMap[Int, String]) - + } diff --git a/test/files/run/t4047.check b/test/files/run/t4047.check index 2a942a70e0..3c41e6e244 100644 --- a/test/files/run/t4047.check +++ b/test/files/run/t4047.check @@ -1,3 +1,15 @@ +t4047.scala:23: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + a.foo + ^ +t4047.scala:24: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + a.foo + ^ +t4047.scala:26: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + b.foo + ^ +t4047.scala:27: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + b.foo + ^ Unit: called A.foo Unit: called B.foo Unit: called C.foo diff --git a/test/files/run/t4047.scala b/test/files/run/t4047.scala index cd42a8b4df..08989bd278 100644 --- a/test/files/run/t4047.scala +++ b/test/files/run/t4047.scala @@ -18,7 +18,7 @@ class D extends Bar[Unit]{ def foo = println("Unit: called D.foo") } -object Test extends Application { +object Test extends App { val a: Foo[Unit] = new A a.foo a.foo diff --git a/test/files/run/t4054.scala b/test/files/run/t4054.scala index 8f1f685854..83a58ef97c 100644 --- a/test/files/run/t4054.scala +++ b/test/files/run/t4054.scala @@ -9,7 +9,7 @@ object Test { def main(args: Array[String]) { val it = Iterator.from(1).map(n => n * n).scanLeft(0)(_+_) - + assert(it.next == 0) assert(it.next == 1) assert(it.next == 5) diff --git a/test/files/run/t4062.scala b/test/files/run/t4062.scala index 6a5aea5b47..f5478e7593 100644 --- a/test/files/run/t4062.scala +++ b/test/files/run/t4062.scala @@ -1,7 +1,7 @@ class A(val f : String) class B(f: String) extends A(f) { - def foo(x: String) = x match { + def foo(x: String) = x match { case `f` => true case _ => false } diff --git a/test/files/run/t4072.scala b/test/files/run/t4072.scala index 872072a4ce..c035fcc22a 100644 --- a/test/files/run/t4072.scala +++ b/test/files/run/t4072.scala @@ -1,12 +1,14 @@ import scala.tools.nsc._ +import scala.language.{ reflectiveCalls } + object Test { class DryRun { - val compiler = new Global(new Settings()) { + val compiler = new Global(new Settings()) { lazy val test1 = new AnyRef } } - + def main(args: Array[String]) { new DryRun().compiler.test1 } diff --git a/test/files/run/t408.scala b/test/files/run/t408.scala index 4d3dcbcb84..9e51e881ed 100644 --- a/test/files/run/t408.scala +++ b/test/files/run/t408.scala @@ -2,7 +2,7 @@ object Test { val a = scala.collection.immutable.Set.empty ++ (0 to 100000) val b = scala.collection.immutable.Set.empty ++ (0 to 100000) - + def main(args: Array[String]): Unit = { a -- b a -- b diff --git a/test/files/run/t4080.scala b/test/files/run/t4080.scala index 92740ed776..1d1418847d 100644 --- a/test/files/run/t4080.scala +++ b/test/files/run/t4080.scala @@ -1,4 +1,5 @@ import scala.collection.mutable.LinkedList +import java.util.NoSuchElementException object Test { def main(args: Array[String]) { @@ -6,7 +7,7 @@ object Test { ll.insert(LinkedList(0)) println(ll) val ll2 = LinkedList[Int]() - try println(ll2.head) - catch { case _ => () } + try println("Empty head? " + ll2.head) + catch { case _: NoSuchElementException => () } } } diff --git a/test/files/run/t4119/J.java b/test/files/run/t4119/J.java index 42508993ea..ee65d33e22 100644 --- a/test/files/run/t4119/J.java +++ b/test/files/run/t4119/J.java @@ -1,6 +1,6 @@ package foo.bar; -public abstract class J { +public abstract class J { protected void foo(J j) { return; } diff --git a/test/files/run/t4119/S.scala b/test/files/run/t4119/S.scala index e5e3db5da3..d6ae5f1b87 100644 --- a/test/files/run/t4119/S.scala +++ b/test/files/run/t4119/S.scala @@ -1,6 +1,6 @@ class S extends foo.bar.J { sss => - + val fn = () => { foo(S.this) } diff --git a/test/files/run/t4122.scala b/test/files/run/t4122.scala index 7ead2b7742..5ff570c009 100644 --- a/test/files/run/t4122.scala +++ b/test/files/run/t4122.scala @@ -4,7 +4,7 @@ object Test { val sw3 = Seq('a', 'b') val sw4 = "ab".toList val all = List(sw, sw2, sw3, sw4) - + def main(args: Array[String]): Unit = { for (s1 <- all ; s2 <- all) { assert(s1 == s2, s1 + " != " + s2) diff --git a/test/files/run/t4124.check b/test/files/run/t4124.check deleted file mode 100644 index 66a0092d93..0000000000 --- a/test/files/run/t4124.check +++ /dev/null @@ -1,4 +0,0 @@ -hi -hi -bye -bye diff --git a/test/files/run/t4124.scala b/test/files/run/t4124.scala deleted file mode 100644 index 9f35b57ce3..0000000000 --- a/test/files/run/t4124.scala +++ /dev/null @@ -1,24 +0,0 @@ -import xml.Node - -object Test extends App { - val body: Node = <elem>hi</elem> - println ((body: AnyRef, "foo") match { - case (node: Node, "bar") => "bye" - case (ser: Serializable, "foo") => "hi" - }) - - println ((body, "foo") match { - case (node: Node, "bar") => "bye" - case (ser: Serializable, "foo") => "hi" - }) - - println ((body: AnyRef, "foo") match { - case (node: Node, "foo") => "bye" - case (ser: Serializable, "foo") => "hi" - }) - - println ((body: AnyRef, "foo") match { - case (node: Node, "foo") => "bye" - case (ser: Serializable, "foo") => "hi" - }) -} diff --git a/test/files/run/t4138.check b/test/files/run/t4138.check deleted file mode 100644 index f561b5e6b0..0000000000 --- a/test/files/run/t4138.check +++ /dev/null @@ -1,2 +0,0 @@ -[1.45] parsed: "lir 'de\' ' \\ \n / upa \"new\" \t parsing" -[1.5] parsed: "s " diff --git a/test/files/run/t4138.scala b/test/files/run/t4138.scala deleted file mode 100644 index 131489e581..0000000000 --- a/test/files/run/t4138.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends App { - object p extends scala.util.parsing.combinator.JavaTokenParsers - - println(p.parse(p.stringLiteral, """"lir 'de\' ' \\ \n / upa \"new\" \t parsing"""")) - println(p.parse(p.stringLiteral, """"s " lkjse"""")) -} diff --git a/test/files/run/t4148.scala b/test/files/run/t4148.scala index 0739403594..d543e093ab 100644 --- a/test/files/run/t4148.scala +++ b/test/files/run/t4148.scala @@ -1,8 +1,8 @@ object Test { - val x1 = try { "aaa".asInstanceOf[Int] } catch { case _ => "cce1" } - val x2 = try { (5: Any).asInstanceOf[Int] } catch { case _ => "cce2" } - val x3 = try { (new java.lang.Short(100.toShort).asInstanceOf[Int]) } catch { case _ => "cce3" } - + val x1 = try { "aaa".asInstanceOf[Int] } catch { case _: Throwable => "cce1" } + val x2 = try { (5: Any).asInstanceOf[Int] } catch { case _: Throwable => "cce2" } + val x3 = try { (new java.lang.Short(100.toShort).asInstanceOf[Int]) } catch { case _: Throwable => "cce3" } + def main(args: Array[String]): Unit = { List(x1, x2, x3) foreach println } diff --git a/test/files/run/t4171.scala b/test/files/run/t4171.scala index fba2fb5ed6..7f6dfd48ce 100644 --- a/test/files/run/t4171.scala +++ b/test/files/run/t4171.scala @@ -1,3 +1,6 @@ + +import scala.language.{ reflectiveCalls } + object Test { val c = { class C; new C { def foo = 1 } } val a = { class B { def bar = 5 }; class C extends B; new C } diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check index b48c9ca056..d94638d27e 100644 --- a/test/files/run/t4172.check +++ b/test/files/run/t4172.check @@ -1,12 +1,8 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - -scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) } +scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) } warning: there were 1 feature warning(s); re-run with -feature for details c: (C, C{def f: Int}) forSome { type C <: AnyRef } = (C,C) scala> - -scala> diff --git a/test/files/run/t4238/J_1.java b/test/files/run/t4238/J_1.java index 21a4b182ad..47a9c21000 100644 --- a/test/files/run/t4238/J_1.java +++ b/test/files/run/t4238/J_1.java @@ -3,14 +3,14 @@ import scala.*; class J_1 { scala.collection.mutable.HashMap<String, String> map = new scala.collection.mutable.HashMap<String, String>(); - + Function1<Tuple2<String, String>, Integer> f = new scala.runtime.AbstractFunction1<Tuple2<String, String>, Integer>() { public Integer apply(Tuple2<String, String> s) { return s._1().length(); } }; - + scala.collection.Seq<Integer> counts = map.groupBy(f).keys().toList(); } diff --git a/test/files/run/t4285.check b/test/files/run/t4285.check index 84f8929e43..314c8e5a35 100644 --- a/test/files/run/t4285.check +++ b/test/files/run/t4285.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> val x = Array(1,2,3,4,5,6,7) x: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7) @@ -13,5 +11,3 @@ scala> println(y.sum) 56 scala> - -scala> diff --git a/test/files/run/t4288.scala b/test/files/run/t4288.scala index eafd2808f1..4e7b366f60 100644 --- a/test/files/run/t4288.scala +++ b/test/files/run/t4288.scala @@ -6,7 +6,7 @@ object Test { def f5 = (1 to 9).toArray.slice(-5, -1) def f6 = (1 to 9).toStream.slice(-5, -1) def f7 = (1 to 9).slice(-5, -1) - + def main(args: Array[String]): Unit = { List[Traversable[Int]](f1, f2, f3, f4, f5, f6, f7) foreach (x => assert(x.isEmpty, x)) } diff --git a/test/files/run/t4294.scala b/test/files/run/t4294.scala index fafaf1d8ef..e15c716047 100644 --- a/test/files/run/t4294.scala +++ b/test/files/run/t4294.scala @@ -1,7 +1,12 @@ object Test { def main(args: Array[String]) { + // Skip test on Avian, see SI-7600 for further information + if (!scala.tools.partest.utils.Properties.isAvian) + run() + } + + def run(): Unit = { (Stream.from(1).collect{case x if x > 5000000 => x}: Stream[Int]) - assert((Stream from 1 take 10 collect { case x if x <= 3 => x*x }).sum == 14) } } diff --git a/test/files/run/t4317/S_3.scala b/test/files/run/t4317/S_3.scala index dd04ea31ef..ce8e2330e3 100644 --- a/test/files/run/t4317/S_3.scala +++ b/test/files/run/t4317/S_3.scala @@ -1,4 +1,4 @@ -object Test { +object Test { def main(args: Array[String]): Unit = { val j = new J_2() println(j.bar1()) diff --git a/test/files/pos/t4351.check b/test/files/run/t4351.check index cb5d407e13..cb5d407e13 100644 --- a/test/files/pos/t4351.check +++ b/test/files/run/t4351.check diff --git a/test/files/pos/t4351.scala b/test/files/run/t4351.scala index 2d57588793..d954d748b7 100644 --- a/test/files/pos/t4351.scala +++ b/test/files/run/t4351.scala @@ -1,7 +1,8 @@ object Test { def main(args: Array[String]): Unit = { - try new BooleanPropImpl() value + try new BooleanPropImpl().value catch { + // was: StackOverflowError case e: RuntimeException => println("runtime exception") } } diff --git a/test/files/run/t4387.scala b/test/files/run/t4387.scala deleted file mode 100644 index 68cbe97d08..0000000000 --- a/test/files/run/t4387.scala +++ /dev/null @@ -1,12 +0,0 @@ -object Test { - import xml.XML.loadString - def mkElem(arg: String) = <foo a="1" b="2" c="3" d="4" e={arg} /> - - val x1 = mkElem("5") - val x2 = mkElem("50") - - def main(args: Array[String]): Unit = { - assert(x1 == loadString("" + x1)) - assert(x2 != loadString("" + x1)) - } -} diff --git a/test/files/run/t4396.scala b/test/files/run/t4396.scala index ca143165b7..d67eaa378e 100644 --- a/test/files/run/t4396.scala +++ b/test/files/run/t4396.scala @@ -1,4 +1,4 @@ -// #43896 +// #43896 trait M extends DelayedInit { def delayedInit(body : => Unit) { println("hallo") diff --git a/test/files/run/t4398.scala b/test/files/run/t4398.scala index 1d57eb688d..87dc870afc 100644 --- a/test/files/run/t4398.scala +++ b/test/files/run/t4398.scala @@ -1,5 +1,7 @@ +import scala.language.{ postfixOps } + object Test { def main(args: Array[String]) { val x = 1 to 10 toSet diff --git a/test/files/run/t4415.scala b/test/files/run/t4415.scala index f96031d650..caf1609b9e 100644 --- a/test/files/run/t4415.scala +++ b/test/files/run/t4415.scala @@ -39,7 +39,7 @@ class SecondProperty extends TopProperty class SubclassSecondProperty extends StandardProperty trait MyProp[T] -case class MyPropImpl[T] extends MyProp[T] +case class MyPropImpl[T]() extends MyProp[T] object SubclassMatch { diff --git a/test/files/run/t4426.scala b/test/files/run/t4426.scala index 95759444d6..1cbd42da25 100644 --- a/test/files/run/t4426.scala +++ b/test/files/run/t4426.scala @@ -5,7 +5,7 @@ object Test { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") - object cc extends Global(settings) { + object cc extends Global(settings) { object dummy override def computePluginPhases() = { @@ -16,9 +16,9 @@ object Test { new cc.Run () } - + def main(args: Array[String]): Unit = { - + } } diff --git a/test/files/run/t4461.scala b/test/files/run/t4461.scala index adc9201313..1801a653e7 100644 --- a/test/files/run/t4461.scala +++ b/test/files/run/t4461.scala @@ -9,7 +9,7 @@ object Test { buf.subscribe(new Subscriber[Message[Int], ObservableBuffer[Int]] { def notify(pub: ObservableBuffer[Int], event: Message[Int]) = println(event) }) - + buf += 1 // works buf ++= Array(2) // works buf ++= ArrayBuffer(3, 4) // works diff --git a/test/files/run/t4535.scala b/test/files/run/t4535.scala index eba79431c9..91c13a28cd 100644 --- a/test/files/run/t4535.scala +++ b/test/files/run/t4535.scala @@ -5,26 +5,26 @@ import collection._ // #4535 object Test { - + def main(args: Array[String]) { val as = new mutable.ArrayStack[Int] as push 1 as push 2 as push 3 println(as.reverse) - + as push 4 as push 5 as push 6 println(as.reverse) - + println(as map { x => x }) - + for (i <- 0 until 100) { as push i assert(as == as.map(x => x)) assert(as == as.reverse.reverse) } } - + } diff --git a/test/files/run/t4536.scala b/test/files/run/t4536.scala index acd91deb7f..6661eae6a7 100644 --- a/test/files/run/t4536.scala +++ b/test/files/run/t4536.scala @@ -37,10 +37,10 @@ object dynamicMixin extends dynamicAbstractClass with dynamicTrait { object Test { - + def main(args: Array[String]) { val cls = new dynamicClass dynamicMixin } - + } diff --git a/test/files/run/t4537.check b/test/files/run/t4537.check new file mode 100644 index 0000000000..63739ca64a --- /dev/null +++ b/test/files/run/t4537.check @@ -0,0 +1 @@ +b.Settings diff --git a/test/files/neg/t4537/a.scala b/test/files/run/t4537/a.scala index 65e183c5f8..125e223e13 100644 --- a/test/files/neg/t4537/a.scala +++ b/test/files/run/t4537/a.scala @@ -1,5 +1,5 @@ package a private[a] object Settings { - val X = 0 -}
\ No newline at end of file + val X = "a.Settings" +} diff --git a/test/files/neg/t4537/b.scala b/test/files/run/t4537/b.scala index bb9dd4e15a..c709d49b04 100644 --- a/test/files/neg/t4537/b.scala +++ b/test/files/run/t4537/b.scala @@ -1,5 +1,5 @@ package b object Settings { - val Y = 0 -}
\ No newline at end of file + val Y = "b.Settings" +} diff --git a/test/files/run/t4537/c.scala b/test/files/run/t4537/c.scala new file mode 100644 index 0000000000..ee05d4bbfb --- /dev/null +++ b/test/files/run/t4537/c.scala @@ -0,0 +1,8 @@ +package b +package c + +import a._ + +object Unambiguous { + println(Settings.Y) +} diff --git a/test/files/run/t4537/d.scala b/test/files/run/t4537/d.scala new file mode 100644 index 0000000000..dd1d2045ed --- /dev/null +++ b/test/files/run/t4537/d.scala @@ -0,0 +1,6 @@ +import a._ +import b._ + +object Test extends App { + println(Settings.Y) +} diff --git a/test/files/run/t4542.check b/test/files/run/t4542.check index cd7a2905e2..5a8108dcbc 100644 --- a/test/files/run/t4542.check +++ b/test/files/run/t4542.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> @deprecated("foooo", "ReplTest version 1.0-FINAL") class Foo() { override def toString = "Bippy" } @@ -18,5 +16,3 @@ scala> val f = new Foo f: Foo = Bippy scala> - -scala> diff --git a/test/files/run/t4560.scala b/test/files/run/t4560.scala index 9979199067..ee657e47eb 100644 --- a/test/files/run/t4560.scala +++ b/test/files/run/t4560.scala @@ -7,6 +7,9 @@ // TEST 1 // self-type is other trait + +import scala.language.{ reflectiveCalls } + trait Aa trait Ab diff --git a/test/files/run/t4570.scala b/test/files/run/t4570.scala index 5408caf6db..5e1a20c52d 100644 --- a/test/files/run/t4570.scala +++ b/test/files/run/t4570.scala @@ -1,8 +1,8 @@ object Test extends Enumeration { val foo = Value def bar = withName("foo") - + def main(args: Array[String]): Unit = { - values foreach println + values foreach println } } diff --git a/test/files/run/t4574.check b/test/files/run/t4574.check deleted file mode 100644 index a4522fff24..0000000000 --- a/test/files/run/t4574.check +++ /dev/null @@ -1,2 +0,0 @@ -I hereby refute null! -I denounce null as unListLike! diff --git a/test/files/run/t4594-repl-settings.scala b/test/files/run/t4594-repl-settings.scala new file mode 100644 index 0000000000..d2335460e5 --- /dev/null +++ b/test/files/run/t4594-repl-settings.scala @@ -0,0 +1,26 @@ + +import scala.tools.partest.SessionTest + +// Detected repl transcript paste: ctrl-D to finish. +object Test extends SessionTest { + def session = +""" |Type in expressions to have them evaluated. + |Type :help for more information. + | + |scala> @deprecated(message="Please don't do that.", since="Time began.") def depp = "john" + |depp: String + | + |scala> def a = depp + |warning: there were 1 deprecation warning(s); re-run with -deprecation for details + |a: String + | + |scala> :settings +deprecation + | + |scala> def b = depp + |<console>:8: warning: method depp is deprecated: Please don't do that. + | def b = depp + | ^ + |b: String + | + |scala> """ +} diff --git a/test/files/run/t4608.scala b/test/files/run/t4608.scala index 2d43bebd10..9ffcb0f3f1 100644 --- a/test/files/run/t4608.scala +++ b/test/files/run/t4608.scala @@ -1,8 +1,8 @@ // #4608 object Test { - + def main(args: Array[String]) { ((1 to 100) sliding 10).toList.par.map{_.map{i => i * i}}.flatten } - + } diff --git a/test/files/run/t4617.scala b/test/files/run/t4617.scala index 3a877c1915..2fea5e29ec 100644 --- a/test/files/run/t4617.scala +++ b/test/files/run/t4617.scala @@ -3,7 +3,7 @@ object Test { def f2 = { lazy val d = 4D lazy val f = 4f - + def bar = "Str " + (d + f) bar } diff --git a/test/files/run/t4656.scala b/test/files/run/t4656.scala index ab3e3cf53d..4f3d189c8f 100644 --- a/test/files/run/t4656.scala +++ b/test/files/run/t4656.scala @@ -6,7 +6,7 @@ object Test { buf prependToList List(4, 5, 6) l } - + def main(args: Array[String]): Unit = { println(f) } diff --git a/test/files/run/t4660.scala b/test/files/run/t4660.scala index e57bb4bf25..9aac10ddfd 100644 --- a/test/files/run/t4660.scala +++ b/test/files/run/t4660.scala @@ -3,7 +3,7 @@ object Test { val traversable = 1 to 20 map (_.toString) def normalize(m: Map[Char, Traversable[String]]) = m.map { case (k,v) => (k, v.toList) } - val groupedFromView = (traversable view).groupBy(_(0)) + val groupedFromView = traversable.view.groupBy(_(0)) val groupedFromStrict = traversable.groupBy(_(0)) assert(normalize(groupedFromView) == normalize(groupedFromStrict)) diff --git a/test/files/run/t4671.check b/test/files/run/t4671.check index 4699818cd4..0c36083759 100644 --- a/test/files/run/t4671.check +++ b/test/files/run/t4671.check @@ -2,7 +2,7 @@ Type in expressions to have them evaluated. Type :help for more information. scala> object o { val file = sys.props("partest.cwd") + "/t4671.scala" } -defined module o +defined object o scala> val s = scala.io.Source.fromFile(o.file) s: scala.io.BufferedSource = non-empty iterator @@ -10,7 +10,7 @@ s: scala.io.BufferedSource = non-empty iterator scala> println(s.getLines.mkString("\n")) import scala.tools.partest.ReplTest -object Test extends ReplTest { +object Test extends ReplTest { // My god...it's full of quines def code = """ object o { val file = sys.props("partest.cwd") + "/t4671.scala" } @@ -30,7 +30,7 @@ s: scala.io.BufferedSource = non-empty iterator scala> println(s.mkString("")) import scala.tools.partest.ReplTest -object Test extends ReplTest { +object Test extends ReplTest { // My god...it's full of quines def code = """ object o { val file = sys.props("partest.cwd") + "/t4671.scala" } diff --git a/test/files/run/t4671.scala b/test/files/run/t4671.scala index aba0138aad..6170104c33 100644 --- a/test/files/run/t4671.scala +++ b/test/files/run/t4671.scala @@ -1,6 +1,6 @@ import scala.tools.partest.ReplTest -object Test extends ReplTest { +object Test extends ReplTest { // My god...it's full of quines def code = """ object o { val file = sys.props("partest.cwd") + "/t4671.scala" } diff --git a/test/files/run/t4680.check b/test/files/run/t4680.check index b5cfc651f2..b2e5209dc5 100644 --- a/test/files/run/t4680.check +++ b/test/files/run/t4680.check @@ -1,3 +1,9 @@ +t4680.scala:51: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + new C { 5 } + ^ +t4680.scala:69: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + new { val x = 5 } with E() { 5 } + ^ // new C { } diff --git a/test/files/run/t4680.scala b/test/files/run/t4680.scala index 88611df7ae..d5c8d0e7af 100644 --- a/test/files/run/t4680.scala +++ b/test/files/run/t4680.scala @@ -43,13 +43,13 @@ class E() extends D() { object Test { def p(msg: String) = println("\n\n// " + msg) - + def main(args: Array[String]) { p("new C { }") new C { } p("new C { 5 }") new C { 5 } - + p("new D()") new D() p("new D() { }") diff --git a/test/files/run/t4697.scala b/test/files/run/t4697.scala index 728d095ff8..95592172e0 100644 --- a/test/files/run/t4697.scala +++ b/test/files/run/t4697.scala @@ -1,7 +1,7 @@ object Test { var st = Stream(0) for (i <- 1 to 10000) st = i +: st - + def main(args: Array[String]): Unit = { println(st.take(10000).sum) } diff --git a/test/files/run/t4729/S_2.scala b/test/files/run/t4729/S_2.scala index e34e3d34d4..f823433ded 100644 --- a/test/files/run/t4729/S_2.scala +++ b/test/files/run/t4729/S_2.scala @@ -1,3 +1,4 @@ +import scala.language.reflectiveCalls // Scala class: class ScalaVarArgs extends J_1 { // -- no problem on overriding it using ordinary class @@ -20,7 +21,7 @@ object Test { (new ScalaVarArgs).method("1", "2") (new ScalaVarArgs: J_1).method("1", "2") - //[4] Not Ok -- error when assigning anonymous class to a explictly typed val + //[4] Not Ok -- error when assigning anonymous class to an explictly typed val // Compiler error: object creation impossible, since method method in trait VarArgs of type (s: <repeated...>[java.lang.String])Unit is not defined val tagged: J_1 = new J_1 { def method(s: String*) { println(s) } diff --git a/test/files/run/t4742.flags b/test/files/run/t4742.flags new file mode 100644 index 0000000000..ae08446055 --- /dev/null +++ b/test/files/run/t4742.flags @@ -0,0 +1 @@ +-Xcheckinit
\ No newline at end of file diff --git a/test/files/run/t4742.scala b/test/files/run/t4742.scala new file mode 100644 index 0000000000..3b42c0c120 --- /dev/null +++ b/test/files/run/t4742.scala @@ -0,0 +1,7 @@ +trait T { val x: Int = 0 } +object O extends T { override final val x = 1 } + +object Test extends App { + // was throwing an UnitializedFieldError as constant 1 is folded into the accessor + assert((O: T).x == 1) +} diff --git a/test/files/run/t4752.scala b/test/files/run/t4752.scala index 2a9fc5361f..3d5c166a7a 100644 --- a/test/files/run/t4752.scala +++ b/test/files/run/t4752.scala @@ -2,8 +2,8 @@ object Test { object Bippy { case object Dingus } - - def main(args: Array[String]): Unit = { + + def main(args: Array[String]): Unit = { assert(None.## == "None".##, None) assert(Test.Bippy.Dingus.## == "Dingus".##, Test.Bippy.Dingus) } diff --git a/test/files/run/t4753.scala b/test/files/run/t4753.scala index 98f3e92678..cfb252cbe5 100644 --- a/test/files/run/t4753.scala +++ b/test/files/run/t4753.scala @@ -1,4 +1,4 @@ -trait A { +trait A { val actualType: Class[_] } trait B extends A { diff --git a/test/files/run/t4761.scala b/test/files/run/t4761.scala index a9c245d7d5..e4bd87cb15 100644 --- a/test/files/run/t4761.scala +++ b/test/files/run/t4761.scala @@ -3,7 +3,7 @@ object Test { val gs = for (x <- (1 to 5)) yield { if (x % 2 == 0) List(1).seq else List(1).par } println(gs.flatten) println(gs.transpose) - + val s = Stream(Vector(1).par, Vector(2).par) println(s.flatten.toList) println(s.transpose.map(_.toList).toList) diff --git a/test/files/run/t4766.scala b/test/files/run/t4766.scala index c2a864ddb2..d67431f50e 100644 --- a/test/files/run/t4766.scala +++ b/test/files/run/t4766.scala @@ -1,3 +1,7 @@ + +import scala.language.postfixOps +import scala.language.reflectiveCalls + object Test extends App { val x = new { def > = 1 diff --git a/test/files/run/t4777.scala b/test/files/run/t4777.scala index 4a811d3b9a..6c7b856e39 100644 --- a/test/files/run/t4777.scala +++ b/test/files/run/t4777.scala @@ -3,6 +3,6 @@ class DefaultsTest(x: Int = 25) extends A(28) object DefaultsTest extends DefaultsTest(12) object Test extends App { - println(new DefaultsTest() a) - println(DefaultsTest a) + println(new DefaultsTest().a) + println(DefaultsTest.a) } diff --git a/test/files/run/t4794.scala b/test/files/run/t4794.scala index afe89fa429..720906f507 100644 --- a/test/files/run/t4794.scala +++ b/test/files/run/t4794.scala @@ -7,6 +7,7 @@ class Arr[@specialized A](val arr: Array[A]) { object Test { def main(args: Array[String]): Unit = { - println(classOf[Arr[_]].getMethods filter (_.getName contains "quux") size) // expect 10, not 1 + def quuxae = classOf[Arr[_]].getMethods filter (_.getName contains "quux") + println(quuxae.size) // expect 10, not 1 } } diff --git a/test/files/run/t4809.scala b/test/files/run/t4809.scala index b30d80562f..4b721d111b 100644 --- a/test/files/run/t4809.scala +++ b/test/files/run/t4809.scala @@ -5,7 +5,7 @@ import scala.util.control.Breaks._ object Test { - + def main(args: Array[String]) { val x = tryBreakable { break @@ -14,14 +14,14 @@ object Test { 3 } assert(x == 3, x) - + val y = tryBreakable { 2 } catchBreak { 3 } assert(y == 2, y) - + val z = tryBreakable { break 1.0 @@ -30,5 +30,5 @@ object Test { } assert(z == 2.0, z) } - + } diff --git a/test/files/run/t4835.scala b/test/files/run/t4835.scala index c964e42e7c..26275c0ab4 100644 --- a/test/files/run/t4835.scala +++ b/test/files/run/t4835.scala @@ -1,6 +1,6 @@ /* * Test case for SI-4835. This tests confirm that the fix - * doesn't break laziness. To test memory consumption, + * doesn't break laziness. To test memory consumption, * I need to confirm that OutOfMemoryError doesn't occur. * I could create such tests. However, such tests consume * too much time and memory. diff --git a/test/files/run/t4859.check b/test/files/run/t4859.check new file mode 100644 index 0000000000..d329744ca0 --- /dev/null +++ b/test/files/run/t4859.check @@ -0,0 +1,8 @@ +Inner +Inner.i +About to reference Inner.i +Outer +Inner.i +About to reference O.N +About to reference O.N +About to reference O.N.apply() diff --git a/test/files/run/t4859.scala b/test/files/run/t4859.scala new file mode 100644 index 0000000000..3c20cea983 --- /dev/null +++ b/test/files/run/t4859.scala @@ -0,0 +1,29 @@ +object O { + case class N() + object P +} + +object Outer { + println("Outer") + object Inner { + println("Inner") + def i { + println("Inner.i") + } + } +} + +object Test { + def main(args: Array[String]) { + Outer.Inner.i // we still don't initialize Outer here (but should we?) + + {println("About to reference Inner.i"); Outer}.Inner.i // Outer will be initialized. + + {println("About to reference O.N" ); O}.N + + {println("About to reference O.N" ); O}.N + + {println("About to reference O.N.apply()"); O}.N.apply() + } +} + diff --git a/test/files/run/t4871.scala b/test/files/run/t4871.scala index 70d8b7145c..e25d5c1387 100644 --- a/test/files/run/t4871.scala +++ b/test/files/run/t4871.scala @@ -5,7 +5,7 @@ object Test { def main(args: Array[String]): Unit = { val z: Class[C] = classOf val z2: Class[D] = classOf[D] - + println(z) println(z2) } diff --git a/test/files/run/t4894.scala b/test/files/run/t4894.scala index aa3b4340af..2b70da141d 100644 --- a/test/files/run/t4894.scala +++ b/test/files/run/t4894.scala @@ -4,24 +4,24 @@ object Test { - + def main(args: Array[String]) { import collection._ val hs = mutable.HashSet[Int]() hs ++= 1 to 10 hs --= 1 to 10 - + val phs = parallel.mutable.ParHashSet[Int]() phs ++= 1 to 10 for (i <- 1 to 10) assert(phs(i)) phs --= 1 to 10 assert(phs.isEmpty) - + val phm = parallel.mutable.ParHashMap[Int, Int]() phm ++= ((1 to 10) zip (1 to 10)) for (i <- 1 to 10) assert(phm(i) == i) phm --= 1 to 10 assert(phm.isEmpty) } - + } diff --git a/test/files/run/t4895.scala b/test/files/run/t4895.scala index a0e8c19f00..3842f8a389 100644 --- a/test/files/run/t4895.scala +++ b/test/files/run/t4895.scala @@ -1,16 +1,16 @@ object Test { - + def checkPar(sz: Int) { import collection._ val hs = mutable.HashSet[Int]() ++ (1 to sz) assert(hs.par.map(_ + 1).seq.toSeq.sorted == (2 to (sz + 1))) } - + def main(args: Array[String]) { for (i <- 0 until 100) checkPar(i) for (i <- 100 until 1000 by 50) checkPar(i) for (i <- 1000 until 10000 by 500) checkPar(i) for (i <- 10000 until 100000 by 5000) checkPar(i) } - + } diff --git a/test/files/run/t4929.check b/test/files/run/t4929.check deleted file mode 100644 index 0f0c913d55..0000000000 --- a/test/files/run/t4929.check +++ /dev/null @@ -1 +0,0 @@ -success
\ No newline at end of file diff --git a/test/files/run/t4929.scala b/test/files/run/t4929.scala deleted file mode 100644 index 3208cd1b09..0000000000 --- a/test/files/run/t4929.scala +++ /dev/null @@ -1,42 +0,0 @@ -import scala.util.parsing.json._ -import java.util.concurrent._ -import collection.JavaConversions._ - -object Test extends App { - - val LIMIT = 2000 - val THREAD_COUNT = 20 - val count = new java.util.concurrent.atomic.AtomicInteger(0) - - val begin = new CountDownLatch(THREAD_COUNT) - val finish = new CountDownLatch(THREAD_COUNT) - - val errors = new ConcurrentLinkedQueue[Throwable] - - (1 to THREAD_COUNT) foreach { i => - val thread = new Thread { - override def run() { - begin.await(1, TimeUnit.SECONDS) - try { - while (count.getAndIncrement() < LIMIT && errors.isEmpty) { - JSON.parseFull("""{"foo": [1,2,3,4]}""") - } - } catch { - case t: Throwable => errors.add(t) - } - - finish.await(10, TimeUnit.SECONDS) - } - } - - thread.setDaemon(true) - thread.start() - - } - - - errors foreach { throw(_) } - - println("success") - -} diff --git a/test/files/run/t4935.flags b/test/files/run/t4935.flags index ac14fe5dbd..49d036a887 100644 --- a/test/files/run/t4935.flags +++ b/test/files/run/t4935.flags @@ -1 +1 @@ --optimize
+-optimize diff --git a/test/files/run/t4954.scala b/test/files/run/t4954.scala index b4916e651d..f0bb1cc02d 100644 --- a/test/files/run/t4954.scala +++ b/test/files/run/t4954.scala @@ -4,7 +4,7 @@ import collection._ object Test { - + def main(args: Array[String]) { val m = scala.collection.mutable.LinkedHashMap("one" -> 1, "two" -> 2, "three" -> 3, "four" -> 4, "five" -> 5) val expected = List("one", "two", "three", "four", "five") @@ -15,7 +15,7 @@ object Test { assert(m.keys.drop(3).iterator.toList == expected.drop(3)) assert(m.keys.drop(4).iterator.toList == expected.drop(4)) assert(m.keys.drop(5).iterator.toList == expected.drop(5)) - + val expvals = List(1, 2, 3, 4, 5) assert(m.values.iterator.toList == expvals) assert(m.values.drop(0).iterator.toList == expvals) @@ -24,7 +24,7 @@ object Test { assert(m.values.drop(3).iterator.toList == expvals.drop(3)) assert(m.values.drop(4).iterator.toList == expvals.drop(4)) assert(m.values.drop(5).iterator.toList == expvals.drop(5)) - + val pred = (x: String) => x.length < 6 val filtered = m.filterKeys(pred) assert(filtered.drop(0).keys.toList == expected.filter(pred)) @@ -32,7 +32,7 @@ object Test { assert(filtered.drop(2).keys.toList == expected.filter(pred).drop(2)) assert(filtered.drop(3).keys.toList == expected.filter(pred).drop(3)) assert(filtered.drop(4).keys.toList == expected.filter(pred).drop(4)) - + val mapped = m.mapValues(-_) assert(mapped.drop(0).keys.toList == expected) assert(mapped.drop(1).keys.toList == expected.drop(1)) @@ -41,5 +41,5 @@ object Test { assert(mapped.drop(4).keys.toList == expected.drop(4)) assert(mapped.drop(5).keys.toList == expected.drop(5)) } - + } diff --git a/test/files/run/t498.scala b/test/files/run/t498.scala index b4ede951f0..5c10e6630f 100644 --- a/test/files/run/t498.scala +++ b/test/files/run/t498.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + object Test extends App { // the function passed to flatMap produces lots of empty streams, but this should not overflow the stack val res = Stream.from(1).flatMap(i => if (i < 3000) Stream.empty else List(1)) diff --git a/test/files/run/t4996.check b/test/files/run/t4996.check new file mode 100644 index 0000000000..8d45b413c9 --- /dev/null +++ b/test/files/run/t4996.check @@ -0,0 +1,4 @@ +B.foo +M.foo +B.foo +M.foo
\ No newline at end of file diff --git a/test/files/run/t4996.scala b/test/files/run/t4996.scala new file mode 100644 index 0000000000..8a38e7fe7f --- /dev/null +++ b/test/files/run/t4996.scala @@ -0,0 +1,47 @@ + + + + + + +trait A[@specialized(Int) T] { + def foo(t: T) +} + + +trait B extends A[Int] { + def foo(t: Int) { + println("B.foo") + } +} + + +trait M extends B { + abstract override def foo(t: Int) { + super.foo(t) + println("M.foo") + } +} + + +object C extends B with M + + +object D extends B { + override def foo(t: Int) { + super.foo(t) + println("M.foo") + } +} + + +object Test { + + def main(args: Array[String]) { + D.foo(42) // OK, prints B.foo M.foo + C.foo(42) // was StackOverflowError + } + +} + + diff --git a/test/files/run/t5018.scala b/test/files/run/t5018.scala index bb67a252e5..70bd6c52ea 100644 --- a/test/files/run/t5018.scala +++ b/test/files/run/t5018.scala @@ -7,7 +7,7 @@ import collection._ object Test { - + def serializeDeserialize[T <: AnyRef](obj: T) = { val buffer = new ByteArrayOutputStream val out = new ObjectOutputStream(buffer) @@ -15,23 +15,23 @@ object Test { val in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray)) in.readObject.asInstanceOf[T] } - + def main(args: Array[String]) { val values = mutable.Map(1 -> 1).values assert(serializeDeserialize(values).toList == values.toList) - + val keyset = mutable.Map(1 -> 1).keySet assert(serializeDeserialize(keyset) == keyset) - + val imkeyset = immutable.Map(1 -> 1).keySet assert(serializeDeserialize(imkeyset) == imkeyset) - + val defaultmap = immutable.Map(1 -> 1).withDefaultValue(1) assert(serializeDeserialize(defaultmap) == defaultmap) - + val minusmap = mutable.Map(1 -> 1).withDefault(x => -x) assert(serializeDeserialize(minusmap) == minusmap) } - + } diff --git a/test/files/run/t5052.scala b/test/files/run/t5052.scala deleted file mode 100644 index 9e418e8ac5..0000000000 --- a/test/files/run/t5052.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends App { - assert(<elem attr={null:String} /> xml_== <elem />) - assert(<elem attr={None} /> xml_== <elem />) - assert(<elem /> xml_== <elem attr={null:String} />) - assert(<elem /> xml_== <elem attr={None} />) -} diff --git a/test/files/run/t5053.scala b/test/files/run/t5053.scala index e46dad5ac6..50057ce66c 100644 --- a/test/files/run/t5053.scala +++ b/test/files/run/t5053.scala @@ -1,20 +1,23 @@ + +import scala.language.{ existentials } + object Test extends App { { val (left, right) = Seq((1, "a"), (1, "a"), (1, "a"), (3, "c")).view.unzip println(left.isInstanceOf[scala.collection.SeqViewLike[_,_,_]]) val (l, m, r) = Seq((1, 1.0, "a"), (1, 1.0, "a"), (1, 1.0, "a"), (3, 3.0, "c")).view.unzip3 - println(l.isInstanceOf[scala.collection.SeqViewLike[_,_,_]]) + println(l.isInstanceOf[scala.collection.SeqViewLike[_,_,_]]) } { val (left, right) = Iterable((1, "a"), (1, "a"), (1, "a"), (3, "c")).view.unzip println(left.isInstanceOf[scala.collection.IterableViewLike[_,_,_]]) val (l, m, r) = Iterable((1, 1.0, "a"), (1, 1.0, "a"), (1, 1.0, "a"), (3, 3.0, "c")).view.unzip3 - println(l.isInstanceOf[scala.collection.IterableViewLike[_,_,_]]) + println(l.isInstanceOf[scala.collection.IterableViewLike[_,_,_]]) } { val (left, right) = Traversable((1, "a"), (1, "a"), (1, "a"), (3, "c")).view.unzip println(left.isInstanceOf[scala.collection.TraversableViewLike[_,_,_]]) val (l, m, r) = Traversable((1, 1.0, "a"), (1, 1.0, "a"), (1, 1.0, "a"), (3, 3.0, "c")).view.unzip3 - println(l.isInstanceOf[scala.collection.TraversableViewLike[_,_,_]]) + println(l.isInstanceOf[scala.collection.TraversableViewLike[_,_,_]]) } } diff --git a/test/files/run/t5064.check b/test/files/run/t5064.check index 077006abd9..61ccfd16e7 100644 --- a/test/files/run/t5064.check +++ b/test/files/run/t5064.check @@ -1,6 +1,6 @@ -[12] T5064.super.<init>() -[12] T5064.super.<init> -[12] this +[53] T5064.super.<init>() +[53] T5064.super.<init> +[53] this [16:23] immutable.this.List.apply(scala.this.Predef.wrapIntArray(Array[Int]{1})) [16:20] immutable.this.List.apply <16:20> immutable.this.List diff --git a/test/files/run/t5072.check b/test/files/run/t5072.check index 8fe75f55d6..ddd49c71cb 100644 --- a/test/files/run/t5072.check +++ b/test/files/run/t5072.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> class C defined class C @@ -10,5 +8,3 @@ scala> Thread.currentThread.getContextClassLoader.loadClass(classOf[C].getName) res0: Class[_] = class C scala> - -scala> diff --git a/test/files/run/t5080.scala b/test/files/run/t5080.scala index ce72d13a54..acb6167f46 100644 --- a/test/files/run/t5080.scala +++ b/test/files/run/t5080.scala @@ -1,3 +1,7 @@ + +import scala.language.implicitConversions +import scala.language.reflectiveCalls + object Test extends App { abstract class Value { diff --git a/test/files/run/t5115.scala b/test/files/run/t5115.scala deleted file mode 100644 index cf25214715..0000000000 --- a/test/files/run/t5115.scala +++ /dev/null @@ -1,14 +0,0 @@ -import scala.collection.Iterable - -object Test extends App { - def assertHonorsIterableContract(i: Iterable[_]) = assert(i.size == i.iterator.size) - - assertHonorsIterableContract(<a/>.attributes) - assertHonorsIterableContract(<a x=""/>.attributes) - assertHonorsIterableContract(<a y={None}/>.attributes) - assertHonorsIterableContract(<a y={None} x=""/>.attributes) - assertHonorsIterableContract(<a a="" y={None} />.attributes) - assertHonorsIterableContract(<a y={null:String}/>.attributes) - assertHonorsIterableContract(<a y={null:String} x=""/>.attributes) - assertHonorsIterableContract(<a a="" y={null:String} />.attributes) -} diff --git a/test/files/run/t5125b.scala b/test/files/run/t5125b.scala index 29c08fee4c..149c49e213 100644 --- a/test/files/run/t5125b.scala +++ b/test/files/run/t5125b.scala @@ -7,7 +7,7 @@ class C2 { @scala.annotation.varargs def f(values:String*) = println("Calling C2.f(): " + values) def g(): String => Int = s => s.hashCode - + class C3 { @scala.annotation.varargs def f(values:String*) = println("Calling C3.f(): " + values) diff --git a/test/files/run/t5224.check b/test/files/run/t5224.check index e15c1c90eb..b11480acdf 100644 --- a/test/files/run/t5224.check +++ b/test/files/run/t5224.check @@ -1,3 +1,8 @@ +t5224.scala:3: warning: Implementation restriction: subclassing Classfile does not +make your annotation visible at runtime. If that is what +you want, you must write the annotation class in Java. +class Foo(bar: String) extends annotation.ClassfileAnnotation + ^ { @new Foo(bar = "qwe") class C extends AnyRef { def <init>() = { diff --git a/test/files/run/t5225_2.check b/test/files/run/t5225_2.check index 5faa365bce..477ea4eb6d 100644 --- a/test/files/run/t5225_2.check +++ b/test/files/run/t5225_2.check @@ -1,4 +1,4 @@ { - def foo(@new `package`.cloneable() x: Int) = ""; + def foo(@new elidable(0) x: Int) = ""; () } diff --git a/test/files/run/t5225_2.scala b/test/files/run/t5225_2.scala index d1b607499c..cf0f23a5c8 100644 --- a/test/files/run/t5225_2.scala +++ b/test/files/run/t5225_2.scala @@ -1,6 +1,6 @@ import scala.reflect.runtime.universe._ object Test extends App { - val tree = reify{def foo(@cloneable x: Int) = ""}.tree + val tree = reify{def foo(@annotation.elidable(0) x: Int) = ""}.tree println(tree.toString) }
\ No newline at end of file diff --git a/test/files/run/t5256d.check b/test/files/run/t5256d.check index b7617e80a2..5705acf20a 100644 --- a/test/files/run/t5256d.check +++ b/test/files/run/t5256d.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ @@ -28,5 +26,3 @@ scala.AnyRef { } scala> - -scala> diff --git a/test/files/run/t5256g.check b/test/files/run/t5256g.check index c9c8d6e63d..cef3a413c2 100644 --- a/test/files/run/t5256g.check +++ b/test/files/run/t5256g.check @@ -1,3 +1,5 @@ -anonymous class $anon$1 +$anon Test.$anon$1 -A with B{def <init>(): A with B} +A with B { + def <init>(): A with B +} diff --git a/test/files/run/t5256h.check b/test/files/run/t5256h.check index 1b23a71a4c..1a4a92a684 100644 --- a/test/files/run/t5256h.check +++ b/test/files/run/t5256h.check @@ -1,4 +1,4 @@ -anonymous class $anon$1 +$anon Test.$anon$1 java.lang.Object { final private val x: Int diff --git a/test/files/run/t5262.scala b/test/files/run/t5262.scala index fc4e57aa96..67448442da 100644 --- a/test/files/run/t5262.scala +++ b/test/files/run/t5262.scala @@ -6,21 +6,21 @@ object Test { - + def serializationDeserialization(obj : Any) { val bos = new java.io.ByteArrayOutputStream() val out = new java.io.ObjectOutputStream(bos) out.writeObject(obj) - + val arr = bos.toByteArray() val in = new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(arr)) val o = in.readObject() println(o) } - + def main(args : Array[String]) { serializationDeserialization(List(1,2,3,4)) serializationDeserialization(List(1,2,null,4)) } - + } diff --git a/test/files/run/t5277_1.scala b/test/files/run/t5277_1.scala index a2d546579d..65232967c2 100644 --- a/test/files/run/t5277_1.scala +++ b/test/files/run/t5277_1.scala @@ -1,6 +1,7 @@ import scala.reflect.runtime.universe._ import scala.tools.reflect.Eval +import scala.language.{ implicitConversions, postfixOps } object Test extends App { reify { def fact(n: Int): BigInt = @@ -12,4 +13,4 @@ object Test extends App { println("10! = " + (10!)) }.eval -}
\ No newline at end of file +} diff --git a/test/files/run/t5284b.check b/test/files/run/t5284b.check index 98d9bcb75a..71426ad0b7 100644 --- a/test/files/run/t5284b.check +++ b/test/files/run/t5284b.check @@ -1 +1,4 @@ +t5284b.scala:27: warning: type S is unused or used in non-specializable positions. + def bar[@specialized(Int) W <: T, @specialized(Int) S](w: W) = id(w) + ^ 17 diff --git a/test/files/run/t5284b.scala b/test/files/run/t5284b.scala index a9282a895f..0da7972490 100644 --- a/test/files/run/t5284b.scala +++ b/test/files/run/t5284b.scala @@ -23,6 +23,6 @@ object Foo { class Foo[@specialized(Int) T] { val id: T => T = x => x - + def bar[@specialized(Int) W <: T, @specialized(Int) S](w: W) = id(w) } diff --git a/test/files/run/t5284c.check b/test/files/run/t5284c.check index 00750edc07..cf578ad102 100644 --- a/test/files/run/t5284c.check +++ b/test/files/run/t5284c.check @@ -1 +1,4 @@ +t5284c.scala:29: warning: type W is unused or used in non-specializable positions. + def bar[@specialized(Int) W <: T](ws: List[W]) = len(ws) + ^ 3 diff --git a/test/files/run/t5284c.scala b/test/files/run/t5284c.scala index 383b84c2cc..dec743fb94 100644 --- a/test/files/run/t5284c.scala +++ b/test/files/run/t5284c.scala @@ -25,6 +25,6 @@ object Foo { class Foo[@specialized(Int) T] { val len: List[T] => Int = xs => xs.length - + def bar[@specialized(Int) W <: T](ws: List[W]) = len(ws) } diff --git a/test/pending/run/t5293-map.scala b/test/files/run/t5293-map.scala index 2707aed07e..ad1bbcfe30 100644 --- a/test/pending/run/t5293-map.scala +++ b/test/files/run/t5293-map.scala @@ -6,7 +6,7 @@ import scala.collection.JavaConverters._ object Test extends App { - + def bench(label: String)(body: => Unit): Long = { val start = System.nanoTime @@ -15,14 +15,14 @@ object Test extends App { val end = System.nanoTime //println("%s: %s ms".format(label, (end - start) / 1000.0 / 1000.0)) - + end - start } - + def benchJava(values: java.util.Map[Int, Int]) = { bench("Java Map") { val m = new java.util.HashMap[Int, Int] - + m.putAll(values) } } @@ -30,33 +30,33 @@ object Test extends App { def benchScala(values: Iterable[(Int, Int)]) = { bench("Scala Map") { val m = new scala.collection.mutable.HashMap[Int, Int] - + m ++= values } } - + def benchScalaSorted(values: Iterable[(Int, Int)]) = { bench("Scala Map sorted") { val m = new scala.collection.mutable.HashMap[Int, Int] - + m ++= values.toArray.sorted } } - + def benchScalaPar(values: Iterable[(Int, Int)]) = { bench("Scala ParMap") { val m = new scala.collection.parallel.mutable.ParHashMap[Int, Int] map { x => x } - + m ++= values } } - + val total = 50000 val values = (0 until total) zip (0 until total) val map = scala.collection.mutable.HashMap.empty[Int, Int] - + map ++= values - + // warmup for (x <- 0 until 5) { benchJava(map.asJava) @@ -66,15 +66,15 @@ object Test extends App { benchScala(map) benchScalaPar(map) } - + val javamap = benchJava(map.asJava) val scalamap = benchScala(map) val scalaparmap = benchScalaPar(map) - + // println(javamap) // println(scalamap) // println(scalaparmap) - + assert(scalamap < (javamap * 10), "scalamap: " + scalamap + " vs. javamap: " + javamap) assert(scalaparmap < (javamap * 10), "scalaparmap: " + scalaparmap + " vs. javamap: " + javamap) } diff --git a/test/pending/run/t5293.scala b/test/files/run/t5293.scala index 01ead45d2a..c42c967b42 100644 --- a/test/pending/run/t5293.scala +++ b/test/files/run/t5293.scala @@ -6,7 +6,7 @@ import scala.collection.JavaConverters._ object Test extends App { - + def bench(label: String)(body: => Unit): Long = { val start = System.nanoTime @@ -15,14 +15,14 @@ object Test extends App { val end = System.nanoTime //println("%s: %s ms".format(label, (end - start) / 1000.0 / 1000.0)) - + end - start } - + def benchJava(values: java.util.Collection[Int]) = { bench("Java Set") { val set = new java.util.HashSet[Int] - + set.addAll(values) } } @@ -30,32 +30,32 @@ object Test extends App { def benchScala(values: Iterable[Int]) = { bench("Scala Set") { val set = new scala.collection.mutable.HashSet[Int] - + set ++= values } } - + def benchScalaSorted(values: Iterable[Int]) = { bench("Scala Set sorted") { val set = new scala.collection.mutable.HashSet[Int] - + set ++= values.toArray.sorted } } - + def benchScalaPar(values: Iterable[Int]) = { bench("Scala ParSet") { val set = new scala.collection.parallel.mutable.ParHashSet[Int] map { x => x } - + set ++= values } } - + val values = 0 until 50000 val set = scala.collection.mutable.HashSet.empty[Int] - + set ++= values - + // warmup for (x <- 0 until 5) { benchJava(set.asJava) @@ -65,11 +65,11 @@ object Test extends App { benchScala(set) benchScalaPar(set) } - + val javaset = benchJava(set.asJava) val scalaset = benchScala(set) val scalaparset = benchScalaPar(set) - + assert(scalaset < (javaset * 8), "scalaset: " + scalaset + " vs. javaset: " + javaset) assert(scalaparset < (javaset * 8), "scalaparset: " + scalaparset + " vs. javaset: " + javaset) } diff --git a/test/files/run/t5300.scala b/test/files/run/t5300.scala index 073b29604a..0f1c807177 100644 --- a/test/files/run/t5300.scala +++ b/test/files/run/t5300.scala @@ -1,6 +1,6 @@ object Test { val pf: PartialFunction[Any, Unit] = { case _ => () } - + def main(args: Array[String]): Unit = { pf orElse pf } diff --git a/test/files/run/t5313.scala b/test/files/run/t5313.scala index 7da8726a1f..0d7168fa89 100644 --- a/test/files/run/t5313.scala +++ b/test/files/run/t5313.scala @@ -1,13 +1,13 @@ -import scala.tools.partest.IcodeTest +import scala.tools.partest.IcodeComparison -object Test extends IcodeTest { +object Test extends IcodeComparison { override def printIcodeAfterPhase = "dce" - override def extraSettings: String = super.extraSettings + " -optimize" + override def extraSettings: String = super.extraSettings + " -optimize" override def code = """class Foo { - def randomBoolean = util.Random.nextInt % 2 == 0 + def randomBoolean = scala.util.Random.nextInt % 2 == 0 def bar = { var kept1 = new Object val result = new java.lang.ref.WeakReference(kept1) @@ -18,11 +18,11 @@ object Test extends IcodeTest { val erased3 = erased2 // and this var erased4 = erased2 // and this val erased5 = erased4 // and this - var kept2: Object = new Object // ultimately can't be eliminated + var kept2: Object = new Object // ultimately can't be eliminated while(randomBoolean) { val kept3 = kept2 kept2 = null // this can't, because it clobbers kept2, which is used - erased4 = null // safe to eliminate + erased4 = null // safe to eliminate println(kept3) } var kept4 = new Object // have to keep, it's used @@ -48,7 +48,7 @@ object Test extends IcodeTest { override def show() { val storeLocal = "STORE_LOCAL" - val lines1 = collectIcode("") filter (_ contains storeLocal) map (x => x.drop(x.indexOf(storeLocal))) + val lines1 = collectIcode() filter (_ contains storeLocal) map (x => x.drop(x.indexOf(storeLocal))) println(lines1 mkString "\n") } } diff --git a/test/files/run/t5356.scala b/test/files/run/t5356.scala index ec17e036ad..dabb9ef855 100644 --- a/test/files/run/t5356.scala +++ b/test/files/run/t5356.scala @@ -1,3 +1,5 @@ + +import scala.language.{ reflectiveCalls } object Test { def f(x: Any { def toInt: Int }) = println(x.toInt + " " + x.getClass.getName) diff --git a/test/files/run/t5375.check b/test/files/run/t5375.check index 7d3002ffda..b1a57eeeec 100644 --- a/test/files/run/t5375.check +++ b/test/files/run/t5375.check @@ -1 +1 @@ -Composite throwable
\ No newline at end of file +Runtime exception diff --git a/test/files/run/t5375.scala b/test/files/run/t5375.scala index e4b329deae..826ecd841e 100644 --- a/test/files/run/t5375.scala +++ b/test/files/run/t5375.scala @@ -1,19 +1,8 @@ - - - -import collection.parallel.CompositeThrowable - - - -object Test { - - def main(args: Array[String]) { - val foos = (1 to 1000) toSeq; - try { - foos.par.map(i => if (i % 37 == 0) sys.error("i div 37") else i) - } catch { - case CompositeThrowable(thr) => println("Composite throwable") - } +object Test extends App { + val foos = (1 to 1000).toSeq + try + foos.par.map(i => if (i % 37 == 0) sys.error("i div 37") else i) + catch { + case ex: RuntimeException => println("Runtime exception") } - } diff --git a/test/files/run/t5380.check b/test/files/run/t5380.check new file mode 100644 index 0000000000..731a798301 --- /dev/null +++ b/test/files/run/t5380.check @@ -0,0 +1,9 @@ +t5380.scala:3: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + val f = () => return try { 1 } catch { case _: Throwable => 0 } + ^ +t5380.scala:3: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + val f = () => return try { 1 } catch { case _: Throwable => 0 } + ^ +t5380.scala:3: warning: enclosing method main has result type Unit: return value discarded + val f = () => return try { 1 } catch { case _: Throwable => 0 } + ^ diff --git a/test/files/run/t5380.scala b/test/files/run/t5380.scala index 6083161a9b..66d12a0ca6 100644 --- a/test/files/run/t5380.scala +++ b/test/files/run/t5380.scala @@ -1,6 +1,6 @@ object Test { def main(args: Array[String]) { - val f = () => return try { 1 } catch { case _ => 0 } + val f = () => return try { 1 } catch { case _: Throwable => 0 } f() } } diff --git a/test/pending/run/t5418.check b/test/files/run/t5418.check index e69de29bb2..e69de29bb2 100644 --- a/test/pending/run/t5418.check +++ b/test/files/run/t5418.check diff --git a/test/pending/run/t5418.scala b/test/files/run/t5418.scala index e3cb20cf82..e3cb20cf82 100644 --- a/test/pending/run/t5418.scala +++ b/test/files/run/t5418.scala diff --git a/test/files/run/t5418b.check b/test/files/run/t5418b.check index 48d82a2aae..f036a4be84 100644 --- a/test/files/run/t5418b.check +++ b/test/files/run/t5418b.check @@ -1,2 +1,2 @@ new Object().getClass() -TypeRef(ThisType(java.lang), java.lang.Class, List(TypeRef(NoPrefix, newTypeName("?0"), List()))) +TypeRef(ThisType(java.lang), java.lang.Class, List(TypeRef(NoPrefix, TypeName("?0"), List()))) diff --git a/test/files/run/t5428.scala b/test/files/run/t5428.scala index 106bb7fc31..44003e06ba 100644 --- a/test/files/run/t5428.scala +++ b/test/files/run/t5428.scala @@ -11,19 +11,19 @@ class A extends StackProxy[Int] { object Test { - + def main(args: Array[String]) { val a = new A - + a push 3 a push 4 a push 5 - + a.push(6, 7, 8) - + println(a) - - a pop + + a.pop } - + } diff --git a/test/files/run/t5488-fn.scala b/test/files/run/t5488-fn.scala index d17bcf90a5..e6efe176c7 100644 --- a/test/files/run/t5488-fn.scala +++ b/test/files/run/t5488-fn.scala @@ -4,7 +4,7 @@ class C[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B, @specialized(I object Test { def main(args:Array[String]) { def show(x: Any) = println(x.getClass.getName) - + show(new B((x: Int) => 1)) show(new B((x: Int) => "abc")) show(new B((x: Int) => ())) diff --git a/test/files/run/t5488.scala b/test/files/run/t5488.scala index 7bab0cdc3c..f93cf29060 100644 --- a/test/files/run/t5488.scala +++ b/test/files/run/t5488.scala @@ -5,15 +5,15 @@ class C0[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B, @specialized( object Test { def main(args:Array[String]) { def show(x: Any) = println(x.getClass.getName) - + show(new A0[Int]()) show(new A0[AnyRef]()) - + show(new B0[Int, Int]()) show(new B0[Int, AnyRef]()) show(new B0[AnyRef, Int]()) show(new B0[AnyRef, AnyRef]()) - + show(new C0[Int, Int, Int]()) show(new C0[Int, Int, AnyRef]()) show(new C0[Int, AnyRef, Int]()) diff --git a/test/files/run/t5500b.scala b/test/files/run/t5500b.scala index 32de858e7b..9a49624fde 100644 --- a/test/files/run/t5500b.scala +++ b/test/files/run/t5500b.scala @@ -26,7 +26,7 @@ object Test { println(new C1A[Double, Int].getClass.getName) println(new C1A[Double, Double].getClass.getName) println(new C1A[Double, String].getClass.getName) - + println(new C1B[String, Int]("abc").getClass.getName) println(new C1B[String, Double]("abc").getClass.getName) println(new C1B[String, String]("abc").getClass.getName) @@ -36,7 +36,7 @@ object Test { println(new C1B[Double, Int](1d).getClass.getName) println(new C1B[Double, Double](1d).getClass.getName) println(new C1B[Double, String](1d).getClass.getName) - + println(new C1C("abc", 123).getClass.getName) println(new C1C("abc", 123).getClass.getName) println(new C1C("a", 1d).getClass.getName) diff --git a/test/files/run/t5514.check b/test/files/run/t5514.check deleted file mode 100644 index c68f7c9029..0000000000 --- a/test/files/run/t5514.check +++ /dev/null @@ -1,19 +0,0 @@ -constructed reader: 10 -constructed reader: 9 -constructed reader: 8 -constructed reader: 7 -constructed reader: 6 -constructed reader: 5 -constructed reader: 4 -constructed reader: 3 -constructed reader: 2 -constructed reader: 1 -constructed reader: 0 -[0.0] parsed: List(s10, s9, s8, s7, s6, s5, s4, s3, s2, s1) -constructed reader: 10 -constructed reader: 9 -constructed reader: 8 -constructed reader: 7 -constructed reader: 6 -constructed reader: 5 -[0.0] parsed: List(s10, s9, s8, s7, s6)
\ No newline at end of file diff --git a/test/files/run/t5514.scala b/test/files/run/t5514.scala deleted file mode 100644 index efd5ba6cb9..0000000000 --- a/test/files/run/t5514.scala +++ /dev/null @@ -1,35 +0,0 @@ - - - -import scala.io.Source -import scala.util.parsing.combinator.Parsers -import scala.util.parsing.input.Reader -import scala.util.parsing.input.Position - - - -class DemoReader(n: Int) extends Reader[String] { - def atEnd = n == 0 - def first = if (n >= 0) "s" + n else throw new IllegalArgumentException("No more input.") - def rest = new DemoReader(n - 1) - def pos = new Position { - def line = 0 - def column = 0 - def lineContents = first - } - println("constructed reader: " + n) -} - - -object Test extends App with Parsers { - type Elem = String - def startsWith(prefix: String) = acceptIf(_ startsWith prefix)("Error: " + _) - - val resrep = startsWith("s").*(new DemoReader(10)) - Console println resrep - - val resrep5 = repN(5, startsWith("s"))(new DemoReader(10)) - Console println resrep5 -} - - diff --git a/test/files/run/t5535.check b/test/files/run/t5535.check index 8da9829b78..a0c87a47f4 100644 --- a/test/files/run/t5535.check +++ b/test/files/run/t5535.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> def h()(i: Int) = 1 + i h: ()(i: Int)Int @@ -16,5 +14,3 @@ scala> println(f(10)) 11 scala> - -scala> diff --git a/test/files/run/t5537.check b/test/files/run/t5537.check index 68c3ebf2e2..b9d521f301 100644 --- a/test/files/run/t5537.check +++ b/test/files/run/t5537.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> List[Predef.type]() res0: List[scala.Predef.type] = List() @@ -16,5 +14,3 @@ scala> List[Set.type]() res3: List[Set.type] = List() scala> - -scala> diff --git a/test/files/run/t5568.flags b/test/files/run/t5568.flags new file mode 100644 index 0000000000..ad51758c39 --- /dev/null +++ b/test/files/run/t5568.flags @@ -0,0 +1 @@ +-nowarn diff --git a/test/files/run/t5577.scala b/test/files/run/t5577.scala index b5d6d8c5b6..650b3c2c69 100644 --- a/test/files/run/t5577.scala +++ b/test/files/run/t5577.scala @@ -6,22 +6,22 @@ import collection._ object Test { - + class AlarmingBuffer[T] extends mutable.ArrayBuffer[T] { override def sizeHint(x: Int) { println("Received a size hint: " + x) super.sizeHint(x) } } - + def main(args: Array[String]) { val iteratorBuilder = (new AlarmingBuffer[Int]) mapResult { res => res.iterator } - + iteratorBuilder.sizeHint(10) iteratorBuilder ++= (0 until 10) iteratorBuilder.result.foreach(println) } - + } diff --git a/test/files/run/t5583.check b/test/files/run/t5583.check index 39b969fbe7..af96405bdd 100644 --- a/test/files/run/t5583.check +++ b/test/files/run/t5583.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> var s = 0 s: Int = 0 @@ -16,5 +14,3 @@ scala> println(s) 165 scala> - -scala> diff --git a/test/files/run/t5590.scala b/test/files/run/t5590.scala index 9c806e0b7d..baf0503a04 100644 --- a/test/files/run/t5590.scala +++ b/test/files/run/t5590.scala @@ -7,25 +7,25 @@ import collection._ object Test { - + def check(obj: AnyRef) { println(obj) - + val bos = new ByteArrayOutputStream() val out = new ObjectOutputStream(bos) out.writeObject(obj) val arr = bos.toByteArray() val in = new ObjectInputStream(new ByteArrayInputStream(arr)) val deser = in.readObject() - + println(deser) } - + def main(args: Array[String]) { val lhm = mutable.LinkedHashMap("a" -> "a", "b" -> "b", "c" -> "c") val lhs = mutable.LinkedHashSet("a", "b", "c", "d", "e") check(lhm) check(lhs) } - + } diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check index 3f19a0a4b1..188f39ff82 100644 --- a/test/files/run/t5603.check +++ b/test/files/run/t5603.check @@ -12,7 +12,7 @@ [95:101]<paramaccessor> private[this] val i: [98:101]Int = _; <119:139>def <init>([95]i: [98]Int) = <119:139>{ <119:139>val nameElse = <134:139>"Bob"; - [94][94][94]super.<init>(); + [NoPosition][NoPosition][NoPosition]super.<init>(); [94]() }; [168:184]val name = [179:184]"avc"; @@ -20,7 +20,7 @@ }; [215:241]object Test extends [227:241][235:238]App { [227]def <init>() = [227]{ - [227][227][227]super.<init>(); + [NoPosition][NoPosition][NoPosition]super.<init>(); [227]() }; [NoPosition]<empty> diff --git a/test/files/run/t5603.scala b/test/files/run/t5603.scala index 60dfd01fee..77c2775cc3 100644 --- a/test/files/run/t5603.scala +++ b/test/files/run/t5603.scala @@ -1,7 +1,7 @@ import scala.tools.partest._ import java.io._ import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser +import scala.tools.cmd.CommandLineParser import scala.tools.nsc.{Global, Settings, CompilerCommand} import scala.tools.nsc.reporters.ConsoleReporter @@ -36,7 +36,8 @@ object Test extends DirectTest { val settings = new Settings() settings.Xprintpos.value = true + settings.Yrangepos.value = true val command = new CompilerCommand((CommandLineParser tokenize extraSettings) ++ args.toList, settings) - new Global(command.settings, new ConsoleReporter(settings)) with interactive.RangePositions + Global(command.settings, new ConsoleReporter(settings)) } } diff --git a/test/files/run/t5610.scala b/test/files/run/t5610.scala index f62b2df6b4..82dabcc59f 100644 --- a/test/files/run/t5610.scala +++ b/test/files/run/t5610.scala @@ -20,7 +20,7 @@ object Test { val f: (String, Int*) => Unit = m(2, 3) f("", 5, 6) } - + def foo(s: => String)(dummy: Int) = () => println(s) def m(a: Int*)(z: String, b: Int*) { diff --git a/test/pending/run/t5610a.check b/test/files/run/t5610a.check index 2aa46b3b91..2aa46b3b91 100644 --- a/test/pending/run/t5610a.check +++ b/test/files/run/t5610a.check diff --git a/test/pending/run/t5610a.scala b/test/files/run/t5610a.scala index f20b295762..f20b295762 100644 --- a/test/pending/run/t5610a.scala +++ b/test/files/run/t5610a.scala diff --git a/test/files/run/t5629.scala b/test/files/run/t5629.scala index 69feddd3a5..5b91007f7e 100644 --- a/test/files/run/t5629.scala +++ b/test/files/run/t5629.scala @@ -27,10 +27,10 @@ class AnyChild extends Parent[Any] { object Test { - + def main(args: Array[String]) { new IntChild().foo(33) new AnyChild().foo(33) } - + } diff --git a/test/files/run/t5629b.scala b/test/files/run/t5629b.scala index 6c908081b9..9ff29c8d89 100644 --- a/test/files/run/t5629b.scala +++ b/test/files/run/t5629b.scala @@ -4,7 +4,7 @@ object Test extends App { - + trait MyPF[@specialized(Int) -A] extends (A => Unit) { def isDefinedAt(x: A): Boolean def applyOrElse[A1 <: A](x: A1, default: A1 => Unit): Unit = { @@ -12,30 +12,30 @@ object Test extends App { if (isDefinedAt(x)) apply(x) else default(x) } } - + trait MySmartPF[@specialized(Int) -A] extends MyPF[A] { def apply(x: A): Unit = { println("MySmartPF.apply entered...") applyOrElse(x, { _: Any => throw new MatchError }) } } - + type T = Int //type T = Any - + def newPF(test: T): MyPF[T] = new MySmartPF[T] { def isDefinedAt(x: T): Boolean = x != test override def applyOrElse[A1 <: T](x: A1, default: A1 => Unit): Unit = { println("newPF.applyOrElse entered...") - if (x != test) { println("ok"); () } else { println("default"); default(x) } + if (x != test) { println("ok"); () } else { println("default"); default(x) } } } - + val pf = newPF(1) println("=== pf(1):") - try { pf(1) } catch { case x => println(x) } + try { pf(1) } catch { case x: Throwable => println(x) } println("=== pf(42):") pf(42) println("=== done") - + } diff --git a/test/files/run/t5655.check b/test/files/run/t5655.check index 43ebd50e7a..06c6b32599 100644 --- a/test/files/run/t5655.check +++ b/test/files/run/t5655.check @@ -1,10 +1,8 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> object x { def x={} } -defined module x +defined object x scala> import x._ import x._ @@ -26,5 +24,3 @@ and import x ^ scala> - -scala> diff --git a/test/files/run/t5656.scala b/test/files/run/t5656.scala index f5ea147a4e..5eb1df51af 100644 --- a/test/files/run/t5656.scala +++ b/test/files/run/t5656.scala @@ -3,9 +3,9 @@ object Test { - + def main(args: Array[String]) { println(Seq(List('1', '2', '3'), List('a', 'b', 'c')).view.addString(new StringBuilder, "_")) } - + } diff --git a/test/files/run/t5676.scala b/test/files/run/t5676.scala index b643c300ce..0c920e4a9d 100644 --- a/test/files/run/t5676.scala +++ b/test/files/run/t5676.scala @@ -13,12 +13,12 @@ class Baz[S] extends Foo[S] { } object Test { - + def main(a: Array[String]) { val b = new Baz[Any] println(b.A.foo()) println(Modifier.isFinal(classOf[Baz[Any]].getModifiers())) println(Modifier.isFinal(Test.getClass.getModifiers())) } - + } diff --git a/test/files/run/t5699.scala b/test/files/run/t5699.scala index 5cef67e3b1..ec3b1d26b4 100755 --- a/test/files/run/t5699.scala +++ b/test/files/run/t5699.scala @@ -1,5 +1,5 @@ import scala.tools.partest.DirectTest -import scala.tools.nsc.util.BatchSourceFile +import scala.reflect.internal.util.BatchSourceFile object Test extends DirectTest { // Java code diff --git a/test/files/run/t5717.scala b/test/files/run/t5717.scala new file mode 100755 index 0000000000..a0997f5a49 --- /dev/null +++ b/test/files/run/t5717.scala @@ -0,0 +1,21 @@ +import scala.tools.partest._ +import java.io.File + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + // TODO + // Don't assume output is on physical disk + // Let the compiler tell us output dir + // val sc = newCompiler("-cp", classpath, "-d", testOutput.path) + // val out = sc.settings.outputDirs.getSingleOutput.get + def show(): Unit = { + // Don't crash when we find a file 'a' where package 'a' should go. + scala.reflect.io.File(testOutput.path + "/a").writeAll("a") + compileCode("package a { class B }") + } +} diff --git a/test/files/run/t5753_1/Test_2.scala b/test/files/run/t5753_1/Test_2.scala index a2777638bc..864d356fdb 100644 --- a/test/files/run/t5753_1/Test_2.scala +++ b/test/files/run/t5753_1/Test_2.scala @@ -1,4 +1,4 @@ -object Test extends App { +object Test extends App { import Macros._ println(foo(42)) }
\ No newline at end of file diff --git a/test/files/run/t5753_2/Impls_Macros_1.scala b/test/files/run/t5753_2/Impls_Macros_1.scala index e23c0b938b..41d584d0ac 100644 --- a/test/files/run/t5753_2/Impls_Macros_1.scala +++ b/test/files/run/t5753_2/Impls_Macros_1.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.{Context => Ctx} trait Macro_T { - def foo[T](c: Ctx)(s: c.Expr[T]) = s + def foo[T](c: Ctx)(s: c.Expr[T]) = s } object Macros { diff --git a/test/files/run/t5753_2/Test_2.scala b/test/files/run/t5753_2/Test_2.scala index a2777638bc..864d356fdb 100644 --- a/test/files/run/t5753_2/Test_2.scala +++ b/test/files/run/t5753_2/Test_2.scala @@ -1,4 +1,4 @@ -object Test extends App { +object Test extends App { import Macros._ println(foo(42)) }
\ No newline at end of file diff --git a/test/files/run/t576.scala b/test/files/run/t576.scala index 756a241572..5c8c9a90cb 100644 --- a/test/files/run/t576.scala +++ b/test/files/run/t576.scala @@ -1,3 +1,5 @@ +import scala.language.reflectiveCalls + class A { override def equals(other: Any) = other match { case _: this.type => true diff --git a/test/files/run/t5789.check b/test/files/run/t5789.check index ea8d4966b1..bcb2382559 100644 --- a/test/files/run/t5789.check +++ b/test/files/run/t5789.check @@ -1,14 +1,10 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - -scala> val n = 2 +scala> val n = 2 n: Int = 2 scala> () => n res0: () => Int = <function0> scala> - -scala> diff --git a/test/files/run/t5804.scala b/test/files/run/t5804.scala index b96a736035..b6a8940c1f 100644 --- a/test/files/run/t5804.scala +++ b/test/files/run/t5804.scala @@ -4,29 +4,29 @@ import collection.mutable._ object Test { - + def main(args: Array[String]) { class CustomHashMap extends HashMap[Int, Int] { override def initialSize = 65 - + println(table.length) } - + new CustomHashMap new HashMap { println(table.length) } - + class CustomHashSet extends HashSet[Int] { override def initialSize = 96 - + println(table.length) } - + new CustomHashSet new HashSet { println(table.length) } } - + } diff --git a/test/files/run/t5843.check b/test/files/run/t5843.check deleted file mode 100644 index 2bf97f4cdb..0000000000 --- a/test/files/run/t5843.check +++ /dev/null @@ -1,9 +0,0 @@ - foo="1" - bar="2" foo="1" -null - bar="2" - foo="1" - bar="2" - foo="1" - bar="2" foo="1" - bar="2" foo="1" diff --git a/test/files/run/t5843.scala b/test/files/run/t5843.scala deleted file mode 100644 index 43d588c7b7..0000000000 --- a/test/files/run/t5843.scala +++ /dev/null @@ -1,15 +0,0 @@ -object Test extends App { - val foo = scala.xml.Attribute(null, "foo", "1", scala.xml.Null) - val bar = scala.xml.Attribute(null, "bar", "2", foo) - println(foo) - println(bar) - println(scala.xml.TopScope.getURI(foo.pre)) - println(bar remove "foo") - println(bar remove "bar") - println(bar remove (null, scala.xml.TopScope, "foo")) - println(bar remove (null, scala.xml.TopScope, "bar")) - - val ns = scala.xml.NamespaceBinding(null, "uri", scala.xml.TopScope) - println(bar remove (null, ns, "foo")) - println(bar remove (null, ns, "bar")) -} diff --git a/test/files/run/t5857.scala b/test/files/run/t5857.scala index bf67bedf54..c82fd88c08 100644 --- a/test/files/run/t5857.scala +++ b/test/files/run/t5857.scala @@ -2,44 +2,44 @@ object Test { - + def time[U](b: =>U): Long = { val start = System.currentTimeMillis b val end = System.currentTimeMillis - + end - start } - + def main(args: Array[String]) { val sz = 1000000000 - + val range = 1 to sz check { assert(range.min == 1, range.min) } check { assert(range.max == sz, range.max) } - + val descending = sz to 1 by -1 check { assert(descending.min == 1) } check { assert(descending.max == sz) } - + val numeric = 1.0 to sz.toDouble by 1 check { assert(numeric.min == 1.0) } check { assert(numeric.max == sz.toDouble) } - + val numdesc = sz.toDouble to 1.0 by -1 check { assert(numdesc.min == 1.0) } check { assert(numdesc.max == sz.toDouble) } } - + def check[U](b: =>U) { val exectime = time { b } - + // whatever it is, it should be less than, say, 250ms // if `max` involves traversal, it takes over 5 seconds on a 3.2GHz i7 CPU //println(exectime) assert(exectime < 250, exectime) } - + } diff --git a/test/files/run/t5867.scala b/test/files/run/t5867.scala index 6a86ac3e6d..f7e9393b7a 100644 --- a/test/files/run/t5867.scala +++ b/test/files/run/t5867.scala @@ -3,12 +3,12 @@ import collection.mutable.UnrolledBuffer object Test { - + def main(args: Array[String]) { val buf = UnrolledBuffer(1 to 50: _*) val dub = buf ++ buf - + println(dub) } - + } diff --git a/test/files/run/t5879.check b/test/files/run/t5879.check index b6cbda35a7..4bdf3f5fcf 100644 --- a/test/files/run/t5879.check +++ b/test/files/run/t5879.check @@ -1,16 +1,8 @@ Map(1 -> 1) 1 -Map(1 -> 1) -1 -(1,1) -Map(1 -> 1) -1 (1,1) Map(1 -> 1) 1 (1,2) Map(1 -> 2) 2 -(1,2) -Map(1 -> 2) -2
\ No newline at end of file diff --git a/test/files/run/t5879.scala b/test/files/run/t5879.scala index e1c07fc4c2..83a583da54 100644 --- a/test/files/run/t5879.scala +++ b/test/files/run/t5879.scala @@ -2,27 +2,23 @@ import collection.immutable.HashMap object Test { - + def main(args: Array[String]) { resolveDefault() resolveFirst() resolveSecond() resolveMany() } - + def resolveDefault() { val a = HashMap(1 -> "1") val b = HashMap(1 -> "2") - + val r = a.merged(b)(null) println(r) println(r(1)) - - val rold = a.merge(b) - println(rold) - println(rold(1)) } - + def resolveFirst() { val a = HashMap(1 -> "1") val b = HashMap(1 -> "2") @@ -30,16 +26,12 @@ object Test { println(a) a } - + val r = a.merged(b) { collision } println(r) println(r(1)) - - val rold = a.merge(b, collision) - println(rold) - println(rold(1)) } - + def resolveSecond() { val a = HashMap(1 -> "1") val b = HashMap(1 -> "2") @@ -47,28 +39,21 @@ object Test { println(b) b } - + val r = a.merged(b) { collision } println(r) println(r(1)) - - val rold = a.merge(b, collision) - println(rold) - println(rold(1)) } - + def resolveMany() { val a = HashMap((0 until 100) zip (0 until 100): _*) val b = HashMap((0 until 100) zip (100 until 200): _*) def collision(a: (Int, Int), b: (Int, Int)) = { (a._1, a._2 + b._2) } - + val r = a.merged(b) { collision } for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v)) - - val rold = a.merge(b, collision) - for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v)) } - + } diff --git a/test/files/run/t5880.scala b/test/files/run/t5880.scala index 4cda599f79..f88df90160 100644 --- a/test/files/run/t5880.scala +++ b/test/files/run/t5880.scala @@ -5,13 +5,13 @@ import scala.collection.JavaConversions._ object Test { - + def main(args:Array[String]) = { val tests = 5000 val jm: java.util.Map[Int, Int] = scala.collection.mutable.Map((0 until tests) zip (0 until tests).reverse: _*) val es = jm.entrySet() val it = es.iterator - + // chi square test val groups = 10 val hits = new Array[Int](groups) @@ -28,7 +28,7 @@ object Test { val diffs = for (i <- 0 until groups) yield (hits(i) - expected) * (hits(i) - expected) diffs.sum.toDouble / expected } - + while (it.hasNext) { val x = it.next() hit(x.##) @@ -37,5 +37,5 @@ object Test { // println(ChiSquare) assert(ChiSquare < 4.0, ChiSquare + " -> " + hits.mkString(", ")) } - + } diff --git a/test/files/run/t5881.scala b/test/files/run/t5881.scala index 01bee29181..04b24b713d 100644 --- a/test/files/run/t5881.scala +++ b/test/files/run/t5881.scala @@ -1,6 +1,7 @@ +import scala.language.existentials import scala.reflect.ClassTag object Test extends App { println(implicitly[ClassTag[List[T forSome {type T <: List[T]}]]]) println(implicitly[ClassTag[List[Any]]]) -}
\ No newline at end of file +} diff --git a/test/files/run/t5903a.check b/test/files/run/t5903a.check new file mode 100644 index 0000000000..ce6efd812d --- /dev/null +++ b/test/files/run/t5903a.check @@ -0,0 +1 @@ +(SomeTree,SomeTree) diff --git a/test/files/run/t5903a.flags b/test/files/run/t5903a.flags new file mode 100644 index 0000000000..02ecab49e7 --- /dev/null +++ b/test/files/run/t5903a.flags @@ -0,0 +1 @@ +-Xlog-reflective-calls
\ No newline at end of file diff --git a/test/files/run/t5903a/Macros_1.scala b/test/files/run/t5903a/Macros_1.scala new file mode 100644 index 0000000000..e82be0fc68 --- /dev/null +++ b/test/files/run/t5903a/Macros_1.scala @@ -0,0 +1,28 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Tree +case object SomeTree extends Tree + +object NewQuasiquotes { + implicit class QuasiquoteInterpolation(c: StringContext) { + object nq { + def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl + } + } +} + +object QuasiquoteMacros { + def unapplyImpl(c: Context)(t: c.Tree) = { + import c.universe._ + q""" + new { + def isEmpty = false + def get = this + def _1 = SomeTree + def _2 = SomeTree + def unapply(t: Tree) = this + }.unapply($t) + """ + } +} diff --git a/test/files/run/t5903a/Test_2.scala b/test/files/run/t5903a/Test_2.scala new file mode 100644 index 0000000000..3a0b68b568 --- /dev/null +++ b/test/files/run/t5903a/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import NewQuasiquotes._ + SomeTree match { + case nq"$x + $y" => println((x, y)) + } +} diff --git a/test/files/run/t5903b.check b/test/files/run/t5903b.check new file mode 100644 index 0000000000..75891bc672 --- /dev/null +++ b/test/files/run/t5903b.check @@ -0,0 +1 @@ +oops diff --git a/test/files/run/t5903b.flags b/test/files/run/t5903b.flags new file mode 100644 index 0000000000..02ecab49e7 --- /dev/null +++ b/test/files/run/t5903b.flags @@ -0,0 +1 @@ +-Xlog-reflective-calls
\ No newline at end of file diff --git a/test/files/run/t5903b/Macros_1.scala b/test/files/run/t5903b/Macros_1.scala new file mode 100644 index 0000000000..c0124850b8 --- /dev/null +++ b/test/files/run/t5903b/Macros_1.scala @@ -0,0 +1,25 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Interpolation { + implicit class TestInterpolation(c: StringContext) { + object t { + def unapply[T](x: T) = macro Macros.unapplyImpl[T] + } + } +} + +object Macros { + def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { + import c.universe._ + q""" + new { + def isEmpty = false + def get = this + def _1 = 2 + def unapply(x: Int) = this + override def toString = "oops" + }.unapply($x) + """ + } +} diff --git a/test/files/run/t5903b/Test_2.scala b/test/files/run/t5903b/Test_2.scala new file mode 100644 index 0000000000..0f6f80d327 --- /dev/null +++ b/test/files/run/t5903b/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import Interpolation._ + 2 match { + case t"$x" => println(x) + } +} diff --git a/test/files/run/t6955.check b/test/files/run/t5903c.check index 0cfbf08886..0cfbf08886 100644 --- a/test/files/run/t6955.check +++ b/test/files/run/t5903c.check diff --git a/test/files/run/t5903c.flags b/test/files/run/t5903c.flags new file mode 100644 index 0000000000..02ecab49e7 --- /dev/null +++ b/test/files/run/t5903c.flags @@ -0,0 +1 @@ +-Xlog-reflective-calls
\ No newline at end of file diff --git a/test/files/run/t5903c/Macros_1.scala b/test/files/run/t5903c/Macros_1.scala new file mode 100644 index 0000000000..f8baa2275b --- /dev/null +++ b/test/files/run/t5903c/Macros_1.scala @@ -0,0 +1,23 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Interpolation { + implicit class TestInterpolation(c: StringContext) { + object t { + def unapply[T](x: T) = macro Macros.unapplyImpl[T] + } + } +} + +object Macros { + def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { + import c.universe._ + q""" + new { + def isEmpty = false + def get = 2 + def unapply(x: Int) = this + }.unapply($x) + """ + } +} diff --git a/test/files/run/t5903c/Test_2.scala b/test/files/run/t5903c/Test_2.scala new file mode 100644 index 0000000000..0f6f80d327 --- /dev/null +++ b/test/files/run/t5903c/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import Interpolation._ + 2 match { + case t"$x" => println(x) + } +} diff --git a/test/files/run/t5903d.check b/test/files/run/t5903d.check new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/test/files/run/t5903d.check @@ -0,0 +1 @@ +42 diff --git a/test/files/run/t5903d.flags b/test/files/run/t5903d.flags new file mode 100644 index 0000000000..02ecab49e7 --- /dev/null +++ b/test/files/run/t5903d.flags @@ -0,0 +1 @@ +-Xlog-reflective-calls
\ No newline at end of file diff --git a/test/files/run/t5903d/Macros_1.scala b/test/files/run/t5903d/Macros_1.scala new file mode 100644 index 0000000000..88d714e17b --- /dev/null +++ b/test/files/run/t5903d/Macros_1.scala @@ -0,0 +1,25 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Interpolation { + implicit class TestInterpolation(c: StringContext) { + object t { + def unapply(x: Int) = macro Macros.unapplyImpl + } + } +} + +object Macros { + def unapplyImpl(c: Context)(x: c.Tree) = { + import c.universe._ + q""" + new { + class Match(x: Int) { + def isEmpty = false + def get = x + } + def unapply(x: Int) = new Match(x) + }.unapply($x) + """ + } +} diff --git a/test/files/run/t5903d/Test_2.scala b/test/files/run/t5903d/Test_2.scala new file mode 100644 index 0000000000..95c717a9d8 --- /dev/null +++ b/test/files/run/t5903d/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import Interpolation._ + 42 match { + case t"$x" => println(x) + } +} diff --git a/test/files/run/t5912.scala b/test/files/run/t5912.scala index 7710d04396..9418e946d0 100644 --- a/test/files/run/t5912.scala +++ b/test/files/run/t5912.scala @@ -1,6 +1,7 @@ +import scala.language.existentials 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")) ) -}
\ No newline at end of file +} diff --git a/test/files/run/t5923a/Macros_1.scala b/test/files/run/t5923a/Macros_1.scala index 6d21362c4d..97076eb102 100644 --- a/test/files/run/t5923a/Macros_1.scala +++ b/test/files/run/t5923a/Macros_1.scala @@ -7,8 +7,46 @@ object C { } object Macros { - def impl[T: c.WeakTypeTag](c: Context) = { + def impl[T](c: Context)(ttag: c.WeakTypeTag[T]) = { import c.universe._ - reify(C[T](c.literal(weakTypeOf[T].toString).splice)) + val ttag0 = ttag; + { + // When we're expanding implicitly[C[Nothing]], the type inferencer will see + // that foo[T] returns C[T] and that we request an implicit of type C[Nothing]. + // + // Then the type inferencer will try to match C[T] against C[Nothing] and infer everything it can infer + // from that match, but not more (e.g. if we were returning Iso[T, U] and the type we were looking at was Iso[Foo, L], + // we wouldn't want U to be auto-inferred to Nothing, as it usually happens with normal methods, + // but would rather want it to remain unknown, so that our macro could take a stab at inferring it: + // see the comments in this commit for more information). + // + // Equipped with common sense, in our case of C[T] and C[Nothing] we would expect T to be inferred as Nothing, and then we + // would expect T in the corresponding macro invocation to be Nothing. Unfortunately it is not that simple. + // + // Internally the type inferencer uses Nothing as a dummy value, which stands for "don't know how to + // infer this type parameter". In the Iso example, matching Iso[T, U] against Iso[Foo, L] would result in + // T being inferred as Foo and U being inferred as Nothing (!!). Then the type inferencer will think: + // "Aha! U ended up being Nothing. This means that I failed to infer it, + // therefore the result of my work is: T -> Foo, U -> still unknown". + // + // That's all very good and works very well until Nothing is a genuine result of type inference, + // as in our original example of inferring T in C[T] from C[Nothing]. In that case, the inferencer becomes confused + // and here in the macro implementation we get weakTypeOf[T] equal to some dummy type carrying a type parameter + // instead of Nothing. + // + // This eccentric behavior of the type inferencer is a long-standing problem in scalac, + // so the best one can do for now until it's fixed is to work around, manually converting + // suspicious T's into Nothings. Of course, this means that we would have to approximate, + // because there's no way to know whether having T here stands for a failed attempt to infer Nothing + // or for a failed attempt to infer anything, but at least we're in full control of making the best + // of this sad situation. + implicit def ttag: WeakTypeTag[T] = { + val tpe = ttag0.tpe + val sym = tpe.typeSymbol.asType + if (sym.isParameter && !sym.isSkolem) TypeTag.Nothing.asInstanceOf[TypeTag[T]] + else ttag0 + } + reify(C[T](c.literal(weakTypeOf[T].toString).splice)) + } } }
\ No newline at end of file diff --git a/test/files/run/t5923c.check b/test/files/run/t5923c.check new file mode 100644 index 0000000000..bed7429108 --- /dev/null +++ b/test/files/run/t5923c.check @@ -0,0 +1 @@ +(23,foo,true) diff --git a/test/files/run/t5923c/Macros_1.scala b/test/files/run/t5923c/Macros_1.scala new file mode 100644 index 0000000000..0b7a3399e2 --- /dev/null +++ b/test/files/run/t5923c/Macros_1.scala @@ -0,0 +1,39 @@ +import language.experimental.macros +import scala.reflect.macros.Context + +trait Iso[T, U] { + def to(t : T) : U + // def from(u : U) : T +} + +object Iso { + implicit def materializeIso[T, U]: Iso[T, U] = macro impl[T, U] + def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context): c.Expr[Iso[T, U]] = { + import c.universe._ + import definitions._ + import Flag._ + + val sym = c.weakTypeOf[T].typeSymbol + if (!sym.isClass || !sym.asClass.isCaseClass) c.abort(c.enclosingPosition, s"$sym is not a case class") + val fields = sym.typeSignature.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } + + def mkTpt() = { + val core = Ident(TupleClass(fields.length) orElse UnitClass) + if (fields.length == 0) core + else AppliedTypeTree(core, fields map (f => TypeTree(f.typeSignature))) + } + + def mkFrom() = { + if (fields.length == 0) Literal(Constant(Unit)) + else Apply(Ident(newTermName("Tuple" + fields.length)), fields map (f => Select(Ident(newTermName("f")), newTermName(f.name.toString.trim)))) + } + + val evidenceClass = ClassDef(Modifiers(FINAL), newTypeName("$anon"), List(), Template( + List(AppliedTypeTree(Ident(newTypeName("Iso")), List(Ident(sym), mkTpt()))), + emptyValDef, + List( + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))), + DefDef(Modifiers(), newTermName("to"), List(), List(List(ValDef(Modifiers(PARAM), newTermName("f"), Ident(sym), EmptyTree))), TypeTree(), mkFrom())))) + c.Expr[Iso[T, U]](Block(List(evidenceClass), Apply(Select(New(Ident(newTypeName("$anon"))), nme.CONSTRUCTOR), List()))) + } +} diff --git a/test/files/run/t5923c/Test_2.scala b/test/files/run/t5923c/Test_2.scala new file mode 100644 index 0000000000..a00f4ed7db --- /dev/null +++ b/test/files/run/t5923c/Test_2.scala @@ -0,0 +1,12 @@ +// see the comments for macroExpandApply.onDelayed for an explanation of what's tested here +object Test extends App { + case class Foo(i: Int, s: String, b: Boolean) + def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c) + + { + val equiv = foo(Foo(23, "foo", true)) + def typed[T](t: => T) {} + typed[(Int, String, Boolean)](equiv) + println(equiv) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-b.check b/test/files/run/t5923d.check index e69de29bb2..e69de29bb2 100644 --- a/test/files/run/macro-expand-tparams-bounds-b.check +++ b/test/files/run/t5923d.check diff --git a/test/files/run/t5923d/Macros_1.scala b/test/files/run/t5923d/Macros_1.scala new file mode 100644 index 0000000000..f32d1af704 --- /dev/null +++ b/test/files/run/t5923d/Macros_1.scala @@ -0,0 +1,9 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context + +trait MappedRow +trait RowMapper[T <: MappedRow] +object RowMapper { + implicit def mapper[T <: MappedRow]: RowMapper[T] = macro impl[T] + def impl[T <: MappedRow : c.WeakTypeTag](c: Context) = c.universe.reify(new RowMapper[T]{}) +}
\ No newline at end of file diff --git a/test/files/run/t5923d/Test_2.scala b/test/files/run/t5923d/Test_2.scala new file mode 100644 index 0000000000..6be10227c2 --- /dev/null +++ b/test/files/run/t5923d/Test_2.scala @@ -0,0 +1,7 @@ +class RowA extends MappedRow +class RowB extends MappedRow + +object Test extends App { + implicitly[RowMapper[RowA]] + implicitly[RowMapper[RowB]] +}
\ No newline at end of file diff --git a/test/files/run/t5937.scala b/test/files/run/t5937.scala index e5bf6617af..9ec4ff12d3 100644 --- a/test/files/run/t5937.scala +++ b/test/files/run/t5937.scala @@ -6,7 +6,7 @@ import collection._ object Test extends App { - + val list: List[Int] = (immutable.Vector(1, 2, 3) :+ 4)(breakOut) - + } diff --git a/test/files/run/t5942.scala b/test/files/run/t5942.scala index 44a8be93f6..c90d29e1ca 100644 --- a/test/files/run/t5942.scala +++ b/test/files/run/t5942.scala @@ -5,6 +5,6 @@ import scala.tools.reflect._ object Test extends App { val tb = cm.mkToolBox() tb.parse("def x = {}") - try { tb.parse("def x = {") } catch { case _ => } + try { tb.parse("def x = {") } catch { case _: Throwable => } tb.parse("def x = {}") } diff --git a/test/files/run/t5971.scala b/test/files/run/t5971.scala index dbd9beebb3..bc24255ece 100644 --- a/test/files/run/t5971.scala +++ b/test/files/run/t5971.scala @@ -12,12 +12,12 @@ * Mind blowing, I know. */ object Test { - + def main(args: Array[String]) { println("bar".view.reverse.filter(_ > 'a').mkString(",")) println("bar".view.reverse.take(1).mkString(",")) println("bar".view.reverse.dropWhile(_ > 'a').mkString(",")) println("bar".view.reverse.takeWhile(_ => true).mkString(",")) } - + } diff --git a/test/files/run/t5986.scala b/test/files/run/t5986.scala index 8cf7086f98..b9c21a7b37 100644 --- a/test/files/run/t5986.scala +++ b/test/files/run/t5986.scala @@ -9,22 +9,22 @@ import scala.collection._ * and the element already exists in the set. */ object Test { - + class Foo(val name: String, val n: Int) { override def equals(obj: Any): Boolean = obj match { case other: Foo => name == other.name; case _ => false } override def hashCode = name.## override def toString = "Foo(" + name + ", " + n + ")" } - + implicit val ordering: Ordering[Foo] = Ordering.fromLessThan[Foo] { (a, b) => a.name.compareTo(b.name) < 0 } - + def check[S <: Set[Foo]](set: S) { def output(s: Set[Foo]) = println(s.toList.sorted.mkString(",")) output(set + new Foo("bar", 2)) output(set ++ List(new Foo("bar", 2), new Foo("bar", 3), new Foo("bar", 4))) output(set union Set(new Foo("bar", 2), new Foo("baz", 3), new Foo("bazz", 4))) } - + def main(args: Array[String]) { check(Set(new Foo("bar", 1))) check(immutable.Set(new Foo("bar", 1))) @@ -32,5 +32,5 @@ object Test { check(immutable.SortedSet(new Foo("bar", 1))) check(mutable.SortedSet(new Foo("bar", 1))) } - + } diff --git a/test/files/run/t6011c.check b/test/files/run/t6011c.check new file mode 100644 index 0000000000..088e6fdaae --- /dev/null +++ b/test/files/run/t6011c.check @@ -0,0 +1,3 @@ +t6011c.scala:11: warning: unreachable code + case 1 => 3 // crash + ^ diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 613d25b075..b37bf51d73 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -1,7 +1,7 @@ [[syntax trees at end of lambdalift]] // newSource1.scala package <empty> { class T extends Object { - <paramaccessor> val T$$classParam: Int = _; + <paramaccessor> val classParam: Int = _; def <init>(classParam: Int): T = { T.super.<init>(); () @@ -11,34 +11,34 @@ package <empty> { def foo(methodParam: Int): Function0 = { val methodLocal: Int = 0; { - (new anonymous class $anonfun$foo$1(T.this, methodParam, methodLocal): Function0) + (new <$anon: Function0>(T.this, methodParam, methodLocal): Function0) } }; def bar(barParam: Int): Object = { - @volatile var MethodLocalObject$module: runtime.VolatileObjectRef = new runtime.VolatileObjectRef(null); + @volatile var MethodLocalObject$module: runtime.VolatileObjectRef = scala.runtime.VolatileObjectRef.zero(); T.this.MethodLocalObject$1(barParam, MethodLocalObject$module) }; def tryy(tryyParam: Int): Function0 = { - var tryyLocal: runtime.IntRef = new runtime.IntRef(0); + var tryyLocal: runtime.IntRef = scala.runtime.IntRef.create(0); { - (new anonymous class $anonfun$tryy$1(T.this, tryyParam, tryyLocal): Function0) + (new <$anon: Function0>(T.this, tryyParam, tryyLocal): Function0) } }; @SerialVersionUID(0) final <synthetic> class $anonfun$foo$1 extends runtime.AbstractFunction0$mcI$sp with Serializable { - def <init>($outer: T, methodParam$1: Int, methodLocal$1: Int): anonymous class $anonfun$foo$1 = { + def <init>($outer: T, methodParam$1: Int, methodLocal$1: Int): <$anon: Function0> = { $anonfun$foo$1.super.<init>(); () }; final def apply(): Int = $anonfun$foo$1.this.apply$mcI$sp(); - <specialized> def apply$mcI$sp(): Int = $anonfun$foo$1.this.$outer.T$$classParam.+($anonfun$foo$1.this.$outer.field()).+($anonfun$foo$1.this.methodParam$1).+($anonfun$foo$1.this.methodLocal$1); - <synthetic> <paramaccessor> private[this] val $outer: T = _; - <synthetic> <stable> def T$$anonfun$$$outer(): T = $anonfun$foo$1.this.$outer; - final <bridge> def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); + <specialized> def apply$mcI$sp(): Int = $anonfun$foo$1.this.$outer.classParam.+($anonfun$foo$1.this.$outer.field()).+($anonfun$foo$1.this.methodParam$1).+($anonfun$foo$1.this.methodLocal$1); + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def $outer(): T = $anonfun$foo$1.this.$outer; + final <bridge> <artifact> def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); <synthetic> <paramaccessor> private[this] val methodParam$1: Int = _; <synthetic> <paramaccessor> private[this] val methodLocal$1: Int = _ }; abstract trait MethodLocalTrait$1 extends Object { - <synthetic> <stable> def T$MethodLocalTrait$$$outer(): T + <synthetic> <stable> <artifact> def $outer(): T }; object MethodLocalObject$2 extends Object with T#MethodLocalTrait$1 { def <init>($outer: T, barParam$1: Int): T#MethodLocalObject$2.type = { @@ -46,9 +46,9 @@ package <empty> { MethodLocalObject$2.this.$asInstanceOf[T#MethodLocalTrait$1$class]()./*MethodLocalTrait$1$class*/$init$(barParam$1); () }; - <synthetic> <paramaccessor> private[this] val $outer: T = _; - <synthetic> <stable> def T$MethodLocalObject$$$outer(): T = MethodLocalObject$2.this.$outer; - <synthetic> <stable> def T$MethodLocalTrait$$$outer(): T = MethodLocalObject$2.this.$outer + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer; + <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer }; final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); @@ -61,7 +61,7 @@ package <empty> { scala.this.Predef.print(scala.Int.box(barParam$1)) }; @SerialVersionUID(0) final <synthetic> class $anonfun$tryy$1 extends runtime.AbstractFunction0$mcV$sp with Serializable { - def <init>($outer: T, tryyParam$1: Int, tryyLocal$1: runtime.IntRef): anonymous class $anonfun$tryy$1 = { + def <init>($outer: T, tryyParam$1: Int, tryyLocal$1: runtime.IntRef): <$anon: Function0> = { $anonfun$tryy$1.super.<init>(); () }; @@ -69,9 +69,9 @@ package <empty> { <specialized> def apply$mcV$sp(): Unit = try { $anonfun$tryy$1.this.tryyLocal$1.elem = $anonfun$tryy$1.this.tryyParam$1 } finally (); - <synthetic> <paramaccessor> private[this] val $outer: T = _; - <synthetic> <stable> def T$$anonfun$$$outer(): T = $anonfun$tryy$1.this.$outer; - final <bridge> def apply(): Object = { + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def $outer(): T = $anonfun$tryy$1.this.$outer; + final <bridge> <artifact> def apply(): Object = { $anonfun$tryy$1.this.apply(); scala.runtime.BoxedUnit.UNIT }; diff --git a/test/files/run/t603.scala b/test/files/run/t603.scala index b8825c933b..84a224a40a 100644 --- a/test/files/run/t603.scala +++ b/test/files/run/t603.scala @@ -1,4 +1,6 @@ object forceDelay { + import scala.language.implicitConversions + class Susp[+A](lazyValue: => A) extends Function0[A] { private var func: () => Any = () => lazyValue private var value: Any = null @@ -22,7 +24,7 @@ object forceDelay { object Test { import forceDelay._ - + def main(args: Array[String]) = { val s: Susp[Int] = delay { Console.println("evaluating..."); 3 } Console.println("s = " + s) diff --git a/test/files/run/t6052.scala b/test/files/run/t6052.scala index 385d5390d3..5482cfb293 100644 --- a/test/files/run/t6052.scala +++ b/test/files/run/t6052.scala @@ -8,13 +8,13 @@ object Test extends App { def seqarr(i: Int) = Array[Int]() ++ (0 until i) def pararr(i: Int) = seqarr(i).par - + def check[T](i: Int, f: Int => T) { val gseq = seqarr(i).toSeq.groupBy(f) val gpar = pararr(i).groupBy(f) assert(gseq == gpar, (gseq, gpar)) } - + for (i <- 0 until 20) check(i, _ > 0) for (i <- 0 until 20) check(i, _ % 2) for (i <- 0 until 20) check(i, _ % 4) diff --git a/test/files/run/t6064.scala b/test/files/run/t6064.scala new file mode 100644 index 0000000000..fc184dd92d --- /dev/null +++ b/test/files/run/t6064.scala @@ -0,0 +1,9 @@ +object Test extends App { + assert(Option(42) contains 42) + assert(Some(42) contains 42) + assert(Option(BigInt(42)) contains 42) + assert(Option(42) contains BigInt(42)) + assert(!(None contains 42)) + assert(Some(null) contains null) + assert(!(Option(null) contains null)) +}
\ No newline at end of file diff --git a/test/files/run/t6070.scala b/test/files/run/t6070.scala index b6af48ef21..434949f869 100644 --- a/test/files/run/t6070.scala +++ b/test/files/run/t6070.scala @@ -11,7 +11,7 @@ class StringBomb extends Bomb { def size(that: String): Int = that.length } -class IntBomb extends Bomb { +class IntBomb extends Bomb { type T = Int val x = 10 @@ -22,7 +22,7 @@ case class Mean(var bomb: Bomb) object Test extends App { def foo(x: Mean) = x match { - case Mean(b) => + case Mean(b) => // BUG: b is assumed to be a stable identifier, but it can actually be mutated println(b.size({ mutate(); b.x })) } diff --git a/test/files/run/t6086-repl.check b/test/files/run/t6086-repl.check index 97f20bd66b..115eff5f85 100644 --- a/test/files/run/t6086-repl.check +++ b/test/files/run/t6086-repl.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> case class X(s: String) defined class X diff --git a/test/files/run/t6102.check b/test/files/run/t6102.check index b6fc4c620b..4e8efa7b6d 100644 --- a/test/files/run/t6102.check +++ b/test/files/run/t6102.check @@ -1 +1,31 @@ -hello
\ No newline at end of file +[running phase parser on t6102.scala] +[running phase namer on t6102.scala] +[running phase packageobjects on t6102.scala] +[running phase typer on t6102.scala] +[running phase patmat on t6102.scala] +[running phase superaccessors on t6102.scala] +[running phase extmethods on t6102.scala] +[running phase pickler on t6102.scala] +[running phase refchecks on t6102.scala] +[running phase uncurry on t6102.scala] +[running phase tailcalls on t6102.scala] +[running phase specialize on t6102.scala] +[running phase explicitouter on t6102.scala] +[running phase erasure on t6102.scala] +[running phase posterasure on t6102.scala] +[running phase lazyvals on t6102.scala] +[running phase lambdalift on t6102.scala] +[running phase constructors on t6102.scala] +[running phase flatten on t6102.scala] +[running phase mixin on t6102.scala] +[running phase cleanup on t6102.scala] +[running phase icode on t6102.scala] +#partest -optimise +[running phase inliner on t6102.scala] +[running phase inlinehandlers on t6102.scala] +[running phase closelim on t6102.scala] +[running phase constopt on t6102.scala] +#partest +[running phase dce on t6102.scala] +[running phase jvm on icode] +hello diff --git a/test/files/run/t6102.flags b/test/files/run/t6102.flags index e35535c8ea..726e2a997f 100644 --- a/test/files/run/t6102.flags +++ b/test/files/run/t6102.flags @@ -1 +1 @@ - -Ydead-code +-Ydead-code -Ydebug -Xfatal-warnings diff --git a/test/files/run/t6113.scala b/test/files/run/t6113.scala index 321cae86a3..b77a56029a 100644 --- a/test/files/run/t6113.scala +++ b/test/files/run/t6113.scala @@ -1,6 +1,8 @@ +import scala.language.higherKinds + trait Foo[C[_]] object Test extends App { import scala.reflect.runtime.universe._ println(typeOf[Foo[({type l[X] = (Int, X)})#l]]) -}
\ No newline at end of file +} diff --git a/test/files/run/t6146b.check b/test/files/run/t6146b.check index 49ff70697e..a3b09efcd9 100644 --- a/test/files/run/t6146b.check +++ b/test/files/run/t6146b.check @@ -1,3 +1,7 @@ +t6146b.scala:15: warning: match may not be exhaustive. +It would fail on the following inputs: S2(), S3() + def foo(f: F[Int]) = f match { case X.S1 => } + ^ Type in expressions to have them evaluated. Type :help for more information. @@ -41,7 +45,7 @@ scala> val mt1 = memType(S1, fTpe) mt1: u.Type = O.X.S1.type scala> global.typeDeconstruct.show(mt1) -res0: String = +res0: String = TypeRef( pre = SingleType(pre = ThisType(object O), object X) TypeSymbol(class S1 extends C.this.F[T]) diff --git a/test/files/run/t6150.scala b/test/files/run/t6150.scala index bd8af5d460..f3e83e1549 100644 --- a/test/files/run/t6150.scala +++ b/test/files/run/t6150.scala @@ -1,7 +1,3 @@ - - - - object Test { import collection.{ immutable, mutable, generic } def TheOneTrueCBF = collection.IndexedSeq.ReusableCBF @@ -38,7 +34,3 @@ object Test { check(iv.:+(4)(cbf3)) } } - - - - diff --git a/test/files/run/t6168/Context.java b/test/files/run/t6168/Context.java new file mode 100644 index 0000000000..d0fb5d2543 --- /dev/null +++ b/test/files/run/t6168/Context.java @@ -0,0 +1,34 @@ +public class Context<ParentType> { + private ParentType parent; + + public Context() {} + + public ParentType getParent() { + return parent; + } + + public void setParent(ParentType parent) { + this.parent = parent; + } + + public Field<Integer> intField() { + return new Field<Integer>() { + @Override + public Integer get() { + return 0; + } + + @Override + public ParentType set(Integer t) { + return parent; + } + }; + } + + public abstract class Field<T> { //Note this is a path dependent type + + public abstract T get(); + + public abstract ParentType set(T t); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168/JavaTest.java b/test/files/run/t6168/JavaTest.java new file mode 100644 index 0000000000..94ae91661d --- /dev/null +++ b/test/files/run/t6168/JavaTest.java @@ -0,0 +1,8 @@ +public class JavaTest { + public static void main(String[] args) { + SomeClass a = new SomeClass(); + SomeClass2 a2 = new SomeClass2(); + SomeClass b = a.f.set(23).f.set(23); + SomeClass2 b2 = a2.f.set(23).f.set(23); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168/SomeClass.java b/test/files/run/t6168/SomeClass.java new file mode 100644 index 0000000000..6f76b829bb --- /dev/null +++ b/test/files/run/t6168/SomeClass.java @@ -0,0 +1,14 @@ +public class SomeClass { + private final Context<SomeClass> context = new Context<SomeClass>(); + { + context.setParent(this); + } + + public final Context<SomeClass>.Field<Integer> f = context.intField(); + + public SomeClass() { + f.set(23).f.set(23); + } +} + + diff --git a/test/files/run/t6168/SomeClass2.java b/test/files/run/t6168/SomeClass2.java new file mode 100644 index 0000000000..b2c7a7540b --- /dev/null +++ b/test/files/run/t6168/SomeClass2.java @@ -0,0 +1,12 @@ +public class SomeClass2 { + private final Context<SomeClass2> context = new Context<SomeClass2>(); + { + context.setParent(this); + } + + public final Context<SomeClass2>.Field<Integer> f = context.intField(); + + public SomeClass2() { + f.set(23).f.set(23); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168/main.scala b/test/files/run/t6168/main.scala new file mode 100644 index 0000000000..c7ad37830b --- /dev/null +++ b/test/files/run/t6168/main.scala @@ -0,0 +1,15 @@ + + +object Test extends App { + JavaTest.main(null) + + var a1 : SomeClass = new SomeClass + var a2 : SomeClass2 = new SomeClass2 + //import language.implicitConversions + //implicit def setParentType2SomeClass(x:Any) = x.asInstanceOf[SomeClass] + //implicit def setParentType2SomeClass2(x:Any) = x.asInstanceOf[SomeClass2] + //var b : SomeClass = a.f.set(23).asInstanceOf[SomeClass].f.set(23).asInstanceOf[SomeClass] + //var b2 : SomeClass2 = a2.f.set(23).asInstanceOf[SomeClass2].f.set(23).asInstanceOf[SomeClass2] + var b1 : SomeClass = a1.f.set(23).f.set(23) + var b2 : SomeClass2 = a2.f.set(23).f.set(23) +} diff --git a/test/files/run/t6168b/Context.java b/test/files/run/t6168b/Context.java new file mode 100644 index 0000000000..b3ea22126f --- /dev/null +++ b/test/files/run/t6168b/Context.java @@ -0,0 +1,34 @@ +public class Context<ParentType> { + private ParentType parent; + + public Context() {} + + public ParentType getParent() { + return parent; + } + + public void setParent(ParentType parent) { + this.parent = parent; + } + + public Field<Integer> intField() { + return new Field<Integer>() { + @Override + public Integer get() { + return 0; + } + + @Override + public ParentType set(Integer t) { + return parent; + } + }; + } + + public static abstract class Field<T> { + + public abstract T get(); + + public abstract Object set(T t); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168b/JavaTest.java b/test/files/run/t6168b/JavaTest.java new file mode 100644 index 0000000000..a09fa0382d --- /dev/null +++ b/test/files/run/t6168b/JavaTest.java @@ -0,0 +1,6 @@ +public class JavaTest { + public static void main(String[] args) { + SomeClass a = new SomeClass(); + Object b = a.f.set(23); + } +}
\ No newline at end of file diff --git a/test/files/run/t6168b/SomeClass.java b/test/files/run/t6168b/SomeClass.java new file mode 100644 index 0000000000..566c55e1c5 --- /dev/null +++ b/test/files/run/t6168b/SomeClass.java @@ -0,0 +1,11 @@ +public class SomeClass { + private final Context<SomeClass> context = new Context<SomeClass>(); + { + context.setParent(this); + } + + public final Context.Field<Integer> f = context.intField(); + +} + + diff --git a/test/files/run/t6168b/main.scala b/test/files/run/t6168b/main.scala new file mode 100644 index 0000000000..187e9fe85e --- /dev/null +++ b/test/files/run/t6168b/main.scala @@ -0,0 +1,8 @@ + + +object Test extends App { + JavaTest.main(null) + + var a1 : SomeClass = new SomeClass + var b1 : Object = a1.f.set(23) +} diff --git a/test/files/run/t6178.scala b/test/files/run/t6178.scala index 0b4cf0bbf5..41e148af91 100644 --- a/test/files/run/t6178.scala +++ b/test/files/run/t6178.scala @@ -2,6 +2,6 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { - val plus = typeOf[java.lang.String].member(newTermName("$plus")).asMethod + val plus = typeOf[java.lang.String].member(TermName("$plus")).asMethod println(cm.reflect("").reflectMethod(plus).apply("2")) }
\ No newline at end of file diff --git a/test/files/run/t6181.scala b/test/files/run/t6181.scala index fb23eaff63..eaa7340178 100644 --- a/test/files/run/t6181.scala +++ b/test/files/run/t6181.scala @@ -3,6 +3,6 @@ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { class C { def test(x: => Int) = println(x) } - val mm = cm.reflect(new C).reflectMethod(typeOf[C].member(newTermName("test")).asMethod) + val mm = cm.reflect(new C).reflectMethod(typeOf[C].member(TermName("test")).asMethod) mm(2) }
\ No newline at end of file diff --git a/test/files/run/t6187.check b/test/files/run/t6187.check index c0ca02923b..621306b2ef 100644 --- a/test/files/run/t6187.check +++ b/test/files/run/t6187.check @@ -12,7 +12,7 @@ scala> def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T] macroImpl: [T](c: scala.reflect.macros.Context)(t: c.Expr[T])(implicit evidence$1: c.WeakTypeTag[T])c.Expr[List[T]] scala> def demo[T](t: T): List[T] = macro macroImpl[T] -demo: [T](t: T)List[T] +defined term macro demo: [T](t: T)List[T] scala> def m[T](t: T): List[List[T]] = demo( List((t,true)) collect { case (x,true) => x } ) diff --git a/test/files/run/t6199-mirror.scala b/test/files/run/t6199-mirror.scala index 772a384542..3fda56bf7c 100644 --- a/test/files/run/t6199-mirror.scala +++ b/test/files/run/t6199-mirror.scala @@ -3,5 +3,5 @@ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { class C { def foo = () } - println(cm.reflect(new C).reflectMethod(typeOf[C].member(newTermName("foo")).asMethod)()) + println(cm.reflect(new C).reflectMethod(typeOf[C].member(TermName("foo")).asMethod)()) }
\ No newline at end of file diff --git a/test/files/run/t6221.check b/test/files/run/t6221.check new file mode 100644 index 0000000000..aa1bdd0e6e --- /dev/null +++ b/test/files/run/t6221.check @@ -0,0 +1 @@ +((x) => x.$percent(2).$eq$eq(0)) diff --git a/test/files/run/t6221/Macros_1.scala b/test/files/run/t6221/Macros_1.scala new file mode 100644 index 0000000000..c9500626d8 --- /dev/null +++ b/test/files/run/t6221/Macros_1.scala @@ -0,0 +1,22 @@ +import language.experimental.macros +import language.implicitConversions +import scala.reflect.macros.Context +import scala.reflect.runtime.universe.Tree + +class ReflectiveClosure[A, B](val tree: Tree, fn: A => B) extends (A => B) { + def apply(x: A) = fn(x) +} + +object ReflectiveClosure { + implicit def reflectClosure[A, B](f: A => B): ReflectiveClosure[A, B] = macro Macros.reflectiveClosureImpl[A, B] +} + +object Macros { + def reflectiveClosureImpl[A, B](c: Context)(f: c.Expr[A => B]): c.Expr[ReflectiveClosure[A, B]] = { + import c.universe._ + val u = treeBuild.mkRuntimeUniverseRef + val m = EmptyTree + val tree = c.Expr[scala.reflect.runtime.universe.Tree](Select(c.reifyTree(u, m, f.tree), newTermName("tree"))) + c.universe.reify(new ReflectiveClosure(tree.splice, f.splice)) + } +} diff --git a/test/files/run/t6221/Test_2.scala b/test/files/run/t6221/Test_2.scala new file mode 100644 index 0000000000..9f6b2280a7 --- /dev/null +++ b/test/files/run/t6221/Test_2.scala @@ -0,0 +1,10 @@ +object Test extends App { + implicit class PimpedList[T](val list: List[T]) { + def query(predicate: ReflectiveClosure[T, Boolean]): List[T] = { + println(predicate.tree) + list filter predicate + } + } + + List(1, 2, 3).query(x => x % 2 == 0) +}
\ No newline at end of file diff --git a/test/files/run/t6223.check b/test/files/run/t6223.check index f83799bab1..4a09d1930f 100644 --- a/test/files/run/t6223.check +++ b/test/files/run/t6223.check @@ -1,4 +1,4 @@ bar bar$mIc$sp bar$mIcI$sp -bar$mcI$sp
\ No newline at end of file +bar$mcI$sp diff --git a/test/files/run/t6246.scala b/test/files/run/t6246.scala index 28765e1adf..2db87aa6d2 100644 --- a/test/files/run/t6246.scala +++ b/test/files/run/t6246.scala @@ -1,5 +1,6 @@ import scala.reflect.{ClassTag, classTag} +@deprecated("Suppress warnings", since="2.11") object Test extends App { def testValueClass(tag: ClassTag[_]) { println(s"runtimeClass = ${tag.runtimeClass}, toString = ${tag.toString}") @@ -23,4 +24,4 @@ object Test extends App { testValueClass(ClassTag.Double) testValueClass(ClassTag.Unit) testValueClass(ClassTag.Boolean) -}
\ No newline at end of file +} diff --git a/test/files/run/t6259.scala b/test/files/run/t6259.scala index 294c95e96b..b2c27df51f 100644 --- a/test/files/run/t6259.scala +++ b/test/files/run/t6259.scala @@ -37,9 +37,9 @@ object Early extends { class DoubleTrouble[X](x: AnyRef)(implicit override val tt: TypeTag[X]) extends A[X] object DoubleOk extends DoubleTrouble[String]({ - // Drops to this.getClass and is an issue - object InnerTrouble extends A[String]; - InnerTrouble + // Drops to this.getClass and is an issue + object InnerTrouble extends A[String]; + InnerTrouble }) object Test extends App { diff --git a/test/files/run/t6273.check b/test/files/run/t6273.check index c1c18daac2..bef0b227d2 100644 --- a/test/files/run/t6273.check +++ b/test/files/run/t6273.check @@ -1,19 +1,15 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> val y = 55 y: Int = 55 scala> val x = s""" y = $y """ -x: String = +x: String = " y = 55 " scala> - -scala> diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check index e940975e44..a032a10de6 100644 --- a/test/files/run/t6288.check +++ b/test/files/run/t6288.check @@ -1,8 +1,8 @@ [[syntax trees at end of patmat]] // newSource1.scala [7]package [7]<empty> { [7]object Case3 extends [13][106]scala.AnyRef { - [13]def <init>(): [13]Case3.type = [13]{ - [13][13][13]Case3.super.<init>(); + [106]def <init>(): [13]Case3.type = [106]{ + [106][106][106]Case3.super.<init>(); [13]() }; [21]def unapply([29]z: [32]<type: [32]scala.Any>): [21]Option[Int] = [56][52][52]scala.Some.apply[[52]Int]([58]-1); @@ -24,8 +24,8 @@ } }; [113]object Case4 extends [119][217]scala.AnyRef { - [119]def <init>(): [119]Case4.type = [119]{ - [119][119][119]Case4.super.<init>(); + [217]def <init>(): [119]Case4.type = [217]{ + [217][217][217]Case4.super.<init>(); [119]() }; [127]def unapplySeq([138]z: [141]<type: [141]scala.Any>): [127]Option[List[Int]] = [167]scala.None; @@ -50,8 +50,8 @@ } }; [224]object Case5 extends [230][312]scala.AnyRef { - [230]def <init>(): [230]Case5.type = [230]{ - [230][230][230]Case5.super.<init>(); + [312]def <init>(): [230]Case5.type = [312]{ + [312][312][312]Case5.super.<init>(); [230]() }; [238]def unapply([246]z: [249]<type: [249]scala.Any>): [238]Boolean = [265]true; @@ -60,7 +60,7 @@ [273]case5()[293]{ [293]<synthetic> val o7: [293]Option[List[Int]] = [293][293]Case4.unapplySeq([293]x1); [293]if ([293]o7.isEmpty.unary_!) - [293]if ([293][293][293][293]o7.get.!=([293]null).&&([293][293][293][293]o7.get.lengthCompare([293]0).==([195]0))) + [293]if ([293][293][293][293]o7.get.!=([293]null).&&([293][293][293][293]o7.get.lengthCompare([293]0).==([293]0))) [304][304]matchEnd4([304]()) else [293][293]case6() diff --git a/test/files/run/t6288b-jump-position.check b/test/files/run/t6288b-jump-position.check index 83ba810958..ece88b18f0 100644 --- a/test/files/run/t6288b-jump-position.check +++ b/test/files/run/t6288b-jump-position.check @@ -65,9 +65,9 @@ object Case3 extends Object { blocks: [1] 1: - 1 THIS(Case3) - 1 CALL_METHOD java.lang.Object.<init> (super()) - 1 RETURN(UNIT) + 12 THIS(Case3) + 12 CALL_METHOD java.lang.Object.<init> (super()) + 12 RETURN(UNIT) } Exception handlers: diff --git a/test/files/run/t6288b-jump-position.scala b/test/files/run/t6288b-jump-position.scala index e22a1ab120..c5f3bbe788 100644 --- a/test/files/run/t6288b-jump-position.scala +++ b/test/files/run/t6288b-jump-position.scala @@ -1,6 +1,6 @@ -import scala.tools.partest.IcodeTest +import scala.tools.partest.IcodeComparison -object Test extends IcodeTest { +object Test extends IcodeComparison { override def code = """object Case3 { // 01 | def unapply(z: Any): Option[Int] = Some(-1) // 02 @@ -15,8 +15,5 @@ object Test extends IcodeTest { | } |}""".stripMargin - override def show() { - val lines1 = collectIcode("") - println(lines1 mkString "\n") - } + override def show() = showIcode() } diff --git a/test/files/run/t6308.check b/test/files/run/t6308.check new file mode 100644 index 0000000000..e2577db72a --- /dev/null +++ b/test/files/run/t6308.check @@ -0,0 +1,16 @@ +- Unspecialized type args +// Specialized +f1 f1$mIc$sp +f2 f2$mIc$sp +f3 f3$mIc$sp +f4 f4$mIc$sp +f5 f5$mIc$sp + +// Unspecialized type args +f4(Boolean) f4 +f4(String) f4 + +// Ideally these would be specialized +todo1 todo1 +todo2 todo2 +todo3 todo3 diff --git a/test/files/run/t6308.scala b/test/files/run/t6308.scala new file mode 100644 index 0000000000..d23cd6e13e --- /dev/null +++ b/test/files/run/t6308.scala @@ -0,0 +1,45 @@ +import scala.{specialized => sp} + +// NOTE: `{ val c = caller; print(""); c }` is used instead of a simple `caller`, +// because we want to prevent tail-call optimization from eliding the stack- +// frames we want to inspect. + +object Test { + def caller = new Exception().getStackTrace()(1).getMethodName + def f1[@sp(Int) A](a: A, b: Any) = { val c = caller; print(""); c } + def f2[@sp(Int) A, B](a: A, b: String) = { val c = caller; print(""); c } + def f3[B, @sp(Int) A](a: A, b: List[B]) = { val c = caller; print(""); c } + def f4[B, @sp(Int) A](a: A, b: List[(A, B)]) = { val c = caller; print(""); c } + + def f5[@sp(Int) A, B <: Object](a: A, b: B) = { val c = caller; print(""); c } + + // `uncurryTreeType` calls a TypeMap on the call to this method and we end up with new + // type parameter symbols, which are not found in `TypeEnv.includes(typeEnv(member), env)` + // in `specSym`. (One of `uncurry`'s tasks is to expand type aliases in signatures.) + type T = Object + def todo1[@sp(Int) A, B <: T](a: A, b: String) = { val c = caller; print(""); c } + def todo2[@sp(Int) A, B <: AnyRef](a: A, b: String) = { val c = caller; print(""); c } + def todo3[B <: List[A], @specialized(Int) A](a: A, b: B) = { val c = caller; print(""); c } + + def main(args: Array[String]) { + val s = "" + val result = + s"""|- Unspecialized type args + |// Specialized + |f1 ${f1(1,"some ref")} + |f2 ${f2(1,"some ref")} + |f3 ${f3(1,List("some ref"))} + |f4 ${f4(1,Nil)} + |f5 ${f5(1,s)} + | + |// Unspecialized type args + |f4(Boolean) ${f4(Boolean,Nil)} + |f4(String) ${f4("",Nil)} + | + |// Ideally these would be specialized + |todo1 ${todo1(1,s)} + |todo2 ${todo2(1,s)} + |todo3 ${todo3(1,List(0))}""".stripMargin + println(result) + } +} diff --git a/test/files/run/t6309.check b/test/files/run/t6309.check new file mode 100644 index 0000000000..7f8f011eb7 --- /dev/null +++ b/test/files/run/t6309.check @@ -0,0 +1 @@ +7 diff --git a/test/files/run/t6309.scala b/test/files/run/t6309.scala new file mode 100644 index 0000000000..7bbca63c2a --- /dev/null +++ b/test/files/run/t6309.scala @@ -0,0 +1,16 @@ +trait A { + def a: Int +} + +object Test { + def f(a: Int) = new { + //private val b = a + private[this] val b = a // crashes, sorry scalac + } with A { + def a = b + } + + def main(args: Array[String]) { + println(f(7).a) + } +} diff --git a/test/files/run/t6320.check b/test/files/run/t6320.check index e56bacd223..013acc1c54 100644 --- a/test/files/run/t6320.check +++ b/test/files/run/t6320.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> import scala.language.dynamics import scala.language.dynamics @@ -13,5 +11,3 @@ scala> new Dyn(Map("foo" -> 10)).foo[Int] res0: Int = 10 scala> - -scala> diff --git a/test/files/run/t6329_repl.check b/test/files/run/t6329_repl.check index 693263a5c2..5049426ab4 100644 --- a/test/files/run/t6329_repl.check +++ b/test/files/run/t6329_repl.check @@ -1,13 +1,35 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> +scala> import scala.reflect.classTag +import scala.reflect.classTag -scala> classManifest[List[_]] +scala> classManifest[scala.List[_]] warning: there were 1 deprecation warning(s); re-run with -deprecation for details -res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[Any] +res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] -scala> scala.reflect.classTag[List[_]] +scala> classTag[scala.List[_]] res1: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List +scala> classManifest[scala.collection.immutable.List[_]] +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +res2: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] + +scala> classTag[scala.collection.immutable.List[_]] +res3: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List + +scala> classManifest[Predef.Set[_]] +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +res4: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] + +scala> classTag[Predef.Set[_]] +res5: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set + +scala> classManifest[scala.collection.immutable.Set[_]] +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +res6: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] + +scala> classTag[scala.collection.immutable.Set[_]] +res7: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set + scala> diff --git a/test/files/run/t6329_repl.scala b/test/files/run/t6329_repl.scala index add6d64962..f210d6512c 100644 --- a/test/files/run/t6329_repl.scala +++ b/test/files/run/t6329_repl.scala @@ -2,7 +2,14 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ - |classManifest[List[_]] - |scala.reflect.classTag[List[_]] - |""".stripMargin + |import scala.reflect.classTag + |classManifest[scala.List[_]] + |classTag[scala.List[_]] + |classManifest[scala.collection.immutable.List[_]] + |classTag[scala.collection.immutable.List[_]] + |classManifest[Predef.Set[_]] + |classTag[Predef.Set[_]] + |classManifest[scala.collection.immutable.Set[_]] + |classTag[scala.collection.immutable.Set[_]] + """.stripMargin } diff --git a/test/files/run/t6329_repl_bug.check b/test/files/run/t6329_repl_bug.check deleted file mode 100644 index 8663184bde..0000000000 --- a/test/files/run/t6329_repl_bug.check +++ /dev/null @@ -1,13 +0,0 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> - -scala> classManifest[List[_]] -warning: there were 1 deprecation warnings; re-run with -deprecation for details -res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[Any] - -scala> scala.reflect.classTag[List[_]] -res1: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List - -scala> diff --git a/test/files/run/t6329_vanilla.check b/test/files/run/t6329_vanilla.check index 8282afaeba..ad8f4b5c77 100644 --- a/test/files/run/t6329_vanilla.check +++ b/test/files/run/t6329_vanilla.check @@ -1,2 +1,8 @@ -scala.collection.immutable.List[Any] +scala.collection.immutable.List[<?>] scala.collection.immutable.List +scala.collection.immutable.List[<?>] +scala.collection.immutable.List +scala.collection.immutable.Set[<?>] +scala.collection.immutable.Set +scala.collection.immutable.Set[<?>] +scala.collection.immutable.Set diff --git a/test/files/run/t6329_vanilla.scala b/test/files/run/t6329_vanilla.scala index a31cd5c72e..ec84f1f938 100644 --- a/test/files/run/t6329_vanilla.scala +++ b/test/files/run/t6329_vanilla.scala @@ -1,4 +1,13 @@ +import scala.reflect.classTag + +@deprecated("Suppress warnings", since="2.11") object Test extends App { - println(classManifest[List[_]]) - println(scala.reflect.classTag[List[_]]) -}
\ No newline at end of file + println(classManifest[scala.List[_]]) + println(classTag[scala.List[_]]) + println(classManifest[scala.collection.immutable.List[_]]) + println(classTag[scala.collection.immutable.List[_]]) + println(classManifest[Predef.Set[_]]) + println(classTag[Predef.Set[_]]) + println(classManifest[scala.collection.immutable.Set[_]]) + println(classTag[scala.collection.immutable.Set[_]]) +} diff --git a/test/files/run/t6329_vanilla_bug.check b/test/files/run/t6329_vanilla_bug.check deleted file mode 100644 index 8282afaeba..0000000000 --- a/test/files/run/t6329_vanilla_bug.check +++ /dev/null @@ -1,2 +0,0 @@ -scala.collection.immutable.List[Any] -scala.collection.immutable.List diff --git a/test/files/run/t6331.scala b/test/files/run/t6331.scala index 4e43a7686e..d9d46f10ea 100644 --- a/test/files/run/t6331.scala +++ b/test/files/run/t6331.scala @@ -1,9 +1,4 @@ -import scala.tools.partest._ -import java.io._ -import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser -import scala.tools.nsc.{Global, Settings, CompilerCommand} -import scala.tools.nsc.reporters.ConsoleReporter +import scala.tools.partest.DirectTest // Test of Constant#equals, which must must account for floating point intricacies. object Test extends DirectTest { diff --git a/test/files/run/t6331b.scala b/test/files/run/t6331b.scala index f966abea51..3a560ea64b 100644 --- a/test/files/run/t6331b.scala +++ b/test/files/run/t6331b.scala @@ -1,12 +1,5 @@ -import scala.tools.partest._ -import java.io._ -import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser -import scala.tools.nsc.{Global, Settings, CompilerCommand} -import scala.tools.nsc.reporters.ConsoleReporter - -import scala.tools.partest.trace -import scala.util.control.Exception._ +import scala.tools.partest.Util.trace +import scala.util.control.Exception.allCatch object Test extends App { diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check new file mode 100644 index 0000000000..5070b67e46 --- /dev/null +++ b/test/files/run/t6381.check @@ -0,0 +1,17 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> import language.experimental.macros +import language.experimental.macros + +scala> def pos_impl(c: reflect.macros.Context): c.Expr[String] = + c.literal(c.enclosingPosition.getClass.toString) +pos_impl: (c: scala.reflect.macros.Context)c.Expr[String] + +scala> def pos = macro pos_impl +defined term macro pos: String + +scala> pos +res0: String = class scala.reflect.internal.util.RangePosition + +scala> diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala new file mode 100644 index 0000000000..859ec3cb30 --- /dev/null +++ b/test/files/run/t6381.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |import language.experimental.macros + |def pos_impl(c: reflect.macros.Context): c.Expr[String] = + | c.literal(c.enclosingPosition.getClass.toString) + |def pos = macro pos_impl + |pos + |""".stripMargin.trim + + override def extraSettings: String = "-Yrangepos" +} diff --git a/test/files/run/t6392b.check b/test/files/run/t6392b.check index b7872f0e08..1ccfced1c6 100644 --- a/test/files/run/t6392b.check +++ b/test/files/run/t6392b.check @@ -1 +1 @@ -ModuleDef(Modifiers(), newTermName("C")#MOD, Template(List(Select(Ident(scala#PK), newTypeName("AnyRef")#TPE)), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR#PCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(newTypeName("C")), tpnme.EMPTY), nme.CONSTRUCTOR#PCTOR), List())), Literal(Constant(()))))))) +ModuleDef(Modifiers(), TermName("C")#MOD, Template(List(Select(Ident(scala#PK), TypeName("AnyRef")#TPE)), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR#PCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(TypeName("C")), tpnme.EMPTY), nme.CONSTRUCTOR#PCTOR), List())), Literal(Constant(()))))))) diff --git a/test/files/run/t6394a/Macros_1.scala b/test/files/run/t6394a/Macros_1.scala index 3d39d3e40a..5aa07e7f41 100644 --- a/test/files/run/t6394a/Macros_1.scala +++ b/test/files/run/t6394a/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def impl(c:Context): c.Expr[Any] = { import c.universe._ - val selfTree = This(c.enclosingClass.symbol.asModule.moduleClass) + val selfTree = This(c.enclosingImpl.symbol.asModule.moduleClass) c.Expr[AnyRef](selfTree) } diff --git a/test/files/run/t6406-regextract.check b/test/files/run/t6406-regextract.check new file mode 100644 index 0000000000..88c5a52eb3 --- /dev/null +++ b/test/files/run/t6406-regextract.check @@ -0,0 +1,4 @@ +List(1, 3) +List(1, 3) +List(1, 3) +Some(2011) Some(2011) diff --git a/test/files/run/t6406-regextract.scala b/test/files/run/t6406-regextract.scala new file mode 100644 index 0000000000..83679a5167 --- /dev/null +++ b/test/files/run/t6406-regextract.scala @@ -0,0 +1,30 @@ + +object Test extends App { + import util.matching._ + import Regex._ + + val r = "(\\d+)".r + val q = """(\d)""".r + val ns = List("1,2","x","3,4") + val u = r.unanchored + + val is = ns collect { case u(x) => x } map { case r(x) => x } + println(is) + // Match from same pattern + val js = (ns map { u findFirstMatchIn _ }).flatten map { case r(x) => x } + println(js) + // Match not from same pattern + val ks = (ns map { q findFirstMatchIn _ }).flatten map { case r(x) => x } + println(ks) + + val t = "Last modified 2011-07-15" + val p1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r + val y1: Option[String] = for { + p1(year, month, day) <- p1 findFirstIn t + } yield year + val y2: Option[String] = for { + p1(year, month, day) <- p1 findFirstMatchIn t + } yield year + println(s"$y1 $y2") + +} diff --git a/test/files/run/t6439.check b/test/files/run/t6439.check index 178ea739f5..f804fa75f4 100644 --- a/test/files/run/t6439.check +++ b/test/files/run/t6439.check @@ -1,13 +1,11 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> class A defined class A scala> object A // warn -defined module A +defined object A warning: previously defined class A is not a companion to object A. Companions must be defined together; you may wish to use :paste mode for this. @@ -15,15 +13,15 @@ scala> trait B defined trait B scala> object B // warn -defined module B +defined object B warning: previously defined trait B is not a companion to object B. Companions must be defined together; you may wish to use :paste mode for this. scala> object C -defined module C +defined object C scala> object Bippy -defined module Bippy +defined object Bippy scala> class C // warn defined class C @@ -40,13 +38,13 @@ scala> val D = 0 // no warn D: Int = 0 scala> object E -defined module E +defined object E scala> var E = 0 // no warn E: Int = 0 scala> object F -defined module F +defined object F scala> type F = Int // no warn defined type alias F @@ -58,9 +56,18 @@ scala> :power ** global._, definitions._ also imported ** ** Try :help, :vals, power.<tab> ** -scala> intp("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols +scala> object lookup { + import intp._ + def apply(name: String): Symbol = types(name) orElse terms(name) + def types(name: String): Symbol = replScope lookup (name: TypeName) orElse getClassIfDefined(name) + def terms(name: String): Symbol = replScope lookup (name: TermName) orElse getModuleIfDefined(name) + def types[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol + def terms[T: global.TypeTag] : Symbol = typeOf[T].termSymbol + def apply[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol +} +defined object lookup + +scala> lookup("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols res0: $r.intp.global.Symbol = type F scala> - -scala> diff --git a/test/files/run/t6439.scala b/test/files/run/t6439.scala index 70a2dbafaf..175a1d134f 100644 --- a/test/files/run/t6439.scala +++ b/test/files/run/t6439.scala @@ -1,6 +1,7 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { + def code = """ class A object A // warn @@ -17,6 +18,15 @@ var E = 0 // no warn object F type F = Int // no warn :power -intp("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols +object lookup { + import intp._ + def apply(name: String): Symbol = types(name) orElse terms(name) + def types(name: String): Symbol = replScope lookup (name: TypeName) orElse getClassIfDefined(name) + def terms(name: String): Symbol = replScope lookup (name: TermName) orElse getModuleIfDefined(name) + def types[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol + def terms[T: global.TypeTag] : Symbol = typeOf[T].termSymbol + def apply[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol +} +lookup("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols """ } diff --git a/test/files/run/t6443.scala b/test/files/run/t6443.scala index 67fe2cab22..3ab8c345fe 100644 --- a/test/files/run/t6443.scala +++ b/test/files/run/t6443.scala @@ -1,3 +1,5 @@ +import scala.language.existentials + class Base class Derived extends Base diff --git a/test/files/run/t6448.check b/test/files/run/t6448.check new file mode 100644 index 0000000000..9401568319 --- /dev/null +++ b/test/files/run/t6448.check @@ -0,0 +1,32 @@ + +=List.collect= +f(1) +f(2) +List(1) + +=List.collectFirst= +f(1) +Some(1) + +=Option.collect= +f(1) +Some(1) + +=Option.collect= +f(2) +None + +=Stream.collect= +f(1) +f(2) +List(1) + +=Stream.collectFirst= +f(1) +Some(1) + +=ParVector.collect= +(ParVector(1),2) + +=ParArray.collect= +(ParArray(1),2) diff --git a/test/files/run/t6448.scala b/test/files/run/t6448.scala new file mode 100644 index 0000000000..4d1528e500 --- /dev/null +++ b/test/files/run/t6448.scala @@ -0,0 +1,61 @@ +// Tests to show that various `collect` functions avoid calling +// both `PartialFunction#isDefinedAt` and `PartialFunction#apply`. +// +object Test { + def f(i: Int) = { println("f(" + i + ")"); true } + class Counter { + var count = 0 + def apply(i: Int) = synchronized {count += 1; true} + } + + def testing(label: String)(body: => Any) { + println(s"\n=$label=") + println(body) + } + + def main(args: Array[String]) { + testing("List.collect")(List(1, 2) collect { case x if f(x) && x < 2 => x}) + testing("List.collectFirst")(List(1, 2) collectFirst { case x if f(x) && x < 2 => x}) + testing("Option.collect")(Some(1) collect { case x if f(x) && x < 2 => x}) + testing("Option.collect")(Some(2) collect { case x if f(x) && x < 2 => x}) + testing("Stream.collect")((Stream(1, 2).collect { case x if f(x) && x < 2 => x}).toList) + testing("Stream.collectFirst")(Stream.continually(1) collectFirst { case x if f(x) && x < 2 => x}) + + import collection.parallel.ParIterable + import collection.parallel.immutable.ParVector + import collection.parallel.mutable.ParArray + testing("ParVector.collect") { + val counter = new Counter() + (ParVector(1, 2) collect { case x if counter(x) && x < 2 => x}, counter.synchronized(counter.count)) + } + + testing("ParArray.collect") { + val counter = new Counter() + (ParArray(1, 2) collect { case x if counter(x) && x < 2 => x}, counter.synchronized(counter.count)) + } + + object PendingTests { + testing("Iterator.collect")((Iterator(1, 2) collect { case x if f(x) && x < 2 => x}).toList) + + testing("List.view.collect")((List(1, 2).view collect { case x if f(x) && x < 2 => x}).force) + + // This would do the trick in Future.collect, but I haven't added this yet as there is a tradeoff + // with extra allocations to consider. + // + // pf.lift(v) match { + // case Some(x) => p success x + // case None => fail(v) + // } + testing("Future.collect") { + import concurrent.ExecutionContext.Implicits.global + import concurrent.Await + import concurrent.duration.Duration + val result = concurrent.future(1) collect { case x if f(x) => x} + Await.result(result, Duration.Inf) + } + + // TODO Future.{onSuccess, onFailure, recoverWith, andThen} + } + + } +} diff --git a/test/files/run/t6467.scala b/test/files/run/t6467.scala new file mode 100644 index 0000000000..dc93b69fdc --- /dev/null +++ b/test/files/run/t6467.scala @@ -0,0 +1,20 @@ + + + + +import collection._ + + + +object Test extends App { + + def compare(s1: String, s2: String) { + assert(s1 == s2, s1 + "\nvs.\n" + s2) + } + + compare(List(1, 2, 3, 4).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(List(1, 2, 3, 4).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(Seq(0 until 100: _*).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + compare(Seq(0 until 100: _*).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + +}
\ No newline at end of file diff --git a/test/files/run/t6488.check b/test/files/run/t6488.check deleted file mode 100644 index 35821117c8..0000000000 --- a/test/files/run/t6488.check +++ /dev/null @@ -1 +0,0 @@ -Success diff --git a/test/files/run/t6488.scala b/test/files/run/t6488.scala index 487614ecfd..e234876fbe 100644 --- a/test/files/run/t6488.scala +++ b/test/files/run/t6488.scala @@ -1,11 +1,64 @@ -import sys.process._ +import scala.sys.process._ +import scala.util.Try +import scala.util.Properties.{ javaHome, javaClassPath } +import java.io.{ File, IOException } +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit._ +import java.util.concurrent.atomic._ + object Test { + /* // Program that prints "Success" if the command was successfully run then destroyed // It will silently pass if the command "/bin/ls" does not exist - // It will fail due to the uncatchable exception in t6488 race condition + // It will fail due to the uncatchable exception in t6488 race condition, + // i.e., if any uncaught exceptions on spawned threads are printed. def main(args: Array[String]) { try Process("/bin/ls").run(ProcessLogger { _ => () }).destroy catch { case _ => () } println("Success") } + */ + + // Show that no uncaught exceptions are thrown on spawned I/O threads + // when the process is destroyed. The default handler will print + // stack traces in the failing case. + def main(args: Array[String]) { + if (args.nonEmpty && args(0) == "data") + data() + else + test() // args(0) == "jvm" + } + + // fork the data spewer, wait for input, then destroy the process + def test() { + val f = new File(javaHome, "bin").listFiles.sorted filter (_.getName startsWith "java") find (_.canExecute) getOrElse { + // todo signal test runner that test is skipped + new File("/bin/ls") // innocuous + } + //Process(f.getAbsolutePath).run(ProcessLogger { _ => () }).destroy + val reading = new CountDownLatch(1) + val count = new AtomicInteger + def counted = count.get + val command = s"${f.getAbsolutePath} -classpath ${javaClassPath} Test data" + Try { + Process(command) run ProcessLogger { (s: String) => + //Console println s"[[$s]]" // java help + count.getAndIncrement + reading.countDown + Thread.`yield`() + } + } foreach { (p: Process) => + val ok = reading.await(10, SECONDS) + if (!ok) Console println "Timed out waiting for process output!" + p.destroy() + } + //Console println s"Read count $counted lines" + } + + // spew something + def data() { + def filler = "." * 100 + for (i <- 1 to 1000) + Console println s"Outputting data line $i $filler" + } } diff --git a/test/files/run/t6507.check b/test/files/run/t6507.check new file mode 100644 index 0000000000..3536c42381 --- /dev/null +++ b/test/files/run/t6507.check @@ -0,0 +1,24 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :silent +Switched off result printing. + +scala> class A { override def toString() = { println("!"); "A" } } + +scala> val a = new A + +scala> var b: A = new A + +scala> b = new A + +scala> new A + +scala> :silent +Switched on result printing. + +scala> res0 +! +res1: A = A + +scala> diff --git a/test/files/run/t6507.scala b/test/files/run/t6507.scala new file mode 100644 index 0000000000..25f0a73e04 --- /dev/null +++ b/test/files/run/t6507.scala @@ -0,0 +1,14 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ +:silent +class A { override def toString() = { println("!"); "A" } } +val a = new A +var b: A = new A +b = new A +new A +:silent +res0 +""" +} diff --git a/test/files/run/t6548.check b/test/files/run/t6548.check new file mode 100644 index 0000000000..5dfcb12e02 --- /dev/null +++ b/test/files/run/t6548.check @@ -0,0 +1,2 @@ +false +List(JavaAnnotationWithNestedEnum_1(value = VALUE)) diff --git a/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java b/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java new file mode 100644 index 0000000000..32004de537 --- /dev/null +++ b/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java @@ -0,0 +1,17 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, + ElementType.TYPE, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +public @interface JavaAnnotationWithNestedEnum_1 +{ + public Value value() default Value.VALUE; + + public enum Value + { + VALUE; + } +}
\ No newline at end of file diff --git a/test/files/run/t6548/Test_2.scala b/test/files/run/t6548/Test_2.scala new file mode 100644 index 0000000000..7200259d36 --- /dev/null +++ b/test/files/run/t6548/Test_2.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +class Bean { + @JavaAnnotationWithNestedEnum_1(JavaAnnotationWithNestedEnum_1.Value.VALUE) + def value = 1 +} + +object Test extends App { + println(cm.staticClass("Bean").isCaseClass) + println(typeOf[Bean].declaration(TermName("value")).annotations) +} diff --git a/test/files/run/t6549.check b/test/files/run/t6549.check index bc78aac741..d5dfc5ebe8 100644 --- a/test/files/run/t6549.check +++ b/test/files/run/t6549.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> case class `X"`(var xxx: Any) defined class X$u0022 @@ -28,5 +26,3 @@ scala> val `"` = 0 ": Int = 0 scala> - -scala> diff --git a/test/files/run/t6555.check b/test/files/run/t6555.check index a18a8e8023..9ac115a13f 100644 --- a/test/files/run/t6555.check +++ b/test/files/run/t6555.check @@ -7,14 +7,14 @@ package <empty> { }; private[this] val f: Int => Int = { @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1$mcII$sp with Serializable { - def <init>(): anonymous class $anonfun = { + def <init>(): <$anon: Int => Int> = { $anonfun.super.<init>(); () }; final def apply(param: Int): Int = $anonfun.this.apply$mcII$sp(param); <specialized> def apply$mcII$sp(param: Int): Int = param }; - (new anonymous class $anonfun(): Int => Int) + (new <$anon: Int => Int>(): Int => Int) }; <stable> <accessor> def f(): Int => Int = Foo.this.f } diff --git a/test/files/run/t657.scala b/test/files/run/t657.scala index a9726092e7..e76b0292dd 100644 --- a/test/files/run/t657.scala +++ b/test/files/run/t657.scala @@ -1,3 +1,5 @@ + +import scala.language.{ implicitConversions } abstract class BaseList { type Node <: NodeImpl; implicit def convertNode(ni : NodeImpl) = ni.asInstanceOf[Node]; diff --git a/test/files/run/t6572/bar_1.scala b/test/files/run/t6572/bar_1.scala deleted file mode 100644 index 5518ced7af..0000000000 --- a/test/files/run/t6572/bar_1.scala +++ /dev/null @@ -1,19 +0,0 @@ -package bar - -abstract class IntBase[V] extends Base[Int, V] - -class DefaultIntBase[V <: IntProvider] extends IntBase[V] { - override protected def hashCode(key: Int) = key -} - -trait IntProvider { - def int: Int -} - -abstract class Base[@specialized K, V] { - - protected def hashCode(key: K) = key.hashCode - - def get(key: K): V = throw new RuntimeException - -}
\ No newline at end of file diff --git a/test/files/run/t6572/foo_2.scala b/test/files/run/t6572/foo_2.scala deleted file mode 100644 index 465f0b7c3c..0000000000 --- a/test/files/run/t6572/foo_2.scala +++ /dev/null @@ -1,17 +0,0 @@ -//package foo - -import bar._ - -class FooProvider extends IntProvider { - def int = 3 -} - -class Wrapper(users: DefaultIntBase[FooProvider]) { - final def user(userId: Int) = users.get(userId) -} - -object Test { - def main(args: Array[String]) { - new Wrapper(new DefaultIntBase) - } -}
\ No newline at end of file diff --git a/test/files/run/t6574b.check b/test/files/run/t6574b.check new file mode 100644 index 0000000000..e10fa4f810 --- /dev/null +++ b/test/files/run/t6574b.check @@ -0,0 +1 @@ +List(5, 4, 3, 2, 1) diff --git a/test/files/run/t6574b.scala b/test/files/run/t6574b.scala new file mode 100644 index 0000000000..df329a31ca --- /dev/null +++ b/test/files/run/t6574b.scala @@ -0,0 +1,7 @@ +object Test extends App { + implicit class AnyOps(val i: Int) extends AnyVal { + private def parentsOf(x: Int): List[Int] = if (x == 0) Nil else x :: parentsOf(x - 1) + def parents: List[Int] = parentsOf(i) + } + println((5).parents) +} diff --git a/test/files/run/t6591_1.check b/test/files/run/t6591_1.check index b6cb6c286d..d1d448f283 100644 --- a/test/files/run/t6591_1.check +++ b/test/files/run/t6591_1.check @@ -1 +1 @@ -Block(List(ValDef(Modifiers(), newTermName("v"), Select(Ident(A), newTypeName("I")), Select(Ident(A), newTermName("impl")))), Ident(newTermName("v"))) +Block(List(ValDef(Modifiers(), TermName("v"), Select(Ident(A), TypeName("I")), Select(Ident(A), TermName("impl")))), Ident(TermName("v"))) diff --git a/test/files/run/t6591_2.check b/test/files/run/t6591_2.check index b2d5797cbf..8c972ef920 100644 --- a/test/files/run/t6591_2.check +++ b/test/files/run/t6591_2.check @@ -1 +1 @@ -Block(List(ValDef(Modifiers(), newTermName("v"), SelectFromTypeTree(Ident(A), newTypeName("I")), Select(Apply(Select(New(Ident(A)), nme.CONSTRUCTOR), List()), newTermName("impl")))), Ident(newTermName("v"))) +Block(List(ValDef(Modifiers(), TermName("v"), SelectFromTypeTree(Ident(A), TypeName("I")), Select(Apply(Select(New(Ident(A)), nme.CONSTRUCTOR), List()), TermName("impl")))), Ident(TermName("v"))) diff --git a/test/files/run/t6591_3.check b/test/files/run/t6591_3.check index a7b594ba65..f4592adce9 100644 --- a/test/files/run/t6591_3.check +++ b/test/files/run/t6591_3.check @@ -1 +1 @@ -Block(List(ValDef(Modifiers(), newTermName("v"), Select(This(newTypeName("A")), newTypeName("I")), Apply(Select(New(Select(This(newTypeName("A")), newTypeName("I"))), nme.CONSTRUCTOR), List()))), Ident(newTermName("v"))) +Block(List(ValDef(Modifiers(), TermName("v"), Select(This(TypeName("A")), TypeName("I")), Apply(Select(New(Select(This(TypeName("A")), TypeName("I"))), nme.CONSTRUCTOR), List()))), Ident(TermName("v"))) diff --git a/test/files/run/t6591_5.check b/test/files/run/t6591_5.check index e0b6d06e6b..4ebc2236af 100644 --- a/test/files/run/t6591_5.check +++ b/test/files/run/t6591_5.check @@ -1 +1 @@ -Expr(Block(List(ValDef(Modifiers(), newTermName("v"), Select(Select(This(newTypeName("A")), newTermName("x")), newTypeName("I")), Select(Ident(scala.Predef), newTermName("$qmark$qmark$qmark")))), Ident(newTermName("v")))) +Expr(Block(List(ValDef(Modifiers(), TermName("v"), Select(Select(This(TypeName("A")), TermName("x")), TypeName("I")), Select(Ident(scala.Predef), TermName("$qmark$qmark$qmark")))), Ident(TermName("v")))) diff --git a/test/files/run/t6591_6.check b/test/files/run/t6591_6.check index 0c4847b628..940e2026fe 100644 --- a/test/files/run/t6591_6.check +++ b/test/files/run/t6591_6.check @@ -1 +1 @@ -Expr(Block(List(ValDef(Modifiers(), newTermName("v"), Select(Select(Ident(newTermName("A")), newTermName("x")), newTypeName("I")), Select(Ident(scala.Predef), newTermName("$qmark$qmark$qmark")))), Ident(newTermName("v")))) +Expr(Block(List(ValDef(Modifiers(), TermName("v"), Select(Select(Ident(TermName("A")), TermName("x")), TypeName("I")), Select(Ident(scala.Predef), TermName("$qmark$qmark$qmark")))), Ident(TermName("v")))) diff --git a/test/files/run/t6608.check b/test/files/run/t6608.check new file mode 100644 index 0000000000..15628b322e --- /dev/null +++ b/test/files/run/t6608.check @@ -0,0 +1 @@ +(C$$yyy,true) diff --git a/test/files/run/t6608.scala b/test/files/run/t6608.scala new file mode 100644 index 0000000000..2f956bfb35 --- /dev/null +++ b/test/files/run/t6608.scala @@ -0,0 +1,16 @@ +import reflect.runtime.universe + +class C { + private val yyy: Any = 1 + @inline def foo = yyy +} + +object Test extends App { + import universe._ + val access = typeOf[C].declarations + .toList + .filter(_.name.toString.endsWith("yyy")) + .map(x => (x.name, x.isPrivate)) + println(access.head) +} + diff --git a/test/files/run/t6611.scala b/test/files/run/t6611.scala index 0947a48f90..c295368aea 100644 --- a/test/files/run/t6611.scala +++ b/test/files/run/t6611.scala @@ -7,55 +7,55 @@ object Test extends App { locally { val a = Array("1": Object) - val a2 = Array[Object](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(true) - val a2 = Array[Boolean](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1: Short) - val a2 = Array[Short](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1: Byte) - val a2 = Array[Byte](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1) - val a2 = Array[Int](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1L) - val a2 = Array[Long](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1f) - val a2 = Array[Float](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1d) - val a2 = Array[Double](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(()) - val a2 = Array[Unit](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } } diff --git a/test/files/run/t6632.scala b/test/files/run/t6632.scala index c1c8d4abe0..0242e60104 100644 --- a/test/files/run/t6632.scala +++ b/test/files/run/t6632.scala @@ -1,6 +1,6 @@ object Test extends App { import collection.mutable.ListBuffer - + def newLB = ListBuffer('a, 'b, 'c, 'd, 'e) val lb0 = newLB diff --git a/test/files/run/t6646.check b/test/files/run/t6646.check index b0b7ad32f3..15715dae91 100644 --- a/test/files/run/t6646.check +++ b/test/files/run/t6646.check @@ -1,4 +1,4 @@ -Found NotNull +Found NoNull Found lower Found 2 A single ident is always a pattern diff --git a/test/files/run/t6646.scala b/test/files/run/t6646.scala index 150b0df11e..a377ac274e 100644 --- a/test/files/run/t6646.scala +++ b/test/files/run/t6646.scala @@ -1,14 +1,14 @@ sealed trait ColumnOption -case object NotNull extends ColumnOption +case object NoNull extends ColumnOption case object PrimaryKey extends ColumnOption case object lower extends ColumnOption object Test { def main(args: Array[String]) { - val l = List(PrimaryKey, NotNull, lower) + val l = List(PrimaryKey, NoNull, lower) // withFilter must be generated in these - for (option @ NotNull <- l) println("Found " + option) + for (option @ NoNull <- l) println("Found " + option) for (option @ `lower` <- l) println("Found " + option) for ((`lower`, i) <- l.zipWithIndex) println("Found " + i) diff --git a/test/files/run/t6669.scala b/test/files/run/t6669.scala index b55718b12b..e18f2514a9 100644 --- a/test/files/run/t6669.scala +++ b/test/files/run/t6669.scala @@ -2,7 +2,7 @@ import java.io.{ByteArrayOutputStream, PrintStream} object Test extends App { val baos = new ByteArrayOutputStream() - val ps = new PrintStream(baos) + val ps = new PrintStream(baos) // first test with the default classpath (scala.Console withOut ps) { diff --git a/test/files/run/t6690.scala b/test/files/run/t6690.scala index 43ede967a0..15b1817e87 100644 --- a/test/files/run/t6690.scala +++ b/test/files/run/t6690.scala @@ -1,5 +1,7 @@ import scala.collection.mutable +import scala.language.{ reflectiveCalls } + object Test extends App { def last0(ml: mutable.MutableList[Int]) = ml.asInstanceOf[{def last0: mutable.LinkedList[Int]}].last0 diff --git a/test/files/run/t6719.check b/test/files/run/t6719.check new file mode 100644 index 0000000000..6a452c185a --- /dev/null +++ b/test/files/run/t6719.check @@ -0,0 +1 @@ +() diff --git a/test/files/run/t6719.scala b/test/files/run/t6719.scala new file mode 100644 index 0000000000..847929a95d --- /dev/null +++ b/test/files/run/t6719.scala @@ -0,0 +1,8 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.{ToolBox, ToolBoxError} +object Test extends App { + val tb = cm.mkToolBox() + val tree = tb.parse("(); val res = 0") + println(tb.eval(tree)) +}
\ No newline at end of file diff --git a/test/files/run/t6731.scala b/test/files/run/t6731.scala index 89d212e91e..12357b935e 100644 --- a/test/files/run/t6731.scala +++ b/test/files/run/t6731.scala @@ -12,7 +12,7 @@ abstract class MonoDynamic extends Dynamic { def applyDynamic(name: String)(args: Any*): String = show(this + "." + name + mkArgs(args: _*)) def applyDynamicNamed(name: String)(args: (String, Any)*): String = show(this + "." + name + mkArgs(args: _*)) - override def toString = this.getClass.getName split '.' last + override def toString = (this.getClass.getName split '.').last } object Mono extends MonoDynamic { diff --git a/test/files/run/t6745-2.scala b/test/files/run/t6745-2.scala new file mode 100644 index 0000000000..31ecd42bd1 --- /dev/null +++ b/test/files/run/t6745-2.scala @@ -0,0 +1,22 @@ +import scala.tools.nsc._ +import scala.tools.partest.CompilerTest +import scala.collection.{ mutable, immutable, generic } + +object Test extends CompilerTest { + import global._ + import rootMirror._ + import definitions._ + import global.analyzer.{Context, ImportInfo} + + override def code = """ +package context { +} + """ + + def check(source: String, unit: global.CompilationUnit) = { + val context: Context = global.analyzer.rootContext(unit) + val importInfo: ImportInfo = context.imports.head // Predef._ + val importedSym = importInfo.importedSymbol(nme.CONSTRUCTOR) + assert(importedSym == NoSymbol, importedSym) // was "constructor Predef" + } +} diff --git a/test/files/run/t6860.check b/test/files/run/t6860.check new file mode 100644 index 0000000000..c96331f540 --- /dev/null +++ b/test/files/run/t6860.check @@ -0,0 +1,4 @@ +Bippy[String] +Bippy[String] +throws[Nothing] +throws[RuntimeException] diff --git a/test/files/run/t6860.scala b/test/files/run/t6860.scala new file mode 100644 index 0000000000..2dcc2a67f7 --- /dev/null +++ b/test/files/run/t6860.scala @@ -0,0 +1,20 @@ +class Bippy[T](val value: T) extends annotation.StaticAnnotation + +class A { + @Bippy("hi") def f1: Int = 1 + @Bippy[String]("hi") def f2: Int = 2 + + @throws("what do I throw?") def f3 = throw new RuntimeException + @throws[RuntimeException]("that's good to know!") def f4 = throw new RuntimeException +} + +object Test { + import scala.reflect.runtime.universe._ + + def main(args: Array[String]): Unit = { + val members = typeOf[A].declarations.toList + val tpes = members flatMap (_.annotations) map (_.tpe) + + tpes.map(_.toString).sorted foreach println + } +} diff --git a/test/files/run/t6863.check b/test/files/run/t6863.check new file mode 100644 index 0000000000..030cb8b265 --- /dev/null +++ b/test/files/run/t6863.check @@ -0,0 +1,12 @@ +t6863.scala:38: warning: comparing values of types Unit and Unit using `==' will always yield true + assert({ () => x}.apply == ()) + ^ +t6863.scala:42: warning: comparing values of types Unit and Unit using `==' will always yield true + assert({ () => x}.apply == ()) + ^ +t6863.scala:46: warning: comparing values of types Unit and Unit using `==' will always yield true + assert({ () => x}.apply == ()) + ^ +t6863.scala:59: warning: comparing values of types Unit and Unit using `==' will always yield true + assert({ () => x }.apply == ()) + ^ diff --git a/test/files/run/t6863.scala b/test/files/run/t6863.scala index d77adb6af4..7210ebc01d 100644 --- a/test/files/run/t6863.scala +++ b/test/files/run/t6863.scala @@ -3,34 +3,34 @@ object Test { def lazyVal() = { // internally lazy vals become vars which are initialized with "_", so they need to be tested just like vars do lazy val x = "42" - assert({ () => x }.apply == "42") + assert({ () => x }.apply == "42") } def ident() = { val y = "42" var x = y - assert({ () => x }.apply == "42") + assert({ () => x }.apply == "42") } def apply() = { def y(x : Int) = x.toString var x = y(42) - assert({ () => x }.apply == "42") + assert({ () => x }.apply == "42") } def literal() = { var x = "42" - assert({ () => x }.apply == "42") + assert({ () => x }.apply == "42") } def `new`() = { var x = new String("42") - assert({ () => x }.apply == "42") + assert({ () => x }.apply == "42") } def select() = { object Foo{val bar = "42"} var x = Foo.bar - assert({ () => x }.apply == "42") + assert({ () => x }.apply == "42") } def `throw`() = { var x = if (true) "42" else throw new Exception("42") - assert({ () => x }.apply == "42") + assert({ () => x }.apply == "42") } def assign() = { var y = 1 @@ -51,7 +51,7 @@ object Test { assert({ () => x }.apply == "42") } def tryCatch() = { - var x = try { "42" } catch { case _ => "43" } + var x = try { "42" } catch { case _: Throwable => "43" } assert({ () => x }.apply == "42") } def `if`() = { @@ -59,7 +59,7 @@ object Test { assert({ () => x }.apply == ()) } def ifElse() = { - var x = if(true) "42" else "43" + var x = if(true) "42" else "43" assert({ () => x }.apply == "42") } def matchCase() = { @@ -77,7 +77,7 @@ object Test { assert({ () => x }.apply == "42") } def labelDef() = { - var x = 100 match { + var x = 100 match { case 100 => try "42" finally () } assert({ () => x }.apply == "42") @@ -85,8 +85,8 @@ object Test { def nested() = { var x = { val y = 42 - if(true) try "42" catch {case _ => "43"} - else "44" + if(true) try "42" catch {case _: Throwable => "43"} + else "44" } assert({ () => x }.apply == "42") } diff --git a/test/files/run/t6937.check b/test/files/run/t6937.check index 9a1fa4cfaf..4729dc7006 100644 --- a/test/files/run/t6937.check +++ b/test/files/run/t6937.check @@ -1,9 +1,7 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - -scala> import scala.reflect.runtime.{universe => ru} +scala> import scala.reflect.runtime.{universe => ru} import scala.reflect.runtime.{universe=>ru} scala> import scala.reflect.runtime.{currentMirror => cm} @@ -22,5 +20,3 @@ scala> apiru.typeTag[A].in(cm) res0: reflect.runtime.universe.TypeTag[A] = TypeTag[A] scala> - -scala> diff --git a/test/files/run/t6955.scala b/test/files/run/t6955.scala index 2610acdec4..329af688e4 100644 --- a/test/files/run/t6955.scala +++ b/test/files/run/t6955.scala @@ -1,5 +1,6 @@ -import scala.tools.partest.IcodeTest +import scala.tools.partest.IcodeComparison +// this class should compile to code that uses switches (twice) class Switches { type Tag = Byte @@ -10,7 +11,8 @@ class Switches { case _ => 0 } - def switchOkay(i: Byte): Int = i match { // notice type of i is Byte + // this worked before, should keep working + def switchOkay(i: Byte): Int = i match { case 1 => 1 case 2 => 2 case 3 => 3 @@ -18,9 +20,15 @@ class Switches { } } -object Test extends IcodeTest { +object Test extends IcodeComparison { // ensure we get two switches out of this -- ignore the rest of the output for robustness // exclude the constant we emit for the "SWITCH ..." string below (we get the icode for all the code you see in this file) - override def show() = println(collectIcode("").filter(x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1).size) + override def show() = { + val expected = 2 + val actual = (collectIcode() filter { + x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1 + }).size + assert(actual == expected) + } } diff --git a/test/files/run/t6956.scala b/test/files/run/t6956.scala index 4a6583ca45..3569adf483 100644 --- a/test/files/run/t6956.scala +++ b/test/files/run/t6956.scala @@ -1,4 +1,4 @@ -import scala.tools.partest.IcodeTest +import scala.tools.partest.IcodeComparison class Switches { private[this] final val ONE = 1 @@ -18,9 +18,14 @@ class Switches { } } -object Test extends IcodeTest { +object Test extends IcodeComparison { // ensure we get two switches out of this -- ignore the rest of the output for robustness // exclude the constant we emit for the "SWITCH ..." string below (we get the icode for all the code you see in this file) - override def show() = println(collectIcode("").filter(x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1).size) + override def show() = { + val expected = 2 + val actual = (collectIcode() filter { + x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1 + }).size + assert(actual == expected) + } } - diff --git a/test/files/run/t6969.scala b/test/files/run/t6969.scala index 8cfc28c1e5..c4561b4424 100644 --- a/test/files/run/t6969.scala +++ b/test/files/run/t6969.scala @@ -1,3 +1,7 @@ + + +import scala.language.{ reflectiveCalls } + object Test { private type Clearable = { def clear(): Unit } private def choke() = { diff --git a/test/files/run/t7008-scala-defined.flags b/test/files/run/t7008-scala-defined.flags new file mode 100644 index 0000000000..49f2d2c4c8 --- /dev/null +++ b/test/files/run/t7008-scala-defined.flags @@ -0,0 +1 @@ +-Ybackend:GenASM diff --git a/test/files/run/t7015.check b/test/files/run/t7015.check new file mode 100644 index 0000000000..7651fe06b0 --- /dev/null +++ b/test/files/run/t7015.check @@ -0,0 +1,11 @@ +Method returns Null type: null +Method takes non Null type: null +call through method null +call through bridge null +fetch field: null +fetch field on companion: null +fetch local: null +fetch array element: null +method that takes object: null +method that takes anyref: null +method that takes any: null diff --git a/test/files/run/t7015.scala b/test/files/run/t7015.scala new file mode 100644 index 0000000000..37a73a9fc4 --- /dev/null +++ b/test/files/run/t7015.scala @@ -0,0 +1,49 @@ +object Test { + def main(args : Array[String]) : Unit = { + println(s"Method returns Null type: $f") + println(s"Method takes non Null type: ${g(null)}") + + // pass things through the g function because it expects + // a string. If we haven't adapted properly then we'll + // get verify errors + val b = new B + println(s"call through method ${g(b.f(null))}") + println(s"call through bridge ${g((b: A).f(null))}") + + println(s"fetch field: ${g(b.nullField)}") + println(s"fetch field on companion: ${g(B.nullCompanionField)}") + + val x = f + println(s"fetch local: ${g(x)}") + + val nulls = Array(f, f, f) + println(s"fetch array element: ${g(nulls(0))}") + + println(s"method that takes object: ${q(f)}") + println(s"method that takes anyref: ${r(f)}") + println(s"method that takes any: ${s(f)}") + } + + def f: Null = null + + def g(x: String) = x + + def q(x: java.lang.Object) = x + def r(x: AnyRef) = x + def s(x: Any) = x +} + +abstract class A { + def f(x: String): String +} + +class B extends A { + val nullField = null + + // this forces a bridge method because the return type is different + override def f(x: String) : Null = null +} + +object B { + val nullCompanionField = null +}
\ No newline at end of file diff --git a/test/files/run/t7047.check b/test/files/run/t7047.check index e69de29bb2..32bd581094 100644 --- a/test/files/run/t7047.check +++ b/test/files/run/t7047.check @@ -0,0 +1,3 @@ +Test_2.scala:2: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + Macros.foo + ^ diff --git a/test/files/run/t7064-old-style-supercalls.scala b/test/files/run/t7064-old-style-supercalls.scala deleted file mode 100644 index cffa7b1888..0000000000 --- a/test/files/run/t7064-old-style-supercalls.scala +++ /dev/null @@ -1,48 +0,0 @@ -import scala.reflect.runtime.universe._ -import Flag._ -import definitions._ -import scala.reflect.runtime.{currentMirror => cm} -import scala.tools.reflect.ToolBox -import scala.tools.reflect.Eval - -object Test extends App { - val PARAMACCESSOR = (1L << 29).asInstanceOf[FlagSet] - - // these trees can be acquired by running the following incantation: - // echo 'class C(val x: Int); class D extends C(2)' > foo.scala - // ./scalac -Xprint:parser -Yshow-trees-stringified -Yshow-trees-compact foo.scala - - val c = ClassDef( - Modifiers(), newTypeName("C"), List(), - Template( - List(Select(Ident(ScalaPackage), newTypeName("AnyRef"))), - emptyValDef, - List( - ValDef(Modifiers(PARAMACCESSOR), newTermName("x"), Ident(newTypeName("Int")), EmptyTree), - DefDef( - Modifiers(), - nme.CONSTRUCTOR, - List(), - List(List(ValDef(Modifiers(PARAM | PARAMACCESSOR), newTermName("x"), Ident(newTypeName("Int")), EmptyTree))), - TypeTree(), - Block( - List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), - Literal(Constant(()))))))) - val d = ClassDef( - Modifiers(), newTypeName("D"), List(), - Template( - List(Ident(newTypeName("C"))), - emptyValDef, - List( - DefDef( - Modifiers(), - nme.CONSTRUCTOR, - List(), - List(List()), - TypeTree(), - Block( - List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List(Literal(Constant(2))))), - Literal(Constant(()))))))) - val result = Select(Apply(Select(New(Ident(newTypeName("D"))), nme.CONSTRUCTOR), List()), newTermName("x")) - println(cm.mkToolBox().eval(Block(List(c, d), result))) -}
\ No newline at end of file diff --git a/test/files/run/t7074.check b/test/files/run/t7074.check deleted file mode 100644 index ab9cf11f16..0000000000 --- a/test/files/run/t7074.check +++ /dev/null @@ -1,9 +0,0 @@ -<a/> -<a b="2" c="3" d="1"/> -<a b="2" c="4" d="1" e="3" f="5"/> -<a b="5" c="4" d="3" e="2" f="1"/> -<a b="1" c="2" d="3" e="4" f="5"/> -<a a:b="2" a:c="3" a:d="1"/> -<a a:b="2" a:c="4" a:d="1" a:e="3" a:f="5"/> -<a a:b="5" a:c="4" a:d="3" a:e="2" a:f="1"/> -<a a:b="1" a:c="2" a:d="3" a:e="4" a:f="5"/> diff --git a/test/files/run/t7074.scala b/test/files/run/t7074.scala deleted file mode 100644 index 693a076a7a..0000000000 --- a/test/files/run/t7074.scala +++ /dev/null @@ -1,15 +0,0 @@ -import scala.xml.Utility.sort - -object Test extends App { - println(sort(<a/>)) - println(sort(<a d="1" b="2" c="3"/>)) - println(sort(<a d="1" b="2" e="3" c="4" f="5"/>)) - println(sort(<a f="1" e="2" d="3" c="4" b="5"/>)) - println(sort(<a b="1" c="2" d="3" e="4" f="5"/>)) - - println(sort(<a a:d="1" a:b="2" a:c="3"/>)) - println(sort(<a a:d="1" a:b="2" a:e="3" a:c="4" a:f="5"/>)) - println(sort(<a a:f="1" a:e="2" a:d="3" a:c="4" a:b="5"/>)) - println(sort(<a a:b="1" a:c="2" a:d="3" a:e="4" a:f="5"/>)) -} - diff --git a/test/files/run/t6956.check b/test/files/run/t7088.check index 0cfbf08886..1191247b6d 100644 --- a/test/files/run/t6956.check +++ b/test/files/run/t7088.check @@ -1 +1,2 @@ +1 2 diff --git a/test/files/run/t7088.scala b/test/files/run/t7088.scala new file mode 100644 index 0000000000..5f0114b940 --- /dev/null +++ b/test/files/run/t7088.scala @@ -0,0 +1,13 @@ +object Test { + type Tag[X] = {type Tag = X} + type TaggedArray[T] = Array[T] with Tag[Any] + + def method[T: scala.reflect.ClassTag](a: TaggedArray[T], value: T) { + a.update(0, value) + a foreach println + } + + def main(args: Array[String]): Unit = { + method(Array(1, 2).asInstanceOf[TaggedArray[Int]], 1) + } +} diff --git a/test/files/run/t7096.scala b/test/files/run/t7096.scala index e9c0323c2e..2495102899 100644 --- a/test/files/run/t7096.scala +++ b/test/files/run/t7096.scala @@ -1,3 +1,6 @@ +/* + * filter: inliner warning\(s\); re-run with -Yinline-warnings for details + */ import scala.tools.partest._ import scala.tools.nsc._ @@ -23,7 +26,7 @@ class Sub extends Base { import syms._ def check(source: String, unit: global.CompilationUnit) { - afterTyper { + exitingTyper { terms.filter(_.name.toString == "foo").foreach(sym => { val xParam = sym.tpe.paramss.flatten.head val annot = sym.tpe.finalResultType.annotations.head diff --git a/test/files/run/t7120.check b/test/files/run/t7120.check new file mode 100644 index 0000000000..45a4fb75db --- /dev/null +++ b/test/files/run/t7120.check @@ -0,0 +1 @@ +8 diff --git a/test/files/run/t7120/Base_1.scala b/test/files/run/t7120/Base_1.scala new file mode 100644 index 0000000000..be07b4f34f --- /dev/null +++ b/test/files/run/t7120/Base_1.scala @@ -0,0 +1,10 @@ +// This bug doesn't depend on separate compilation, +// in the interests of minimizing the log output during +// debugging this problem, I've split the compilation. + +case class Container( v: String ) + +trait Base[ T <: AnyRef ] { + type UserType = T + protected def defect: PartialFunction[ UserType, String ] +} diff --git a/test/files/run/t7120/Derived_2.scala b/test/files/run/t7120/Derived_2.scala new file mode 100644 index 0000000000..e0de629f82 --- /dev/null +++ b/test/files/run/t7120/Derived_2.scala @@ -0,0 +1,9 @@ +trait Derived extends Base[ Container ] { + protected def defect = { case c: Container => c.v.toString } +} + +// Erasure was ignoring the prefix `Derived#7001.this` when erasing +// A1, and consequently used `Object` rather than `Container`, which +// was only seen because that signature clashed with the bridge method. +// +// applyOrElse[A1 <: Derived#7001.this.UserType#7318, B1 >: String](x1: A1) diff --git a/test/files/run/t7120/Run_3.scala b/test/files/run/t7120/Run_3.scala new file mode 100644 index 0000000000..95e7f994ff --- /dev/null +++ b/test/files/run/t7120/Run_3.scala @@ -0,0 +1,3 @@ +object Test extends Derived with App { + println( defect( Container( "8" ) ) ) +} diff --git a/test/files/run/t7120b.check b/test/files/run/t7120b.check new file mode 100644 index 0000000000..aa2f5e7c9f --- /dev/null +++ b/test/files/run/t7120b.check @@ -0,0 +1,2 @@ +public int C$D.foo(java.lang.String) +public int C$D.foo(java.lang.String) diff --git a/test/files/run/t7120b.scala b/test/files/run/t7120b.scala new file mode 100644 index 0000000000..0be4eb70a7 --- /dev/null +++ b/test/files/run/t7120b.scala @@ -0,0 +1,30 @@ + +import scala.language.higherKinds + +trait Base[A] { type B = A; } +class C extends Base[String] { + class D { + def foo[B1 <: B](b: B1) = 0 + } +} + +trait BaseHK[M[_], A] { type B = M[A]; } +object BaseHK { type Id[X] = X } +class CHK extends BaseHK[BaseHK.Id, String] { + class D { + def foo[B1 <: B](b: B1) = 0 + } +} + + +object Test extends App { + val c = new C + val d = new c.D() + val meth = d.getClass.getMethods.find(_.getName == "foo").get + println(meth) + + val chk = new CHK + val dhk = new chk.D() + val methhk = d.getClass.getMethods.find(_.getName == "foo").get + println(methhk) +} diff --git a/test/files/run/t7151.check b/test/files/run/t7151.check new file mode 100644 index 0000000000..d532d9589f --- /dev/null +++ b/test/files/run/t7151.check @@ -0,0 +1,6 @@ +class Test$InnerObject$ isFinal = false +class Test$InnerCase isFinal = true +class Test$InnerNonCase isFinal = true +class TopLevelObject$ isFinal = true +class TopLevelCase isFinal = true +class TopLevelNonCase isFinal = true diff --git a/test/files/run/t7151.scala b/test/files/run/t7151.scala new file mode 100644 index 0000000000..f6492ba43c --- /dev/null +++ b/test/files/run/t7151.scala @@ -0,0 +1,24 @@ +import java.lang.reflect.Modifier.isFinal + +object Test { + object InnerObject + final case class InnerCase() + final class InnerNonCase() + + def main(args: Array[String]) { + def checkFinal(clazz: Class[_]) = + println(s"${clazz} isFinal = ${isFinal(clazz.getModifiers())}") + + checkFinal(InnerObject.getClass) + checkFinal(classOf[InnerCase]) + checkFinal(classOf[InnerNonCase]) + + checkFinal(TopLevelObject.getClass) + checkFinal(classOf[TopLevelCase]) + checkFinal(classOf[TopLevelNonCase]) + } +} + +object TopLevelObject +final case class TopLevelCase() +final case class TopLevelNonCase() diff --git a/test/files/run/t7157.check b/test/files/run/t7157.check new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/test/files/run/t7157.check @@ -0,0 +1 @@ +1 diff --git a/test/files/run/t7157/Impls_Macros_1.scala b/test/files/run/t7157/Impls_Macros_1.scala new file mode 100644 index 0000000000..ad3d96eb85 --- /dev/null +++ b/test/files/run/t7157/Impls_Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Macros { + object AImpl { + def a(ctx: Context)(args: ctx.Expr[Any]*): ctx.Expr[Unit] = { + import ctx.universe._ + ctx.Expr[Unit](Apply(Ident(TermName("println")), List(Literal(Constant(1))))) + } + } + + implicit class A(context: StringContext) { + def a(args: Any*): Unit = macro AImpl.a + } +}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d1/Test_2.scala b/test/files/run/t7157/Test_2.scala index 7dffc5107d..cceb5ca177 100644 --- a/test/files/run/macro-def-path-dependent-d1/Test_2.scala +++ b/test/files/run/t7157/Test_2.scala @@ -1,3 +1,5 @@ +import Macros._ + object Test extends App { - println("it works") + a"" }
\ No newline at end of file diff --git a/test/files/run/t7171.check b/test/files/run/t7171.check new file mode 100644 index 0000000000..d826f6cb94 --- /dev/null +++ b/test/files/run/t7171.check @@ -0,0 +1,3 @@ +t7171.scala:2: warning: The outer reference in this type test cannot be checked at run time. + final case class A() + ^ diff --git a/test/files/run/t7171.flags b/test/files/run/t7171.flags new file mode 100644 index 0000000000..c02e5f2461 --- /dev/null +++ b/test/files/run/t7171.flags @@ -0,0 +1 @@ +-unchecked diff --git a/test/files/run/t7171.scala b/test/files/run/t7171.scala index 97585b9860..e0a1192228 100644 --- a/test/files/run/t7171.scala +++ b/test/files/run/t7171.scala @@ -16,7 +16,7 @@ object Test extends App { val a1 = new t1.A() val a2 = new t1.A() assert(t1.foo(a1)) - // as noted in the unchecked warning (tested in the corresponding neg test), + // as noted in the unchecked warning (also tested in the corresponding neg test), // the outer pointer isn't checked assert(t1.foo(a2)) } diff --git a/test/files/run/t7181.check b/test/files/run/t7181.check new file mode 100644 index 0000000000..e4b8e30dfe --- /dev/null +++ b/test/files/run/t7181.check @@ -0,0 +1,23 @@ +normal exit MainNormalExit +finally MainNormalExit +normal flow MainNormalExit + +return MainReturn +finally MainReturn + +uncaught exception MainUncaughtException +finally MainUncaughtException + +caught exception ExceptionNormalExit +normal exit ExceptionNormalExit +finally ExceptionNormalExit +normal flow ExceptionNormalExit + +caught exception ExceptionReturn +return ExceptionReturn +finally ExceptionReturn + +caught exception ExceptionUncaughtException +uncaught exception ExceptionUncaughtException +finally ExceptionUncaughtException + diff --git a/test/files/run/t7181.scala b/test/files/run/t7181.scala new file mode 100644 index 0000000000..489ec313f6 --- /dev/null +++ b/test/files/run/t7181.scala @@ -0,0 +1,78 @@ +sealed abstract class Action +// exit the try body normally +case object MainNormalExit extends Action +// exit the try body with a 'return' +case object MainReturn extends Action +// exit the try body with an uncaught exception +case object MainUncaughtException extends Action +// exit the try body with a caught exception and exit the exception handler normally +case object ExceptionNormalExit extends Action +// exit the try body with a caught exception and exit the exception handler with a 'return' +case object ExceptionReturn extends Action +// exit the try body with a caught exception and exit the exception handler with an uncaught exception +case object ExceptionUncaughtException extends Action + +case class UncaughtException(action: Action) extends RuntimeException +case class CaughtException(action: Action) extends RuntimeException + +object Test extends App { + def test(action: Action, expectException: Boolean = false) { + var gotException = false + val result = try + driver(action) + catch { + case UncaughtException(a) => + gotException = true + a + } + if (gotException) assert(expectException, "Got unexpected exception") + else assert(!expectException, "Did not get expected exception") + + assert(result == action, s"Expected $action but got $result") + println() + } + + def driver(action: Action): Action = { + val result = try { + action match { + case MainNormalExit => + println(s"normal exit $action") + action + case MainReturn => + println(s"return $action") + return action + case MainUncaughtException => + println(s"uncaught exception $action") + throw UncaughtException(action) + case _ => + println(s"caught exception $action") + throw CaughtException(action) + } + } catch { + case CaughtException(action) => action match { + case ExceptionNormalExit => + println(s"normal exit $action") + action + case ExceptionReturn => + println(s"return $action") + return action + case ExceptionUncaughtException => + println(s"uncaught exception $action") + throw UncaughtException(action) + case _ => + sys.error(s"unexpected $action in exception handler") + } + } finally { + println(s"finally $action") + } + println(s"normal flow $action") + result + } + + test(MainNormalExit) + test(MainReturn) + test(MainUncaughtException, true) + test(ExceptionNormalExit) + test(ExceptionReturn) + test(ExceptionUncaughtException, true) +} diff --git a/test/files/run/t7185.check b/test/files/run/t7185.check index 455c1aa3b7..38449b3497 100644 --- a/test/files/run/t7185.check +++ b/test/files/run/t7185.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> import scala.tools.reflect.ToolBox import scala.tools.reflect.ToolBox @@ -10,13 +8,13 @@ scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ scala> object O { def apply() = 0 } -defined module O +defined object O scala> val ORef = reify { O }.tree ORef: reflect.runtime.universe.Tree = $read.O scala> val tree = Apply(Block(Nil, Block(Nil, ORef)), Nil) -tree: reflect.runtime.universe.Apply = +tree: reflect.runtime.universe.Apply = { { $read.O @@ -24,7 +22,7 @@ tree: reflect.runtime.universe.Apply = }() scala> {val tb = reflect.runtime.currentMirror.mkToolBox(); tb.typeCheck(tree): Any} -res0: Any = +res0: Any = { { $read.O.apply() diff --git a/test/files/run/t7198.check b/test/files/run/t7198.check new file mode 100644 index 0000000000..6dad496f49 --- /dev/null +++ b/test/files/run/t7198.check @@ -0,0 +1,2 @@ +The quick brown fox jumped +And ran away with the vixen. diff --git a/test/files/run/t7198.scala b/test/files/run/t7198.scala new file mode 100644 index 0000000000..26e1d8805a --- /dev/null +++ b/test/files/run/t7198.scala @@ -0,0 +1,9 @@ +/* spew a few lines + * filter: Over the moon + */ +object Test extends App { + Console println "The quick brown fox jumped" + Console println "Over the moon" + Console println "And ran away with the vixen." + Console println "Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 28)." +} diff --git a/test/files/run/t7214.scala b/test/files/run/t7214.scala index ff1ea8082d..15c2c24fa0 100644 --- a/test/files/run/t7214.scala +++ b/test/files/run/t7214.scala @@ -25,7 +25,7 @@ class Crash { def unapply(a: Alias): Option[Any] = None } (t: Any) match { - case Extractor() => + case Extractor(_) => case _ => } diff --git a/test/files/run/t7223.check b/test/files/run/t7223.check new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/test/files/run/t7223.check @@ -0,0 +1 @@ +0 diff --git a/test/files/run/t7223.scala b/test/files/run/t7223.scala new file mode 100644 index 0000000000..a707e957df --- /dev/null +++ b/test/files/run/t7223.scala @@ -0,0 +1,11 @@ +class D(val a: () => Int => () => Any) { + a()(0)() +} + +object Crash extends D(() => { + (x: Int) => {() => { new { println(x.toString) } }} +}) + +object Test extends App { + Crash +} diff --git a/test/files/jvm/backendBugUnapply.check b/test/files/run/t7231.check index 9d1e7b29c2..c1e4b6c175 100644 --- a/test/files/jvm/backendBugUnapply.check +++ b/test/files/run/t7231.check @@ -1,2 +1,2 @@ -baz +null null diff --git a/test/files/run/t7231.scala b/test/files/run/t7231.scala new file mode 100644 index 0000000000..7d6bc81f3f --- /dev/null +++ b/test/files/run/t7231.scala @@ -0,0 +1,11 @@ +object Test extends App { + val bar: Null = null + + def foo(x: Array[Int]) = x + def baz(x: String) = x + + // first line was failing + println(foo(bar)) + // this line worked but good to have a double check + println(baz(bar)) +}
\ No newline at end of file diff --git a/test/files/run/t7240/Test_2.scala b/test/files/run/t7240/Test_2.scala index 2450bdabf9..5cc2cc7f78 100644 --- a/test/files/run/t7240/Test_2.scala +++ b/test/files/run/t7240/Test_2.scala @@ -1,3 +1,3 @@ object Test extends App { - bakery.Bakery.failure -}
\ No newline at end of file + val v = bakery.Bakery.failure +} diff --git a/test/files/run/t7265.scala b/test/files/run/t7265.scala deleted file mode 100644 index c556930303..0000000000 --- a/test/files/run/t7265.scala +++ /dev/null @@ -1,27 +0,0 @@ - -import scala.util.Properties._ - -object Test extends App { - - setProp("java.specification.version", "1.7") - - assert( isJavaAtLeast("1.5")) - assert( isJavaAtLeast("1.6")) - assert( isJavaAtLeast("1.7")) - assert(!isJavaAtLeast("1.8")) - assert(!isJavaAtLeast("1.71")) - - failing(isJavaAtLeast("1.a")) - failing(isJavaAtLeast("1")) - failing(isJavaAtLeast("")) - failing(isJavaAtLeast(".")) - failing(isJavaAtLeast(".5")) - failing(isJavaAtLeast("1.7.1")) - - def failing(u: =>Unit) = try { - u - assert(false, "Expected Exception") - } catch { - case _: NumberFormatException => - } -} diff --git a/test/files/run/t7271.check b/test/files/run/t7271.check index dcd828a307..f7a23018ca 100644 --- a/test/files/run/t7271.check +++ b/test/files/run/t7271.check @@ -1,12 +1,12 @@ [[syntax trees at end of parser]] // newSource1.scala -[0:91]package [0:0]<empty> { - [0:91]class C extends [8:91][91]scala.AnyRef { +[6]package [6]<empty> { + [6]class C extends [8][91]scala.AnyRef { [8]def <init>() = [8]{ - [8][8][8]super.<init>(); + [NoPosition][NoPosition][NoPosition]super.<init>(); [8]() }; - [16:44]def quote = [28:44]<28:44><28:44>[28]StringContext([30:34]"foo", [40:44]"baz").s([35:39]this); - [51:85]def tripleQuote = [69:85]<69:85><69:85>[69]StringContext([71:75]"foo", [81:85]"baz").s([76:80]this) + [20]def quote = [28][28][28][28]StringContext([30]"foo", [40]"baz").s([35]this); + [55]def tripleQuote = [69][69][69][69]StringContext([71]"foo", [81]"baz").s([76]this) } } diff --git a/test/files/run/t7271.scala b/test/files/run/t7271.scala index 6fccf14d20..69d5ea377e 100644 --- a/test/files/run/t7271.scala +++ b/test/files/run/t7271.scala @@ -1,9 +1,9 @@ import scala.tools.partest._ -import java.io._ import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser +import scala.tools.cmd.CommandLineParser import scala.tools.nsc.{Global, Settings, CompilerCommand} import scala.tools.nsc.reporters.ConsoleReporter +import scala.reflect.internal.Positions object Test extends DirectTest { @@ -29,6 +29,6 @@ object Test extends DirectTest { val settings = new Settings() settings.Xprintpos.value = true val command = new CompilerCommand((CommandLineParser tokenize extraSettings) ++ args.toList, settings) - new Global(command.settings, new ConsoleReporter(settings)) with interactive.RangePositions + new Global(command.settings, new ConsoleReporter(settings)) with Positions } } diff --git a/test/files/run/t7290.check b/test/files/run/t7290.check new file mode 100644 index 0000000000..aff48abd4a --- /dev/null +++ b/test/files/run/t7290.check @@ -0,0 +1,6 @@ +t7290.scala:4: warning: Pattern contains duplicate alternatives: 0 + case 0 | 0 => 0 + ^ +t7290.scala:5: warning: Pattern contains duplicate alternatives: 2, 3 + case 2 | 2 | 2 | 3 | 2 | 3 => 0 + ^ diff --git a/test/files/run/t7291b.check b/test/files/run/t7291.check index c07ba986a3..c07ba986a3 100644 --- a/test/files/run/t7291b.check +++ b/test/files/run/t7291.check diff --git a/test/files/run/t7291a.scala b/test/files/run/t7291.scala index 4b7c4a4184..ca44e96693 100644 --- a/test/files/run/t7291a.scala +++ b/test/files/run/t7291.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds, implicitConversions } + trait Fooable[T] object Fooable { implicit def conjure[T]: Fooable[T] = { diff --git a/test/files/run/t7291a.check b/test/files/run/t7291a.check deleted file mode 100644 index 126faa15b4..0000000000 --- a/test/files/run/t7291a.check +++ /dev/null @@ -1 +0,0 @@ -conjure diff --git a/test/files/run/t7291b.flags b/test/files/run/t7291b.flags deleted file mode 100644 index d564f2b1f8..0000000000 --- a/test/files/run/t7291b.flags +++ /dev/null @@ -1 +0,0 @@ --Xdivergence211
\ No newline at end of file diff --git a/test/files/run/t7291b.scala b/test/files/run/t7291b.scala deleted file mode 100644 index 30c4261a81..0000000000 --- a/test/files/run/t7291b.scala +++ /dev/null @@ -1,19 +0,0 @@ -trait Fooable[T] -object Fooable { - implicit def conjure[T]: Fooable[T] = { - println("conjure") - new Fooable[T]{} - } - -} - -object Test { - implicit def traversable[T, Coll[_] <: Traversable[_]](implicit -elem: Fooable[T]): Fooable[Coll[T]] = { - println("traversable") - new Fooable[Coll[T]]{} - } - def main(args: Array[String]) { - implicitly[Fooable[List[Any]]] - } -} diff --git a/test/files/run/t7064-old-style-supercalls.check b/test/files/run/t7300.check index 0cfbf08886..51993f072d 100644 --- a/test/files/run/t7064-old-style-supercalls.check +++ b/test/files/run/t7300.check @@ -1 +1,2 @@ 2 +2 diff --git a/test/files/run/t7300.scala b/test/files/run/t7300.scala new file mode 100644 index 0000000000..ec841690df --- /dev/null +++ b/test/files/run/t7300.scala @@ -0,0 +1,11 @@ +object Test extends App { + // single line comment in multi line comment + /*//*/ val x = 1 */*/ + val x = 2 + println(x) + + // single line comment in nested multi line comment + /*/*//*/ val y = 1 */*/*/ + val y = 2 + println(y) +} diff --git a/test/files/run/t7319.check b/test/files/run/t7319.check index 966736915e..d03ee3a6cf 100644 --- a/test/files/run/t7319.check +++ b/test/files/run/t7319.check @@ -1,8 +1,6 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> - scala> class M[A] defined class M @@ -32,7 +30,14 @@ argument expression's type is not compatible with formal parameter type; convert(Some[Int](0)) ^ +scala> Range(1,2).toArray: Seq[_] +<console>:11: error: polymorphic expression cannot be instantiated to expected type; + found : [B >: Int]Array[B] + required: Seq[_] + Range(1,2).toArray: Seq[_] + ^ + scala> 0 -res1: Int = 0 +res2: Int = 0 scala> diff --git a/test/files/run/t7319.scala b/test/files/run/t7319.scala index 23ffeb977d..65a3ed922d 100644 --- a/test/files/run/t7319.scala +++ b/test/files/run/t7319.scala @@ -9,5 +9,6 @@ implicit def ma0[A](a: A): M[A] = null implicit def ma1[A](a: A): M[A] = null def convert[F[X <: F[X]]](builder: F[_ <: F[_]]) = 0 convert(Some[Int](0)) +Range(1,2).toArray: Seq[_] 0""" // before the fix, this line, and all that followed, re-issued the implicit ambiguity error. } diff --git a/test/files/run/t7331b.check b/test/files/run/t7331b.check index 7034a95a3f..413c93aaf7 100644 --- a/test/files/run/t7331b.check +++ b/test/files/run/t7331b.check @@ -1,3 +1,3 @@ -reflective compilation has failed: +reflective compilation has failed: ')' expected but eof found. diff --git a/test/files/run/t7331c.check b/test/files/run/t7331c.check index af9f1b1ad9..fd3ac1d9ef 100644 --- a/test/files/run/t7331c.check +++ b/test/files/run/t7331c.check @@ -1,3 +1,3 @@ -ClassDef(Modifiers(), newTypeName("C"), List(), Template(List(Select(Ident(scala), newTypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(()))))))) +ClassDef(Modifiers(), TypeName("C"), List(), Template(List(Select(Ident(scala), TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(()))))))) source-<toolbox>,line-1,offset=6 NoPosition diff --git a/test/files/run/t7336.scala b/test/files/run/t7336.scala index ace83f2c1f..21b0be5446 100644 --- a/test/files/run/t7336.scala +++ b/test/files/run/t7336.scala @@ -9,7 +9,7 @@ import scala.concurrent.duration.Duration * resulting in a speedy OutOfMemoryError. Now, each array should be freed soon * after it is created and the test should complete without problems. */ -object Test { +object Test { def main(args: Array[String]) { def loop(i: Int, arraySize: Int): Future[Unit] = { val array = new Array[Byte](arraySize) diff --git a/test/files/run/t7337.check b/test/files/run/t7337.check new file mode 100644 index 0000000000..dd2b31f23c --- /dev/null +++ b/test/files/run/t7337.check @@ -0,0 +1 @@ +doesnotexist does not exist or is not a directory diff --git a/test/files/run/t7337.scala b/test/files/run/t7337.scala new file mode 100644 index 0000000000..9913f8ae45 --- /dev/null +++ b/test/files/run/t7337.scala @@ -0,0 +1,19 @@ +import scala.tools.partest._ +import scala.tools.nsc._ +import scala.tools.cmd.CommandLineParser + +object Test extends DirectTest { + override def code = "class C" + override def newCompiler(args: String*): Global = { + val settings = newSettings((CommandLineParser tokenize ("-d doesnotexist " + extraSettings)) ++ args.toList) + newCompiler(settings) + } + + override def show() { + try { + newCompiler() + } catch { + case fe: FatalError => println(fe.getMessage) + } + } +} diff --git a/test/files/run/t7341.scala b/test/files/run/t7341.scala index dc526c6c19..ffea7f918b 100755 --- a/test/files/run/t7341.scala +++ b/test/files/run/t7341.scala @@ -4,7 +4,7 @@ object Obj { def foo { returning(() => cache = ()) } - + def apply(): Any = { cache } diff --git a/test/files/run/t7407.check b/test/files/run/t7407.check new file mode 100644 index 0000000000..e965047ad7 --- /dev/null +++ b/test/files/run/t7407.check @@ -0,0 +1 @@ +Hello diff --git a/test/files/run/t7407.flags b/test/files/run/t7407.flags new file mode 100644 index 0000000000..c8547a27dc --- /dev/null +++ b/test/files/run/t7407.flags @@ -0,0 +1 @@ +-Ynooptimise -Ybackend:GenBCode diff --git a/test/files/run/t7407.scala b/test/files/run/t7407.scala new file mode 100644 index 0000000000..cf67602126 --- /dev/null +++ b/test/files/run/t7407.scala @@ -0,0 +1,11 @@ +// SI-7407 +object Test { + + def main(args: Array[String]) { println(foo) } + + def foo: String = { + try return "Hello" finally 10 match {case x => ()} + } + +} + diff --git a/test/files/run/t7407b.check b/test/files/run/t7407b.check new file mode 100644 index 0000000000..f30294447b --- /dev/null +++ b/test/files/run/t7407b.check @@ -0,0 +1,2 @@ +Hello +abc diff --git a/test/files/run/t7407b.flags b/test/files/run/t7407b.flags new file mode 100644 index 0000000000..c8547a27dc --- /dev/null +++ b/test/files/run/t7407b.flags @@ -0,0 +1 @@ +-Ynooptimise -Ybackend:GenBCode diff --git a/test/files/run/t7407b.scala b/test/files/run/t7407b.scala new file mode 100644 index 0000000000..b0c00878b5 --- /dev/null +++ b/test/files/run/t7407b.scala @@ -0,0 +1,20 @@ +object Test { + + def main(args: Array[String]) { + println(foo(true)) + println(foo(false)) + } + + def foo(b: Boolean): String = { + try { + if(b) + return "Hello" + else + "abc" + } finally { + 10 match {case x => ()} + } + } + +} + diff --git a/test/files/run/t7436.scala b/test/files/run/t7436.scala new file mode 100644 index 0000000000..867a931e05 --- /dev/null +++ b/test/files/run/t7436.scala @@ -0,0 +1,9 @@ +class A(val p: Int*) + +class B(val p1: Int) extends A(p1) + +object Test { + def main(args: Array[String]) { + new B(1).p1 // threw java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofInt cannot be cast to java.lang.Integer + } +} diff --git a/test/files/run/t7439.check b/test/files/run/t7439.check new file mode 100644 index 0000000000..9ea09f9c40 --- /dev/null +++ b/test/files/run/t7439.check @@ -0,0 +1,2 @@ +Recompiling after deleting t7439-run.obj/A_1.class +pos: NoPosition Class A_1 not found - continuing with a stub. WARNING diff --git a/test/files/run/t7439/A_1.java b/test/files/run/t7439/A_1.java new file mode 100644 index 0000000000..4accd95d57 --- /dev/null +++ b/test/files/run/t7439/A_1.java @@ -0,0 +1,3 @@ +public class A_1 { + +}
\ No newline at end of file diff --git a/test/files/run/t7439/B_1.java b/test/files/run/t7439/B_1.java new file mode 100644 index 0000000000..5dd3b93d6f --- /dev/null +++ b/test/files/run/t7439/B_1.java @@ -0,0 +1,3 @@ +public class B_1 { + public void b(A_1[] a) {} +} diff --git a/test/files/run/t7439/Test_2.scala b/test/files/run/t7439/Test_2.scala new file mode 100644 index 0000000000..ce9b907145 --- /dev/null +++ b/test/files/run/t7439/Test_2.scala @@ -0,0 +1,33 @@ +import scala.tools.partest._ +import java.io.File + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def C = """ + class C { + new B_1 + } + """ + + def show(): Unit = { + //compileCode(C) + assert(filteredInfos.isEmpty, filteredInfos) + + // blow away the entire package + val a1Class = new File(testOutput.path, "A_1.class") + assert(a1Class.exists) + assert(a1Class.delete()) + // testIdent normalizes to separate names using '/' regardless of platform, drops all but last two parts + println(s"Recompiling after deleting ${a1Class.testIdent}") + + // bad symbolic reference error expected (but no stack trace!) + compileCode(C) + println(storeReporter.infos.mkString("\n")) // Included a NullPointerException before. + } +} diff --git a/test/files/run/t744.scala b/test/files/run/t744.scala index d5e9f6df34..4895e9baa0 100644 --- a/test/files/run/t744.scala +++ b/test/files/run/t744.scala @@ -5,7 +5,7 @@ trait Linked { } } object Test { - class Test extends Linked { + class Test extends Linked { trait FileImpl extends super.FileImpl { // val x: int = 1 } diff --git a/test/files/run/t7482a.check b/test/files/run/t7482a.check new file mode 100644 index 0000000000..943538f352 --- /dev/null +++ b/test/files/run/t7482a.check @@ -0,0 +1,10 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> val v: java.util.ArrayList[String] = new java.util.ArrayList[String](5) +v: java.util.ArrayList[String] = [] + +scala> val v: java.util.ArrayList[String] = new java.util.ArrayList[String](5) +v: java.util.ArrayList[String] = [] + +scala> diff --git a/test/files/run/t7482a.scala b/test/files/run/t7482a.scala new file mode 100644 index 0000000000..d674558b98 --- /dev/null +++ b/test/files/run/t7482a.scala @@ -0,0 +1,8 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def code = """ + val v: java.util.ArrayList[String] = new java.util.ArrayList[String](5) + val v: java.util.ArrayList[String] = new java.util.ArrayList[String](5) + """ +}
\ No newline at end of file diff --git a/test/files/run/t7569.check b/test/files/run/t7569.check index aade96d233..98513c3ab2 100644 --- a/test/files/run/t7569.check +++ b/test/files/run/t7569.check @@ -1,8 +1,8 @@ source-newSource1.scala,line-3,offset=49 A.this.one source-newSource1.scala,line-3,offset=49 A.this -source-newSource1.scala,line-2,offset=41 A.super.<init>() -source-newSource1.scala,line-2,offset=41 A.super.<init> -source-newSource1.scala,line-2,offset=41 this +source-newSource1.scala,line-4,offset=67 A.super.<init>() +source-newSource1.scala,line-4,offset=67 A.super.<init> +source-newSource1.scala,line-4,offset=67 this source-newSource1.scala,line-3,offset=49 A.this.one source-newSource1.scala,line-3,offset=49 A.this RangePosition(newSource1.scala, 55, 57, 65) scala.Int.box(1).toString() diff --git a/test/files/run/t7582-private-within.check b/test/files/run/t7582-private-within.check new file mode 100644 index 0000000000..b2743ffa06 --- /dev/null +++ b/test/files/run/t7582-private-within.check @@ -0,0 +1,12 @@ +private[package pack] class JavaPackagePrivate +private[package pack] module JavaPackagePrivate +private[package pack] module class JavaPackagePrivate +private[package pack] field field +private[package pack] primary constructor <init> +private[package pack] method meth +private[package pack] field staticField +private[package pack] method staticMeth +private[package pack] method <clinit> +private[package pack] field staticField +private[package pack] method staticMeth +private[package pack] method <clinit> diff --git a/test/files/run/t7582-private-within/JavaPackagePrivate.java b/test/files/run/t7582-private-within/JavaPackagePrivate.java new file mode 100644 index 0000000000..672d19b57e --- /dev/null +++ b/test/files/run/t7582-private-within/JavaPackagePrivate.java @@ -0,0 +1,8 @@ +package pack; + +class JavaPackagePrivate { + int field = 0; + static int staticField = 0; + void meth() { } + static void staticMeth() { } +} diff --git a/test/files/run/t7582-private-within/Test.scala b/test/files/run/t7582-private-within/Test.scala new file mode 100644 index 0000000000..3d581f063b --- /dev/null +++ b/test/files/run/t7582-private-within/Test.scala @@ -0,0 +1,22 @@ +import scala.tools.partest.DirectTest + +// Testing that the `privateWithin` field is correctly populated on all +// the related symbols (e.g. module class) under separate compilation. +object Test extends DirectTest { + def code = ??? + + def show(): Unit = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + val global = newCompiler("-usejavacp", "-cp", classpath, "-d", testOutput.path) + import global._ + withRun(global) { _ => + def check(sym: Symbol) = { + sym.initialize + println(f"${sym.accessString}%12s ${sym.accurateKindString} ${sym.name.decode}") // we want to see private[pack] for all of these. + } + val sym = rootMirror.getRequiredClass("pack.JavaPackagePrivate") + val syms = Seq(sym, sym.companionModule, sym.companionModule.moduleClass) + (syms ++ syms.flatMap(_.info.decls)).foreach(check) + } + } +} diff --git a/test/files/run/t7582.check b/test/files/run/t7582.check new file mode 100644 index 0000000000..225fb1ace8 --- /dev/null +++ b/test/files/run/t7582.check @@ -0,0 +1,2 @@ +warning: there were 1 inliner warning(s); re-run with -Yinline-warnings for details +2 diff --git a/test/files/run/t7582.flags b/test/files/run/t7582.flags new file mode 100644 index 0000000000..1182725e86 --- /dev/null +++ b/test/files/run/t7582.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/test/files/run/t7582/InlineHolder.scala b/test/files/run/t7582/InlineHolder.scala new file mode 100644 index 0000000000..a18b9effaa --- /dev/null +++ b/test/files/run/t7582/InlineHolder.scala @@ -0,0 +1,16 @@ +package p1 { + object InlineHolder { + @inline def inlinable = p1.PackageProtectedJava.protectedMethod() + 1 + } +} + +object O { + @noinline + def x = p1.InlineHolder.inlinable +} + +object Test { + def main(args: Array[String]) { + println(O.x) + } +} diff --git a/test/files/run/t7582/PackageProtectedJava.java b/test/files/run/t7582/PackageProtectedJava.java new file mode 100644 index 0000000000..b7ea2a7676 --- /dev/null +++ b/test/files/run/t7582/PackageProtectedJava.java @@ -0,0 +1,6 @@ +package p1; + +// public class, protected method +public class PackageProtectedJava { + static final int protectedMethod() { return 1; } +} diff --git a/test/files/run/t7582b.check b/test/files/run/t7582b.check new file mode 100644 index 0000000000..225fb1ace8 --- /dev/null +++ b/test/files/run/t7582b.check @@ -0,0 +1,2 @@ +warning: there were 1 inliner warning(s); re-run with -Yinline-warnings for details +2 diff --git a/test/files/run/t7582b.flags b/test/files/run/t7582b.flags new file mode 100644 index 0000000000..1182725e86 --- /dev/null +++ b/test/files/run/t7582b.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/test/files/run/t7582b/InlineHolder.scala b/test/files/run/t7582b/InlineHolder.scala new file mode 100644 index 0000000000..a18b9effaa --- /dev/null +++ b/test/files/run/t7582b/InlineHolder.scala @@ -0,0 +1,16 @@ +package p1 { + object InlineHolder { + @inline def inlinable = p1.PackageProtectedJava.protectedMethod() + 1 + } +} + +object O { + @noinline + def x = p1.InlineHolder.inlinable +} + +object Test { + def main(args: Array[String]) { + println(O.x) + } +} diff --git a/test/files/run/t7582b/PackageProtectedJava.java b/test/files/run/t7582b/PackageProtectedJava.java new file mode 100644 index 0000000000..55a44b79f9 --- /dev/null +++ b/test/files/run/t7582b/PackageProtectedJava.java @@ -0,0 +1,6 @@ +package p1; + +// protected class, public method +class PackageProtectedJava { + public static final int protectedMethod() { return 1; } +} diff --git a/test/files/run/t7584.check b/test/files/run/t7584.check new file mode 100644 index 0000000000..9f53e5dde5 --- /dev/null +++ b/test/files/run/t7584.check @@ -0,0 +1,6 @@ +no calls +call A +a +call B twice +b +b diff --git a/test/files/run/t7584.flags b/test/files/run/t7584.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/run/t7584.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/run/t7584.scala b/test/files/run/t7584.scala new file mode 100644 index 0000000000..6d7f4f7ebb --- /dev/null +++ b/test/files/run/t7584.scala @@ -0,0 +1,14 @@ +// Test case added to show the behaviour of functions with +// by-name parameters. The evaluation behaviour was already correct. +// +// We did flush out a spurious "pure expression does nothing in statement position" +// warning, hence -Xfatal-warnings in the flags file. +object Test extends App { + def foo(f: (=> Int, => Int) => Unit) = f({println("a"); 0}, {println("b"); 1}) + println("no calls") + foo((a, b) => ()) + println("call A") + foo((a, b) => a) + println("call B twice") + foo((a, b) => {b; b}) +} diff --git a/test/files/run/t7715.check b/test/files/run/t7715.check new file mode 100644 index 0000000000..592d7fe2ea --- /dev/null +++ b/test/files/run/t7715.check @@ -0,0 +1,3 @@ +6 +4 +4 diff --git a/test/files/run/t7715.scala b/test/files/run/t7715.scala new file mode 100644 index 0000000000..0ad3913016 --- /dev/null +++ b/test/files/run/t7715.scala @@ -0,0 +1,24 @@ + +import PartialFunction.cond +import util._ + +object Test extends App { + + object I { def unapply(x: String): Option[Int] = Try(x.toInt).toOption } + implicit class RX(val sc: StringContext) { + def rx = sc.parts.mkString("(.+)").r + } + + Console println ("2 by 4" match { + case rx"${I(a)} by ${I(b)}" => a+b + case _ => -1 + }) + Console println ("2 by 4" match { + case rx"${_} by ${I(b)}" => b // pattern placeholder + case _ => -1 + }) + Console println ("2 by 4" match { + case rx"$_ by ${I(b)}" => b // is permitted this way, too + case _ => -1 + }) +} diff --git a/test/files/run/t7763.scala b/test/files/run/t7763.scala new file mode 100644 index 0000000000..638077e64a --- /dev/null +++ b/test/files/run/t7763.scala @@ -0,0 +1,20 @@ +object Test { + class A; class B + def main(args: Array[String]) { + def noExpectedType() { + a().asInstanceOf[B] // cast elided! + } + def withExpectedType(): B = { + a().asInstanceOf[B] + } + def test(a: => Any) = try { + a + sys.error("no CCE!") + } catch {case _: ClassCastException => } + + test(noExpectedType()) + test(withExpectedType()) + } + + def a(): Object = new A +} diff --git a/test/files/run/t7791-script-linenums.check b/test/files/run/t7791-script-linenums.check new file mode 100644 index 0000000000..b7d969564a --- /dev/null +++ b/test/files/run/t7791-script-linenums.check @@ -0,0 +1 @@ +hello, scripted test diff --git a/test/files/run/t7791-script-linenums.scala b/test/files/run/t7791-script-linenums.scala new file mode 100644 index 0000000000..d89b8d4c63 --- /dev/null +++ b/test/files/run/t7791-script-linenums.scala @@ -0,0 +1,16 @@ + +import scala.tools.partest.ScriptTest + +object Test extends ScriptTest { + object ExceptionLine { + def unapply(e: Exception) = Some(e.getStackTrace()(0).getLineNumber) + } + override def show() = { + import util._ + Try(super.show()) match { + case Failure(ExceptionLine(7)) => () + case Failure(e) => e.printStackTrace() + case Success(_) => Console println "Expected error" + } + } +} diff --git a/test/files/run/t7791-script-linenums.script b/test/files/run/t7791-script-linenums.script new file mode 100644 index 0000000000..403dcc2d28 --- /dev/null +++ b/test/files/run/t7791-script-linenums.script @@ -0,0 +1,8 @@ +#!/bin/bash +exec ${SCALA_HOME}/bin/scala "$0" "$@" 2>&1 +!# + +Console println s"hello, scripted test" + +throw new RuntimeException("failing") // line 7 + diff --git a/test/files/run/t7801.check b/test/files/run/t7801.check new file mode 100644 index 0000000000..d72060c684 --- /dev/null +++ b/test/files/run/t7801.check @@ -0,0 +1,11 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> val g: scala.reflect.internal.SymbolTable = null; import g.abort +g: scala.reflect.internal.SymbolTable = null +import g.abort + +scala> class C(val a: Any) extends AnyVal +defined class C + +scala> diff --git a/test/files/run/t7801.scala b/test/files/run/t7801.scala new file mode 100644 index 0000000000..3a3cc97a51 --- /dev/null +++ b/test/files/run/t7801.scala @@ -0,0 +1,12 @@ +import scala.tools.partest.ReplTest + +// was crashing due to a subtle interaction of the Namer entering packages into +// enclosing packages by mutating the scope in place without invalidating later +// entries in the enclosing package class symbols type history. +// +// Sadly, I couldn't whittle the test case down further. +object Test extends ReplTest { + override def code = """val g: scala.reflect.internal.SymbolTable = null; import g.abort + |class C(val a: Any) extends AnyVal""".stripMargin + +} diff --git a/test/files/run/t7805-repl-i.check b/test/files/run/t7805-repl-i.check new file mode 100644 index 0000000000..eecfff079a --- /dev/null +++ b/test/files/run/t7805-repl-i.check @@ -0,0 +1,11 @@ +Loading t7805-repl-i.script... +import util._ + +Welcome to Scala +Type in expressions to have them evaluated. +Type :help for more information. + +scala> Console println Try(8) +Success(8) + +scala> diff --git a/test/files/run/t7805-repl-i.scala b/test/files/run/t7805-repl-i.scala new file mode 100644 index 0000000000..bb5203951e --- /dev/null +++ b/test/files/run/t7805-repl-i.scala @@ -0,0 +1,42 @@ + +import scala.tools.partest.{ ReplTest, Welcoming } +import scala.tools.nsc.{ GenericRunnerSettings, Settings } +import scala.tools.nsc.settings.MutableSettings + +object Test extends ReplTest with HangingRepl with Welcoming { + def script = testPath changeExtension "script" + override def transformSettings(s: Settings) = s match { + case m: MutableSettings => + val t = new GenericRunnerSettings(s.errorFn) + m copyInto t + t processArgumentString s"-i $script" + t + case _ => s + } + def code = "Console println Try(8)" +} + +object Resulting { + import scala.concurrent._ + import scala.concurrent.duration._ + implicit class AwaitResult[A](val f: Future[A]) extends AnyVal { + def resultWithin(d: Duration): A = Await.result(f, d) + } +} + +/** Test that hangs the REPL. + * Usually that is the "before" case. + */ +trait HangingRepl extends ReplTest { + import scala.language.postfixOps + import scala.util._ + import scala.concurrent._ + import scala.concurrent.duration._ + import ExecutionContext.Implicits._ + import Resulting._ + def timeout = 120 seconds + def hanging[A](a: =>A): A = future(a) resultWithin timeout + override def show() = Try(hanging(super.show())) recover { + case e => e.printStackTrace() + } +} diff --git a/test/files/run/t7805-repl-i.script b/test/files/run/t7805-repl-i.script new file mode 100644 index 0000000000..eb2b8705f3 --- /dev/null +++ b/test/files/run/t7805-repl-i.script @@ -0,0 +1 @@ +import util._ diff --git a/test/files/run/t7817-tree-gen.check b/test/files/run/t7817-tree-gen.check new file mode 100644 index 0000000000..4ed4b0d94a --- /dev/null +++ b/test/files/run/t7817-tree-gen.check @@ -0,0 +1,104 @@ + + +Joint Compilation: + + typer [ O] - O.this + pickler [ O] - O.this + refchecks [ O] - O.this + uncurry [ O] - O.this + specialize [ O] - O.this + explicitouter [ O] - O.this + erasure [ O] - O.this + posterasure [ O] - C.this.O() + flatten [ O] - C.this.O() + mixin [ O] - test.O() + cleanup [ O] - test.O() + + typer [ P] - P.this + pickler [ P] - P.this + refchecks [ P] - P.this + uncurry [ P] - P.this + specialize [ P] - P.this + explicitouter [ P] - P.this + erasure [ P] - P.this + posterasure [ P] - D.this.P() + flatten [ P] - D.this.P() + mixin [ P] - P() + cleanup [ P] - P() + + typer [ test2.PO] - PO.this + pickler [ test2.PO] - PO.this + refchecks [ test2.PO] - PO.this + uncurry [ test2.PO] - PO.this + specialize [ test2.PO] - PO.this + explicitouter [ test2.PO] - PO.this + erasure [ test2.PO] - PO.this + posterasure [ test2.PO] - test2.`package`.PO + flatten [ test2.PO] - test2.`package`.PO + mixin [ test2.PO] - test2.package$PO + cleanup [ test2.PO] - test2.package$PO + + typer [ test2.bar] - `package`.this.bar + pickler [ test2.bar] - `package`.this.bar + refchecks [ test2.bar] - `package`.this.bar + uncurry [ test2.bar] - `package`.this.bar + specialize [ test2.bar] - `package`.this.bar + explicitouter [ test2.bar] - `package`.this.bar + erasure [ test2.bar] - `package`.this.bar + posterasure [ test2.bar] - test2.`package`.bar + flatten [ test2.bar] - test2.`package`.bar + mixin [ test2.bar] - test2.`package`.bar + cleanup [ test2.bar] - test2.`package`.bar + + + +Separate Compilation: + + typer [ O] - O.this + pickler [ O] - O.this + refchecks [ O] - O.this + uncurry [ O] - O.this + specialize [ O] - O.this + explicitouter [ O] - O.this + erasure [ O] - O.this + posterasure [ O] - C.this.O() + flatten [ O] - C.this.O() + mixin [ O] - testSep.O() + cleanup [ O] - testSep.O() + + typer [ P] - P.this + pickler [ P] - P.this + refchecks [ P] - P.this + uncurry [ P] - P.this + specialize [ P] - P.this + explicitouter [ P] - P.this + erasure [ P] - P.this + posterasure [ P] - DSep.this.P() + flatten [ P] - DSep.this.P() + mixin [ P] - P() + cleanup [ P] - P() + + typer [ PO] - PO.this + pickler [ PO] - PO.this + refchecks [ PO] - PO.this + uncurry [ PO] - PO.this + specialize [ PO] - PO.this + explicitouter [ PO] - PO.this + erasure [ PO] - PO.this + posterasure [ PO] - test2.`package`.PO + flatten [ PO] - test2.`package`.PO + mixin [ PO] - test2.package$PO + cleanup [ PO] - test2.package$PO + + typer [testSep2.bar] - `package`.this.bar + pickler [testSep2.bar] - `package`.this.bar + refchecks [testSep2.bar] - `package`.this.bar + uncurry [testSep2.bar] - `package`.this.bar + specialize [testSep2.bar] - `package`.this.bar + explicitouter [testSep2.bar] - `package`.this.bar + erasure [testSep2.bar] - `package`.this.bar + posterasure [testSep2.bar] - test2.`package`.bar + flatten [testSep2.bar] - test2.`package`.bar + mixin [testSep2.bar] - test2.`package`.bar + cleanup [testSep2.bar] - test2.`package`.bar + diff --git a/test/files/run/t7817-tree-gen.flags b/test/files/run/t7817-tree-gen.flags new file mode 100644 index 0000000000..ce6e93b3da --- /dev/null +++ b/test/files/run/t7817-tree-gen.flags @@ -0,0 +1 @@ +-Ynooptimise
\ No newline at end of file diff --git a/test/files/run/t7817-tree-gen.scala b/test/files/run/t7817-tree-gen.scala new file mode 100644 index 0000000000..a8317fda6e --- /dev/null +++ b/test/files/run/t7817-tree-gen.scala @@ -0,0 +1,65 @@ +import scala.tools.partest._ + +// Testing that `mkAttributedRef` doesn't incude the package object test.`package`, +// under joint and separate compilation. + +package testSep { class C { object O } } +package testSep2 { object `package` { object PO; def bar = 0 } } +class DSep { object P } + +object Test extends CompilerTest { + import global._ + override def extraSettings = super.extraSettings + " -d " + testOutput.path + override def sources = List( + """ + package test { class C { object O } } + class D { object P } + package test2 { object `package` { object PO; def bar = 0 } } + """ + ) + def check(source: String, unit: CompilationUnit) = enteringTyper { + def checkTree(msg: String, t: => Tree) = { + val run = currentRun + import run._ + val phases = List(typerPhase, picklerPhase, refchecksPhase, uncurryPhase, specializePhase, + explicitouterPhase, erasurePhase, posterasurePhase, flattenPhase, mixinPhase, cleanupPhase) + for (phase <- phases) { + enteringPhase(phase) { + val error = t.exists(t => t.symbol == NoSymbol) + val errorStr = if (error) "!!!" else " - " + println(f"$phase%18s [$msg%12s] $errorStr $t") + } + } + println("") + } + import rootMirror._ + + println("\n\nJoint Compilation:\n") + + { + val c = staticClass("test.C") + val o = c.info.decl(TermName("O")) + checkTree("O", gen.mkAttributedQualifier(o.moduleClass.thisType)) + val d = staticClass("D") + val p = d.info.decl(TermName("P")) + checkTree("P", gen.mkAttributedQualifier(p.moduleClass.thisType)) + val po = staticModule("test2.package").moduleClass.info.decl(TermName("PO")) + checkTree("test2.PO", gen.mkAttributedQualifier(po.moduleClass.thisType)) + checkTree("test2.bar", gen.mkAttributedRef(po.owner.info.decl(TermName("bar")))) + } + + println("\n\nSeparate Compilation:\n") + + { + val c = typeOf[testSep.C].typeSymbol + val o = c.info.decl(TermName("O")) + checkTree("O", gen.mkAttributedQualifier(o.moduleClass.thisType)) + val d = staticClass("DSep") + val p = d.info.decl(TermName("P")) + checkTree("P", gen.mkAttributedQualifier(p.moduleClass.thisType)) + val po = staticModule("test2.package").moduleClass.info.decl(TermName("PO")) + checkTree("PO", gen.mkAttributedQualifier(po.moduleClass.thisType)) + checkTree("testSep2.bar", gen.mkAttributedRef(po.owner.info.decl(TermName("bar")))) + } + } +} diff --git a/test/files/run/t7817.scala b/test/files/run/t7817.scala new file mode 100644 index 0000000000..905b8aeb09 --- /dev/null +++ b/test/files/run/t7817.scala @@ -0,0 +1,31 @@ +import language.reflectiveCalls + +package test { + class C1 { + object O { + def struct(s: {def foo: Any}) = s.foo + } + } + trait T { + object O { + def struct(s: {def foo: Any}) = s.foo + } + } + object O1 extends T + + object O2 { + object O { + def struct(s: {def foo: Any}) = s.foo + } + } +} + +object Test extends App { + object fooable { def foo = "foo" } + def check(result: Any) = assert(result == "foo", result.toString) + + val s = new test.C1 + check(s.O.struct(fooable)) + check(test.O1.O.struct(fooable)) + check(test.O2.O.struct(fooable)) +} diff --git a/test/files/run/t7291a.flags b/test/files/run/t7852.check index e69de29bb2..e69de29bb2 100644 --- a/test/files/run/t7291a.flags +++ b/test/files/run/t7852.check diff --git a/test/files/run/t7852.flags b/test/files/run/t7852.flags new file mode 100644 index 0000000000..f6262fd3e0 --- /dev/null +++ b/test/files/run/t7852.flags @@ -0,0 +1 @@ +-Ynooptimise diff --git a/test/files/run/t7852.scala b/test/files/run/t7852.scala new file mode 100644 index 0000000000..c93db718fd --- /dev/null +++ b/test/files/run/t7852.scala @@ -0,0 +1,39 @@ +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import scala.tools.asm.util._ +import scala.tools.nsc.util.stringFromWriter +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + val nullChecks = Set(asm.Opcodes.IFNONNULL, asm.Opcodes.IFNULL) + + def show: Unit = { + def test(methodName: String, expected: Int) { + val classNode = loadClassNode("Lean") + val methodNode = getMethod(classNode, methodName) + val got = countNullChecks(methodNode.instructions) + assert(got == expected, s"expected $expected but got $got comparisons") + } + test("string", expected = 0) + test("module", expected = 0) + test("moduleIndirect", expected = 2) + } + + def countNullChecks(insnList: asm.tree.InsnList): Int = + insnList.iterator.asScala.map(_.getOpcode).count(nullChecks) +} + +class Lean { + def string { + "" == toString + } + + def module { + Nil == (toString: Any) + } + + def moduleIndirect { + val n: Nil.type = null + n == (toString: Any) // still need null checks here. + } +} diff --git a/test/files/run/t7868.scala b/test/files/run/t7868.scala new file mode 100644 index 0000000000..1f938adf31 --- /dev/null +++ b/test/files/run/t7868.scala @@ -0,0 +1,13 @@ +object A { + def unapply(n: Int): Option[Int] = Some(n) + + def run = (0: Short) match { + case A(_) => + case _ => + } +} + + +object Test extends App { + A.run +} diff --git a/test/files/run/t7868b.check b/test/files/run/t7868b.check new file mode 100644 index 0000000000..6577c4bc4e --- /dev/null +++ b/test/files/run/t7868b.check @@ -0,0 +1,6 @@ +Expr[Int]({ + val x = (0: Short): @unchecked match { + case A((x @ _)) => x + }; + x +}) diff --git a/test/files/run/t7868b.scala b/test/files/run/t7868b.scala new file mode 100644 index 0000000000..759eeaf862 --- /dev/null +++ b/test/files/run/t7868b.scala @@ -0,0 +1,11 @@ +object A { + def unapply(n: Int): Option[Int] = Some(1) +} + +object Test extends App { + import reflect.runtime.universe._ + println(reify { + val A(x) = (0: Short) + x + }) +} diff --git a/test/files/run/t7876.scala b/test/files/run/t7876.scala new file mode 100644 index 0000000000..aeec8c8cce --- /dev/null +++ b/test/files/run/t7876.scala @@ -0,0 +1,26 @@ +import scala.tools.partest._ + +// Type constructors for FunctionN and TupleN should not be considered as function type / tuple types. +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp" + + def code = "" + + def show() { + val global = newCompiler() + new global.Run() + import global._, definitions._ + val function0TC = FunctionClass(0).typeConstructor + val tuple1TC = TupleClass(1).typeConstructor + FunctionClass.seq.foreach { sym => + val tc = sym.typeConstructor + assert(!isFunctionType(tc), s"$tc") + assert(!isFunctionTypeDirect(tc), s"$tc (direct)") + } + TupleClass.seq.foreach { sym => + val tc = sym.typeConstructor + assert(!isTupleType(tc), s"$sym") + assert(!isTupleTypeDirect(tc), s"$tc (direct)") + } + } +} diff --git a/test/files/run/t874.scala b/test/files/run/t874.scala index 41d124f728..b077859ef3 100644 --- a/test/files/run/t874.scala +++ b/test/files/run/t874.scala @@ -1,3 +1,5 @@ + +import scala.language.{ reflectiveCalls } object Test { abstract class Base { val U: { @@ -5,7 +7,7 @@ object Test { } U("xyz")(2) } - class Mix extends Base { + class Mix extends Base { case class U[A](x1: A)(x2: Int) { Console.println("U created with "+x1+" and "+x2) } diff --git a/test/files/run/t920.scala b/test/files/run/t920.scala index 1e12e6ba87..6a7f122d55 100644 --- a/test/files/run/t920.scala +++ b/test/files/run/t920.scala @@ -7,7 +7,7 @@ object Test { trait Foo extends Test.Foo0 { def foo : B.this.type = B.this; } - class baz extends Baz with Foo { + class baz extends Baz with Foo { override def toString = "baz" } Console.println(new baz); diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check index f123bc8f25..7607921856 100644 --- a/test/files/run/tailcalls.check +++ b/test/files/run/tailcalls.check @@ -1,3 +1,4 @@ +#partest !avian test Object .f was successful test Final .f was successful test Class .f raised exception java.lang.StackOverflowError @@ -51,3 +52,57 @@ test TailCall.b2 was successful test FancyTailCalls.tcTryLocal was successful test FancyTailCalls.differentInstance was successful test PolyObject.tramp was successful +#partest avian +test Object .f was successful +test Final .f was successful +test Class .f was successful +test SubClass .f was successful +test Sealed .f was successful +test SubSealed.f was successful + +test O .f was successful +test c .f was successful +test O.O .f was successful +test O.c .f was successful +test c.O .f was successful +test c.c .f was successful +test O.O.O .f was successful +test O.O.c .f was successful +test O.c.O .f was successful +test O.c.c .f was successful +test c.O.O .f was successful +test c.O.c .f was successful +test c.c.O .f was successful +test c.c.c .f was successful +test O.O.O.O.f was successful +test O.O.O.c.f was successful +test O.O.c.O.f was successful +test O.O.c.c.f was successful +test O.c.O.O.f was successful +test O.c.O.c.f was successful +test O.c.c.O.f was successful +test O.c.c.c.f was successful +test c.O.O.O.f was successful +test c.O.O.c.f was successful +test c.O.c.O.f was successful +test c.O.c.c.f was successful +test c.c.O.O.f was successful +test c.c.O.c.f was successful +test c.c.c.O.f was successful +test c.c.c.c.f was successful + +test TailCall.f1 was successful +test TailCall.f2 was successful +test TailCall.f3 was successful +test TailCall.g1 was successful +test TailCall.g2 was successful +test TailCall.g3 was successful +test TailCall.h1 was successful + +test NonTailCall.f1 0 1 2 was successful +test NonTailCall.f2 +test TailCall.b1 was successful +test TailCall.b2 was successful +test FancyTailCalls.tcTryLocal was successful +test FancyTailCalls.differentInstance was successful +test PolyObject.tramp was successful diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala index 04a1a8ba19..e5d8891cc7 100644 --- a/test/files/run/tailcalls.scala +++ b/test/files/run/tailcalls.scala @@ -194,10 +194,10 @@ object FancyTailCalls { } object PolyObject extends App { - def tramp[A](x: Int): Int = + def tramp[A](x: Int): Int = if (x > 0) tramp[A](x - 1) - else + else 0 } @@ -233,7 +233,7 @@ class NonTailCall { if (n == 0) 0 else f2(n - 1) } - + } //############################################################################ @@ -273,7 +273,7 @@ object Test { } println } - + def check_overflow(name: String, closure: => Int) { print("test " + name) try { @@ -295,7 +295,7 @@ object Test { while (!stop) { try { calibrator.f(n, n); - if (n >= Int.MaxValue / 2) error("calibration failure"); + if (n >= Int.MaxValue / 2) sys.error("calibration failure"); n = 2 * n; } catch { case exception: compat.Platform.StackOverflowError => stop = true @@ -307,7 +307,7 @@ object Test { def main(args: Array[String]) { // compute min and max iteration number val min = 16; - val max = calibrate; + val max = if (scala.tools.partest.utils.Properties.isAvian) 10000 else calibrate // test tail calls in different contexts val Final = new Final() @@ -367,7 +367,7 @@ object Test { check_success("TailCall.g3", TailCall.g3(max, max, Nil), 0) check_success("TailCall.h1", TailCall.h1(max, max ), 0) println - + val NonTailCall = new NonTailCall check_success("NonTailCall.f1", NonTailCall.f1(2), 0) check_overflow("NonTailCall.f2", NonTailCall.f2(max)) @@ -382,17 +382,30 @@ object Test { } // testing explicit tailcalls. - + import scala.util.control.TailCalls._ def isEven(xs: List[Int]): TailRec[Boolean] = if (xs.isEmpty) done(true) else tailcall(isOdd(xs.tail)) def isOdd(xs: List[Int]): TailRec[Boolean] = - if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail)) + if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail)) + + def fib(n: Int): TailRec[Int] = + if (n < 2) done(n) else for { + x <- tailcall(fib(n - 1)) + y <- tailcall(fib(n - 2)) + } yield (x + y) + + def rec(n: Int): TailRec[Int] = + if (n == 1) done(n) else for { + x <- tailcall(rec(n - 1)) + } yield x assert(isEven((1 to 100000).toList).result) - + //assert(fib(40).result == 102334155) // Commented out, as it takes a long time + assert(rec(100000).result == 1) + } //############################################################################ diff --git a/test/files/run/takeAndDrop.scala b/test/files/run/takeAndDrop.scala index 6e87838e11..8d2dff0bfa 100644 --- a/test/files/run/takeAndDrop.scala +++ b/test/files/run/takeAndDrop.scala @@ -1,9 +1,9 @@ -object Test { +object Test { def main(args: Array[String]): Unit = { val range = 1 to 10 val target = (3 to 8).toList val confirm = (xs: Seq[Int]) => assert(xs.toList == target, xs) - + confirm(range drop 2 dropRight 2) confirm(range drop 1 dropRight 1 drop 1 dropRight 1) confirm(range take 8 drop 2) diff --git a/test/files/run/tcpoly_monads.scala b/test/files/run/tcpoly_monads.scala index cffbcc963b..978f889590 100644 --- a/test/files/run/tcpoly_monads.scala +++ b/test/files/run/tcpoly_monads.scala @@ -1,18 +1,21 @@ + +import scala.language.{ higherKinds, implicitConversions } + trait Monads { /** * class Monad m where * (>>=) :: m a -> (a -> m b) -> m b * return :: a -> m a * - * MonadTC encodes the above Haskell type class, + * 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 + * 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) */ - trait MonadTC[m[x], a] { + trait MonadTC[m[x], a] { def unit[a](orig: a): m[a] // >>='s first argument comes from the implicit definition constructing this "method dictionary" @@ -27,7 +30,7 @@ trait Monads { */ 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] + 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 { diff --git a/test/files/run/tcpoly_overriding.scala b/test/files/run/tcpoly_overriding.scala index 86ba89f530..32174ad8bf 100644 --- a/test/files/run/tcpoly_overriding.scala +++ b/test/files/run/tcpoly_overriding.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds } + abstract class A[t[x]] { def b: t[Int] } diff --git a/test/files/run/tcpoly_parseridioms.check b/test/files/run/tcpoly_parseridioms.check index 5fff2efb15..ab829e0a0e 100644 --- a/test/files/run/tcpoly_parseridioms.check +++ b/test/files/run/tcpoly_parseridioms.check @@ -1 +1,21 @@ +tcpoly_parseridioms.scala:18: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + case Success(next, x) => b(next) match { + ^ +tcpoly_parseridioms.scala:17: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + def apply(in: Input): ParseResult[Pair[T, U]] = a(in) match { + ^ +tcpoly_parseridioms.scala:30: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + case Failure(_, _) => b(in) match { + ^ +tcpoly_parseridioms.scala:28: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + def apply(in: Input): ParseResult[T] = a(in) match { + ^ +tcpoly_parseridioms.scala:39: warning: match may not be exhaustive. +It would fail on the following input: ParseResult() + def apply(in: Input): ParseResult[U] = a(in) match { + ^ Success(List(),Plus(1,2)) diff --git a/test/files/run/tcpoly_parseridioms.scala b/test/files/run/tcpoly_parseridioms.scala index 634240e44d..c8bcf693a1 100644 --- a/test/files/run/tcpoly_parseridioms.scala +++ b/test/files/run/tcpoly_parseridioms.scala @@ -1,10 +1,13 @@ + +import scala.language.{ higherKinds, implicitConversions, postfixOps } + trait Parsers { type Input = List[Char] - + sealed class ParseResult[+t](val next: Input) - case class Success[+t](override val next: Input, result: t) extends ParseResult[t](next) + case class Success[+t](override val next: Input, result: t) extends ParseResult[t](next) case class Failure(override val next: Input, msg: String) extends ParseResult[Nothing](next) - + abstract class Parser[+t] { def apply(in: Input): ParseResult[t] } @@ -16,7 +19,7 @@ trait Parsers { case Success(next2, y) => Success(next2, Pair(x,y)) case Failure(_, msg) => Failure(in, msg) } - case Failure(_, msg) => Failure(in, msg) + case Failure(_, msg) => Failure(in, msg) } } @@ -38,20 +41,20 @@ trait Parsers { case Failure(n, msg) => Failure(n, msg) } } - + def accept[T](c: Char, r: T): Parser[T] = new Parser[T] { def apply(in: Input) = in match { case c2 :: n if c2 == c => Success(n, r) case n => Failure(n, "expected "+c+" at the head of "+n) } } - - def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Pair[s=>tt, s], tt]({case Pair(f, a) => f(a)})(sq(fun, arg)) - + + def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Pair[s=>tt, s], tt]({case Pair(f, a) => f(a)})(sq(fun, arg)) + def success[u](v: u): Parser[u] = new Parser[u] { def apply(in: Input) = Success(in, v) } - + } trait Idioms { @@ -61,21 +64,21 @@ trait Idioms { def pureMethod[a](name: String, x: a): idi[a] = pure(x) // hack for Mirrors: allow passing of method names } - class IdiomaticTarget[idi[x], idiom <: Idiom[idi], s](i: idiom, tgt: s) { + class IdiomaticTarget[idi[x], idiom <: Idiom[idi], s](i: idiom, tgt: s) { def dot [t](fun: s => t, name: String) = new IdiomaticApp2[idi, idiom, t](i, i.liftedApply(i.pureMethod(name, fun))(i.pure(tgt))) } // TODO: `.` --> java.lang.ClassFormatError: Illegal method name "." in class Idioms$Id$ - class IdiomaticFunction[idi[x], idiom <: Idiom[idi], s, t](i: idiom, fun: s => t) { + class IdiomaticFunction[idi[x], idiom <: Idiom[idi], s, t](i: idiom, fun: s => t) { def <| (a: idi[s]) = new IdiomaticApp[idi, idiom, t](i, i.liftedApply(i.pure(fun))(a)) } class IdiomaticApp[idi[x], idiom <: Idiom[idi], x](i: idiom, a: idi[x]) { // where x <: s=>t -- TODO can this be expressed without generalised constraints? def <> [s, t](b: idi[s]) = new IdiomaticApp[idi, idiom, t](i, i.liftedApply(a.asInstanceOf[idi[s=>t]])(b)) - + def |> : idi[x] = a } - + class IdiomaticApp2[idi[x], idiom <: Idiom[idi], x](i: idiom, a: idi[x]) extends IdiomaticApp[idi, idiom, x](i, a) { def <| [s, t](b: idi[s]) = <>[s,t](b) } @@ -86,22 +89,22 @@ trait ParserIdioms extends Parsers with Idioms { def liftedApply[s, t](fun: Parser[s => t])(arg: Parser[s]): Parser[t] = apply_++(fun, arg) def pure[a](x: a): Parser[a] = success(x) } - - implicit def parserIdiomFun[s, t](fun: s=>t): IdiomaticFunction[Parser, ParserIdiom.type, s, t] = + + implicit def parserIdiomFun[s, t](fun: s=>t): IdiomaticFunction[Parser, ParserIdiom.type, s, t] = new IdiomaticFunction[Parser, ParserIdiom.type, s, t](ParserIdiom, fun) - implicit def parserIdiomTgt[s](tgt: s): IdiomaticTarget[Parser, ParserIdiom.type, s] = + implicit def parserIdiomTgt[s](tgt: s): IdiomaticTarget[Parser, ParserIdiom.type, s] = new IdiomaticTarget[Parser, ParserIdiom.type, s](ParserIdiom, tgt) - + trait Expr case class Plus(a: Int, b: Int) extends Expr - + def num = or(accept('0', 0), or(accept('1', 1),accept('2', 2))) - - // TODO: how can parserIdiom(curry2(_)) be omitted? + + // TODO: how can parserIdiom(curry2(_)) be omitted? def expr: Parser[Expr] = parserIdiomFun(curry2(Plus)) <| num <> num |> - + implicit def curry2[s,t,u](fun: (s, t)=>u)(a: s)(b: t) = fun(a, b) - implicit def curry3[r,s,t,u](fun: (r,s, t)=>u)(a: r)(b: s)(c: t) = fun(a, b, c) + implicit def curry3[r,s,t,u](fun: (r,s, t)=>u)(a: r)(b: s)(c: t) = fun(a, b, c) } object Test extends ParserIdioms with App { diff --git a/test/files/run/test-cpp.scala b/test/files/run/test-cpp.scala index 5b3bc7b746..4e00e72658 100644 --- a/test/files/run/test-cpp.scala +++ b/test/files/run/test-cpp.scala @@ -3,25 +3,25 @@ * in the copy-propagation performed before ClosureElimination. * * In the general case, the local variable 'l' is connected through - * a alias chain with other local variables and at the end of the + * an alias chain with other local variables and at the end of the * alias chain there may be a Value, call it 'v'. * * If 'v' is cheaper to access (it is a Deref(This) or Const(_)), then - * replace the instruction to load it from the cheaper place. + * replace the instruction to load it from the cheaper place. * Otherwise, we use the local variable at the end of the alias chain * instead of 'l'. */ -import scala.tools.partest.IcodeTest +import scala.tools.partest.IcodeComparison -object Test extends IcodeTest { +object Test extends IcodeComparison { override def printIcodeAfterPhase = "dce" } import scala.util.Random._ -/** - * The example in the bug report (Issue-5321): an alias chain which store +/** + * The example in the bug report (Issue-5321): an alias chain which store * an Unknown. Should remove local variable 'y'. */ object TestBugReport { @@ -42,20 +42,20 @@ object TestSetterInline { } -/** +/** * The access of the local variable 'y' should be replaced by the * constant. - */ + */ object TestAliasChainConstat { def main(args: Array[String]): Unit = { val x = 2 val y = x - println(y) + println(y) } } -/** +/** * At the end of the alias chain we have a reference to 'this'. * The local variables should be all discarded and replace by a * direct reference to this @@ -72,7 +72,7 @@ class TestAliasChainDerefThis { /** * At the end of the alias chain, there is the value of a field. * The use of variable 'y' should be replaced by 'x', not by an access - * to the field 'f' since it is more costly. + * to the field 'f' since it is more costly. */ object TestAliasChainDerefField { def f = nextInt @@ -86,7 +86,7 @@ object TestAliasChainDerefField { /** - * The first time 'println' is called, 'x' is replaced by 'y' + * The first time 'println' is called, 'x' is replaced by 'y' * and the second time, 'y' is replaced by 'x'. But none of them * can be removed. */ diff --git a/test/files/run/toolbox_console_reporter.scala b/test/files/run/toolbox_console_reporter.scala index d672ccb9cb..ce28086c25 100644 --- a/test/files/run/toolbox_console_reporter.scala +++ b/test/files/run/toolbox_console_reporter.scala @@ -4,10 +4,10 @@ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.{ToolBox, mkConsoleFrontEnd} object Test extends App { - val oldErr = Console.err; - val baos = new java.io.ByteArrayOutputStream(); - Console.setErr(new java.io.PrintStream(baos)); - try { + //val oldErr = Console.err; + val baos = new java.io.ByteArrayOutputStream() + val errs = new java.io.PrintStream(baos) + (Console withErr errs) { val toolbox = cm.mkToolBox(frontEnd = mkConsoleFrontEnd(), options = "-deprecation") toolbox.eval(reify{ object Utils { @@ -18,12 +18,11 @@ object Test extends App { Utils.foo }.tree) println("============compiler console=============") + errs.flush() println(baos.toString); println("=========================================") println("============compiler messages============") toolbox.frontEnd.infos.foreach(println(_)) println("=========================================") - } finally { - Console.setErr(oldErr); } -}
\ No newline at end of file +} diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.check b/test/files/run/toolbox_typecheck_implicitsdisabled.check index db64e118ca..009ba651fe 100644 --- a/test/files/run/toolbox_typecheck_implicitsdisabled.check +++ b/test/files/run/toolbox_typecheck_implicitsdisabled.check @@ -1,5 +1,5 @@ { import scala.Predef._; - scala.Predef.any2ArrowAssoc[Int](1).->[Int](2) + scala.Predef.ArrowAssoc[Int](1).->[Int](2) } scala.tools.reflect.ToolBoxError: reflective typecheck has failed: value -> is not a member of Int diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.scala b/test/files/run/toolbox_typecheck_implicitsdisabled.scala index 8a3d433142..95a7056279 100644 --- a/test/files/run/toolbox_typecheck_implicitsdisabled.scala +++ b/test/files/run/toolbox_typecheck_implicitsdisabled.scala @@ -7,16 +7,16 @@ object Test extends App { val toolbox = cm.mkToolBox() val tree1 = Block(List( - Import(Select(Ident(newTermName("scala")), newTermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), - Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + 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) println(ttree1) try { val tree2 = Block(List( - Import(Select(Ident(newTermName("scala")), newTermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), - Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + 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) println(ttree2) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check index 688f37927c..3de296f1ad 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled.check @@ -2,7 +2,7 @@ val $u: ru.type = ru; val $m: $u.Mirror = ru.runtimeMirror({ final class $anon extends scala.AnyRef { - def <init>(): anonymous class $anon = { + def <init>(): <$anon: AnyRef> = { $anon.super.<init>(); () }; diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala index 51eb63f294..1f7fda8575 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala @@ -15,11 +15,11 @@ object Test extends App { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) + val tree1 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) println(ttree1) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) 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 e7011d1ae2..9810946024 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -2,7 +2,7 @@ val $u: ru.type = ru; val $m: $u.Mirror = ru.runtimeMirror({ final class $anon extends scala.AnyRef { - def <init>(): anonymous class $anon = { + def <init>(): <$anon: AnyRef> = { $anon.super.<init>(); () }; @@ -19,7 +19,7 @@ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) } }; new $treecreator1() diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala index 74fd09d9fd..7bfe3ba8a4 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -15,11 +15,11 @@ object Test extends App { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + 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) println(ttree1) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + 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) println(ttree2) } diff --git a/test/files/run/tpeCache-tyconCache.check b/test/files/run/tpeCache-tyconCache.check new file mode 100644 index 0000000000..a892f5477a --- /dev/null +++ b/test/files/run/tpeCache-tyconCache.check @@ -0,0 +1,19 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :power +** Power User mode enabled - BEEP WHIR GYVE ** +** :phase has been set to 'typer'. ** +** scala.tools.nsc._ has been imported ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** + +scala> + +scala> AnyRefClass.tpe eq AnyRefClass.typeConstructor +res0: Boolean = true + +scala> AnyRefClass.tpe eq AnyRefClass.typeConstructor +res1: Boolean = true + +scala> diff --git a/test/files/run/tpeCache-tyconCache.scala b/test/files/run/tpeCache-tyconCache.scala new file mode 100644 index 0000000000..f907167a33 --- /dev/null +++ b/test/files/run/tpeCache-tyconCache.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def code = """ +:power + +AnyRefClass.tpe eq AnyRefClass.typeConstructor +AnyRefClass.tpe eq AnyRefClass.typeConstructor + """.trim +} diff --git a/test/files/run/trait-renaming/A_1.scala b/test/files/run/trait-renaming/A_1.scala index 2c3d4f566f..d0fab7bfc3 100644 --- a/test/files/run/trait-renaming/A_1.scala +++ b/test/files/run/trait-renaming/A_1.scala @@ -9,7 +9,7 @@ package bippy { } new B with C { } } - + def g = Class.forName("bippy.A$B$1$class") } } diff --git a/test/files/run/transform.scala b/test/files/run/transform.scala index 5cc1c49d6f..d73155ceec 100644 --- a/test/files/run/transform.scala +++ b/test/files/run/transform.scala @@ -1,6 +1,6 @@ object Test { - val x = 1 to 10 toBuffer - + val x = (1 to 10).toBuffer + def main(args: Array[String]): Unit = { x transform (_ * 2) assert(x.sum == (1 to 10).sum * 2) diff --git a/test/files/run/transpose.scala b/test/files/run/transpose.scala index 3bea74b365..2761a24ff5 100644 --- a/test/files/run/transpose.scala +++ b/test/files/run/transpose.scala @@ -1,8 +1,8 @@ object Test { - def wrap[T >: Null](body: => T) = + def wrap[T >: Null](body: => T) = try body catch { case _: IllegalArgumentException => null } - + def main(args: Array[String]): Unit = { assert(wrap(Nil.transpose) == Nil) assert(wrap(List(List(1, 2), List(1)).transpose) == null) diff --git a/test/files/run/triemap-hash.scala b/test/files/run/triemap-hash.scala index 7f19997da0..f9913816d4 100644 --- a/test/files/run/triemap-hash.scala +++ b/test/files/run/triemap-hash.scala @@ -6,41 +6,41 @@ import util.hashing.Hashing object Test { - + def main(args: Array[String]) { hashing() equality() } - + def hashing() { import collection._ - + val tm = new concurrent.TrieMap[String, String](Hashing.fromFunction(x => x.length + x(0).toInt), Equiv.universal) tm.put("a", "b") tm.put("c", "d") - + assert(tm("a") == "b") assert(tm("c") == "d") - + for (i <- 0 until 1000) tm(i.toString) = i.toString for (i <- 0 until 1000) assert(tm(i.toString) == i.toString) } - + def equality() { import collection._ - + val tm = new concurrent.TrieMap[String, String](Hashing.fromFunction(x => x(0).toInt), Equiv.fromFunction(_(0) == _(0))) tm.put("a", "b") tm.put("a1", "d") tm.put("b", "c") - + assert(tm("a") == "d", tm) assert(tm("b") == "c", tm) - + for (i <- 0 until 1000) tm(i.toString) = i.toString assert(tm.size == 12, tm) assert(tm("0") == "0", tm) for (i <- 1 to 9) assert(tm(i.toString) == i.toString + "99", tm) } - + } diff --git a/test/files/run/triple-quoted-expr.scala b/test/files/run/triple-quoted-expr.scala index 0b30946de2..6d91ac5888 100644 --- a/test/files/run/triple-quoted-expr.scala +++ b/test/files/run/triple-quoted-expr.scala @@ -1,18 +1,18 @@ class A { def f1 = { val x = 5 - + """ hi""" } def f2 = { val x = 5 - + """hi""" - } + } def f3 = { val x = 5 - + "\nhi" } } diff --git a/test/files/run/try-2.check b/test/files/run/try-2.check index 6c4a024c93..987d3462df 100644 --- a/test/files/run/try-2.check +++ b/test/files/run/try-2.check @@ -1,3 +1,6 @@ +try-2.scala:41: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 10; + ^ exception happened Nothin diff --git a/test/files/run/try-2.scala b/test/files/run/try-2.scala index 677f0b48eb..b55977ba8b 100644 --- a/test/files/run/try-2.scala +++ b/test/files/run/try-2.scala @@ -7,47 +7,47 @@ object Test { - def tryAllUnit: Unit = + def tryAllUnit: Unit = try { throw new Error(); } catch { - case _ => Console.println("exception happened\n"); + case _: Throwable => Console.println("exception happened\n"); } - def tryUnitAll: Unit = + def tryUnitAll: Unit = try { Console.println("Nothin"); } catch { - case _ => error("Bad, bad, lama!"); + case _: Throwable => sys.error("Bad, bad, lama!"); } - def tryAllAll: Unit = + def tryAllAll: Unit = try { throw new Error(); } catch { - case _ => error("Bad, bad, lama!"); + case _: Throwable => sys.error("Bad, bad, lama!"); } - def tryUnitUnit: Unit = + def tryUnitUnit: Unit = try { Console.println("Nothin"); } catch { - case _ => Console.println("Nothin"); + case _: Throwable => Console.println("Nothin"); } - def tryIntUnit: Unit = + def tryIntUnit: Unit = try { 10; } catch { - case _ => Console.println("Huh?"); + case _: Throwable => Console.println("Huh?"); } def execute(f: => Unit) = try { f; } catch { - case _ => (); + case _: Throwable => (); } @@ -55,7 +55,7 @@ object Test { execute(tryAllUnit); execute(tryUnitAll); execute(tryAllAll); - execute(tryUnitUnit); + execute(tryUnitUnit); execute(tryIntUnit); } } diff --git a/test/files/run/try-catch-unify.scala b/test/files/run/try-catch-unify.scala index 8cb14d060e..151e549e5f 100644 --- a/test/files/run/try-catch-unify.scala +++ b/test/files/run/try-catch-unify.scala @@ -9,7 +9,7 @@ object Test { try { catching(classOf[NumberFormatException]) withTry (sys.error("O NOES")) } catch { - case t => println(t.getMessage) + case t: Throwable => println(t.getMessage) } println(nonFatalCatch withTry ("Hi".toDouble)) } diff --git a/test/files/run/try.check b/test/files/run/try.check index 3983e26060..f742ccb0df 100644 --- a/test/files/run/try.check +++ b/test/files/run/try.check @@ -1,3 +1,6 @@ +try.scala:65: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 1+1; + ^ 1 + 1 = 2 1 + 1 = 2 1 + 1 = 2 diff --git a/test/files/run/try.scala b/test/files/run/try.scala index ad3d606246..a4fdfd796b 100644 --- a/test/files/run/try.scala +++ b/test/files/run/try.scala @@ -17,8 +17,8 @@ object Test extends AnyRef with App { Console.println( (try { x } catch { case _: Error => 1; - }) - + + }) + + (try { x } catch { case _: Error => 1; }) @@ -45,7 +45,7 @@ object Test extends AnyRef with App { instance = try { "" //new String(); } catch { - case _ => + case _: Throwable => val cs = "aaa"; if (cs.length() > 0) { "" //new String(); @@ -61,17 +61,17 @@ object Test extends AnyRef with App { Console.print("1 + 1 = "); try { if (true) - error("exit"); + sys.error("exit"); 1+1; () } catch { - case _ => + case _: Throwable => Console.println("2"); - error("for good"); + sys.error("for good"); } Console.println("a"); } catch { - case _ => (); + case _: Throwable => (); } class A { @@ -95,7 +95,7 @@ object Test extends AnyRef with App { try { null } catch { - case _ => null + case _: Throwable => null } new AnyRef { @@ -116,7 +116,7 @@ object Test extends AnyRef with App { } */ - + try1; try2; try3; diff --git a/test/files/run/tuple-match.scala b/test/files/run/tuple-match.scala index 57ba9cf6e1..fcaefbff5b 100644 --- a/test/files/run/tuple-match.scala +++ b/test/files/run/tuple-match.scala @@ -1,7 +1,7 @@ object Test { val FOUR = (-1, -2, -3, "bingo donkey vegas") val THREE = (-1, -2, -3) - + def f(x: Any) = x match { case FOUR => "FOUR" case (_, _, 3, _) => "4, #3" @@ -13,7 +13,7 @@ object Test { case (_, 2) => "2, #2" case _ => "default" } - + def main(args: Array[String]): Unit = { println(f((1, 2, 3, 4))) println(f((1, 2, 30, 4))) diff --git a/test/files/run/tuple-zipped.scala b/test/files/run/tuple-zipped.scala index b197183844..37ac52977f 100644 --- a/test/files/run/tuple-zipped.scala +++ b/test/files/run/tuple-zipped.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + object Test { val xs1 = List.range(1, 100) val xs2 = xs1.view @@ -8,32 +11,31 @@ object Test { val as1 = 1 to 100 toArray val as2 = as1.view val as3 = as1 take 10 - + def xss1 = List[Seq[Int]](xs1, xs2, xs3, ss1, ss2, ss3, as1, as2, as3) def xss2 = List[Seq[Int]](xs1, xs2, xs3, ss3, as1, as2, as3) // no infinities def xss3 = List[Seq[Int]](xs2, xs3, ss3, as1) // representative sampling - + def main(args: Array[String]): Unit = { for (cc1 <- xss1 ; cc2 <- xss2) { val sum1 = (cc1, cc2).zipped map { case (x, y) => x + y } sum val sum2 = (cc1, cc2).zipped map (_ + _) sum - + assert(sum1 == sum2) } - + for (cc1 <- xss1 ; cc2 <- xss2 ; cc3 <- xss3) { val sum1 = (cc1, cc2, cc3).zipped map { case (x, y, z) => x + y + z } sum val sum2 = (cc1, cc2, cc3).zipped map (_ + _ + _) sum - + assert(sum1 == sum2) } - + assert((ss1, ss1).zipped exists ((x, y) => true)) assert((ss1, ss1, ss1).zipped exists ((x, y, z) => true)) - + assert(!(ss1, ss2, 1 to 3).zipped.exists(_ + _ + _ > 100000)) assert((1 to 3, ss1, ss2).zipped.forall(_ + _ + _ > 0)) assert((ss1, 1 to 3, ss2).zipped.map(_ + _ + _).size == 3) } } - diff --git a/test/files/run/tuples.scala b/test/files/run/tuples.scala index 4854e36c96..a4ea9ddbcc 100644 --- a/test/files/run/tuples.scala +++ b/test/files/run/tuples.scala @@ -6,6 +6,7 @@ object Test extends App { Console.println(xyz) xyz match { case (1, "abc", true) => Console.println("OK") + case _ => ??? } def func(x: Int, y: String, z: Double) { Console.println("x = " + x + "; y = " + y + "; z = " + z); diff --git a/test/files/run/type-currying.scala b/test/files/run/type-currying.scala index f9764c64f0..e10f8fc9f1 100644 --- a/test/files/run/type-currying.scala +++ b/test/files/run/type-currying.scala @@ -1,3 +1,6 @@ + + +import scala.language.{ higherKinds, reflectiveCalls } import scala.collection.{ mutable, immutable, generic } import generic.CanBuildFrom @@ -33,10 +36,10 @@ object Test { val immutableBippy = Partial[immutable.HashMap].values[Int] def make[T](xs: T*) = immutableBippy[T] ++ xs.zipWithIndex - + val n0 = Partial[immutable.HashMap][String][Int] ++ Seq(("a", 1)) val n1 = Partial.apply[immutable.HashMap].apply[String].apply[Int] ++ Seq(("a", 1)) - + def main(args: Array[String]): Unit = { println(mutableBippy) make('a' to 'z': _*).toList.sorted foreach println diff --git a/test/files/run/typealias_overriding.scala b/test/files/run/typealias_overriding.scala index 8a2d1312ab..4b6a0037ec 100644 --- a/test/files/run/typealias_overriding.scala +++ b/test/files/run/typealias_overriding.scala @@ -1,21 +1,21 @@ // this bug (http://scala-webapps.epfl.ch/bugtracking/bugs/displayItem.do?id=1065) -// was caused by Uncurry not normalizing all the types +// was caused by Uncurry not normalizing all the types // (more specifically the argument/return types of an anonymous Function) object Test extends App { trait AddRemove { type TNode <: NodeImpl; trait NodeImpl; - + object removing { type TNode = AddRemove.this.TNode; def printNode(node: TNode, f: TNode => String) = Console.println(f(node)) } } - + class Linked extends AddRemove { type TNode = Node // can also directly write `class Node extends super.NodeImpl' -- doesn't change the bug class Node extends super.NodeImpl { override def toString = "LinkedNode" } - + removing.printNode(new Node, (x: removing.TNode) => x.toString) // make inference explicit, doesn't affect the bug } diff --git a/test/files/run/unapply.check b/test/files/run/unapply.check new file mode 100644 index 0000000000..847e3b381e --- /dev/null +++ b/test/files/run/unapply.check @@ -0,0 +1,3 @@ +unapply.scala:57: warning: comparing values of types Null and Null using `==' will always yield true + assert(doMatch2(b) == null) + ^ diff --git a/test/files/run/unapply.scala b/test/files/run/unapply.scala index 90dd4fae73..0c5a70e768 100644 --- a/test/files/run/unapply.scala +++ b/test/files/run/unapply.scala @@ -22,7 +22,7 @@ object Faa { def unapply(x: Any): Option[String] = if(x.isInstanceOf[Bar]) Some(x.asInstanceOf[Bar].name) else None } object FaaPrecise { - def unapply(x: Bar): Option[String] = Some(x.name) + def unapply(x: Bar): Option[String] = Some(x.name) } object FaaPreciseSome { def unapply(x: Bar) = Some(x.name) // return type Some[String] @@ -108,14 +108,14 @@ object Test1256 { class Sync { def unapply(scrut: Any): Boolean = false } - + class Buffer { val Get = new Sync val jp: PartialFunction[Any, Any] = { case Get() => } } - + def run() { assert(!(new Buffer).jp.isDefinedAt(42)) } diff --git a/test/files/run/unittest_collection.scala b/test/files/run/unittest_collection.scala index 3639b496b3..822e2b0c98 100644 --- a/test/files/run/unittest_collection.scala +++ b/test/files/run/unittest_collection.scala @@ -12,7 +12,7 @@ object Test { } def test(x: Buffer[String]) { - // testing method += + // testing method += x += "one" assert(x(0) == "one", "retrieving 'one'") assert(x.length == 1, "length A") @@ -25,10 +25,10 @@ object Test { assert(x.length == 1, "length C") - try { x(1); sys.error("no exception for removed element") } + try { x(1); sys.error("no exception for removed element") } catch { case i:IndexOutOfBoundsException => } - try { x.remove(1); sys.error("no exception for removed element") } + try { x.remove(1); sys.error("no exception for removed element") } catch { case i:IndexOutOfBoundsException => } x += "two2" diff --git a/test/files/run/unittest_io.scala b/test/files/run/unittest_io.scala deleted file mode 100644 index 2cadb9b1df..0000000000 --- a/test/files/run/unittest_io.scala +++ /dev/null @@ -1,40 +0,0 @@ -object Test { - - def main(args: Array[String]) { - UTF8Tests.run() - SourceTest.run() - } - - object UTF8Tests { - def decode(ch: Int) = new String(Array(ch), 0, 1).getBytes("UTF-8") - - def run() { - assert(new String( decode(0x004D), "utf8") == new String(Array(0x004D.asInstanceOf[Char]))) - assert(new String( decode(0x0430), "utf8") == new String(Array(0x0430.asInstanceOf[Char]))) - assert(new String( decode(0x4E8C), "utf8") == new String(Array(0x4E8C.asInstanceOf[Char]))) - assert(new String(decode(0x10302), "utf8") == new String(Array(0xD800.asInstanceOf[Char], - 0xDF02.asInstanceOf[Char]))) - // a client - val test = "{\"a\":\"\\u0022\"}" - val expected = "a" -> "\"" - - val parsed = scala.util.parsing.json.JSON.parseFull(test) - val result = parsed == Some(Map(expected)) - if(result) - assert(result) - else { - Console.println(parsed); assert(result) - } - } - } - - object SourceTest { - def run() { - val s = "Here is a test string" - val f = io.Source.fromBytes(s.getBytes("utf-8")) - val b = new collection.mutable.ArrayBuffer[Char]() - f.copyToBuffer(b) - assert(s == new String(b.toArray)) - } - } -} diff --git a/test/files/run/unittest_iterator.scala b/test/files/run/unittest_iterator.scala index 89ccdb9d58..21dc64c3c5 100644 --- a/test/files/run/unittest_iterator.scala +++ b/test/files/run/unittest_iterator.scala @@ -1,5 +1,5 @@ // Some iterator grouped/sliding unit tests -object Test { +object Test { def it = (1 to 10).iterator def assertThat[T](expectedLength: Int, expectedLast: Seq[T])(it: Iterator[Seq[T]]) { val xs = it.toList @@ -7,15 +7,15 @@ object Test { assert(xs.size == expectedLength, fail("expected length " + expectedLength)) assert(xs.last == expectedLast, fail("expected last " + expectedLast)) } - + def main(args: Array[String]): Unit = { val itSum = it.toStream.sum for (i <- it) { // sum of the groups == sum of the original val thisSum = ((it grouped i) map (_.sum)).toStream.sum - assert(thisSum == itSum, thisSum + " != " + itSum) + assert(thisSum == itSum, thisSum + " != " + itSum) } - + // grouped assertThat(4, List(10)) { it grouped 3 } assertThat(3, List(7, 8, 9)) { it grouped 3 withPartial false } @@ -32,11 +32,11 @@ object Test { assertThat(1, (1 to 8).toList) { it.sliding(8, 8) withPartial false } assertThat(2, List(9, 10, -1, -1, -1)) { it.sliding(5, 8) withPadding -1 } assertThat(1, (1 to 5).toList) { it.sliding(5, 8) withPartial false } - + // larger step than window assertThat(5, List(9)) { it.sliding(1, 2) } assertThat(3, List(9, 10)) { it.sliding(2, 4) } - + // make sure it throws past the end val thrown = try { val it = List(1,2,3).sliding(2) diff --git a/test/files/run/unreachable.scala b/test/files/run/unreachable.scala new file mode 100644 index 0000000000..bb907c92bf --- /dev/null +++ b/test/files/run/unreachable.scala @@ -0,0 +1,128 @@ +import scala.util.Random.nextInt +import scala.sys.error + +object Test extends App { + def unreachableNormalExit: Int = { + return 42 + 0 + } + + def unreachableIf: Int = { + return 42 + if (nextInt % 2 == 0) + 0 + else + 1 + } + + def unreachableIfBranches: Int = { + if (nextInt % 2 == 0) + return 42 + else + return 42 + + return 0 + } + + def unreachableOneLegIf: Int = { + if (nextInt % 2 == 0) + return 42 + + return 42 + } + + def unreachableLeftBranch: Int = { + val result = if (nextInt % 2 == 0) + return 42 + else + 42 + + return result + } + + def unreachableRightBranch: Int = { + val result = if (nextInt % 2 == 0) + 42 + else + return 42 + + return result + } + + def unreachableTryCatchFinally: Int = { + return 42 + try { + return 0 + } catch { + case x: Throwable => return 1 + } finally { + return 2 + } + return 3 + } + + def unreachableAfterTry: Int = { + try { + return 42 + } catch { + case x: Throwable => return 2 + } + return 3 + } + + def unreachableAfterCatch: Int = { + try { + error("haha") + } catch { + case x: Throwable => return 42 + } + return 3 + } + + def unreachableAfterFinally: Int = { + try { + return 1 + } catch { + case x: Throwable => return 2 + } finally { + return 42 + } + return 3 + } + + def unreachableSwitch: Int = { + return 42 + val x = nextInt % 2 + x match { + case 0 => return 0 + case 1 => return 1 + case -1 => return 2 + } + 3 + } + + def unreachableAfterSwitch: Int = { + val x = nextInt % 2 + x match { + case 0 => return 42 + case 1 => return 41 + x + case -1 => return 43 + x + } + 2 + } + + def check(f: Int) = assert(f == 42, s"Expected 42 but got $f") + + check(unreachableNormalExit) + check(unreachableIf) + check(unreachableIfBranches) + check(unreachableOneLegIf) + check(unreachableLeftBranch) + check(unreachableRightBranch) + check(unreachableTryCatchFinally) + check(unreachableAfterTry) + check(unreachableAfterCatch) + check(unreachableAfterFinally) + check(unreachableSwitch) + check(unreachableAfterSwitch) +} diff --git a/test/files/run/value-class-extractor-2.check b/test/files/run/value-class-extractor-2.check new file mode 100644 index 0000000000..5903b996b6 --- /dev/null +++ b/test/files/run/value-class-extractor-2.check @@ -0,0 +1,8 @@ +String +List +Int +Something else +String +List +Int +Something else diff --git a/test/files/run/value-class-extractor-2.scala b/test/files/run/value-class-extractor-2.scala new file mode 100644 index 0000000000..d776c35eda --- /dev/null +++ b/test/files/run/value-class-extractor-2.scala @@ -0,0 +1,108 @@ +final class Opt[+A >: Null](val value: A) extends AnyVal { + def get: A = value + def isEmpty = value == null +} +object Opt { + final val None = new Opt[Null](null) + def apply[A >: Null](value: A): Opt[A] = if (value == null) None else new Opt[A](value) +} + +object ValueOpt { + // public java.lang.String unapply(java.lang.Object); + // 0: aload_1 + // 1: instanceof #16 // class java/lang/String + // 4: ifeq 21 + // 7: getstatic #21 // Field Opt$.MODULE$:LOpt$; + // 10: astore_2 + // 11: ldc #23 // String String + // 13: checkcast #16 // class java/lang/String + // 16: astore 5 + // 18: goto 71 + // 21: aload_1 + // 22: instanceof #25 // class scala/collection/immutable/List + // 25: ifeq 42 + // 28: getstatic #21 // Field Opt$.MODULE$:LOpt$; + // 31: astore_3 + // 32: ldc #27 // String List + // 34: checkcast #16 // class java/lang/String + // 37: astore 5 + // 39: goto 71 + // 42: aload_1 + // 43: instanceof #29 // class java/lang/Integer + // 46: ifeq 64 + // 49: getstatic #21 // Field Opt$.MODULE$:LOpt$; + // 52: astore 4 + // 54: ldc #31 // String Int + // 56: checkcast #16 // class java/lang/String + // 59: astore 5 + // 61: goto 71 + // 64: getstatic #21 // Field Opt$.MODULE$:LOpt$; + // 67: pop + // 68: aconst_null + // 69: astore 5 + // 71: aload 5 + // 73: areturn + def unapply(x: Any): Opt[String] = x match { + case _: String => Opt("String") + case _: List[_] => Opt("List") + case _: Int => Opt("Int") + case _ => Opt.None + } +} +object RegularOpt { + // public scala.Option<java.lang.String> unapply(java.lang.Object); + // 0: aload_1 + // 1: instanceof #16 // class java/lang/String + // 4: ifeq 20 + // 7: new #18 // class scala/Some + // 10: dup + // 11: ldc #20 // String String + // 13: invokespecial #23 // Method scala/Some."<init>":(Ljava/lang/Object;)V + // 16: astore_2 + // 17: goto 64 + // 20: aload_1 + // 21: instanceof #25 // class scala/collection/immutable/List + // 24: ifeq 40 + // 27: new #18 // class scala/Some + // 30: dup + // 31: ldc #27 // String List + // 33: invokespecial #23 // Method scala/Some."<init>":(Ljava/lang/Object;)V + // 36: astore_2 + // 37: goto 64 + // 40: aload_1 + // 41: instanceof #29 // class java/lang/Integer + // 44: ifeq 60 + // 47: new #18 // class scala/Some + // 50: dup + // 51: ldc #31 // String Int + // 53: invokespecial #23 // Method scala/Some."<init>":(Ljava/lang/Object;)V + // 56: astore_2 + // 57: goto 64 + // 60: getstatic #36 // Field scala/None$.MODULE$:Lscala/None$; + // 63: astore_2 + // 64: aload_2 + // 65: areturn + def unapply(x: Any): Option[String] = x match { + case _: String => Some("String") + case _: List[_] => Some("List") + case _: Int => Some("Int") + case _ => None + } +} + +object Test { + def f(x: Any) = x match { + case ValueOpt(s) => s + case _ => "Something else" + } + def g(x: Any) = x match { + case RegularOpt(s) => s + case _ => "Something else" + } + val xs = List("abc", Nil, 5, Test) + + def main(args: Array[String]): Unit = { + xs map f foreach println + xs map g foreach println + } +} diff --git a/test/files/run/value-class-extractor-seq.check b/test/files/run/value-class-extractor-seq.check new file mode 100644 index 0000000000..84552a7aa5 --- /dev/null +++ b/test/files/run/value-class-extractor-seq.check @@ -0,0 +1,3 @@ +Bip(1, 2, 3) +Bip(1, 2, c @ Array(3, 4, 5): _*) +class [I diff --git a/test/files/run/value-class-extractor-seq.scala b/test/files/run/value-class-extractor-seq.scala new file mode 100644 index 0000000000..f17a5314f2 --- /dev/null +++ b/test/files/run/value-class-extractor-seq.scala @@ -0,0 +1,59 @@ +import scala.runtime.ScalaRunTime.stringOf + +final class ArrayOpt[T](val xs: Array[T]) extends AnyVal { + def isEmpty = xs == null + def get = xs +} + +object Bip { + def mkInts(xs: Array[Short]) = xs map (_.toInt) + def unapplySeq(x: Any): ArrayOpt[Int] = x match { + case xs: Array[Int] => new ArrayOpt(xs) + case xs: Array[Short] => new ArrayOpt(mkInts(xs)) + case _ => new ArrayOpt(null) + } + // public int[] unapplySeq(java.lang.Object); + // 0: aload_1 + // 1: astore_2 + // 2: aload_2 + // 3: instanceof #52 // class "[I" + // 6: ifeq 20 + // 9: aload_2 + // 10: checkcast #52 // class "[I" + // 13: astore_3 + // 14: aload_3 + // 15: astore 4 + // 17: goto 47 + // 20: aload_2 + // 21: instanceof #58 // class "[S" + // 24: ifeq 44 + // 27: aload_2 + // 28: checkcast #58 // class "[S" + // 31: astore 5 + // 33: aload_0 + // 34: aload 5 + // 36: invokevirtual #60 // Method mkInts:([S)[I + // 39: astore 4 + // 41: goto 47 + // 44: aconst_null + // 45: astore 4 + // 47: aload 4 + // 49: areturn +} + +object Test { + def f(x: Any) = x match { + case Bip(a, b, c) => s"Bip($a, $b, $c)" + case Bip(a, b, c @ _*) => s"Bip($a, $b, c @ ${stringOf(c)}: _*)" + case _ => "" + x.getClass + } + + def main(args: Array[String]): Unit = { + println(f(Array[Int](1,2,3))) + println(f(Array[Int](1,2,3,4,5))) + println(f(Array[Int](1))) + } + // Bip(1, 2, 3) + // Bip(1, 2, c @ [I@782be20e: _*) + // class [I +} diff --git a/test/files/run/value-class-extractor.check b/test/files/run/value-class-extractor.check new file mode 100644 index 0000000000..e16447118c --- /dev/null +++ b/test/files/run/value-class-extractor.check @@ -0,0 +1,9 @@ +'a' +'b' +'c' +NoChar +Some(a) +Some(b) +Some(c) +None +9 diff --git a/test/files/run/value-class-extractor.scala b/test/files/run/value-class-extractor.scala new file mode 100644 index 0000000000..3eaffa0c23 --- /dev/null +++ b/test/files/run/value-class-extractor.scala @@ -0,0 +1,91 @@ +final class NonNullChar(val get: Char) extends AnyVal { + def isEmpty = get == 0.toChar + override def toString = if (isEmpty) "NoChar" else s"'$get'" +} +object NonNullChar { + @inline final val None = new NonNullChar(0.toChar) +} + +final class SomeProduct extends Product3[String, Int, List[String]] { + def canEqual(x: Any) = x.isInstanceOf[SomeProduct] + def _1 = "abc" + def _2 = 5 + def _3 = List("bippy") + def isEmpty = false + def get = this +} +object SomeProduct { + def unapply(x: SomeProduct) = x +} + +object Test { + def prod(x: SomeProduct): Int = x match { + case SomeProduct(x, y, z) => x.length + y + z.length + case _ => -1 + } + + def f(x: Char): NonNullChar = x match { + case 'a' => new NonNullChar('a') + case 'b' => new NonNullChar('b') + case 'c' => new NonNullChar('c') + case _ => NonNullChar.None + } + // public char f(char); + // 0: iload_1 + // 1: tableswitch { // 97 to 99 + // 97: 47 + // 98: 42 + // 99: 37 + // default: 28 + // } + // 28: getstatic #19 // Field NonNullChar$.MODULE$:LNonNullChar$; + // 31: invokevirtual #23 // Method NonNullChar$.None:()C + // 34: goto 49 + // 37: bipush 99 + // 39: goto 49 + // 42: bipush 98 + // 44: goto 49 + // 47: bipush 97 + // 49: ireturn + def g(x: Char): Option[Char] = x match { + case 'a' => Some('a') + case 'b' => Some('b') + case 'c' => Some('c') + case _ => None + } + // public scala.Option<java.lang.Object> g(char); + // 0: iload_1 + // 1: tableswitch { // 97 to 99 + // 97: 64 + // 98: 49 + // 99: 34 + // default: 28 + // } + // 28: getstatic #33 // Field scala/None$.MODULE$:Lscala/None$; + // 31: goto 76 + // 34: new #35 // class scala/Some + // 37: dup + // 38: bipush 99 + // 40: invokestatic #41 // Method scala/runtime/BoxesRunTime.boxToCharacter:(C)Ljava/lang/Character; + // 43: invokespecial #44 // Method scala/Some."<init>":(Ljava/lang/Object;)V + // 46: goto 76 + // 49: new #35 // class scala/Some + // 52: dup + // 53: bipush 98 + // 55: invokestatic #41 // Method scala/runtime/BoxesRunTime.boxToCharacter:(C)Ljava/lang/Character; + // 58: invokespecial #44 // Method scala/Some."<init>":(Ljava/lang/Object;)V + // 61: goto 76 + // 64: new #35 // class scala/Some + // 67: dup + // 68: bipush 97 + // 70: invokestatic #41 // Method scala/runtime/BoxesRunTime.boxToCharacter:(C)Ljava/lang/Character; + // 73: invokespecial #44 // Method scala/Some."<init>":(Ljava/lang/Object;)V + // 76: areturn + def main(args: Array[String]): Unit = { + "abcd" foreach (ch => println(f(ch))) + "abcd" foreach (ch => println(g(ch))) + println(prod(new SomeProduct)) + } +} + + diff --git a/test/files/run/valueclasses-classmanifest-basic.scala b/test/files/run/valueclasses-classmanifest-basic.scala index c2aa08ef86..50addda359 100644 --- a/test/files/run/valueclasses-classmanifest-basic.scala +++ b/test/files/run/valueclasses-classmanifest-basic.scala @@ -1,5 +1,6 @@ class Foo(val x: Int) extends AnyVal +@deprecated("Suppress warnings", since="2.11") object Test extends App { println(classManifest[Foo]) -}
\ No newline at end of file +} diff --git a/test/files/run/valueclasses-classmanifest-existential.scala b/test/files/run/valueclasses-classmanifest-existential.scala index 11999df678..6bcd7cf942 100644 --- a/test/files/run/valueclasses-classmanifest-existential.scala +++ b/test/files/run/valueclasses-classmanifest-existential.scala @@ -1,5 +1,6 @@ class Foo[T](val x: T) extends AnyVal +@deprecated("Suppress warnings", since="2.11") object Test extends App { println(classManifest[Foo[_]]) -}
\ No newline at end of file +} diff --git a/test/files/run/valueclasses-classmanifest-generic.scala b/test/files/run/valueclasses-classmanifest-generic.scala index 280152dc1d..5efcaed959 100644 --- a/test/files/run/valueclasses-classmanifest-generic.scala +++ b/test/files/run/valueclasses-classmanifest-generic.scala @@ -1,5 +1,6 @@ class Foo[T](val x: T) extends AnyVal +@deprecated("Suppress warnings", since="2.11") object Test extends App { println(classManifest[Foo[String]]) -}
\ No newline at end of file +} diff --git a/test/files/run/vector1.scala b/test/files/run/vector1.scala index b37cfe82e8..d536183961 100644 --- a/test/files/run/vector1.scala +++ b/test/files/run/vector1.scala @@ -9,7 +9,7 @@ import scala.collection.mutable.Builder object Test { - + def vector(label: String, n: Int): Vector[String] = { val a = new VectorBuilder[String] for (i <- 0 until n) @@ -67,7 +67,7 @@ object Test { def test1() = { println("===== test1 =====") - + val N = 150000 val a = vector("a", N) val b = vectorForward("b", N) @@ -81,33 +81,33 @@ object Test { println("===== test2 =====") var a: Vector[String] = Vector.empty - + val rand = new java.util.Random - + val N = 150000 var min = N/2//rand.nextInt(N) var max = min - + val chunkLimit = 11 - + def nextChunkSize = 3 //rand.nextInt(chunkLimit) - + def seqBack() = for (i <- 0 until Math.min(nextChunkSize, N-max)) { a = a :+ ("a"+max); max += 1 } def seqFront() = for (i <- 0 until Math.min(nextChunkSize, min)) { min -= 1; a = ("a"+min) +: a } - + try { - + while (min > 0 || max < N) { seqFront() seqBack() } } catch { - case ex => + case ex: Throwable => //println("----------------") //a.debug throw ex } - + assertVector(a, "a", 0, N) } @@ -122,14 +122,14 @@ object Test { val pos = scala.util.Random.shuffle(scala.collection.mutable.WrappedArray.make[Int](Array.tabulate[Int](N)(i => i))) var b = a - + { var i = 0 while (i < N) { b = b.updated(pos(i), "b"+(pos(i))) i += 1 } - + assertVector(b, "b", 0, N) } diff --git a/test/files/run/verify-ctor.scala b/test/files/run/verify-ctor.scala index 17e4f71be5..528d038a8e 100644 --- a/test/files/run/verify-ctor.scala +++ b/test/files/run/verify-ctor.scala @@ -1,6 +1,6 @@ class Foo(val str: String) { def this(arr: Array[Char]) = this({ - if (arr.length == 0) exit(1) + if (arr.length == 0) sys.exit(1) new String(arr) }) } diff --git a/test/files/run/view-headoption.scala b/test/files/run/view-headoption.scala index 629b974c19..659c7e6b82 100644 --- a/test/files/run/view-headoption.scala +++ b/test/files/run/view-headoption.scala @@ -2,13 +2,13 @@ object Test { val failer = () => { println("fail") ; None } val succeeder = () => { println("success") ; Some(5) } val fs = List(failer, succeeder, failer, failer, succeeder, failer, failer, failer, succeeder) - + def f0 = fs.view flatMap (f => f()) def f1 = f0.headOption def f2 = f0.head def f3 = f0.lastOption def f4 = f0.last - + def main(args: Array[String]): Unit = { println("f1: " + f1) println("f2: " + f2) diff --git a/test/files/run/view-iterator-stream.scala b/test/files/run/view-iterator-stream.scala index f91407f92c..0e0c42d7d3 100644 --- a/test/files/run/view-iterator-stream.scala +++ b/test/files/run/view-iterator-stream.scala @@ -1,3 +1,6 @@ + +import scala.language.postfixOps + import scala.collection.{ mutable, immutable, generic } import collection.TraversableView @@ -18,7 +21,7 @@ object Test { } def and(g: Perturber): Perturber = new Perturber(this.labels ++ g.labels, f andThen g.f) - + override def toString = labels mkString " -> " } object Perturber { @@ -39,14 +42,14 @@ object Test { "slice(%d, %d)".format(from, until), _.toTraversable.slice(from, until) ) - + val fns = List[Perturber](toV, toI, toS, toIS) def tds(n: Int): Perturber = p(drop(n), take(n / 2), slice(1, n / 4)) def dts(n: Int): Perturber = p(take(n), drop(n / 2), slice(1, n / 4)) def sdt(n: Int): Perturber = p(slice(n, n * 2), drop(n / 2), take(n / 4)) def std(n: Int): Perturber = p(slice(n, n * 2), take(n / 2), drop(n / 4)) - + val transforms = (fns.permutations map (xs => p(xs take 3: _*))).toList.distinct def mkOps(n: Int) = List[Perturber](tds(n), dts(n), sdt(n), std(n)) def runOps(n: Int) = { @@ -60,7 +63,7 @@ object Test { } () } - + def main(args: Array[String]): Unit = { runOps(20) } diff --git a/test/files/run/viewtest.scala b/test/files/run/viewtest.scala index bb2c28d68a..581958e9a6 100755 --- a/test/files/run/viewtest.scala +++ b/test/files/run/viewtest.scala @@ -25,8 +25,8 @@ object Test extends App { 2.8 regression: CCE when zipping list projection with stream Reported by: szeiger Owned by: odersky Priority: normal Component: Standard Library -Keywords: collections, zip Cc: -Fixed in version: +Keywords: collections, zip Cc: +Fixed in version: Description Welcome to Scala version 2.8.0.r18784-b20090925021043 (Java HotSpot(TM) Client VM, Java 1.6.0_11). diff --git a/test/files/run/virtpatmat_alts.check b/test/files/run/virtpatmat_alts.check index 7a4ad0a741..f39e292fef 100644 --- a/test/files/run/virtpatmat_alts.check +++ b/test/files/run/virtpatmat_alts.check @@ -1 +1,7 @@ +virtpatmat_alts.scala:5: warning: match may not be exhaustive. + (true, true) match { + ^ +virtpatmat_alts.scala:9: warning: match may not be exhaustive. + List(5) match { + ^ OK 5 diff --git a/test/files/run/virtpatmat_alts.flags b/test/files/run/virtpatmat_alts.flags deleted file mode 100644 index 3f5a3100e4..0000000000 --- a/test/files/run/virtpatmat_alts.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_alts.scala b/test/files/run/virtpatmat_alts.scala index b7717524e2..d1dfa8a4a1 100644 --- a/test/files/run/virtpatmat_alts.scala +++ b/test/files/run/virtpatmat_alts.scala @@ -1,3 +1,6 @@ +/* + * filter: It would fail on the following input + */ object Test extends App { (true, true) match { case (true, true) | (false, false) => 1 @@ -9,4 +12,4 @@ object Test extends App { case 7 :: Nil => println("FAILED") case Nil => println("FAILED") } -}
\ No newline at end of file +} diff --git a/test/files/run/virtpatmat_apply.scala b/test/files/run/virtpatmat_apply.scala index 34cb80e449..b8776f4afb 100644 --- a/test/files/run/virtpatmat_apply.scala +++ b/test/files/run/virtpatmat_apply.scala @@ -1,5 +1,5 @@ object Test extends App { - List(1, 2, 3) match { + List(1, 2, 3) match { case Nil => println("FAIL") case x :: y :: xs if xs.length == 2 => println("FAIL") case x :: y :: xs if xs.length == 1 => println("OK "+ y) diff --git a/test/files/run/virtpatmat_casting.scala b/test/files/run/virtpatmat_casting.scala index d970abae90..a36daec6fb 100644 --- a/test/files/run/virtpatmat_casting.scala +++ b/test/files/run/virtpatmat_casting.scala @@ -1,8 +1,9 @@ object Test extends App { - println(List(1,2,3) match { - case Nil => List(0) -// since the :: extractor's argument must be a ::, there has to be a cast before its unapply is invoked + println(List(1,2,3) match { + case Nil => List(0) +// since the :: extractor's argument must be a ::, there has to be a cast before its unapply is invoked case x :: y :: z :: a :: xs => xs ++ List(x) case x :: y :: z :: xs => xs ++ List(x) + case _ => List(0) }) } diff --git a/test/files/run/virtpatmat_literal.scala b/test/files/run/virtpatmat_literal.scala index 5bd6b30791..9a68d296b5 100644 --- a/test/files/run/virtpatmat_literal.scala +++ b/test/files/run/virtpatmat_literal.scala @@ -1,22 +1,22 @@ object Test extends App { val a = 1 - 1 match { - case 2 => println("FAILED") - case 1 => println("OK") - case `a` => println("FAILED") + 1 match { + case 2 => println("FAILED") + case 1 => println("OK") + case `a` => println("FAILED") } val one = 1 - 1 match { - case 2 => println("FAILED") - case `one` => println("OK") - case 1 => println("FAILED") + 1 match { + case 2 => println("FAILED") + case `one` => println("OK") + case 1 => println("FAILED") } - 1 match { - case 2 => println("FAILED") - case Test.one => println("OK") - case 1 => println("FAILED") + 1 match { + case 2 => println("FAILED") + case Test.one => println("OK") + case 1 => println("FAILED") } }
\ No newline at end of file diff --git a/test/files/run/virtpatmat_nested_lists.check b/test/files/run/virtpatmat_nested_lists.check index d8263ee986..ddf68eeedd 100644 --- a/test/files/run/virtpatmat_nested_lists.check +++ b/test/files/run/virtpatmat_nested_lists.check @@ -1 +1,4 @@ -2
\ No newline at end of file +virtpatmat_nested_lists.scala:5: warning: match may not be exhaustive. + List(List(1), List(2)) match { case x :: (y :: Nil) :: Nil => println(y) } + ^ +2 diff --git a/test/files/run/virtpatmat_nested_lists.flags b/test/files/run/virtpatmat_nested_lists.flags deleted file mode 100644 index 3f5a3100e4..0000000000 --- a/test/files/run/virtpatmat_nested_lists.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_nested_lists.scala b/test/files/run/virtpatmat_nested_lists.scala index fef74cea15..d1aa68ea93 100644 --- a/test/files/run/virtpatmat_nested_lists.scala +++ b/test/files/run/virtpatmat_nested_lists.scala @@ -1,3 +1,6 @@ +/* + * filter: It would fail on the following input + */ object Test extends App { List(List(1), List(2)) match { case x :: (y :: Nil) :: Nil => println(y) } } diff --git a/test/files/run/virtpatmat_opt_sharing.check b/test/files/run/virtpatmat_opt_sharing.check index d00491fd7e..78ec61f19d 100644 --- a/test/files/run/virtpatmat_opt_sharing.check +++ b/test/files/run/virtpatmat_opt_sharing.check @@ -1 +1,4 @@ +virtpatmat_opt_sharing.scala:7: warning: match may not be exhaustive. + List(1, 3, 4, 7) match { + ^ 1 diff --git a/test/files/run/virtpatmat_opt_sharing.flags b/test/files/run/virtpatmat_opt_sharing.flags deleted file mode 100644 index 3f5a3100e4..0000000000 --- a/test/files/run/virtpatmat_opt_sharing.flags +++ /dev/null @@ -1 +0,0 @@ - -Xexperimental diff --git a/test/files/run/virtpatmat_opt_sharing.scala b/test/files/run/virtpatmat_opt_sharing.scala index 119e3050ea..d2c42cab48 100644 --- a/test/files/run/virtpatmat_opt_sharing.scala +++ b/test/files/run/virtpatmat_opt_sharing.scala @@ -1,3 +1,6 @@ +/* + * filter: It would fail on the following input + */ object Test extends App { virtMatch() def virtMatch() = { @@ -7,4 +10,4 @@ object Test extends App { case 1 :: 3 :: 4 :: 7 :: x => println(1) } } -}
\ No newline at end of file +} diff --git a/test/files/run/virtpatmat_staging.scala b/test/files/run/virtpatmat_staging.scala index c17b45043b..d444829b02 100644 --- a/test/files/run/virtpatmat_staging.scala +++ b/test/files/run/virtpatmat_staging.scala @@ -1,3 +1,6 @@ + +import scala.language.{ higherKinds, implicitConversions } + trait Intf { type Rep[+T] type M[+T] = Rep[Maybe[T]] @@ -9,7 +12,7 @@ trait Intf { def zero: M[Nothing] def one[T](x: Rep[T]): M[T] - def guard[T](cond: Rep[Boolean], then: => Rep[T]): M[T] + def guard[T](cond: Rep[Boolean], dann: => Rep[T]): M[T] def isSuccess[T, U](x: Rep[T])(f: Rep[T] => M[U]): Rep[Boolean] // used for isDefinedAt } @@ -33,7 +36,7 @@ trait Impl extends Intf { def runOrElse[T, U](in: Rep[T])(matcher: Rep[T] => M[U]): Rep[U] = ("runOrElse("+ in +", ?" + matcher("?") + ")") def zero: M[Nothing] = "zero" def one[T](x: Rep[T]): M[T] = "one("+x.toString+")" - def guard[T](cond: Rep[Boolean], then: => Rep[T]): M[T] = "guard("+cond+","+then+")" + def guard[T](cond: Rep[Boolean], dann: => Rep[T]): M[T] = s"guard($cond,$dann)" def isSuccess[T, U](x: Rep[T])(f: Rep[T] => M[U]): Rep[Boolean] = ("isSuccess("+x+", ?" + f("?") + ")") } diff --git a/test/files/run/virtpatmat_stringinterp.scala b/test/files/run/virtpatmat_stringinterp.scala index 213712f17a..c6c951e6e5 100644 --- a/test/files/run/virtpatmat_stringinterp.scala +++ b/test/files/run/virtpatmat_stringinterp.scala @@ -1,3 +1,6 @@ + +import scala.language.{ implicitConversions } + object Test extends App { case class Node(x: Int) @@ -10,4 +13,4 @@ object Test extends App { val x: Node = Node(0) x match { case xml"""<foo arg=$a/>""" => println(a) } -}
\ No newline at end of file +} diff --git a/test/files/run/virtpatmat_switch.scala b/test/files/run/virtpatmat_switch.scala index 1329c19d0f..2f2e210d9e 100644 --- a/test/files/run/virtpatmat_switch.scala +++ b/test/files/run/virtpatmat_switch.scala @@ -4,11 +4,11 @@ object Test extends App { case 1 => "one" case _ => "many" } - + println(intSwitch(0)) println(intSwitch(1)) println(intSwitch(10)) - + def charSwitch(x: Char) = x match { case 'a' => "got a" case 'b' => "got b" @@ -20,15 +20,15 @@ object Test extends App { case 'b' => "got b" case _ => "got some letter" } - + println(charSwitch('a')) println(byteSwitch('b')) println(charSwitch('z')) - + def implicitDefault(x: Int) = x match { case 0 => 0 } - + try { implicitDefault(5) } catch { diff --git a/test/files/run/virtpatmat_try.scala b/test/files/run/virtpatmat_try.scala index 46e67cb72e..dab2c89227 100644 --- a/test/files/run/virtpatmat_try.scala +++ b/test/files/run/virtpatmat_try.scala @@ -8,7 +8,7 @@ object Test extends App { } catch { // this should emit a "catch-switch" case y: A => println(y.x) case (_ : A | _ : B) => println("B") - case _ => println("other") + case _: Throwable => println("other") } try { @@ -17,7 +17,7 @@ object Test extends App { // case A(x) => println(x) case y: A => println(y.x) case x@((_ : A) | (_ : B)) => println(x) - case _ => println("other") + case _: Throwable => println("other") } def simpleTry { @@ -34,7 +34,7 @@ object Test extends App { } def wildcardTry { - try { bla } catch { case _ => bla } + try { bla } catch { case _: Throwable => bla } } def tryPlusFinally { @@ -44,4 +44,4 @@ object Test extends App { def catchAndPassToLambda { try { bla } catch { case ex: Exception => val f = () => ex } } -}
\ No newline at end of file +} diff --git a/test/files/run/virtpatmat_typed.check b/test/files/run/virtpatmat_typed.check index cec2740d18..b304fa5ffc 100644 --- a/test/files/run/virtpatmat_typed.check +++ b/test/files/run/virtpatmat_typed.check @@ -1 +1,4 @@ +virtpatmat_typed.scala:5: warning: unreachable code + case x: String => println("FAILED") + ^ OK foo diff --git a/test/files/run/virtpatmat_typed.scala b/test/files/run/virtpatmat_typed.scala index a9863cc48a..cdd6d3c749 100644 --- a/test/files/run/virtpatmat_typed.scala +++ b/test/files/run/virtpatmat_typed.scala @@ -1,7 +1,7 @@ object Test extends App { - ("foo": Any) match { - case x: Int => println("FAILED") - case x: String => println("OK "+ x) - case x: String => println("FAILED") + ("foo": Any) match { + case x: Int => println("FAILED") + case x: String => println("OK "+ x) + case x: String => println("FAILED") } }
\ No newline at end of file diff --git a/test/files/run/virtpatmat_unapply.scala b/test/files/run/virtpatmat_unapply.scala index 6d7b4dbe68..a6e71f3963 100644 --- a/test/files/run/virtpatmat_unapply.scala +++ b/test/files/run/virtpatmat_unapply.scala @@ -6,12 +6,12 @@ object IntList { } object Test extends App { - IntList(1, IntList(2, NilIL)) match { + IntList(1, IntList(2, NilIL)) match { case IntList(a1, IntList(a2, IntList(a3, y))) => println(a1 + a2 + a3) case IntList(x, y) => println(x) } - IntList(1, IntList(2, IntList(3, NilIL))) match { + IntList(1, IntList(2, IntList(3, NilIL))) match { case IntList(a1, IntList(a2, IntList(a3, y))) => println(a1 + a2 + a3) case IntList(x, y) => println(x) } @@ -20,12 +20,12 @@ object Test extends App { // ((x1: IntList) => IntList.unapply(x1).flatMap(((x4: (Int, IntList)) => IntList.unapply(x4._2).flatMap(((x5: (Int, IntList)) => IntList.unapply(x5._2).flatMap(((x6: (Int, IntList)) => implicitly[Predef.MatchingStrategy[Option]].success(Predef.println(x4._1.+(x5._1).+(x6._1))))))))).orElse(IntList.unapply(x1).flatMap(((x7: (Int, IntList)) => implicitly[scala.Predef.MatchingStrategy[Option]].success(Predef.println(x7._1))))).orElse(implicitly[scala.Predef.MatchingStrategy[Option]].fail))(IntList.apply(1, IntList.apply(2, IntList.apply(3, null)))) /* - ((x1: IntList) => - IntList.this.unapply(x1).flatMap[Int](((x4: (Int, IntList)) => - IntList.this.unapply(x4._2).flatMap[Int](((x5: (Int, IntList)) => - IntList.this.unapply(x5._2).flatMap[Int](((x6: (Int, IntList)) => + ((x1: IntList) => + IntList.this.unapply(x1).flatMap[Int](((x4: (Int, IntList)) => + IntList.this.unapply(x4._2).flatMap[Int](((x5: (Int, IntList)) => + IntList.this.unapply(x5._2).flatMap[Int](((x6: (Int, IntList)) => Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).success[Int](x6._1))))))).orElse[Int]( - IntList.this.unapply(x1).flatMap[Int](((x7: (Int, IntList)) => + IntList.this.unapply(x1).flatMap[Int](((x7: (Int, IntList)) => Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).success[Int](x7._1)))).orElse[Int]( Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).fail) ).apply(IntList.apply(1, null)) diff --git a/test/files/run/xml-attribute.check b/test/files/run/xml-attribute.check deleted file mode 100644 index 3cfe3779fc..0000000000 --- a/test/files/run/xml-attribute.check +++ /dev/null @@ -1,12 +0,0 @@ -<t/> -<t/> -<t/> -<t/> -<t/> -<t b="1" d="2"/> -<t b="1" d="2"/> -<t b="1" d="2"/> -<t a="1" d="2"/> -<t b="1" d="2"/> -<t a="1" b="2" c="3"/> -<t g="1" e="2" p:a="3" f:e="4" mgruhu:ji="5"/> diff --git a/test/files/run/xml-attribute.scala b/test/files/run/xml-attribute.scala deleted file mode 100644 index eb3956c41b..0000000000 --- a/test/files/run/xml-attribute.scala +++ /dev/null @@ -1,37 +0,0 @@ -import xml.Node - -object Test { - def main(args: Array[String]): Unit = { - val noAttr = <t/> - val attrNull = <t a={ null: String }/> - val attrNone = <t a={ None: Option[Seq[Node]] }/> - val preAttrNull = <t p:a={ null: String }/> - val preAttrNone = <t p:a={ None: Option[Seq[Node]] }/> - assert(noAttr == attrNull) - assert(noAttr == attrNone) - assert(noAttr == preAttrNull) - assert(noAttr == preAttrNone) - - println(noAttr) - println(attrNull) - println(attrNone) - println(preAttrNull) - println(preAttrNone) - - val xml1 = <t b="1" d="2"/> - val xml2 = <t a={ null: String } p:a={ null: String } b="1" c={ null: String } d="2"/> - val xml3 = <t b="1" c={ null: String } d="2" a={ null: String } p:a={ null: String }/> - assert(xml1 == xml2) - assert(xml1 == xml3) - - println(xml1) - println(xml2) - println(xml3) - - // Check if attribute order is retained - println(<t a="1" d="2"/>) - println(<t b="1" d="2"/>) - println(<t a="1" b="2" c="3"/>) - println(<t g="1" e="2" p:a="3" f:e="4" mgruhu:ji="5"/>) - } -} diff --git a/test/files/run/xml-loop-bug.scala b/test/files/run/xml-loop-bug.scala deleted file mode 100644 index 67637674b2..0000000000 --- a/test/files/run/xml-loop-bug.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - val sink = new java.io.PrintStream(new java.io.ByteArrayOutputStream()) - Console setOut sink - Console setErr sink - scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<!DOCTYPE xmeml SYSTEM> <xmeml> <sequence> </sequence> </xmeml> "), true).document.docElem - } -} diff --git a/test/files/scalacheck/CheckCollections.scala b/test/files/scalacheck/CheckCollections.scala new file mode 100644 index 0000000000..108040b900 --- /dev/null +++ b/test/files/scalacheck/CheckCollections.scala @@ -0,0 +1,59 @@ +import org.scalacheck.{ ConsoleReporter, Properties } +import org.scalacheck.Prop._ + +import scala.reflect.internal.util.Collections._ + +object Test extends Properties("reflect.internal.util.Collections") { + def map2ConserveOld[A <: AnyRef, B](xs: List[A], ys: List[B])(f: (A, B) => A): List[A] = + if (xs.isEmpty || ys.isEmpty) xs + else { + val x1 = f(xs.head, ys.head) + val xs1 = map2Conserve(xs.tail, ys.tail)(f) + if ((x1 eq xs.head) && (xs1 eq xs.tail)) xs + else x1 :: xs1 + } + + val testfun: (String, Int) => String = { case(x, y) => + x.toLowerCase + y.toString + } + val testid: (String, Int) => String = { case (x, y) => x } + + val prop1_map2Conserve = forAll { (xs: List[String], ys: List[Int]) => + val res = map2Conserve(xs, ys)(testid) + res eq xs + } + + val prop2_map2Conserve = forAll { (xs: List[String], ys: List[Int]) => + map2Conserve(xs, ys)(testid) == map2ConserveOld(xs, ys)(testid) && + map2Conserve(xs, ys)(testfun) == map2ConserveOld(xs, ys)(testfun) + } + + def checkStackOverflow() { + var xs: List[String] = Nil + var ys: List[Int] = Nil + for (i <- 0 until 250000) { + xs = "X" :: xs + ys = 1 :: ys + } + map2Conserve(xs, ys){ case(x, y) => x.toLowerCase + y.toString } + } + + + val tests = List( + ("map2Conserve(identity)", prop1_map2Conserve), + ("map2Conserve == old impl", prop2_map2Conserve) + ) + + checkStackOverflow() + + for { + (label, prop) <- tests + } property(label) = prop + + import org.scalacheck.{ Test => STest } + + def runTests() = + STest.checkProperties( + STest.Params(testCallback = ConsoleReporter(0)), this) + +} diff --git a/test/files/scalacheck/CheckEither.scala b/test/files/scalacheck/CheckEither.scala index 4e8480d72e..4d0cab4693 100644 --- a/test/files/scalacheck/CheckEither.scala +++ b/test/files/scalacheck/CheckEither.scala @@ -8,18 +8,18 @@ import org.scalacheck.ConsoleReporter.testStatsEx import Function.tupled object Test extends Properties("Either") { - implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = + implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = Arbitrary[Either[X, Y]](oneOf(arbitrary[X].map(Left(_)), arbitrary[Y].map(Right(_)))) - val prop_either1 = forAll((n: Int) => Left(n).fold(x => x, b => error("fail")) == n) + val prop_either1 = forAll((n: Int) => Left(n).fold(x => x, b => sys.error("fail")) == n) - val prop_either2 = forAll((n: Int) => Right(n).fold(a => error("fail"), x => x) == n) + val prop_either2 = forAll((n: Int) => Right(n).fold(a => sys.error("fail"), x => x) == n) val prop_swap = forAll((e: Either[Int, Int]) => e match { case Left(a) => e.swap.right.get == a case Right(b) => e.swap.left.get == b }) - + val prop_isLeftRight = forAll((e: Either[Int, Int]) => e.isLeft != e.isRight) object CheckLeftProjection { @@ -35,7 +35,7 @@ object Test extends Properties("Either") { val prop_exists = forAll((e: Either[Int, Int]) => e.left.exists(_ % 2 == 0) == (e.isLeft && e.left.get % 2 == 0)) - + val prop_flatMapLeftIdentity = forAll((e: Either[Int, Int], n: Int, s: String) => { def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) Left(n).left.flatMap(f(_)) == f(n)}) @@ -115,7 +115,7 @@ object Test extends Properties("Either") { } val prop_Either_left = forAll((n: Int) => Left(n).left.get == n) - + val prop_Either_right = forAll((n: Int) => Right(n).right.get == n) val prop_Either_joinLeft = forAll((e: Either[Either[Int, Int], Int]) => e match { @@ -128,12 +128,12 @@ object Test extends Properties("Either") { case Right(ee) => e.joinRight == ee }) - val prop_Either_reduce = forAll((e: Either[Int, Int]) => + val prop_Either_reduce = forAll((e: Either[Int, Int]) => e.merge == (e match { case Left(a) => a case Right(a) => a })) - + /** Hard to believe I'm "fixing" a test to reflect B before A ... */ val prop_Either_cond = forAll((c: Boolean, a: Int, b: Int) => Either.cond(c, a, b) == (if(c) Right(a) else Left(b))) @@ -168,19 +168,19 @@ object Test extends Properties("Either") { ("Right.prop_seq", CheckRightProjection.prop_seq), ("Right.prop_option", CheckRightProjection.prop_option), ("prop_Either_left", prop_Either_left), - ("prop_Either_right", prop_Either_right), + ("prop_Either_right", prop_Either_right), ("prop_Either_joinLeft", prop_Either_joinLeft), - ("prop_Either_joinRight", prop_Either_joinRight), - ("prop_Either_reduce", prop_Either_reduce), + ("prop_Either_joinRight", prop_Either_joinRight), + ("prop_Either_reduce", prop_Either_reduce), ("prop_Either_cond", prop_Either_cond) ) - + for ((label, prop) <- tests) { property(label) = prop } - + import org.scalacheck.{ Test => STest } - + def runTests() = { STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), this) } diff --git a/test/files/scalacheck/Ctrie.scala b/test/files/scalacheck/Ctrie.scala index 736bf938bc..714f1c3b09 100644 --- a/test/files/scalacheck/Ctrie.scala +++ b/test/files/scalacheck/Ctrie.scala @@ -17,21 +17,21 @@ case class Wrap(i: Int) { /** A check mainly oriented towards checking snapshot correctness. */ object Test extends Properties("concurrent.TrieMap") { - + /* generators */ - + val sizes = choose(0, 200000) - + val threadCounts = choose(2, 16) - + val threadCountsAndSizes = for { p <- threadCounts sz <- sizes } yield (p, sz); - - + + /* helpers */ - + def inParallel[T](totalThreads: Int)(body: Int => T): Seq[T] = { val threads = for (idx <- 0 until totalThreads) yield new Thread { setName("ParThread-" + idx) @@ -44,11 +44,11 @@ object Test extends Properties("concurrent.TrieMap") { res } } - + threads foreach (_.start()) threads map (_.result) } - + def spawn[T](body: =>T): { def get: T } = { val t = new Thread { setName("SpawnThread") @@ -66,7 +66,7 @@ object Test extends Properties("concurrent.TrieMap") { } } } - + def elementRange(threadIdx: Int, totalThreads: Int, totalElems: Int): Range = { val sz = totalElems val idx = threadIdx @@ -76,7 +76,7 @@ object Test extends Properties("concurrent.TrieMap") { val end = start + elems (start until end) } - + def hasGrown[K, V](last: Map[K, V], current: Map[K, V]) = { (last.size <= current.size) && { last forall { @@ -84,7 +84,7 @@ object Test extends Properties("concurrent.TrieMap") { } } } - + object err { var buffer = new StringBuilder def println(a: AnyRef) = buffer.append(a.toString).append("\n") @@ -94,16 +94,16 @@ object Test extends Properties("concurrent.TrieMap") { clear() } } - - + + /* properties */ - + property("concurrent growing snapshots") = forAll(threadCounts, sizes) { (numThreads, numElems) => val p = 3 //numThreads val sz = 102 //numElems val ct = new TrieMap[Wrap, Int] - + // checker val checker = spawn { def check(last: Map[Wrap, Int], iterationsLeft: Int): Boolean = { @@ -115,23 +115,23 @@ object Test extends Properties("concurrent.TrieMap") { } check(ct.readOnlySnapshot(), 500) } - + // fillers inParallel(p) { idx => elementRange(idx, p, sz) foreach (i => ct.update(Wrap(i), i)) } - + // wait for checker to finish val growing = true//checker.get - + val ok = growing && ((0 until sz) forall { case i => ct.get(Wrap(i)) == Some(i) }) - + ok } - + property("update") = forAll(sizes) { (n: Int) => val ct = new TrieMap[Int, Int] @@ -140,52 +140,52 @@ object Test extends Properties("concurrent.TrieMap") { case i => ct(i) == i } } - + property("concurrent update") = forAll(threadCountsAndSizes) { case (p, sz) => val ct = new TrieMap[Wrap, Int] - + inParallel(p) { idx => for (i <- elementRange(idx, p, sz)) ct(Wrap(i)) = i } - + (0 until sz) forall { case i => ct(Wrap(i)) == i } } - - + + property("concurrent remove") = forAll(threadCounts, sizes) { (p, sz) => val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct(Wrap(i)) = i - + inParallel(p) { idx => for (i <- elementRange(idx, p, sz)) ct.remove(Wrap(i)) } - + (0 until sz) forall { case i => ct.get(Wrap(i)) == None } } - - + + property("concurrent putIfAbsent") = forAll(threadCounts, sizes) { (p, sz) => val ct = new TrieMap[Wrap, Int] - + val results = inParallel(p) { idx => elementRange(idx, p, sz) find (i => ct.putIfAbsent(Wrap(i), i) != None) } - + (results forall (_ == None)) && ((0 until sz) forall { case i => ct.get(Wrap(i)) == Some(i) }) } - + } diff --git a/test/files/scalacheck/HashTrieSplit.scala b/test/files/scalacheck/HashTrieSplit.scala deleted file mode 100644 index 908c878f54..0000000000 --- a/test/files/scalacheck/HashTrieSplit.scala +++ /dev/null @@ -1,47 +0,0 @@ - - - - - -import collection._ - - - - -// checks whether hash tries split their iterators correctly -// even after some elements have been traversed -object Test { - def main(args: Array[String]) { - doesSplitOk - } - - def doesSplitOk = { - val sz = 2000 - var ht = new parallel.immutable.ParHashMap[Int, Int] - // println("creating trie") - for (i <- 0 until sz) ht += ((i + sz, i)) - // println("created trie") - for (n <- 0 until (sz - 1)) { - // println("---------> n = " + n) - val pit = ht.splitter - val pit2 = ht.splitter - var i = 0 - while (i < n) { - pit.next - pit2.next - i += 1 - } - // println("splitting") - val pits = pit.split - val fst = pits(0).toSet - val snd = pits(1).toSet - val orig = pit2.toSet - if (orig.size != (fst.size + snd.size) || orig != (fst ++ snd)) { - println("Original: " + orig) - println("First: " + fst) - println("Second: " + snd) - assert(false) - } - } - } -} diff --git a/test/files/scalacheck/ReflectionExtractors.scala b/test/files/scalacheck/ReflectionExtractors.scala new file mode 100644 index 0000000000..a2615feb3e --- /dev/null +++ b/test/files/scalacheck/ReflectionExtractors.scala @@ -0,0 +1,52 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object Test extends Properties("reflection extractors") { + + val genFlag = oneOf( + TRAIT, INTERFACE, MUTABLE, MACRO, DEFERRED, ABSTRACT, FINAL, SEALED, + IMPLICIT, LAZY, OVERRIDE, PRIVATE, PROTECTED, LOCAL, CASE, ABSOVERRIDE, + BYNAMEPARAM, PARAM, COVARIANT, CONTRAVARIANT, DEFAULTPARAM, PRESUPER, + DEFAULTINIT + ) + val genModifiers = + for(flag <- genFlag; privateWithin <- genName) + yield Modifiers(flag, privateWithin, Nil) + val genTermName = for(name <- arbitrary[String]) yield TermName(name) + val genTypeName = for(name <- arbitrary[String]) yield TypeName(name) + val genName = oneOf(genTermName, genTypeName) + + implicit val arbTermName: Arbitrary[TermName] = Arbitrary(genTermName) + implicit val arbTypeName: Arbitrary[TypeName] = Arbitrary(genTypeName) + implicit val arbName: Arbitrary[Name] = Arbitrary(genName) + implicit val arbMods: Arbitrary[Modifiers] = Arbitrary(genModifiers) + + property("extract term name") = forAll { (name: TermName) => + val TermName(s) = name + s == name.toString + } + + property("extract type name") = forAll { (name: TypeName) => + val TypeName(s) = name + s == name.toString + } + + property("extract term or type name") = forAll { (name: Name) => + name match { + case TermName(s) => s == name.toString + case TypeName(s) => s == name.toString + } + } + + property("extract modifiers") = forAll { (mods: Modifiers) => + val Modifiers(flags, priv, annots) = mods + flags == mods.flags && + priv == mods.privateWithin && + annots == mods.annotations + } +}
\ No newline at end of file diff --git a/test/files/scalacheck/Unrolled.scala b/test/files/scalacheck/Unrolled.scala index 8067a44501..34604b8667 100644 --- a/test/files/scalacheck/Unrolled.scala +++ b/test/files/scalacheck/Unrolled.scala @@ -5,7 +5,7 @@ import Gen._ import collection.mutable.UnrolledBuffer object Test extends Properties("UnrolledBuffer") { - + property("concat size") = forAll { (l1: List[Int], l2: List[Int]) => val u1 = new UnrolledBuffer[Int] u1 ++= l1 @@ -15,12 +15,12 @@ object Test extends Properties("UnrolledBuffer") { u1 concat u2 totalsz == u1.size } - + property("adding") = forAll { (l: List[Int]) => val u = new UnrolledBuffer[Int] u ++= l u == l } - + } diff --git a/test/files/scalacheck/array-old.scala b/test/files/scalacheck/array-old.scala index f262bc6320..03c0217180 100644 --- a/test/files/scalacheck/array-old.scala +++ b/test/files/scalacheck/array-old.scala @@ -11,7 +11,7 @@ object Test extends Properties("Array") { */ implicit def arbArray[T](implicit a: Arbitrary[T], m: Manifest[T]): Arbitrary[Array[T]] = Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray)) - + val arrGen: Gen[Array[_]] = oneOf( arbitrary[Array[Int]], arbitrary[Array[Array[Int]]], @@ -20,7 +20,7 @@ object Test extends Properties("Array") { arbitrary[Array[Boolean]], arbitrary[Array[AnyVal]] ) - + // inspired by #1857 and #2352 property("eq/ne") = forAll(arrGen, arrGen) { (c1, c2) => (c1 eq c2) || (c1 ne c2) @@ -32,6 +32,6 @@ object Test extends Properties("Array") { val arr = Array.ofDim[String](i1, i2, i3) val flattened = arr flatMap (x => x) flatMap (x => x) flattened.length == i1 * i2 * i3 - } + } } diff --git a/test/files/scalacheck/avl.scala b/test/files/scalacheck/avl.scala index af79ad49e3..4cfacaf407 100644 --- a/test/files/scalacheck/avl.scala +++ b/test/files/scalacheck/avl.scala @@ -2,14 +2,12 @@ import org.scalacheck.Gen import org.scalacheck.Prop.forAll import org.scalacheck.Properties -import util.logging.ConsoleLogger - package scala.collection.mutable { /** * Property of an AVL Tree : Any node of the tree has a balance value beetween in [-1; 1] */ - abstract class AVLTreeTest(name: String) extends Properties(name) with ConsoleLogger { + abstract class AVLTreeTest(name: String) extends Properties(name) { def `2^`(n: Int) = (1 to n).fold(1)((a, b) => b*2) @@ -54,7 +52,7 @@ package scala.collection.mutable { } yield { // selected mustn't be in elements already val list = makeAllBalancedTree(elements.sorted.distinct.map(_*2)) - (selected*2+1, list) + (selected*2+1, list) } def genInputDelete: org.scalacheck.Gen[(Int, List[AVLTree[Int]])] = for { @@ -65,7 +63,7 @@ package scala.collection.mutable { } yield { // selected must be in elements already val list = makeAllBalancedTree(e) - (e(selected), list) + (e(selected), list) } } @@ -78,7 +76,7 @@ package scala.collection.mutable { } def setup(invariant: AVLTree[Int] => Boolean) = forAll(genInput) { - case (selected: Int, trees: List[AVLTree[Int]]) => + case (selected: Int, trees: List[AVLTree[Int]]) => trees.map(tree => invariant(tree)).fold(true)((a, b) => a && b) } diff --git a/test/files/scalacheck/list.scala b/test/files/scalacheck/list.scala index 4e1cf1fc80..5f6de95237 100644 --- a/test/files/scalacheck/list.scala +++ b/test/files/scalacheck/list.scala @@ -12,7 +12,7 @@ object Test extends Properties("List") { property("startsWith/take") = forAll { (xs: List[Int], count: Int) => xs startsWith (xs take count) } property("endsWith/takeRight") = forAll { (xs: List[Int], count: Int) => xs endsWith (xs takeRight count) } property("fill") = forAll(choose(1, 100)) { count => - forAll { (x: Int) => + forAll { (x: Int) => val xs = List.fill(count)(x) (xs.length == count) && (xs.distinct == List(x)) } diff --git a/test/files/scalacheck/parallel-collections/IntOperators.scala b/test/files/scalacheck/parallel-collections/IntOperators.scala index 5c997962ba..4a74b91da8 100644 --- a/test/files/scalacheck/parallel-collections/IntOperators.scala +++ b/test/files/scalacheck/parallel-collections/IntOperators.scala @@ -106,7 +106,7 @@ trait IntSeqOperators extends IntOperators with SeqOperators[Int] { List(4, 5, 6, 7, 8, 9, 10), List(4, 5, 6, 7, 8, 9, 0), List(-4, -3, -2, -1) - ) + ) } diff --git a/test/files/scalacheck/parallel-collections/PairOperators.scala b/test/files/scalacheck/parallel-collections/PairOperators.scala index 4711e21c34..fe851114be 100644 --- a/test/files/scalacheck/parallel-collections/PairOperators.scala +++ b/test/files/scalacheck/parallel-collections/PairOperators.scala @@ -7,76 +7,76 @@ import scala.collection.parallel._ trait PairOperators[K, V] extends Operators[(K, V)] { def koperators: Operators[K] def voperators: Operators[V] - + private def zipPredicates(kps: List[K => Boolean], vps: List[V => Boolean]): List[((K, V)) => Boolean] = for { (kp, vp) <- koperators.countPredicates zip voperators.countPredicates } yield new Function1[(K, V), Boolean] { def apply(kv: (K, V)) = kp(kv._1) && vp(kv._2) } - + /* operators */ - + def reduceOperators = for { (kop, vop) <- koperators.reduceOperators zip voperators.reduceOperators } yield new Function2[(K, V), (K, V), (K, V)] { def apply(kv1: (K, V), kv2: (K, V)) = (kop(kv1._1, kv2._1), vop(kv1._2, kv2._2)) } - + def countPredicates = zipPredicates(koperators.countPredicates, voperators.countPredicates) - + def forallPredicates = zipPredicates(koperators.forallPredicates, voperators.forallPredicates) - + def existsPredicates = zipPredicates(koperators.existsPredicates, voperators.existsPredicates) - + def findPredicates = zipPredicates(koperators.findPredicates, voperators.findPredicates) - + def mapFunctions = for { (km, vm) <- koperators.mapFunctions zip voperators.mapFunctions } yield new Function1[(K, V), (K, V)] { def apply(kv: (K, V)) = (km(kv._1), vm(kv._2)) } - + def partialMapFunctions = for { (kpm, vpm) <- koperators.partialMapFunctions zip voperators.partialMapFunctions } yield new PartialFunction[(K, V), (K, V)] { def isDefinedAt(kv: (K, V)) = kpm.isDefinedAt(kv._1) && vpm.isDefinedAt(kv._2) def apply(kv: (K, V)) = (kpm(kv._1), vpm(kv._2)) } - + def flatMapFunctions = for { (kfm, vfm) <- koperators.flatMapFunctions zip voperators.flatMapFunctions } yield new Function1[(K, V), Traversable[(K, V)]] { def apply(kv: (K, V)) = kfm(kv._1).toIterable zip vfm(kv._2).toIterable } - + def filterPredicates = zipPredicates(koperators.filterPredicates, voperators.filterPredicates) - + def filterNotPredicates = filterPredicates - + def partitionPredicates = filterPredicates - + def takeWhilePredicates = zipPredicates(koperators.takeWhilePredicates, voperators.takeWhilePredicates) - + def dropWhilePredicates = takeWhilePredicates - + def spanPredicates = takeWhilePredicates - + def foldArguments = for { ((kinit, kop), (vinit, vop)) <- koperators.foldArguments zip voperators.foldArguments } yield ((kinit, vinit), new Function2[(K, V), (K, V), (K, V)] { def apply(kv1: (K, V), kv2: (K, V)) = (kop(kv1._1, kv2._1), vop(kv1._2, kv2._2)) }) - + def addAllTraversables = for { (kt, vt) <- koperators.addAllTraversables zip voperators.addAllTraversables } yield kt.toIterable zip vt.toIterable - + def newArray(sz: Int) = new Array[(K, V)](sz) - + def groupByFunctions = (koperators.groupByFunctions zip voperators.groupByFunctions) map { opt => { (p: (K, V)) => (opt._1(p._1), opt._2(p._2)) } } - + } diff --git a/test/files/scalacheck/parallel-collections/PairValues.scala b/test/files/scalacheck/parallel-collections/PairValues.scala index 5007c4598b..864dad2425 100644 --- a/test/files/scalacheck/parallel-collections/PairValues.scala +++ b/test/files/scalacheck/parallel-collections/PairValues.scala @@ -17,7 +17,7 @@ import org.scalacheck.Arbitrary._ trait PairValues[K, V] { def kvalues: Seq[Gen[K]] def vvalues: Seq[Gen[V]] - + def values = for { kg <- kvalues vg <- vvalues diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala b/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala index a01c8c7dbe..255c04498e 100644 --- a/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelArrayCheck.scala @@ -17,11 +17,11 @@ import scala.collection.parallel.ops._ abstract class ParallelArrayCheck[T](tp: String) extends ParallelSeqCheck[T]("ParArray[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParArray[T] - + def isCheckingViews = false - + def hasStrictOrder = true def ofSize(vals: Seq[Gen[T]], sz: Int) = { @@ -30,7 +30,7 @@ abstract class ParallelArrayCheck[T](tp: String) extends ParallelSeqCheck[T]("Pa for (i <- 0 until sz) a += sample(gen) a } - + def fromSeq(a: Seq[T]) = { val pa = new ParArray[T](a.size) var i = 0 @@ -40,20 +40,20 @@ abstract class ParallelArrayCheck[T](tp: String) extends ParallelSeqCheck[T]("Pa } pa } - + property("array mappings must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((f, ind) <- mapFunctions.zipWithIndex) yield ("op index: " + ind) |: t.map(f) == coll.map(f) results.reduceLeft(_ && _) } - + } object IntParallelArrayCheck extends ParallelArrayCheck[Int]("Int") with IntSeqOperators with IntValues { override def instances(vals: Seq[Gen[Int]]) = oneOf(super.instances(vals), sized { sz => (0 until sz).toArray.toSeq - }, sized { sz => + }, sized { sz => (-sz until 0).toArray.toSeq }) } diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala b/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala index 680f6e1d28..db2b1ea01e 100644 --- a/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala +++ b/test/files/scalacheck/parallel-collections/ParallelArrayTest.scala @@ -15,7 +15,7 @@ // /** // * this currently passes, but do we want it to? -// * does it have meaning to have an empty parallel array? +// * does it have meaning to have an empty parallel array? // */ // new ParallelArray(0) // () diff --git a/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala b/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala index d2a8fa7c22..9805e2644f 100644 --- a/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelArrayViewCheck.scala @@ -24,18 +24,18 @@ // extends ParallelSeqCheck[T]("ParallelSeqView[" + tp + ", ParallelArray[" + tp + "]]") { // // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + // type CollType = ParallelSeqView[T, ParallelArray[T], ArraySeq[T]] - + // def isCheckingViews = true - + // def instances(vals: Seq[Gen[T]]): Gen[Seq[T]] = sized { sz => // val a = new ArrayBuffer[T](sz) // val gen = vals(rnd.nextInt(vals.size)) // for (i <- 0 until sz) a += sample(gen) // a // } - + // def fromSeq(a: Seq[T]) = { // val pa = new ParallelArray[T](a.size) // var i = 0 @@ -45,13 +45,13 @@ // } // pa.view // } - + // property("forces must be equal") = forAll(collectionPairs) { case (s, coll) => // val smodif = (s ++ s).reverse.take(s.length).reverse.zip(s).drop(s.length / 2) // val cmodif = (coll ++ s).reverse.take(s.length).reverse.zip(s).drop(s.length / 2).force // smodif == cmodif // } - + // } @@ -68,18 +68,18 @@ // extends ParallelSeqCheck[T]("ParallelSeqView[" + tp + "], ParallelArray[" + tp + "].++.patch.reverse.take.reverse") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + // type CollType = collection.parallel.ParallelSeq[T] - + // def isCheckingViews = true - + // def instances(vals: Seq[Gen[T]]): Gen[Seq[T]] = sized { sz => // val a = new ArrayBuffer[T](sz) // val gen = vals(rnd.nextInt(vals.size)) // for (i <- 0 until sz) a += sample(gen) // a // } - + // def fromSeq(a: Seq[T]) = { // val pa = new ParallelArray[T](a.size) // var i = 0 @@ -91,7 +91,7 @@ // val original = modified.take(modified.length / 2).reverse // original // } - + // } diff --git a/test/files/scalacheck/parallel-collections/ParallelCtrieCheck.scala b/test/files/scalacheck/parallel-collections/ParallelCtrieCheck.scala index e141c398fd..b952704af2 100644 --- a/test/files/scalacheck/parallel-collections/ParallelCtrieCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelCtrieCheck.scala @@ -18,20 +18,20 @@ import scala.collection.parallel.ops._ abstract class ParallelConcurrentTrieMapCheck[K, V](tp: String) extends ParallelMapCheck[K, V]("mutable.ParConcurrentTrieMap[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParTrieMap[K, V] - + def isCheckingViews = false - + def hasStrictOrder = false - def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { + def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { val ct = new concurrent.TrieMap[K, V] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) ct += sample(gen) ct } - + def fromTraversable(t: Traversable[(K, V)]) = { val pct = new ParTrieMap[K, V] var i = 0 @@ -41,7 +41,7 @@ abstract class ParallelConcurrentTrieMapCheck[K, V](tp: String) extends Parallel } pct } - + } @@ -52,22 +52,22 @@ with PairValues[Int, Int] def intvalues = new IntValues {} def kvalues = intvalues.values def vvalues = intvalues.values - + val intoperators = new IntOperators {} def voperators = intoperators def koperators = intoperators - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParTrieMap[k, v] => println("Mutable parallel ctrie") case _ => println("could not match data structure type: " + ds.getClass) } - + override def checkDataStructureInvariants(orig: Traversable[(Int, Int)], ds: AnyRef) = ds match { // case pm: ParHashMap[k, v] if 1 == 0 => // disabled this to make tests faster // val invs = pm.brokenInvariants - + // val containsall = (for ((k, v) <- orig) yield { // if (pm.asInstanceOf[ParHashMap[Int, Int]].get(k) == Some(v)) true // else { @@ -75,8 +75,8 @@ with PairValues[Int, Int] // false // } // }).foldLeft(true)(_ && _) - - + + // if (invs.isEmpty) containsall // else { // println("Invariants broken:\n" + invs.mkString("\n")) @@ -84,7 +84,7 @@ with PairValues[Int, Int] // } case _ => true } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala index 0152b1b435..9299a201a1 100644 --- a/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelHashMapCheck.scala @@ -17,20 +17,20 @@ import scala.collection.parallel.ops._ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K, V]("mutable.ParHashMap[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParHashMap[K, V] - + def isCheckingViews = false - + def hasStrictOrder = false - def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { + def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { val hm = new mutable.HashMap[K, V] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) hm += sample(gen) hm } - + def fromTraversable(t: Traversable[(K, V)]) = { val phm = new ParHashMap[K, V] var i = 0 @@ -40,7 +40,7 @@ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K } phm } - + } @@ -51,22 +51,22 @@ with PairValues[Int, Int] def intvalues = new IntValues {} def kvalues = intvalues.values def vvalues = intvalues.values - + val intoperators = new IntOperators {} def voperators = intoperators def koperators = intoperators - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParHashMap[k, v] => println("Mutable parallel hash map\n" + pm.hashTableContents.debugInformation) case _ => println("could not match data structure type: " + ds.getClass) } - + override def checkDataStructureInvariants(orig: Traversable[(Int, Int)], ds: AnyRef) = ds match { // case pm: ParHashMap[k, v] if 1 == 0 => // disabled this to make tests faster // val invs = pm.brokenInvariants - + // val containsall = (for ((k, v) <- orig) yield { // if (pm.asInstanceOf[ParHashMap[Int, Int]].get(k) == Some(v)) true // else { @@ -74,8 +74,8 @@ with PairValues[Int, Int] // false // } // }).foldLeft(true)(_ && _) - - + + // if (invs.isEmpty) containsall // else { // println("Invariants broken:\n" + invs.mkString("\n")) @@ -83,7 +83,7 @@ with PairValues[Int, Int] // } case _ => true } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala index a0a6d1ae5e..8b41908a26 100644 --- a/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelHashSetCheck.scala @@ -17,20 +17,20 @@ import scala.collection.parallel.ops._ abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T]("mutable.ParHashSet[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParHashSet[T] - + def isCheckingViews = false - + def hasStrictOrder = false - def ofSize(vals: Seq[Gen[T]], sz: Int) = { + def ofSize(vals: Seq[Gen[T]], sz: Int) = { val hm = new mutable.HashSet[T] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) hm += sample(gen) hm } - + def fromTraversable(t: Traversable[T]) = { val phm = new ParHashSet[T] var i = 0 @@ -40,7 +40,7 @@ abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T](" } phm } - + } @@ -54,12 +54,12 @@ with IntValues case _ => println("could not match data structure type: " + ds.getClass) } - + override def checkDataStructureInvariants(orig: Traversable[Int], ds: AnyRef) = ds match { // case pm: ParHashSet[t] if 1 == 0 => // // for an example of how not to write code proceed below // val invs = pm.brokenInvariants - + // val containsall = (for (elem <- orig) yield { // if (pm.asInstanceOf[ParHashSet[Int]](elem) == true) true // else { @@ -69,8 +69,8 @@ with IntValues // false // } // }).foldLeft(true)(_ && _) - - + + // if (invs.isEmpty) { // if (!containsall) println(pm.debugInformation) // containsall @@ -80,7 +80,7 @@ with IntValues // } case _ => true } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala b/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala index 3a2893f48a..bbec52dc92 100644 --- a/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelHashTrieCheck.scala @@ -17,20 +17,20 @@ import scala.collection.parallel.ops._ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K, V]("immutable.ParHashMap[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParHashMap[K, V] - + def isCheckingViews = false - + def hasStrictOrder = false - + def ofSize(vals: Seq[Gen[(K, V)]], sz: Int) = { var hm = new immutable.HashMap[K, V] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) hm += sample(gen) hm } - + def fromTraversable(t: Traversable[(K, V)]) = { var phm = new ParHashMap[K, V] var i = 0 @@ -40,7 +40,7 @@ abstract class ParallelHashMapCheck[K, V](tp: String) extends ParallelMapCheck[K } phm } - + } @@ -51,11 +51,11 @@ with PairValues[Int, Int] def intvalues = new IntValues {} def kvalues = intvalues.values def vvalues = intvalues.values - + val intoperators = new IntOperators {} def voperators = intoperators def koperators = intoperators - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParHashMap[k, v] => pm.printDebugInfo @@ -69,20 +69,20 @@ with PairValues[Int, Int] abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T]("immutable.ParHashSet[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParHashSet[T] - + def isCheckingViews = false - + def hasStrictOrder = false - + def ofSize(vals: Seq[Gen[T]], sz: Int) = { var hm = new immutable.HashSet[T] val gen = vals(rnd.nextInt(vals.size)) for (i <- 0 until sz) hm += sample(gen) hm } - + def fromTraversable(t: Traversable[T]) = { var phm = new ParHashSet[T] var i = 0 @@ -92,14 +92,14 @@ abstract class ParallelHashSetCheck[T](tp: String) extends ParallelSetCheck[T](" } phm } - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParHashSet[t] => println("Parallel hash set") case _ => println("could not match data structure type: " + ds.getClass) } - + } @@ -110,7 +110,7 @@ with IntValues def intvalues = new IntValues {} def kvalues = intvalues.values def vvalues = intvalues.values - + override def printDataStructureDebugInfo(ds: AnyRef) = ds match { case pm: ParHashMap[k, v] => pm.printDebugInfo diff --git a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala index e3f8778bca..26fa71d72c 100644 --- a/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelIterableCheck.scala @@ -16,14 +16,14 @@ import scala.collection.parallel._ abstract class ParallelIterableCheck[T](collName: String) extends Properties(collName) with Operators[T] { type CollType <: ParIterable[T] - + def values: Seq[Gen[T]] def ofSize(vals: Seq[Gen[T]], sz: Int): Iterable[T] def fromTraversable(t: Traversable[T]): CollType def isCheckingViews: Boolean def hasStrictOrder: Boolean - - + + def instances(vals: Seq[Gen[T]]): Gen[Iterable[T]] = oneOf( sized( sz => @@ -31,46 +31,46 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ), for (sz <- choose(1000, 2000)) yield ofSize(vals, sz), for (sz <- choose(4000, 4001)) yield ofSize(vals, sz), - for (sz <- choose(10000, 10001)) yield ofSize(vals, sz) + for (sz <- choose(10000, 10001)) yield ofSize(vals, sz) ) - + // used to check if constructed collection is valid def checkDataStructureInvariants(orig: Traversable[T], cf: AnyRef) = { // can be overriden in subclasses true } - + def printDataStructureDebugInfo(cf: AnyRef) { // can be overridden in subclasses } - + val rnd = new scala.util.Random - + def sample(gen: Gen[T]): T = { var s = gen.sample while (s == None) s = gen.sample s.get } - + def sampleValue: T = sample(values(rnd.nextInt(values.length))) - + def collectionPairs = for (inst <- instances(values)) yield (inst, fromTraversable(inst)) - + def collectionPairsWithLengths = for (inst <- instances(values); s <- choose(0, inst.size)) yield (inst, fromTraversable(inst), s) - + def collectionPairsWith2Indices = for ( inst <- instances(values); f <- choose(0, inst.size); s <- choose(0, inst.size)) yield (inst, fromTraversable(inst), f, s) - - def collectionTriplets = for (inst <- instances(values); + + def collectionTriplets = for (inst <- instances(values); updStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { val modif = inst.toSeq.patch(updStart, inst.toSeq, howMany) (inst, fromTraversable(inst), modif) } - + def areEqual(t1: GenTraversable[T], t2: GenTraversable[T]) = if (hasStrictOrder) { t1 == t2 && t2 == t1 } else (t1, t2) match { // it is slightly delicate what `equal` means if the order is not strict @@ -81,14 +81,14 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col i1s == i2s && i2s == i1s case _ => t1 == t2 && t2 == t1 } - + def printDebugInfo(coll: ParIterableLike[_, _, _]) { println("Collection debug info: ") coll.printDebugBuffer println("Task debug info: ") println(coll.tasksupport.debugMessages.mkString("\n")) } - + def printComparison(t: Traversable[_], coll: ParIterable[_], tf: Traversable[_], cf: ParIterable[_], ind: Int) { printDebugInfo(coll) println("Operator: " + ind) @@ -108,7 +108,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col println("tf == cf - " + (tf == cf)) println("cf == tf - " + (cf == tf)) } - + property("reductions must be equal for assoc. operators") = forAll(collectionPairs) { case (t, coll) => if (t.size != 0) { val results = for ((op, ind) <- reduceOperators.zipWithIndex) yield { @@ -126,7 +126,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col results.reduceLeft(_ && _) } else "has size 0" |: true } - + property("counts must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((pred, ind) <- countPredicates.zipWithIndex) yield { val tc = t.count(pred) @@ -142,19 +142,19 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } results.reduceLeft(_ && _) } - + property("forall must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((pred, ind) <- forallPredicates.zipWithIndex) yield ("op index: " + ind) |: t.forall(pred) == coll.forall(pred) results.reduceLeft(_ && _) } - + property("exists must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((pred, ind) <- existsPredicates.zipWithIndex) yield ("op index: " + ind) |: t.exists(pred) == coll.exists(pred) results.reduceLeft(_ && _) } - + property("both must find or not find an element") = forAll(collectionPairs) { case (t, coll) => val results = for ((pred, ind) <- findPredicates.zipWithIndex) yield { val ft = t.find(pred) @@ -163,7 +163,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } results.reduceLeft(_ && _) } - + property("mappings must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((f, ind) <- mapFunctions.zipWithIndex) yield { val ms = t.map(f) @@ -184,7 +184,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } results.reduceLeft(_ && _) } - + property("collects must be equal") = forAll(collectionPairs) { case (t, coll) => val results = for ((f, ind) <- partialMapFunctions.zipWithIndex) yield { val ps = t.collect(f) @@ -200,12 +200,12 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } results.reduceLeft(_ && _) } - + property("flatMaps must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((f, ind) <- flatMapFunctions.zipWithIndex) yield ("op index: " + ind) |: areEqual(t.flatMap(f), coll.flatMap(f))).reduceLeft(_ && _) } - + property("filters must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((p, ind) <- filterPredicates.zipWithIndex) yield { val tf = t.filter(p) @@ -234,7 +234,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("op index: " + ind) |: tf == cf && cf == tf && invs }).reduceLeft(_ && _) } - + property("filterNots must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((p, ind) <- filterNotPredicates.zipWithIndex) yield { val tf = t.filterNot(p) @@ -243,7 +243,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("op index: " + ind) |: tf == cf && cf == tf }).reduceLeft(_ && _) } - + if (!isCheckingViews) property("partitions must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((p, ind) <- partitionPredicates.zipWithIndex) yield { val tpart = t.partition(p) @@ -257,15 +257,15 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("op index: " + ind) |: tpart == cpart }).reduceLeft(_ && _) } - + if (hasStrictOrder) property("takes must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) => ("take " + n + " elements") |: t.take(n) == coll.take(n) } - + if (hasStrictOrder) property("drops must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) => ("drop " + n + " elements") |: t.drop(n) == coll.drop(n) } - + if (hasStrictOrder) property("slices must be equal") = forAll(collectionPairsWith2Indices) { case (t, coll, fr, slicelength) => val from = if (fr < 0) 0 else fr @@ -289,7 +289,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } ("slice from " + from + " until " + until) |: tsl == collsl } - + if (hasStrictOrder) property("splits must be equal") = forAll(collectionPairsWithLengths) { case (t, coll, n) => val tspl = t.splitAt(n) val cspl = coll.splitAt(n) @@ -302,7 +302,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } ("splitAt " + n) |: tspl == cspl } - + if (hasStrictOrder) property("takeWhiles must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((pred, ind) <- takeWhilePredicates.zipWithIndex) yield { val tt = t.takeWhile(pred) @@ -317,7 +317,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tt == ct }).reduceLeft(_ && _) } - + if (hasStrictOrder) property("spans must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((pred, ind) <- spanPredicates.zipWithIndex) yield { val tsp = t.span(pred) @@ -335,13 +335,13 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tsp == csp }).reduceLeft(_ && _) } - + if (hasStrictOrder) property("dropWhiles must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((pred, ind) <- dropWhilePredicates.zipWithIndex) yield { ("operator " + ind) |: t.dropWhile(pred) == coll.dropWhile(pred) }).reduceLeft(_ && _) } - + property("folds must be equal for assoc. operators") = forAll(collectionPairs) { case (t, coll) => (for (((first, op), ind) <- foldArguments.zipWithIndex) yield { val tres = t.foldLeft(first)(op) @@ -356,7 +356,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tres == cres }).reduceLeft(_ && _) } - + property("++s must be equal") = forAll(collectionTriplets) { case (t, coll, colltoadd) => val toadd = colltoadd val tr = t ++ toadd.iterator @@ -383,7 +383,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("traversable " + ind) |: areEqual(tadded, cadded) }).reduceLeft(_ && _) } - + if (hasStrictOrder) property("copies to array must be equal") = forAll(collectionPairs) { case (t, coll) => val tarr = newArray(t.size) val collarr = newArray(coll.size) @@ -397,7 +397,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col } tarr.toSeq == collarr.toSeq } - + if (hasStrictOrder) property("scans must be equal") = forAll(collectionPairs) { case (t, coll) => (for (((first, op), ind) <- foldArguments.zipWithIndex) yield { @@ -413,7 +413,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tscan == cscan && cscan == tscan }).reduceLeft(_ && _) } - + property("groupBy must be equal") = forAll(collectionPairs) { case (t, coll) => (for ((f, ind) <- groupByFunctions.zipWithIndex) yield { @@ -429,7 +429,7 @@ abstract class ParallelIterableCheck[T](collName: String) extends Properties(col ("operator " + ind) |: tgroup == cgroup && cgroup == tgroup }).reduceLeft(_ && _) } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala b/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala index b6af8f41bd..d4643e7f2c 100644 --- a/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala +++ b/test/files/scalacheck/parallel-collections/ParallelMapCheck1.scala @@ -16,15 +16,15 @@ import scala.collection.parallel._ abstract class ParallelMapCheck[K, V](collname: String) extends ParallelIterableCheck[(K, V)](collname) { type CollType <: ParMap[K, V] - + property("gets iterated keys") = forAll(collectionPairs) { case (t, coll) => val containsT = for ((k, v) <- t) yield (coll.get(k) == Some(v)) val containsSelf = coll.map { case (k, v) => coll.get(k) == Some(v) } ("Par contains elements of seq map" |: containsT.forall(_ == true)) && ("Par contains elements of itself" |: containsSelf.forall(_ == true)) - } - + } + } diff --git a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala b/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala index 3c6a35d8f1..372d6b9fbd 100644 --- a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala @@ -20,15 +20,15 @@ import scala.collection.parallel.ops._ object ParallelRangeCheck extends ParallelSeqCheck[Int]("ParallelRange[Int]") with ops.IntSeqOperators { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = collection.parallel.ParSeq[Int] - + def hasStrictOrder = true - + def isCheckingViews = false - + def ofSize(vals: Seq[Gen[Int]], sz: Int) = unsupported - + override def instances(vals: Seq[Gen[Int]]): Gen[Seq[Int]] = sized { start => sized { end => sized { step => @@ -36,7 +36,7 @@ object ParallelRangeCheck extends ParallelSeqCheck[Int]("ParallelRange[Int]") wi } } } - + def fromSeq(a: Seq[Int]) = a match { case r: Range => ParRange(r.start, r.end, r.step, false) case _ => @@ -44,14 +44,14 @@ object ParallelRangeCheck extends ParallelSeqCheck[Int]("ParallelRange[Int]") wi for (i <- 0 until a.length) pa(i) = a(i) pa } - + override def traversable2Seq(t: Traversable[Int]): Seq[Int] = t match { case r: Range => r case _ => t.toSeq } - + def values = Seq(choose(-100, 100)) - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala b/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala index dd897412ae..3f8a8ad4f5 100644 --- a/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelSeqCheck.scala @@ -16,13 +16,13 @@ import scala.collection.parallel._ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableCheck[T](collName) with SeqOperators[T] { - + type CollType <: collection.parallel.ParSeq[T] - + def ofSize(vals: Seq[Gen[T]], sz: Int): Seq[T] def fromSeq(s: Seq[T]): CollType - + override def instances(vals: Seq[Gen[T]]): Gen[Seq[T]] = oneOf( sized( sz => @@ -31,17 +31,17 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe for (sz <- choose(1000, 2000)) yield ofSize(vals, sz) ) - + def fromTraversable(t: Traversable[T]) = fromSeq(traversable2Seq(t)) def traversable2Seq(t: Traversable[T]): Seq[T] = { if (t.isInstanceOf[Iterable[_]]) t.asInstanceOf[Iterable[T]].iterator.toList else t.toList } - + override def collectionPairs: Gen[(Seq[T], CollType)] = for (inst <- instances(values)) yield (inst, fromSeq(inst)) - + override def collectionPairsWithLengths: Gen[(Seq[T], CollType, Int)] = for (inst <- instances(values); s <- choose(0, inst.size)) yield (inst, fromSeq(inst), s); - + def collectionPairsWithModifiedWithLengths: Gen[(Seq[T], CollType, ParSeq[T], Int)] = for (inst <- instances(values); s <- choose(0, inst.size); updateStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { @@ -49,31 +49,31 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe val parcollmodif = fromSeq(modifySlightly(inst, updateStart, howMany)) (inst, parcoll, parcollmodif, s) } - + def collectionPairsWithModified: Gen[(Seq[T], CollType, ParSeq[T])] = for (inst <- instances(values); updateStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { val parcoll = fromSeq(inst) val parcollmodif = fromSeq(modifySlightly(inst, updateStart, howMany)) (inst, parcoll, parcollmodif) } - + def collectionPairsWithSliced: Gen[(Seq[T], CollType, ParSeq[T])] = for (inst <- instances(values); sliceStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { val parcoll = fromSeq(inst) val parcollsliced = fromSeq(inst.slice(sliceStart, sliceStart + howMany)) (inst, parcoll, parcollsliced) } - + def collectionTripletsWith2Indices: Gen[(Seq[T], CollType, Seq[T], Int, Int)] = for (inst <- instances(values); f <- choose(0, inst.size); s <- choose(0, inst.size - f); third <- instances(values); sliceStart <- choose(0, inst.size); howMany <- choose(0, inst.size)) yield { (inst, fromSeq(inst), inst.slice(sliceStart, sliceStart + howMany), f, s) } - + private def modifySlightly(coll: Seq[T], updateStart: Int, howMany: Int) = { coll.patch(updateStart, coll, howMany) } - + property("segmentLengths must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => (for ((pred, ind) <- segmentLengthPredicates.zipWithIndex) yield { val slen = s.segmentLength(pred, if (len < 0) 0 else len) @@ -87,13 +87,13 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("operator " + ind) |: slen == clen }).reduceLeft(_ && _) } - + property("prefixLengths must be equal") = forAll(collectionPairs) { case (s, coll) => (for ((pred, ind) <- segmentLengthPredicates.zipWithIndex) yield { ("operator " + ind) |: s.prefixLength(pred) == coll.prefixLength(pred) }).reduceLeft(_ && _) } - + property("indexWheres must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => (for ((pred, ind) <- indexWherePredicates.zipWithIndex) yield { val sind = s.indexWhere(pred, len) @@ -108,7 +108,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("operator " + ind) |: sind == cind }).reduceLeft(_ && _) } - + property("lastIndexWheres must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => (for ((pred, ind) <- lastIndexWherePredicates.zipWithIndex) yield { val end = if (len >= s.size) s.size - 1 else len @@ -117,7 +117,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("operator " + ind) |: sind == cind }).reduceLeft(_ && _) } - + property("reverses must be equal") = forAll(collectionPairs) { case (s, coll) => (s.length == 0 && s.getClass == classOf[collection.immutable.Range]) || { @@ -132,13 +132,13 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe sr == cr } } - + property("reverseMaps must be equal") = forAll(collectionPairs) { case (s, coll) => (for ((f, ind) <- reverseMapFunctions.zipWithIndex) yield { ("operator " + ind) |: s.reverseMap(f) == coll.reverseMap(f) }).reduceLeft(_ && _) } - + property("sameElements must be equal") = forAll(collectionPairsWithModifiedWithLengths) { case (s, coll, collmodif, len) => val pos = if (len < 0) 0 else len @@ -170,7 +170,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("collection " + ind) |: sres == pres }).reduceLeft(_ && _) } - + property("startsWiths must be equal") = forAll(collectionPairsWithModifiedWithLengths) { case (s, coll, collmodif, len) => val pos = if (len < 0) 0 else len @@ -194,7 +194,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("seq " + sq) |: ss == cs }).reduceLeft(_ && _) } - + property("endsWiths must be equal") = forAll(collectionPairsWithModified) { case (s, coll, collmodif) => ("ends with self" |: s.endsWith(s) == coll.endsWith(s)) && @@ -213,18 +213,18 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("seq " + sq) |: sew == cew }).reduceLeft(_ && _) } - + property("unions must be equal") = forAll(collectionPairsWithModified) { case (s, coll, collmodif) => ("modified" |: s.union(collmodif.seq) == coll.union(collmodif)) && ("empty" |: s.union(Nil) == coll.union(fromSeq(Nil))) } - + // This is failing with my views patch: array index out of bounds in the array iterator. // Couldn't see why this and only this was impacted, could use a second pair of eyes. - // + // // This was failing because some corner cases weren't added to the patch method in ParSeqLike. // Curiously, this wasn't detected before. - // + // if (!isCheckingViews) property("patches must be equal") = forAll(collectionTripletsWith2Indices) { case (s, coll, pat, from, repl) => ("with seq" |: s.patch(from, pat, repl) == coll.patch(from, pat, repl)) && @@ -232,7 +232,7 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("with empty" |: s.patch(from, Nil, repl) == coll.patch(from, fromSeq(Nil), repl)) && ("with one" |: (s.length == 0 || s.patch(from, List(s(0)), 1) == coll.patch(from, fromSeq(List(coll(0))), 1))) } - + if (!isCheckingViews) property("updates must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => val pos = if (len >= s.length) s.length - 1 else len if (s.length > 0) { @@ -247,15 +247,15 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe "from first" |: (supd == cupd) } else "trivially" |: true } - + property("prepends must be equal") = forAll(collectionPairs) { case (s, coll) => s.length == 0 || s(0) +: s == coll(0) +: coll } - + property("appends must be equal") = forAll(collectionPairs) { case (s, coll) => s.length == 0 || s :+ s(0) == coll :+ coll(0) } - + property("padTos must be equal") = forAll(collectionPairsWithLengths) { case (s, coll, len) => val someValue = sampleValue val sdoub = s.padTo(len * 2, someValue) @@ -269,14 +269,14 @@ abstract class ParallelSeqCheck[T](collName: String) extends ParallelIterableChe ("smaller" |: s.padTo(len / 2, someValue) == coll.padTo(len / 2, someValue)) && ("bigger" |: sdoub == cdoub) } - + property("corresponds must be equal") = forAll(collectionPairsWithModified) { case (s, coll, modified) => val modifcut = modified.toSeq.slice(0, modified.length) ("self" |: s.corresponds(s)(_ == _) == coll.corresponds(coll)(_ == _)) && ("modified" |: s.corresponds(modified.seq)(_ == _) == coll.corresponds(modified)(_ == _)) && ("modified2" |: s.corresponds(modifcut)(_ == _) == coll.corresponds(modifcut)(_ == _)) } - + } diff --git a/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala b/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala index 4211abbd16..56f7832fed 100644 --- a/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelSetCheck.scala @@ -16,15 +16,15 @@ import scala.collection.parallel._ abstract class ParallelSetCheck[T](collname: String) extends ParallelIterableCheck[T](collname) { type CollType <: ParSet[T] - + property("gets iterated keys") = forAll(collectionPairs) { case (t, coll) => val containsT = for (elem <- t) yield (coll.contains(elem)) val containsSelf = for (elem <- coll) yield (coll.contains(elem)) ("Par contains elements of seq map" |: containsT.forall(_ == true)) && ("Par contains elements of itself" |: containsSelf.forall(_ == true)) - } - + } + } diff --git a/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala b/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala index e4bb588fa7..a2b6cef96d 100644 --- a/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelVectorCheck.scala @@ -23,11 +23,11 @@ import immutable.VectorBuilder abstract class ParallelVectorCheck[T](tp: String) extends collection.parallel.ParallelSeqCheck[T]("ParVector[" + tp + "]") { // ForkJoinTasks.defaultForkJoinPool.setMaximumPoolSize(Runtime.getRuntime.availableProcessors * 2) // ForkJoinTasks.defaultForkJoinPool.setParallelism(Runtime.getRuntime.availableProcessors * 2) - + type CollType = ParVector[T] - + def isCheckingViews = false - + def hasStrictOrder = true def ofSize(vals: Seq[Gen[T]], sz: Int) = { @@ -36,13 +36,13 @@ abstract class ParallelVectorCheck[T](tp: String) extends collection.parallel.Pa for (i <- 0 until sz) vb += sample(gen) vb.result } - + def fromSeq(a: Seq[T]) = { val pa = ParVector.newCombiner[T] for (elem <- a.toList) pa += elem pa.result } - + } diff --git a/test/files/scalacheck/parallel-collections/pc.scala b/test/files/scalacheck/parallel-collections/pc.scala index 0a91977da0..c588692fd2 100644 --- a/test/files/scalacheck/parallel-collections/pc.scala +++ b/test/files/scalacheck/parallel-collections/pc.scala @@ -1,42 +1,41 @@ - - - +/* + * scalac: -deprecation + * scalacheck: -workers 1 -minSize 0 -maxSize 4000 -minSuccessfulTests 5 + */ import org.scalacheck._ - import scala.collection.parallel._ - class ParCollProperties extends Properties("Parallel collections") { /* Collections */ - + // parallel arrays include(mutable.IntParallelArrayCheck) - + // parallel ranges include(immutable.ParallelRangeCheck) - + // parallel immutable hash maps (tries) include(immutable.IntIntParallelHashMapCheck) - + // parallel immutable hash sets (tries) include(immutable.IntParallelHashSetCheck) - + // parallel mutable hash maps (tables) include(mutable.IntIntParallelHashMapCheck) - + // parallel ctrie include(mutable.IntIntParallelConcurrentTrieMapCheck) - + // parallel mutable hash sets (tables) include(mutable.IntParallelHashSetCheck) - + // parallel vectors include(immutable.IntParallelVectorCheck) } - -object Test { +object Test extends ParCollProperties { + /* def main(args: Array[String]) { val pc = new ParCollProperties org.scalacheck.Test.checkProperties( @@ -51,4 +50,5 @@ object Test { pc ) } + */ } diff --git a/test/files/scalacheck/primitive-eqeq.scala b/test/files/scalacheck/primitive-eqeq.scala index a783805e46..60fe63c207 100644 --- a/test/files/scalacheck/primitive-eqeq.scala +++ b/test/files/scalacheck/primitive-eqeq.scala @@ -4,7 +4,7 @@ import Gen._ object Test extends Properties("==") { def equalObjectsEqualHashcodes(x: Any, y: Any) = (x != y) || (x == y && x.## == y.##) - + // ticket #2087 property("short/char") = forAll { (x: Short) => { val ch: Char = x.toChar @@ -14,15 +14,15 @@ object Test extends Properties("==") { property("symmetry") = forAll { (x: AnyVal, y: AnyVal) => (x == y) == (y == x) } property("transitivity") = forAll { (x: AnyVal, y: AnyVal, z: AnyVal) => x != y || y != z || x == z } - - property("##") = forAll { + + property("##") = forAll { (x: Short) => { val anyvals = List(x.toByte, x.toChar, x, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x)) val shortAndLarger = anyvals drop 2 val result = ( - ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) && - ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) && + ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) && + ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) && ((shortAndLarger, shortAndLarger).zipped forall ((x, y) => (x: Any) == (y: Any))) ) result diff --git a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala new file mode 100644 index 0000000000..23b6a5fbdb --- /dev/null +++ b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala @@ -0,0 +1,307 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.api._ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.universe.Flag._ + +trait ArbitraryTreesAndNames { + def smallList[T](size: Int, g: Gen[T]) = { + val n: Int = choose(0, size / 2 + 1).sample match { + case Some(i) => i + case None => 0 + } + containerOfN[List, T](n, g) + } + + def shortIdent(len: Int) = + for(name <- identifier) + yield if(name.length <= len) name + else name.substring(0, len - 1) + + def genTermName = for(name <- shortIdent(8)) yield TermName(name) + def genTypeName = for(name <- shortIdent(8)) yield TypeName(name) + def genName = oneOf(genTermName, genTypeName) + + def genFlagSet = oneOf( + TRAIT, INTERFACE, MUTABLE, MACRO, + DEFERRED, ABSTRACT, FINAL, SEALED, + IMPLICIT, LAZY, OVERRIDE, PRIVATE, + PROTECTED, LOCAL, CASE, ABSOVERRIDE, + BYNAMEPARAM, PARAM, COVARIANT, CONTRAVARIANT, + DEFAULTPARAM, PRESUPER, DEFAULTINIT + ) + + def genModifiers = for(flagset <- genFlagSet) yield Modifiers(flagset) + + def genConstant = + for(value <- oneOf(arbitrary[Byte], arbitrary[Short], arbitrary[Char], + arbitrary[Int], arbitrary[Long], arbitrary[Float], + arbitrary[Double], arbitrary[Boolean], arbitrary[String])) + yield Constant(value) + + def genAnnotated(size: Int, argGen: Int => Gen[Tree]) = + for(annot <- genTree(size - 1); arg <- argGen(size - 1)) + yield Annotated(annot, arg) + + def genAlternative(size: Int): Gen[Alternative] = + for(trees <- smallList(size, genTree(size - 1))) + yield Alternative(trees) + + def genAppliedTypeTree(size: Int) = + for(tpt <- genTree(size - 1) if tpt.isType; + args <- smallList(size, genTree(size - 1))) + yield AppliedTypeTree(tpt, args) + + def genApply(size: Int) = + for(fun <- genTree(size - 1); + args <- smallList(size, genTree(size - 1))) + yield Apply(fun, args) + + def genAssign(size: Int) = + for(lhs <- genTree(size - 1); rhs <- genTree(size - 1)) + yield Assign(lhs, rhs) + + def genAssignOrNamedArg(size: Int) = + for(lhs <- genTree(size - 1); rhs <- genTree(size - 1)) + yield AssignOrNamedArg(lhs, rhs) + + def genBind(size: Int, nameGen: Gen[Name]) = + for(name <- nameGen; body <- genTree(size - 1)) + yield Bind(name, body) + + def genBlock(size: Int) = + for(stats <- smallList(size, genTree(size - 1)); expr <- genTree(size - 1)) + yield Block(stats, expr) + + def genCaseDef(size: Int) = + for(pat <- genTree(size - 1); guard <- genTree(size - 1); body <- genTree(size - 1)) + yield CaseDef(pat, guard, body) + + def genClassDef(size: Int) = + for(mods <- genModifiers; name <- genTypeName; + tparams <- smallList(size, genTypeDef(size - 1)); + impl <- genTemplate(size - 1)) + yield ClassDef(mods, name, tparams, impl) + + def genCompoundTypeTree(size: Int) = + for(templ <- genTemplate(size - 1)) + yield CompoundTypeTree(templ) + + def genDefDef(size: Int) = + for(mods <- genModifiers; name <- genTermName; + tpt <- genTree(size -1); rhs <- genTree(size - 1); + tparams <- smallList(size, genTypeDef(size - 1)); + vparamss <- smallList(size, smallList(size, genValDef(size - 1)))) + yield DefDef(mods, name, tparams, vparamss, tpt, rhs) + + def genExistentialTypeTree(size: Int) = + for(tpt <- genTree(size - 1); where <- smallList(size, genTree(size - 1))) + yield ExistentialTypeTree(tpt, where) + + def genFunction(size: Int) = + for(vparams <- smallList(size, genValDef(size - 1)); body <- genTree(size - 1)) + yield Function(vparams, body) + + def genIdent(nameGen: Gen[Name] = genName) = + for(name <- nameGen) yield Ident(name) + + def genIf(size: Int) = + for(cond <- genTree(size - 1); thenp <- genTree(size - 1); elsep <- genTree(size - 1)) + yield If(cond, thenp, elsep) + + def genImport(size: Int) = + for(expr <- genTree(size - 1); selectors <- smallList(size, genImportSelector(size - 1))) + yield Import(expr, selectors) + + def genImportSelector(size: Int) = + for(name <- genName; namePos <- arbitrary[Int]; rename <- genName; renamePos <- arbitrary[Int]) + yield ImportSelector(name, namePos, rename, renamePos) + + def genTemplate(size: Int) = + for(parents <- smallList(size, genTree(size - 1)); + self <- genValDef(size - 1); + body <- smallList(size, genTree(size - 1))) + yield Template(parents, self, body) + + def genLabelDef(size: Int) = + for(name <- genTermName; params <- smallList(size, genIdent()); rhs <- genTree(size - 1)) + yield LabelDef(name, params, rhs) + + def genLiteral = + for(const <- genConstant) yield Literal(const) + + def genMatch(size: Int) = + for(selector <- genTree(size - 1); cases <- smallList(size, genCaseDef(size - 1))) + yield Match(selector, cases) + + def genModuleDef(size: Int) = + for(mods <- genModifiers; name <- genTermName; impl <- genTemplate(size - 1)) + yield ModuleDef(mods, name, impl) + + def genNew(size: Int) = + for(tpt <- genTree(size - 1)) + yield New(tpt) + + def genRefTree(size: Int) = + oneOf(genSelect(size), genIdent(), genSelectFromTypeTree(size)) + + def genPackageDef(size: Int) = + for(reftree <- genRefTree(size - 1); stats <- smallList(size, genTree(size - 1))) + yield PackageDef(reftree, stats) + + def genTypeSelect(size: Int) = + for(qual <- genTree(size - 1); name <- genTypeName) + yield Select(qual, name) + + def genSelect(size: Int, nameGen: Gen[Name] = genName) = + for(qual <- genTree(size - 1); name <- nameGen) + yield Select(qual, name) + + def genSelectFromTypeTree(size: Int) = + for(qual <- genTreeIsType(size - 1); name <- genTypeName) + yield SelectFromTypeTree(qual, name) + + def genReferenceToBoxed(size: Int) = + for(ident <- genIdent()) + yield ReferenceToBoxed(ident) + + def genReturn(size: Int) = + for(expr <- genTree(size - 1)) + yield Return(expr) + + def genSingletonTypeTree(size: Int) = + for(expr <- genTree(size - 1)) + yield SingletonTypeTree(expr) + + def genStar(size: Int) = + for(expr <- genTree(size - 1)) + yield Star(expr) + + def genSuper(size: Int) = + for(qual <- genTree(size - 1); mix <- genTypeName) + yield Super(qual, mix) + + def genThis(size: Int) = + for(qual <- genTypeName) + yield This(qual) + + def genThrow(size: Int) = + for(expr <- genTree(size - 1)) + yield Throw(expr) + + def genTry(size: Int) = + for(block <- genTree(size - 1); + catches <- smallList(size, genCaseDef(size - 1)); + finalizer <- genTree(size - 1)) + yield Try(block, catches, finalizer) + + def genTypeApply(size: Int) = + for(fun <- genTreeIsTerm(size - 1); args <- smallList(size, genTree(size - 1))) + yield TypeApply(fun, args) + + def genTypeBoundsTree(size: Int) = + for(lo <- genTree(size - 1); hi <- genTree(size - 1)) + yield TypeBoundsTree(lo, hi) + + def genTypeDef(size: Int): Gen[TypeDef] = + for(mods <- genModifiers; name <- genTypeName; + tparams <- smallList(size, genTypeDef(size - 1)); rhs <- genTree(size - 1)) + yield TypeDef(mods, name, tparams, rhs) + + def genTypeTree: Gen[TypeTree] = TypeTree() + + def genTyped(size: Int) = + for(expr <- genTree(size - 1); tpt <- genTree(size - 1)) + yield Typed(expr, tpt) + + def genUnApply(size: Int) = + for(fun <- genTree(size - 1); args <- smallList(size, genTree(size - 1))) + yield UnApply(fun, args) + + def genValDef(size: Int) = + for(mods <- genModifiers; name <- genTermName; + tpt <- genTree(size - 1); rhs <- genTree(size - 1)) + yield ValDef(mods, name, tpt, rhs) + + def genTree(size: Int): Gen[Tree] = + if (size <= 1) oneOf(EmptyTree, genTreeIsTerm(size), genTreeIsType(size)) + else oneOf(genTree(1), + // these trees are neither terms nor types + genPackageDef(size - 1), genModuleDef(size - 1), + genCaseDef(size - 1), genDefDef(size - 1), + genTypeDef(size - 1), genTemplate(size - 1), + genClassDef(size - 1), genValDef(size - 1), + genImport(size - 1)) + + def genTreeIsTerm(size: Int): Gen[Tree] = + if (size <= 1) oneOf(genLiteral, genIdent(genTermName)) + else oneOf(genTreeIsTerm(1), genBind(size - 1, genTermName), + genAnnotated(size - 1, genTreeIsTerm), genSelect(size - 1, genTermName), + genAlternative(size - 1), genApply(size - 1), genAssign(size - 1), + genAssignOrNamedArg(size - 1), genBlock(size - 1), genFunction(size - 1), + genIf(size - 1), genLabelDef(size - 1), genMatch(size - 1), genNew(size - 1), + genReturn(size - 1), genStar(size - 1), genSuper(size - 1), genThis(size - 1), + genThrow(size - 1), genTry(size - 1), genTypeApply(size - 1), + genTyped(size - 1), genUnApply(size - 1)) + + def genTreeIsType(size: Int): Gen[Tree] = + if (size <= 1) genIdent(genTypeName) + else oneOf(genTreeIsType(1), genAnnotated(size - 1, genTreeIsType), + genBind(size - 1, genTypeName), genSelect(size - 1, genTypeName), + genSingletonTypeTree(size - 1), genSelectFromTypeTree(size - 1), + genExistentialTypeTree(size - 1), genCompoundTypeTree(size - 1), + genAppliedTypeTree(size - 1), genTypeBoundsTree(size - 1)) + + /* These are marker types that allow to write tests that + * depend specificly on Trees that are terms or types. + * They are transperantly tranformed to trees through + * implicit conversions and liftables for quasiquotes. + */ + + case class TreeIsTerm(tree: Tree) { require(tree.isTerm, showRaw(tree)) } + case class TreeIsType(tree: Tree) { require(tree.isType, showRaw(tree)) } + + def genTreeIsTermWrapped(size: Int) = + for(tit <- genTreeIsTerm(size)) yield TreeIsTerm(tit) + + 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 def treeIsTerm2tree(tit: TreeIsTerm) = tit.tree + implicit def treeIsType2tree(tit: TreeIsType) = tit.tree + + implicit val arbConstant: Arbitrary[Constant] = Arbitrary(genConstant) + implicit val arbModifiers: Arbitrary[Modifiers] = Arbitrary(genModifiers) + implicit val arbTermName: Arbitrary[TermName] = Arbitrary(genTermName) + implicit val arbTypeName: Arbitrary[TypeName] = Arbitrary(genTypeName) + implicit val arbName: Arbitrary[Name] = Arbitrary(genName) + + // Trees generators are bound by this size to make + // generation times shorter and less memory hungry. + // TODO: is there any better solution? + val maxTreeSize = 5 + + def arbitrarySized[T](gen: Int => Gen[T]) = + Arbitrary(sized(s => gen(s.min(maxTreeSize)))) + + implicit val arbLiteral: Arbitrary[Literal] = Arbitrary(genLiteral) + implicit val arbIdent: Arbitrary[Ident] = Arbitrary(genIdent()) + implicit val arbValDef: Arbitrary[ValDef] = arbitrarySized(genValDef) + implicit val arbDefDef: Arbitrary[DefDef] = arbitrarySized(genDefDef) + implicit val arbTypeDef: Arbitrary[TypeDef] = arbitrarySized(genTypeDef) + implicit val arbBind: Arbitrary[Bind] = arbitrarySized(genBind(_, genName)) + implicit val arbTree: Arbitrary[Tree] = arbitrarySized(genTree) + implicit val arbTreeIsTerm: Arbitrary[TreeIsTerm] = arbitrarySized(genTreeIsTermWrapped) + implicit val arbTreeIsType: Arbitrary[TreeIsType] = arbitrarySized(genTreeIsTypeWrapped) +}
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala new file mode 100644 index 0000000000..153e23d947 --- /dev/null +++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala @@ -0,0 +1,293 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.universe.build.ScalaDot +import Flag._ + +object DefinitionConstructionProps + extends QuasiquoteProperties("definition construction") + with ClassConstruction + with TraitConstruction + with TypeDefConstruction + with ValDefConstruction + +trait ClassConstruction { self: QuasiquoteProperties => + val anyRef = ScalaDot(TypeName("AnyRef")) + val emtpyConstructor = + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), + List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))) + def classWith(name: TypeName, parents: List[Tree] = List(anyRef), body: List[DefDef] = Nil) = + ClassDef( + Modifiers(), name, List(), + Template(parents, emptyValDef, emtpyConstructor :: body)) + + property("construct case class") = test { + val params = q"val x: Int" :: q"val y: Int" :: Nil + val name = TypeName("Point") + assertEqAst(q"$CASE class $name(..$params)", "case class Point(x: Int, y: Int)") + } + + property("case class bare param") = test { + assertEqAst(q"$CASE class Point(x: Int, y: Int)", "case class Point(private[this] val x: Int, private[this] val y: Int)") + } + + property("generate default constructors automatically") = test { + val parents = List.empty[Tree] + assertEqAst(q"class Foo extends ..$parents", "class Foo") + } + + property("splice term name into class") = forAll { (name: TypeName) => + eqAst(q"class $name", "class " + name.toString) + } + + property("splice method into class") = forAll { (name: TypeName, method: DefDef) => + q"class $name { $method }" ≈ classWith(name, body = List(method)) + } + + property("splice members into class") = forAll { (name: TypeName, defs: List[DefDef], extra: DefDef) => + q"""class $name { + ..$defs + $extra + }""" ≈ classWith(name, body = defs :+ extra) + } + + property("splice type name into class parents") = forAll { (name: TypeName, parent: TypeName) => + q"class $name extends $parent" ≈ classWith(name, parents = List(Ident(parent))) + } + + property("param flags are consistent with raw code") = test { + val pubx = q"val x: Int" + val privx = q"private[this] val x: Int" + assertEqAst(q" class C(x: Int)", " class C(x: Int) ") + assertEqAst(q"case class C(x: Int)", "case class C(x: Int) ") + assertEqAst(q" class C($pubx) ", " class C(val x: Int) ") + assertEqAst(q"case class C($pubx) ", "case class C(x: Int) ") + assertEqAst(q" class C($privx)", " class C(x: Int) ") + assertEqAst(q"case class C($privx)", "case class C(private[this] val x: Int)") + } +} + +trait TraitConstruction { self: QuasiquoteProperties => + property("splice name into trait def") = test { + val Foo = TypeName("Foo") + assert(q"trait $Foo" ≈ q"trait Foo") + } + + property("splice type params into trait def") = test { + val tparams = q"type A" :: q"type B" :: Nil + assert(q"trait Foo[..$tparams]" ≈ q"trait Foo[A, B]") + } + + property("splice defs into trait body") = test { + val body = q"def foo" :: q"val bar: Baz" :: Nil + assert(q"trait Foo { ..$body }" ≈ q"trait Foo { def foo; val bar: Baz }") + } + + property("splice parents into trait") = test { + val parents = tq"A" :: tq"B" :: Nil + assert(q"trait Foo extends ..$parents" ≈ q"trait Foo extends A with B") + } + + property("splice early valdef into trait") = test { + val x = q"val x: Int = 1" + assertEqAst(q"trait T extends { $x } with Any", "trait T extends { val x: Int = 1} with Any") + } + + property("construct trait with early valdef") = test { + assertEqAst(q"trait T extends { val x: Int = 1 } with Any", "trait T extends { val x: Int = 1 } with Any") + } + + property("splice defs into early block") = test { + val defs = q"val x: Int = 0" :: q"type Foo = Bar" :: Nil + assert(q"trait T extends { ..$defs } with Bippy" ≈ + q"trait T extends { val x: Int = 0; type Foo = Bar} with Bippy") + } + + property("fail on splicing of non-valid early tree") = test { + val defn = q"def x: Int = 0" + assertThrows[IllegalArgumentException] { q"trait T extends { $defn } with Bar" } + } +} + +trait TypeDefConstruction { self: QuasiquoteProperties => + property("splice type name into typedef") = forAll { (name1: TypeName, name2: TypeName) => + q"type $name1 = $name2" ≈ TypeDef(Modifiers(), name1, List(), Ident(name2)) + } + + property("splice type names into type bounds") = forAll { (T1: TypeName, T2: TypeName, T3: TypeName) => + q"type $T1 >: $T2 <: $T3" ≈ + TypeDef( + Modifiers(DEFERRED), T1, List(), + TypeBoundsTree(Ident(T2), Ident(T3))) + } + + property("splice trees names into type bounds") = forAll { (T: TypeName, t1: Tree, t2: Tree) => + q"type $T >: $t1 <: $t2" ≈ + TypeDef( + Modifiers(DEFERRED), T, List(), + TypeBoundsTree(t1, t2)) + } + + property("splice tparams into typedef (1)") = forAll { (T: TypeName, targs: List[TypeDef], t: Tree) => + q"type $T[..$targs] = $t" ≈ TypeDef(Modifiers(), T, targs, t) + } + + property("splice tparams into typedef (2)") = forAll { (T: TypeName, targs1: List[TypeDef], targs2: List[TypeDef], t: Tree) => + q"type $T[..$targs1, ..$targs2] = $t" ≈ TypeDef(Modifiers(), T, targs1 ++ targs2, t) + } + + property("splice tparams into typedef (3)") = forAll { (T: TypeName, targ: TypeDef, targs: List[TypeDef], t: Tree) => + q"type $T[$targ, ..$targs] = $t" ≈ TypeDef(Modifiers(), T, targ :: targs, t) + } + + property("splice typename into typedef with default bounds") = forAll { (T1: TypeName, T2: TypeName, t: Tree) => + q"type $T1[$T2 >: Any <: Nothing] = $t" ≈ + TypeDef( + Modifiers(), T1, + List(TypeDef( + Modifiers(PARAM), T2, + List(), + TypeBoundsTree( + Ident(TypeName("Any")), + Ident(TypeName("Nothing"))))), + t) + } + + property("splice type names into compound type tree") = forAll { (T: TypeName, A: TypeName, B: TypeName) => + q"type $T = $A with $B" ≈ + TypeDef( + Modifiers(), T, List(), + CompoundTypeTree( + Template(List(Ident(A), Ident(B)), ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(), EmptyTree), List()))) + } + + property("splice trees into existential type tree") = forAll { + (T1: TypeName, T2: TypeName, X: TypeName, Lo: TypeName, Hi: TypeName) => + + q"type $T1 = $T2[$X] forSome { type $X >: $Lo <: $Hi }" ≈ + TypeDef( + Modifiers(), T1, List(), + ExistentialTypeTree( + AppliedTypeTree(Ident(T2), List(Ident(X))), + List( + TypeDef(Modifiers(DEFERRED), X, List(), TypeBoundsTree(Ident(Lo), Ident(Hi)))))) + } + + property("splice tree into singleton type tree") = forAll { (name: TypeName, t: Tree) => + q"type $name = $t.type" ≈ q"type $name = ${SingletonTypeTree(t)}" + } + + property("splice into applied type tree") = forAll { (T1: TypeName, T2: TypeName, args: List[Tree]) => + q"type $T1 = $T2[..$args]" ≈ + TypeDef(Modifiers(), T1, List(), + if(args.nonEmpty) AppliedTypeTree(Ident(T2), args) else Ident(T2)) + } +} + +trait ValDefConstruction { self: QuasiquoteProperties => + property("splice term name into val") = forAll { (name: TermName, tpt: Tree, rhs: Tree) => + q"val $name: $tpt = $rhs" ≈ ValDef(Modifiers(), name, tpt, rhs) + } + + property("splice term name into var") = forAll { (name: TermName, tpt: Tree, rhs: Tree) => + q"var $name: $tpt = $rhs" ≈ ValDef(Modifiers(MUTABLE), name, tpt, rhs) + } +} + +trait MethodConstruction { self: QuasiquoteProperties => + property("splice paramss into defdef") = test { + val paramss = List(q"val x: Int") :: List(q"val y: Int = 1") :: Nil + assert(q"def foo(...$paramss)" ≈ parse("def foo(x: Int)(y: Int = 1)")) + } + + property("splice tparams into defdef") = test { + val tparams = q"type A" :: q"type B <: Bippy" :: Nil + assert(q"def foo[..$tparams]" ≈ parse("def foo[A, B <: Bippy]")) + } + + def assertSameAnnots(tree: {def mods: Modifiers}, annots: List[Tree]) = + assert(tree.mods.annotations ≈ annots, + s"${tree.mods.annotations} =/= ${annots}") + + def assertSameAnnots(tree1: {def mods: Modifiers}, tree2: {def mods: Modifiers}) = + assert(tree1.mods.annotations ≈ tree2.mods.annotations, + s"${tree1.mods.annotations} =/= ${tree2.mods.annotations}") + + property("splice type name into annotation") = test { + val name = TypeName("annot") + assertSameAnnots(q"@$name def foo", List(annot(name))) + } + + property("splice ident into annotation") = test { + val name = TypeName("annot") + val ident = Ident(name) + assertSameAnnots(q"@$ident def foo", List(annot(name))) + } + + property("splice idents into annotation") = test { + val idents = List(Ident(TypeName("annot1")), Ident(TypeName("annot2"))) + assertSameAnnots(q"@..$idents def foo", + idents.map { ident => Apply(Select(New(ident), nme.CONSTRUCTOR), List()) }) + } + + property("splice constructor calls into annotation") = test { + val ctorcalls = List(annot("a1"), annot("a2")) + assertSameAnnots(q"@..$ctorcalls def foo", ctorcalls) + } + + property("splice multiple annotations (1)") = test { + val annot1 = annot("a1") + val annot2 = annot("a2") + val res = q"@$annot1 @$annot2 def foo" + assertSameAnnots(res, List(annot1, annot2)) + } + + property("splice multiple annotations (2)") = test { + val annot1 = annot("a1") + val annots = List(annot("a2"), annot("a3")) + val res = q"@$annot1 @..$annots def foo" + assertSameAnnots(res, annot1 :: annots) + } + + property("splice annotations with arguments (1)") = test { + val a = annot("a", List(q"x")) + assertSameAnnots(q"@$a def foo", q"@a(x) def foo") + } + + property("splice annotations with arguments (2)") = test { + val a = newTypeName("a") + assertSameAnnots(q"@$a(x) def foo", q"@a(x) def foo") + } + + property("splice annotations with arguments (3") = test { + val a = Ident(newTypeName("a")) + assertSameAnnots(q"@$a(x) def foo", q"@a(x) def foo") + } + + property("splice improper tree into annot") = test { + val t = tq"Foo[Baz]" + assertThrows[IllegalArgumentException] { + q"@$t def foo" + } + } + + property("can't splice annotations with arguments specificed twice") = test { + val a = annot("a", List(q"x")) + assertThrows[IllegalArgumentException] { + q"@$a(y) def foo" + } + } + + property("splice annotation with targs") = test { + val a = q"new Foo[A, B]" + assertEqAst(q"@$a def foo", "@Foo[A,B] def foo") + } + + 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") + } +}
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala new file mode 100644 index 0000000000..fdfbfe871c --- /dev/null +++ b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala @@ -0,0 +1,147 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object DefinitionDeconstructionProps + extends QuasiquoteProperties("definition deconstruction") + with TraitDeconstruction + with ClassDeconstruction + with ObjectDeconstruction + with ModsDeconstruction + with ValVarDeconstruction + +trait TraitDeconstruction { self: QuasiquoteProperties => + property("exhaustive trait matcher") = test { + def matches(line: String) { + val q"""$mods trait $name[..$targs] + extends { ..$early } with ..$parents { $self => ..$body }""" = parse(line) + } + matches("trait Foo") + matches("trait Foo[T]") + matches("trait Foo { def bar }") + matches("trait Foo extends Bar with Baz") + matches("trait Foo { self: Bippy => val x: Int = 1}") + matches("trait Foo extends { val early: Int = 1 } with Bar { val late = early }") + matches("private[Gap] trait Foo") + } +} + +trait ObjectDeconstruction { self: QuasiquoteProperties => + property("exhaustive object matcher") = test { + def matches(line: String) = { + val q"""$mods object $name extends { ..$early } with ..$parents { $self => ..$body }""" = parse(line) + } + matches("object Foo") + matches("object Foo extends Bar[T]") + matches("object Foo extends { val early: T = v } with Bar") + matches("object Foo extends Foo { selfy => body }") + matches("private[Bippy] object Foo extends Bar with Baz") + } +} + +trait ClassDeconstruction { self: QuasiquoteProperties => + property("class without params") = test { + val q"class $name { ..$body }" = q"class Foo { def bar = 3 }" + assert(body ≈ List(q"def bar = 3")) + } + + property("class constructor") = test { + val q"class $name(...$argss)" = q"class Foo(x: Int)(y: Int)" + assert(argss.length == 2) + } + + property("class parents") = test { + val q"class $name extends ..$parents" = q"class Foo extends Bar with Blah" + assert(parents ≈ List(tq"Bar", tq"Blah")) + } + + property("class selfdef") = test { + val q"class $name { $self => }" = q"class Foo { self: T => }" + assert(self.name ≈ TermName("self") && self.tpt ≈ tq"T") + } + + property("class tparams") = test { + val q"class $name[..$tparams]" = q"class Foo[A, B]" + assert(tparams.map { _.name } == List(TypeName("A"), TypeName("B"))) + } + + property("deconstruct bare case class") = test { + val q"$mods class $name(..$args) extends ..$parents" = q"case class Foo(x: Int)" + } + + property("exhaustive class matcher") = test { + def matches(line: String) { + val q"""$classMods class $name[..$targs] $ctorMods(...$argss) + extends { ..$early } with ..$parents { $self => ..$body }""" = parse(line) + } + matches("class Foo") + matches("class Foo[T]") + matches("class Foo[T] @annot") + matches("class Foo extends Bar with Baz") + matches("class Foo { body }") + matches("class Foo extends { val early = 0 } with Any") + matches("abstract class Foo") + matches("private[Baz] class Foo") + matches("class Foo(first: A)(second: B)") + matches("class Foo(first: A) extends Bar(first) with Baz") + matches("class Foo private (first: A) { def bar }") + matches("class Foo { self => bar(self) }") + matches("case class Foo(x: Int)") + } +} + +trait ModsDeconstruction { self: QuasiquoteProperties => + property("deconstruct mods") = test { + val mods = Modifiers(IMPLICIT | PRIVATE, TermName("foobar"), Nil) + val q"$mods0 def foo" = q"$mods def foo" + assert(mods0 ≈ mods) + } + + property("@$annot def foo") = forAll { (annotName: TypeName) => + val q"@$annot def foo" = q"@$annotName def foo" + annot ≈ Apply(Select(New(Ident(annotName)), nme.CONSTRUCTOR), List()) + } + + property("@$annot(..$args) def foo") = forAll { (annotName: TypeName, tree: Tree) => + val q"@$annot(..$args) def foo" = q"@$annotName($tree) def foo" + annot ≈ Ident(annotName) && args ≈ List(tree) + } + + property("@..$annots def foo") = test { + val a = annot("a") + val b = annot("b") + val q"@..$annots def foo" = q"@$a @$b def foo" + annots ≈ List(a, b) + } + + property("@$annot @..$annots def foo") = test { + val a = annot("a") + val b = annot("b") + val c = annot("c") + val q"@$first @..$rest def foo" = q"@$a @$b @$c def foo" + first ≈ a && rest ≈ List(b, c) + } +} + +trait ValVarDeconstruction { self: QuasiquoteProperties => + property("exhaustive val matcher") = test { + def matches(line: String) { val q"$mods val $name: $tpt = $rhs" = parse(line) } + matches("val x: Int") + matches("val x: Int = 1") + matches("lazy val x: Int = 1") + matches("implicit val x = 1") + assertThrows[MatchError] { matches("var x = 1") } + } + + property("exhaustive var matcher") = test { + def matches(line: String) { val q"$mods var $name: $tpt = $rhs" = parse(line) } + matches("var x: Int") + matches("var x: Int = 1") + matches("var x = 1") + assertThrows[MatchError] { matches("val x = 1") } + } +}
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/DeprecationProps.scala b/test/files/scalacheck/quasiquotes/DeprecationProps.scala new file mode 100644 index 0000000000..8e1601cf9d --- /dev/null +++ b/test/files/scalacheck/quasiquotes/DeprecationProps.scala @@ -0,0 +1,52 @@ +import org.scalacheck._, Prop._, Gen._, Arbitrary._ +import scala.reflect.runtime.universe._ + +object DeprecationProps extends QuasiquoteProperties("deprecation") { + val tname = TypeName("Foo") + val tpt = tq"Foo" + val tpe = typeOf[Int] + val sym = tpe.typeSymbol.asType + val argss = List(q"x") :: List(q"y") :: Nil + val args = q"x" :: q"y" :: Nil + + property("new tpt argss") = test { + assert(q"new $tpt(...$argss)" ≈ New(tpt, argss)) + } + + property("new tpe args") = test { + assert(q"new $tpe(..$args)" ≈ New(tpe, args: _*)) + } + + property("new tpe args") = test { + assert(q"new ${sym.toType}(..$args)" ≈ New(sym, args: _*)) + } + + property("apply sym args") = test { + assert(q"$sym(..$args)" ≈ Apply(sym, args: _*)) + } + + property("applyconstructor") = test { + assert(q"new $tpt(..$args)" ≈ ApplyConstructor(tpt, args)) + } + + property("super sym name") = test { + assert(q"$sym.super[$tname].x".qualifier ≈ Super(sym, tname)) + } + + property("throw tpe args") = test { + assert(q"throw new $tpe(..$args)" ≈ Throw(tpe, args: _*)) + } + + property("casedef pat body") = test { + val pat = pq"foo" + val body = q"bar" + assert(cq"$pat => $body" ≈ CaseDef(pat, body)) + } + + property("try body cases") = test { + val cases = (pq"a", q"b") :: (pq"c", q"d") :: Nil + val newcases = cases.map { case (pat, body) => cq"$pat => $body" } + val body = q"foo" + assert(q"try $body catch { case ..$newcases }" ≈ Try(body, cases: _*)) + } +}
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/ErrorProps.scala b/test/files/scalacheck/quasiquotes/ErrorProps.scala new file mode 100644 index 0000000000..b9e69e0e88 --- /dev/null +++ b/test/files/scalacheck/quasiquotes/ErrorProps.scala @@ -0,0 +1,193 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object ErrorProps extends QuasiquoteProperties("errors") { + property("can't extract two .. cardinalities in a row") = fails( + "Can't extract with .. here", + """ + val xs = List(q"x1", q"x2") + val q"f(..$xs1, ..$xs2)" = xs + """) + + property("can't splice with given cardinality") = fails( + "Can't splice List[reflect.runtime.universe.Ident], consider using ..", + """ + val xs = List(q"x", q"x") + q"$xs" + """) + + property("splice typename into typedef with default bounds") = fails( + "reflect.runtime.universe.Name expected but reflect.runtime.universe.TypeDef found", + """ + val T1 = TypeName("T1") + val T2 = q"type T" + val t = EmptyTree + q"type $T1[$T2 >: _root_.scala.Any <: _root_.scala.Nothing] = $t" ≈ + TypeDef(Modifiers(), T1, List(T2), t) + """) + + property("can't splice annotations with ... cardinality") = fails( + "Can't splice with ... here", + """ + val annots = List(List(q"Foo")) + q"@...$annots def foo" + """) + + property("@..$first @$rest def foo") = fails( + "Can't extract with .. here", + """ + val a = annot("a") + val b = annot("b") + val c = annot("c") + val q"@..$first @$rest def foo" = q"@$a @$b @$c def foo" + """) + + property("only literal string arguments") = fails( + "Quasiquotes can only be used with literal strings", + """ + val s: String = "foo" + StringContext(s).q() + """) + + property("don't know how to splice inside of strings") = fails( + "Don't know how to splice here", + """ + val x: Tree = EmptyTree + StringContext("\"", "\"").q(x) + """) + + property("expected different cardinality") = fails( + "Can't splice List[reflect.runtime.universe.Tree] with ..., consider using ..", + """ + val args: List[Tree] = Nil + q"f(...$args)" + """) + + property("non-liftable type ..") = fails( + "Can't splice List[StringBuilder] with .., consider omitting the dots or providing an implicit instance of Liftable[StringBuilder]", + """ + import java.lang.StringBuilder + val bazs = List(new StringBuilder) + q"f(..$bazs)" + """) + + property("non-liftable type ...") = fails( + "Can't splice List[List[StringBuilder]] with .., consider using ... or providing an implicit instance of Liftable[StringBuilder]", + """ + import java.lang.StringBuilder + val bazs = List(List(new StringBuilder)) + q"f(..$bazs)" + """) + + property("use .. card or provide liftable") = fails( + "Can't splice List[StringBuilder], consider using .. or providing an implicit instance of Liftable[List[StringBuilder]]", + """ + import java.lang.StringBuilder + val lst: List[StringBuilder] = Nil + q"f($lst)" + """) + + property("use ... card or provide liftable") = fails( + "Can't splice List[List[reflect.runtime.universe.Ident]], consider using ...", + """ + val xs = List(List(q"x", q"x")) + q"$xs" + """) + + property("use zero card") = fails( + "Can't splice reflect.runtime.universe.Tree with .., consider omitting the dots", + """ + val t = EmptyTree + q"f(..$t)" + """) + + property("not liftable or natively supported") = fails( + "Can't splice StringBuilder, consider providing an implicit instance of Liftable[StringBuilder]", + """ + import java.lang.StringBuilder + val sb = new StringBuilder + 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", + """ + val lst: List[List[Tree]] = Nil; val t = EmptyTree + q"f(...$lst, $t)" + """) + + property("name expected") = fails( + "reflect.runtime.universe.Name expected but reflect.runtime.universe.Tree found", + """ + val t = EmptyTree + q"class $t" + """) + + property("flags or mods expected") = fails( + "reflect.runtime.universe.FlagSet or reflect.runtime.universe.Modifiers expected but reflect.runtime.universe.Tree found", + """ + val t = EmptyTree + q"$t def foo" + """) + + property("cant splice flags together with mods") = fails( + "Can't splice flags together with modifiers, consider merging flags into modifiers", + """ + val f = Flag.IMPLICIT; val m = NoMods + q"$f $m def foo" + """) + + property("can't splice mods with annots") = fails( + "Can't splice modifiers together with annotations, consider merging annotations into modifiers", + """ + val m = NoMods + q"@annot $m def foo" + """) + + property("can't splice modifiers with inline flags") = fails( + "Can't splice modifiers together with flags, consider merging flags into modifiers", + """ + val m = NoMods + q"$m implicit def foo" + """) + + property("can't splice multiple mods") = fails( + "Can't splice multiple modifiers, consider merging them into a single modifiers instance", + """ + val m1 = NoMods; val m2 = NoMods + q"$m1 $m2 def foo" + """) + + property("can't extract with .. card here") = fails( + "Can't extract with .. here", + """ + val q"f(..$xs, $y)" = EmptyTree + """) + + property("can't extract mods with annots") = fails( + "Can't extract modifiers together with annotations, consider extracting just modifiers", + """ + val q"@$annot $mods def foo" = EmptyTree + """) + + property("can't extract multiple mods") = fails( + "Can't extract multiple modifiers together, consider extracting a single modifiers instance", + """ + val q"$m1 $m2 def foo" = EmptyTree + """) + + // // 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 new file mode 100644 index 0000000000..510ab99068 --- /dev/null +++ b/test/files/scalacheck/quasiquotes/LiftableProps.scala @@ -0,0 +1,84 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object LiftableProps extends QuasiquoteProperties("liftable") { + property("splice byte") = test { + val c: Byte = 0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice short") = test { + val c: Short = 0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice char") = test { + val c: Char = 'c' + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice int") = test { + val c: Int = 0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice long") = test { + val c: Long = 0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice float") = test { + val c: Float = 0.0f + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice double") = test { + val c: Double = 0.0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice boolean") = test { + val c: Boolean = false + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice string") = test { + val c: String = "s" + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice unit") = test { + val c: Unit = () + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("lift symbol") = test { + val s = rootMirror.staticClass("scala.Int") + assert(q"$s" ≈ Ident(s)) + } + + property("lift type") = test { + val tpe = rootMirror.staticClass("scala.Int").toType + assert(q"$tpe" ≈ TypeTree(tpe)) + } + + property("lift type tag") = test { + val tag = TypeTag.Int + assert(q"$tag" ≈ TypeTree(tag.tpe)) + } + + property("lift weak type tag") = test { + val tag = WeakTypeTag.Int + assert(q"$tag" ≈ TypeTree(tag.tpe)) + } + + property("lift constant") = test { + val const = Constant(0) + assert(q"$const" ≈ q"0") + } +}
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala new file mode 100644 index 0000000000..504cb2a77d --- /dev/null +++ b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala @@ -0,0 +1,37 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object PatternConstructionProps extends QuasiquoteProperties("pattern construction") { + property("splice bind") = forAll { (bind: Bind) => + pq"$bind" ≈ bind + } + + property("splice name into bind") = forAll { (name: TermName) => + pq"$name" ≈ Bind(name, Ident(nme.WILDCARD)) + } + + property("splice name and tree into bind") = forAll { (name: TermName, tree: Tree) => + pq"$name @ $tree" ≈ Bind(name, tree) + } + + property("splice type name into typed") = forAll { (name: TypeName) => + pq"_ : $name" ≈ Typed(Ident(nme.WILDCARD), Ident(name)) + } + + property("splice tree into typed") = forAll { (typ: Tree) => + pq"_ : $typ" ≈ Typed(Ident(nme.WILDCARD), typ) + } + + property("splice into apply") = forAll { (pat: Tree, subpat: Tree) => + pq"$pat($subpat)" ≈ Apply(pat, List(subpat)) + } + + property("splice into casedef") = forAll { (pat: Tree, cond: Tree, body: Tree) => + cq"$pat if $cond => $body" ≈ CaseDef(pat, cond, body) + } +}
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala new file mode 100644 index 0000000000..f73fd29b22 --- /dev/null +++ b/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala @@ -0,0 +1,35 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ +import definitions._ + +object PatternDeconstructionProps extends QuasiquoteProperties("pattern deconstruction") { + property("extract bind") = forAll { (bind: Bind) => + val pq"$bind0" = pq"$bind" + bind0 ≈ bind + } + + property("extract bind and subpattern") = forAll { (name: TermName, subp: Tree) => + val pq"$name0 @ $subp0" = pq"$name @ $subp" + name0 ≈ name && subp0 ≈ subp + } + + property("extract typed") = forAll { (typ: Tree) => + val pq"_ : $typ0" = pq"_ : $typ" + typ0 ≈ typ + } + + property("extract apply") = forAll { (pat: Tree, subpat: Tree) => + val pq"$pat0($subpat0)" = pq"$pat($subpat)" + pat0 ≈ pat && subpat0 ≈ subpat + } + + property("extract casedef") = forAll { (pat: Tree, cond: Tree, body: Tree) => + val cq"$pat0 if $cond0 => $body0" = cq"$pat if $cond => $body" + pat0 ≈ pat && cond0 ≈ cond && body0 ≈ body + } +}
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala new file mode 100644 index 0000000000..6a531071bf --- /dev/null +++ b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala @@ -0,0 +1,98 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.universe.definitions._ +import scala.reflect.runtime.universe.Flag._ +import scala.reflect.runtime.currentMirror +import scala.reflect.api.{Liftable, Universe} +import scala.reflect.macros.TypecheckException +import scala.tools.reflect.{ToolBox, ToolBoxError} + +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +class QuasiquoteProperties(name: String) extends Properties(name) with ArbitraryTreesAndNames with Helpers + +trait Helpers { + /** Runs a code block and returns proof confirmation + * if no exception has been thrown while executing code + * block. This is useful for simple one-off tests. + */ + def test[T](block: => T)= + Prop { (params) => + block + Result(Prop.Proof) + } + + implicit class TestSimilarTree(tree1: Tree) { + def ≈(tree2: Tree) = tree1.equalsStructure(tree2) + } + + implicit class TestSimilarListTree(lst: List[Tree]) { + def ≈(other: List[Tree]) = (lst.length == other.length) && lst.zip(other).forall { case (t1, t2) => t1 ≈ t2 } + } + + implicit class TestSimilarListListTree(lst: List[List[Tree]]) { + def ≈(other: List[List[Tree]]) = (lst.length == other.length) && lst.zip(other).forall { case (l1, l2) => l1 ≈ l2 } + } + + implicit class TestSimilarName(name: Name) { + def ≈(other: Name) = name == other + } + + implicit class TestSimilarMods(mods: Modifiers) { + def ≈(other: Modifiers) = (mods.flags == other.flags) && (mods.privateWithin ≈ other.privateWithin) && (mods.annotations ≈ other.annotations) + } + + def assertThrows[T <: AnyRef](f: => Any)(implicit manifest: Manifest[T]): Unit = { + val clazz = manifest.erasure.asInstanceOf[Class[T]] + val thrown = + try { + f + false + } catch { + case u: Throwable => + if (!clazz.isAssignableFrom(u.getClass)) + assert(false, s"wrong exception: $u") + true + } + if(!thrown) + assert(false, "exception wasn't thrown") + } + + def assertEqAst(tree: Tree, code: String) = assert(eqAst(tree, code)) + def eqAst(tree: Tree, code: String) = tree ≈ parse(code) + + val toolbox = currentMirror.mkToolBox() + val parse = toolbox.parse(_) + val compile = toolbox.compile(_) + val eval = toolbox.eval(_) + + def fails(msg: String, block: String) = { + def result(ok: Boolean, description: String = "") = { + val status = if (ok) Prop.Proof else Prop.False + val labels = if (description != "") Set(description) else Set.empty[String] + Prop { new Prop.Result(status, Nil, Set.empty, labels) } + } + try { + compile(parse(s""" + object Wrapper extends Helpers { + import scala.reflect.runtime.universe._ + $block + } + """)) + result(false, "given code doesn't fail to typecheck") + } catch { + case ToolBoxError(emsg, _) => + if (!emsg.contains(msg)) + result(false, s"error message '${emsg}' is not the same as expected '$msg'") + else + result(true) + } + } + + def annot(name: String): Tree = annot(TypeName(name), Nil) + 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 diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala new file mode 100644 index 0000000000..753ad1aa59 --- /dev/null +++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala @@ -0,0 +1,194 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object TermConstructionProps extends QuasiquoteProperties("term construction") { + + property("splice single tree return tree itself") = forAll { (t: Tree) => + q"$t" ≈ t + } + + property("splice trees into if expression") = forAll { (t1: Tree, t2: Tree, t3: Tree) => + q"if($t1) $t2 else $t3" ≈ If(t1, t2, t3) + } + + property("splice trees into ascriptiopn") = forAll { (t1: Tree, t2: Tree) => + q"$t1 : $t2" ≈ Typed(t1, t2) + } + + property("splice trees into apply") = forAll { (t1: Tree, t2: Tree, t3: Tree) => + q"$t1($t2, $t3)" ≈ Apply(t1, List(t2, t3)) + } + + property("splice trees with .. cardinality into apply") = forAll { (ts: List[Tree]) => + q"f(..$ts)" ≈ Apply(q"f", ts) + } + + property("splice iterable into apply") = forAll { (trees: List[Tree]) => + val itrees: Iterable[Tree] = trees + q"f(..$itrees)" ≈ Apply(q"f", trees) + } + + property("splice trees with ... cardinality into apply") = forAll { (ts1: List[Tree], ts2: List[Tree]) => + val argss = List(ts1, ts2) + q"f(...$argss)" ≈ Apply(Apply(q"f", ts1), ts2) + } + + property("splice term name into assign") = forAll { (name: TermName, t: Tree) => + q"$name = $t" ≈ Assign(Ident(name), t) + } + + property("splice trees into block") = forAll { (t1: Tree, t2: Tree, t3: Tree) => + blockInvariant(q"""{ + $t1 + $t2 + $t3 + }""", List(t1, t2, t3)) + } + + + property("splice tree into new") = forAll { (tree: Tree) => + q"new $tree" ≈ Apply(Select(New(tree), nme.CONSTRUCTOR), List()) + } + + property("splice tree into return") = forAll { (tree: Tree) => + q"return $tree" ≈ Return(tree) + } + + property("splice a list of arguments") = forAll { (fun: Tree, args: List[Tree]) => + q"$fun(..$args)" ≈ Apply(fun, args) + } + + property("splice list and non-list fun arguments") = forAll { (fun: Tree, arg1: Tree, arg2: Tree, args: List[Tree]) => + q"$fun(..$args, $arg1, $arg2)" ≈ Apply(fun, args ++ List(arg1) ++ List(arg2)) && + q"$fun($arg1, ..$args, $arg2)" ≈ Apply(fun, List(arg1) ++ args ++ List(arg2)) && + q"$fun($arg1, $arg2, ..$args)" ≈ Apply(fun, List(arg1) ++ List(arg2) ++ args) + } + + property("splice into new") = forAll { (name: TypeName, body: List[Tree]) => + q"new $name { ..$body }" ≈ + q"""{ + final class $$anon extends $name { + ..$body + } + new $$anon + }""" + } + + property("splice type name into this") = forAll { (T: TypeName) => + q"$T.this" ≈ This(T) + } + + property("splice tree into throw") = forAll { (t: Tree) => + q"throw $t" ≈ Throw(t) + } + + property("splice trees into type apply") = forAll { (fun: TreeIsTerm, types: List[Tree]) => + q"$fun[..$types]" ≈ (if (types.nonEmpty) TypeApply(fun, types) else fun) + } + + property("splice names into import selector") = forAll { + (expr: Tree, plain: Name, oldname: Name, newname: Name, discard: Name) => + + val Import(expr1, List( + ImportSelector(plain11, _, plain12, _), + ImportSelector(oldname1, _, newname1, _), + ImportSelector(discard1, _, wildcard, _))) = + q"import $expr.{$plain, $oldname => $newname, $discard => _}" + + expr1 ≈ expr && plain11 == plain12 && plain12 == plain && + oldname1 == oldname && newname1 == newname && discard1 == discard && wildcard == nme.WILDCARD + } + + property("splice trees into while loop") = forAll { (cond: Tree, body: Tree) => + val LabelDef(_, List(), If(cond1, Block(List(body1), Apply(_, List())), Literal(Constant(())))) = q"while($cond) $body" + body1 ≈ body && cond1 ≈ cond + } + + property("splice trees into do while loop") = forAll { (cond: Tree, body: Tree) => + val LabelDef(_, List(), Block(List(body1), If(cond1, Apply(_, List()), Literal(Constant(()))))) = q"do $body while($cond)" + body1 ≈ body && cond1 ≈ cond + } + + property("splice trees into alternative") = forAll { (c: Tree, A: Tree, B: Tree) => + q"$c match { case $A | $B => }" ≈ + Match(c, List( + CaseDef(Alternative(List(A, B)), EmptyTree, Literal(Constant(()))))) + } + + def blockInvariant(quote: Tree, trees: List[Tree]) = + quote ≈ (trees match { + case Nil => q"()" + case _ :+ last if !last.isTerm => Block(trees, q"()") + case head :: Nil => head + case init :+ last => Block(init, last) + }) + + property("splice list of trees into block (1)") = forAll { (trees: List[Tree]) => + blockInvariant(q"{ ..$trees }", trees) + } + + property("splice list of trees into block (2)") = forAll { (trees1: List[Tree], trees2: List[Tree]) => + blockInvariant(q"{ ..$trees1 ; ..$trees2 }", trees1 ++ trees2) + } + + property("splice list of trees into block (3)") = forAll { (trees: List[Tree], tree: Tree) => + blockInvariant(q"{ ..$trees; $tree }", trees :+ tree) + } + + property("splice term into brackets") = test { + val a = q"a" + assert(q"($a)" ≈ a) + } + + property("splice terms into tuple") = test { + val a1 = q"a1" + val a2 = q"a2" + val as = List(a1, a2) + assert(q"(..$as)" ≈ q"Tuple2($a1, $a2)") + assert(q"(a0, ..$as)" ≈ q"Tuple3(a0, $a1, $a2)") + } + + property("splice empty list into tuple") = test { + val empty = List[Tree]() + assert(q"(..$empty)" ≈ q"()") + } + + property("function param flags are the same") = test { + val xy = q"val x: A" :: q"val y: B" :: Nil + assertEqAst(q"(..$xy) => x + y", "(x: A, y: B) => x + y") + } + + property("anonymous functions don't support default values") = test { + val x = q"val x: Int = 1" + assertThrows[IllegalArgumentException] { q"($x) => x" } + } + + property("assign variable") = test { + val v = q"v" + val value = q"foo" + assertEqAst(q"$v = $value", "v = foo") + } + + property("assign update 1") = test { + val v = q"v" + val args = q"1" :: q"2" :: Nil + val value = q"foo" + assertEqAst(q"$v(..$args) = $value", "v(1, 2) = foo") + } + + property("assign update 2") = test { + val a = q"v(0)" + val value = q"foo" + assertEqAst(q"$a = $value", "v(0) = foo") + } + + property("assign or named arg") = test { + val assignx = q"x = 1" + assertEqAst(q"f($assignx)", "f(x = 1)") + } +} diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala new file mode 100644 index 0000000000..22d4b1ce4f --- /dev/null +++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala @@ -0,0 +1,114 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction") { + property("f(..x) = f") = test { + assertThrows[MatchError] { + val q"f(..$argss)" = q"f" + } + } + + property("f(x)") = forAll { (x: Tree) => + val q"f($x1)" = q"f($x)" + x1 ≈ x + } + + property("f(..xs)") = forAll { (x1: Tree, x2: Tree) => + val q"f(..$xs)" = q"f($x1, $x2)" + xs ≈ List(x1, x2) + } + + property("f(y, ..ys)") = forAll { (x1: Tree, x2: Tree, x3: Tree) => + val q"f($y, ..$ys)" = q"f($x1, $x2, $x3)" + y ≈ x1 && ys ≈ List(x2, x3) + } + + property("f(y1, y2, ..ys)") = forAll { (x1: Tree, x2: Tree, x3: Tree) => + val q"f($y1, $y2, ..$ys)" = q"f($x1, $x2, $x3)" + y1 ≈ x1 && y2 ≈ x2 && ys ≈ List(x3) + } + + property("f(...xss)") = forAll { (x1: Tree, x2: Tree) => + val q"f(...$argss)" = q"f($x1)($x2)" + argss ≈ List(List(x1), List(x2)) + } + + property("f(...xss) = f") = forAll { (x1: Tree, x2: Tree) => + val q"f(...$argss)" = q"f" + argss ≈ List() + } + + property("deconstruct unit as tuple") = test { + val q"(..$xs)" = q"()" + assert(xs.isEmpty) + } + + property("deconstruct tuple") = test { + val q"(..$xs)" = q"(a, b)" + assert(xs ≈ List(q"a", q"b")) + } + + property("deconstruct tuple mixed") = test { + val q"($first, ..$rest)" = q"(a, b, c)" + assert(first ≈ q"a" && rest ≈ List(q"b", q"c")) + } + + property("deconstruct cases") = test { + val q"$x match { case ..$cases }" = q"x match { case 1 => case 2 => }" + x ≈ q"x" && cases ≈ List(cq"1 =>", cq"2 =>") + } + + property("deconstruct block") = test { + val q"{ ..$xs }" = q"{ x1; x2; x3 }" + assert(xs ≈ List(q"x1", q"x2", q"x3")) + } + + property("exhaustive function matcher") = test { + def matches(line: String) { val q"(..$args) => $body" = parse(line) } + matches("() => bippy") + matches("(y: Y) => y oh y") + matches("(x: X, y: Y) => x and y") + } + + property("exhaustive new pattern") = test { + def matches(line: String) { + val q"new { ..$early } with $name[..$targs](...$vargss) with ..$mixin { $self => ..$body }" = parse(line) + } + matches("new foo") + matches("new foo { body }") + matches("new foo[t]") + matches("new foo(x)") + matches("new foo[t](x)") + matches("new foo[t](x) { body }") + matches("new foo with bar") + matches("new foo with bar { body }") + matches("new { anonymous }") + matches("new { val early = 1} with Parent[Int] { body }") + matches("new Foo { selfie => }") + } + + property("exhaustive assign pattern") = test { + def matches(tree: Tree) { val q"$rhs = $lhs" = tree } + matches(parse("left = right")) + matches(parse("arr(1) = 2")) + matches(AssignOrNamedArg(EmptyTree, EmptyTree)) + } + + property("deconstruct update 1") = test { + val q"$obj(..$args) = $value" = q"foo(bar) = baz" + assert(obj ≈ q"foo") + assert(args ≈ List(q"bar")) + assert(value ≈ q"baz") + } + + property("deconstruct update 2") = test { + val q"$left = $value" = q"foo(bar) = baz" + assert(left ≈ q"foo(bar)") + assert(value ≈ q"baz") + } +} diff --git a/test/files/scalacheck/quasiquotes/Test.scala b/test/files/scalacheck/quasiquotes/Test.scala new file mode 100644 index 0000000000..f41d961888 --- /dev/null +++ b/test/files/scalacheck/quasiquotes/Test.scala @@ -0,0 +1,15 @@ +import org.scalacheck._ + +object Test extends Properties("quasiquotes") { + include(TermConstructionProps) + include(TermDeconstructionProps) + include(TypeConstructionProps) + include(TypeDeconstructionProps) + include(PatternConstructionProps) + include(PatternDeconstructionProps) + include(LiftableProps) + include(ErrorProps) + include(DefinitionConstructionProps) + include(DefinitionDeconstructionProps) + include(DeprecationProps) +} diff --git a/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala new file mode 100644 index 0000000000..cac83ff8ac --- /dev/null +++ b/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala @@ -0,0 +1,36 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object TypeConstructionProps extends QuasiquoteProperties("type construction") { + property("bare idents contain type names") = test { + tq"x" ≈ Ident(TypeName("x")) + } + + property("splice type names into AppliedTypeTree") = forAll { (name1: TypeName, name2: TypeName) => + tq"$name1[$name2]" ≈ AppliedTypeTree(Ident(name1), List(Ident(name2))) + } + + property("tuple type") = test { + val empty = List[Tree]() + val ts = List(tq"t1", tq"t2") + assert(tq"(..$empty)" ≈ tq"scala.Unit") + assert(tq"(..$ts)" ≈ tq"Tuple2[t1, t2]") + assert(tq"(t0, ..$ts)" ≈ tq"Tuple3[t0, t1, t2]") + } + + property("refined type") = test { + val stats = q"def foo" :: q"val x: Int" :: q"type Y = String" :: Nil + assert(tq"T { ..$stats }" ≈ tq"T { def foo; val x: Int; type Y = String }") + } + + property("function type") = test { + val argtpes = tq"A" :: tq"B" :: Nil + val restpe = tq"C" + assert(tq"..$argtpes => $restpe" ≈ tq"(A, B) => C") + } +}
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala new file mode 100644 index 0000000000..e1d5f4df96 --- /dev/null +++ b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala @@ -0,0 +1,40 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object TypeDeconstructionProps extends QuasiquoteProperties("type deconstruction") { + property("ident(type name)") = forAll { (name: TypeName) => + val t = Ident(name) + val tq"$t1" = t + t1 ≈ t + } + + property("applied type tree") = forAll { (name1: TypeName, name2: TypeName) => + val tq"$a[$b]" = AppliedTypeTree(Ident(name1), List(Ident(name2))) + a ≈ Ident(name1) && b ≈ Ident(name2) + } + + property("tuple type") = test { + val tq"(..$empty)" = tq"_root_.scala.Unit" + assert(empty.isEmpty) + val tq"(..$ts)" = tq"(t1, t2)" + assert(ts ≈ List(tq"t1", tq"t2")) + val tq"($head, ..$tail)" = tq"(t0, t1, t2)" + assert(head ≈ tq"t0" && tail ≈ List(tq"t1", tq"t2")) + } + + property("refined type") = test { + val tq"T { ..$stats }" = tq"T { def foo; val x: Int; type Y = String }" + assert(stats ≈ (q"def foo" :: q"val x: Int" :: q"type Y = String" :: Nil)) + } + + property("function type") = test { + val tq"..$argtpes => $restpe" = tq"(A, B) => C" + assert(argtpes ≈ (tq"A" :: tq"B" :: Nil)) + assert(restpe ≈ tq"C") + } +}
\ No newline at end of file diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala index 72979115be..6c7c32bfdf 100644 --- a/test/files/scalacheck/range.scala +++ b/test/files/scalacheck/range.scala @@ -30,7 +30,7 @@ abstract class RangeTest(kind: String) extends Properties("Range "+kind) { def myGen: Gen[Range] def genReasonableSizeRange = oneOf(genArbitraryRange, genBoundaryRange) - + def genArbitraryRange = for { start <- choose(Int.MinValue, Int.MaxValue) end <- choose(Int.MinValue, Int.MaxValue) @@ -56,7 +56,7 @@ abstract class RangeTest(kind: String) extends Properties("Range "+kind) { } yield if (start < end) Range(start, end, step) else Range(start, end, -step) def genRangeByOne = oneOf(genRangeOpenByOne, genRangeClosedByOne) - + def genRangeOpenByOne = for { r <- oneOf(genSmallRange, genBoundaryRange) if (r.end.toLong - r.start.toLong).abs <= 10000000L diff --git a/test/files/scalacheck/redblack.scala b/test/files/scalacheck/redblack.scala deleted file mode 100644 index bbc6504f58..0000000000 --- a/test/files/scalacheck/redblack.scala +++ /dev/null @@ -1,213 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ - -/* -Properties of a Red & Black Tree: - -A node is either red or black. -The root is black. (This rule is used in some definitions and not others. Since the -root can always be changed from red to black but not necessarily vice-versa this -rule has little effect on analysis.) -All leaves are black. -Both children of every red node are black. -Every simple path from a given node to any of its descendant leaves contains the same number of black nodes. -*/ - -abstract class RedBlackTest extends Properties("RedBlack") { - def minimumSize = 0 - def maximumSize = 5 - - object RedBlackTest extends scala.collection.immutable.RedBlack[String] { - def isSmaller(x: String, y: String) = x < y - } - - import RedBlackTest._ - - def nodeAt[A](tree: Tree[A], n: Int): Option[(String, A)] = if (n < tree.iterator.size && n >= 0) - Some(tree.iterator.drop(n).next) - else - None - - def treeContains[A](tree: Tree[A], key: String) = tree.iterator.map(_._1) contains key - - def mkTree(level: Int, parentIsBlack: Boolean = false, label: String = ""): Gen[Tree[Int]] = - if (level == 0) { - value(Empty) - } else { - for { - oddOrEven <- choose(0, 2) - tryRed = oddOrEven.sample.get % 2 == 0 // work around arbitrary[Boolean] bug - isRed = parentIsBlack && tryRed - nextLevel = if (isRed) level else level - 1 - left <- mkTree(nextLevel, !isRed, label + "L") - right <- mkTree(nextLevel, !isRed, label + "R") - } yield { - if (isRed) - RedTree(label + "N", 0, left, right) - else - BlackTree(label + "N", 0, left, right) - } - } - - def genTree = for { - depth <- choose(minimumSize, maximumSize + 1) - tree <- mkTree(depth) - } yield tree - - type ModifyParm - def genParm(tree: Tree[Int]): Gen[ModifyParm] - def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] - - def genInput: Gen[(Tree[Int], ModifyParm, Tree[Int])] = for { - tree <- genTree - parm <- genParm(tree) - } yield (tree, parm, modify(tree, parm)) -} - -trait RedBlackInvariants { - self: RedBlackTest => - - import RedBlackTest._ - - def rootIsBlack[A](t: Tree[A]) = t.isBlack - - def areAllLeavesBlack[A](t: Tree[A]): Boolean = t match { - case Empty => t.isBlack - case ne: NonEmpty[_] => List(ne.left, ne.right) forall areAllLeavesBlack - } - - def areRedNodeChildrenBlack[A](t: Tree[A]): Boolean = t match { - case RedTree(_, _, left, right) => List(left, right) forall (t => t.isBlack && areRedNodeChildrenBlack(t)) - case BlackTree(_, _, left, right) => List(left, right) forall areRedNodeChildrenBlack - case Empty => true - } - - def blackNodesToLeaves[A](t: Tree[A]): List[Int] = t match { - case Empty => List(1) - case BlackTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves map (_ + 1) - case RedTree(_, _, left, right) => List(left, right) flatMap blackNodesToLeaves - } - - def areBlackNodesToLeavesEqual[A](t: Tree[A]): Boolean = t match { - case Empty => true - case ne: NonEmpty[_] => - ( - blackNodesToLeaves(ne).distinct.size == 1 - && areBlackNodesToLeavesEqual(ne.left) - && areBlackNodesToLeavesEqual(ne.right) - ) - } - - def orderIsPreserved[A](t: Tree[A]): Boolean = - t.iterator zip t.iterator.drop(1) forall { case (x, y) => isSmaller(x._1, y._1) } - - def setup(invariant: Tree[Int] => Boolean) = forAll(genInput) { case (tree, parm, newTree) => - invariant(newTree) - } - - property("root is black") = setup(rootIsBlack) - property("all leaves are black") = setup(areAllLeavesBlack) - property("children of red nodes are black") = setup(areRedNodeChildrenBlack) - property("black nodes are balanced") = setup(areBlackNodesToLeavesEqual) - property("ordering of keys is preserved") = setup(orderIsPreserved) -} - -object TestInsert extends RedBlackTest with RedBlackInvariants { - import RedBlackTest._ - - override type ModifyParm = Int - override def genParm(tree: Tree[Int]): Gen[ModifyParm] = choose(0, tree.iterator.size + 1) - override def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] = tree update (generateKey(tree, parm), 0) - - def generateKey(tree: Tree[Int], parm: ModifyParm): String = nodeAt(tree, parm) match { - case Some((key, _)) => key.init.mkString + "MN" - case None => nodeAt(tree, parm - 1) match { - case Some((key, _)) => key.init.mkString + "RN" - case None => "N" - } - } - - property("update adds elements") = forAll(genInput) { case (tree, parm, newTree) => - treeContains(newTree, generateKey(tree, parm)) - } -} - -object TestModify extends RedBlackTest { - import RedBlackTest._ - - def newValue = 1 - override def minimumSize = 1 - override type ModifyParm = Int - override def genParm(tree: Tree[Int]): Gen[ModifyParm] = choose(0, tree.iterator.size) - override def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] = nodeAt(tree, parm) map { - case (key, _) => tree update (key, newValue) - } getOrElse tree - - property("update modifies values") = forAll(genInput) { case (tree, parm, newTree) => - nodeAt(tree,parm) forall { case (key, _) => - newTree.iterator contains (key, newValue) - } - } -} - -object TestDelete extends RedBlackTest with RedBlackInvariants { - import RedBlackTest._ - - override def minimumSize = 1 - override type ModifyParm = Int - override def genParm(tree: Tree[Int]): Gen[ModifyParm] = choose(0, tree.iterator.size) - override def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] = nodeAt(tree, parm) map { - case (key, _) => tree delete key - } getOrElse tree - - property("delete removes elements") = forAll(genInput) { case (tree, parm, newTree) => - nodeAt(tree, parm) forall { case (key, _) => - !treeContains(newTree, key) - } - } -} - -object TestRange extends RedBlackTest with RedBlackInvariants { - import RedBlackTest._ - - override type ModifyParm = (Option[Int], Option[Int]) - override def genParm(tree: Tree[Int]): Gen[ModifyParm] = for { - from <- choose(0, tree.iterator.size) - to <- choose(0, tree.iterator.size) suchThat (from <=) - optionalFrom <- oneOf(Some(from), None, Some(from)) // Double Some(n) to get around a bug - optionalTo <- oneOf(Some(to), None, Some(to)) // Double Some(n) to get around a bug - } yield (optionalFrom, optionalTo) - - override def modify(tree: Tree[Int], parm: ModifyParm): Tree[Int] = { - val from = parm._1 flatMap (nodeAt(tree, _) map (_._1)) - val to = parm._2 flatMap (nodeAt(tree, _) map (_._1)) - tree range (from, to) - } - - property("range boundaries respected") = forAll(genInput) { case (tree, parm, newTree) => - val from = parm._1 flatMap (nodeAt(tree, _) map (_._1)) - val to = parm._2 flatMap (nodeAt(tree, _) map (_._1)) - ("lower boundary" |: (from forall ( key => newTree.iterator.map(_._1) forall (key <=)))) && - ("upper boundary" |: (to forall ( key => newTree.iterator.map(_._1) forall (key >)))) - } - - property("range returns all elements") = forAll(genInput) { case (tree, parm, newTree) => - val from = parm._1 flatMap (nodeAt(tree, _) map (_._1)) - val to = parm._2 flatMap (nodeAt(tree, _) map (_._1)) - val filteredTree = (tree.iterator - .map(_._1) - .filter(key => from forall (key >=)) - .filter(key => to forall (key <)) - .toList) - filteredTree == newTree.iterator.map(_._1).toList - } -} - -object Test extends Properties("RedBlack") { - include(TestInsert) - include(TestModify) - include(TestDelete) - include(TestRange) -} - diff --git a/test/files/scalacheck/redblacktree.scala b/test/files/scalacheck/redblacktree.scala index bc7f92aa1b..871444a4b8 100644 --- a/test/files/scalacheck/redblacktree.scala +++ b/test/files/scalacheck/redblacktree.scala @@ -205,22 +205,22 @@ package scala.collection.immutable.redblacktree { filteredTree == keysIterator(newTree).toList } } - + object TestDrop extends RedBlackTreeTest with RedBlackTreeInvariants { import RB._ - + override type ModifyParm = Int override def genParm(tree: Tree[String, Int]): Gen[ModifyParm] = choose(0, iterator(tree).size) override def modify(tree: Tree[String, Int], parm: ModifyParm): Tree[String, Int] = drop(tree, parm) - + property("drop") = forAll(genInput) { case (tree, parm, newTree) => iterator(tree).drop(parm).toList == iterator(newTree).toList } } - + object TestTake extends RedBlackTreeTest with RedBlackTreeInvariants { import RB._ - + override type ModifyParm = Int override def genParm(tree: Tree[String, Int]): Gen[ModifyParm] = choose(0, iterator(tree).size) override def modify(tree: Tree[String, Int], parm: ModifyParm): Tree[String, Int] = take(tree, parm) @@ -229,7 +229,7 @@ package scala.collection.immutable.redblacktree { iterator(tree).take(parm).toList == iterator(newTree).toList } } - + object TestSlice extends RedBlackTreeTest with RedBlackTreeInvariants { import RB._ @@ -239,7 +239,7 @@ package scala.collection.immutable.redblacktree { to <- choose(from, iterator(tree).size) } yield (from, to) override def modify(tree: Tree[String, Int], parm: ModifyParm): Tree[String, Int] = slice(tree, parm._1, parm._2) - + property("slice") = forAll(genInput) { case (tree, parm, newTree) => iterator(tree).slice(parm._1, parm._2).toList == iterator(newTree).toList } diff --git a/test/files/scalacheck/si4147.scala b/test/files/scalacheck/si4147.scala index 1453440ef1..05507b1b18 100644 --- a/test/files/scalacheck/si4147.scala +++ b/test/files/scalacheck/si4147.scala @@ -1,4 +1,4 @@ -import org.scalacheck.Prop.forAll +import org.scalacheck.Prop.{forAll, throws} import org.scalacheck.Properties import org.scalacheck.ConsoleReporter.testStatsEx import org.scalacheck.Gen @@ -64,4 +64,7 @@ object Test extends Properties("Mutable TreeSet") { view.filter(_ < 50) == Set[Int]() && view.filter(_ >= 150) == Set[Int]() } } + + property("ordering must not be null") = + throws(mutable.TreeSet.empty[Int](null), classOf[NullPointerException]) } diff --git a/test/files/scalacheck/substringTests.scala b/test/files/scalacheck/substringTests.scala index a48356e1fa..76260b9dd2 100644 --- a/test/files/scalacheck/substringTests.scala +++ b/test/files/scalacheck/substringTests.scala @@ -6,11 +6,11 @@ object Test extends Properties("String") { property("endsWith") = Prop.forAll((a: String, b: String) => (a+b).endsWith(b)) - property("concat") = Prop.forAll((a: String, b: String) => + property("concat") = Prop.forAll((a: String, b: String) => (a+b).length >= a.length && (a+b).length >= b.length ) - property("substring") = Prop.forAll((a: String, b: String) => + property("substring") = Prop.forAll((a: String, b: String) => (a+b).substring(a.length) == b ) diff --git a/test/files/scalacheck/treeset.scala b/test/files/scalacheck/treeset.scala index 98e38c8219..7fca3ed5e4 100644 --- a/test/files/scalacheck/treeset.scala +++ b/test/files/scalacheck/treeset.scala @@ -149,4 +149,7 @@ object Test extends Properties("TreeSet") { val result = subject.foldLeft(subject)((acc, elt) => acc - elt) result.isEmpty } + + property("ordering must not be null") = + throws(TreeSet.empty[Int](null), classOf[NullPointerException]) } diff --git a/test/files/scalap/abstractClass/result.test b/test/files/scalap/abstractClass.check index ef1daac23d..95e80ac3c9 100644 --- a/test/files/scalap/abstractClass/result.test +++ b/test/files/scalap/abstractClass.check @@ -1,4 +1,4 @@ abstract class AbstractClass extends scala.AnyRef { def this() = { /* compiled code */ } - def foo : scala.Predef.String + def foo: scala.Predef.String } diff --git a/test/files/scalap/abstractClass/A.scala b/test/files/scalap/abstractClass.scala index 19a528d5a1..19a528d5a1 100644 --- a/test/files/scalap/abstractClass/A.scala +++ b/test/files/scalap/abstractClass.scala diff --git a/test/files/scalap/abstractMethod.check b/test/files/scalap/abstractMethod.check new file mode 100644 index 0000000000..0d0b1b7421 --- /dev/null +++ b/test/files/scalap/abstractMethod.check @@ -0,0 +1,5 @@ +trait AbstractMethod extends scala.AnyRef { + def $init$(): scala.Unit = { /* compiled code */ } + def arity: scala.Int + def isCool: scala.Boolean = { /* compiled code */ } +} diff --git a/test/files/scalap/abstractMethod/A.scala b/test/files/scalap/abstractMethod.scala index 4bedb377b3..4bedb377b3 100644 --- a/test/files/scalap/abstractMethod/A.scala +++ b/test/files/scalap/abstractMethod.scala diff --git a/test/files/scalap/abstractMethod/result.test b/test/files/scalap/abstractMethod/result.test deleted file mode 100644 index 40fa02d408..0000000000 --- a/test/files/scalap/abstractMethod/result.test +++ /dev/null @@ -1,5 +0,0 @@ -trait AbstractMethod extends scala.AnyRef { - def $init$() : scala.Unit = { /* compiled code */ } - def arity : scala.Int - def isCool : scala.Boolean = { /* compiled code */ } -} diff --git a/test/files/scalap/caseClass.check b/test/files/scalap/caseClass.check new file mode 100644 index 0000000000..51ad90d9b2 --- /dev/null +++ b/test/files/scalap/caseClass.check @@ -0,0 +1,20 @@ +case class CaseClass[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String) extends scala.AnyRef with scala.Product with scala.Serializable { + val i: A = { /* compiled code */ } + val s: scala.Predef.String = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } + def copy[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String): CaseClass[A] = { /* compiled code */ } + override def productPrefix: java.lang.String = { /* compiled code */ } + def productArity: scala.Int = { /* compiled code */ } + def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ } + override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ } + def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ } + override def hashCode(): scala.Int = { /* compiled code */ } + override def toString(): java.lang.String = { /* compiled code */ } + override def equals(x$1: scala.Any): scala.Boolean = { /* compiled code */ } +} +object CaseClass extends scala.AnyRef with scala.Serializable { + def this() = { /* compiled code */ } + final override def toString(): java.lang.String = { /* compiled code */ } + def apply[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String): CaseClass[A] = { /* compiled code */ } + def unapply[A <: scala.Seq[scala.Int]](x$0: CaseClass[A]): scala.Option[scala.Tuple2[A, scala.Predef.String]] = { /* compiled code */ } +} diff --git a/test/files/scalap/caseClass/A.scala b/test/files/scalap/caseClass.scala index 95f9984519..be86714898 100644 --- a/test/files/scalap/caseClass/A.scala +++ b/test/files/scalap/caseClass.scala @@ -1,3 +1,3 @@ case class CaseClass[A <: Seq[Int]](i: A, s: String) { - def foo = 239 + def foo = 239 } diff --git a/test/files/scalap/caseClass/result.test b/test/files/scalap/caseClass/result.test deleted file mode 100644 index 7d7aa4fd8f..0000000000 --- a/test/files/scalap/caseClass/result.test +++ /dev/null @@ -1,20 +0,0 @@ -case class CaseClass[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends scala.AnyRef with scala.Product with scala.Serializable { - val i : A = { /* compiled code */ } - val s : scala.Predef.String = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } - def copy[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) : CaseClass[A] = { /* compiled code */ } - override def productPrefix : java.lang.String = { /* compiled code */ } - def productArity : scala.Int = { /* compiled code */ } - def productElement(x$1 : scala.Int) : scala.Any = { /* compiled code */ } - override def productIterator : scala.collection.Iterator[scala.Any] = { /* compiled code */ } - def canEqual(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } - override def hashCode() : scala.Int = { /* compiled code */ } - override def toString() : java.lang.String = { /* compiled code */ } - override def equals(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } -} -object CaseClass extends scala.AnyRef with scala.Serializable { - def this() = { /* compiled code */ } - final override def toString() : java.lang.String = { /* compiled code */ } - def apply[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) : CaseClass[A] = { /* compiled code */ } - def unapply[A <: scala.Seq[scala.Int]](x$0 : CaseClass[A]) : scala.Option[scala.Tuple2[A, scala.Predef.String]] = { /* compiled code */ } -} diff --git a/test/files/scalap/caseObject.check b/test/files/scalap/caseObject.check new file mode 100644 index 0000000000..a342e5ff1a --- /dev/null +++ b/test/files/scalap/caseObject.check @@ -0,0 +1,10 @@ +case object CaseObject extends scala.AnyRef with scala.Product with scala.Serializable { + def bar: scala.Int = { /* compiled code */ } + override def productPrefix: java.lang.String = { /* compiled code */ } + def productArity: scala.Int = { /* compiled code */ } + def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ } + override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ } + def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ } + override def hashCode(): scala.Int = { /* compiled code */ } + override def toString(): java.lang.String = { /* compiled code */ } +} diff --git a/test/files/scalap/caseObject/A.scala b/test/files/scalap/caseObject.scala index 6a3ff10d75..809341ade9 100644 --- a/test/files/scalap/caseObject/A.scala +++ b/test/files/scalap/caseObject.scala @@ -1,3 +1,3 @@ case object CaseObject { - def bar = 239 + def bar = 239 } diff --git a/test/files/scalap/caseObject/result.test b/test/files/scalap/caseObject/result.test deleted file mode 100644 index 867a4b2162..0000000000 --- a/test/files/scalap/caseObject/result.test +++ /dev/null @@ -1,10 +0,0 @@ -case object CaseObject extends scala.AnyRef with scala.Product with scala.Serializable { - def bar : scala.Int = { /* compiled code */ } - override def productPrefix : java.lang.String = { /* compiled code */ } - def productArity : scala.Int = { /* compiled code */ } - def productElement(x$1 : scala.Int) : scala.Any = { /* compiled code */ } - override def productIterator : scala.collection.Iterator[scala.Any] = { /* compiled code */ } - def canEqual(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } - override def hashCode() : scala.Int = { /* compiled code */ } - override def toString() : java.lang.String = { /* compiled code */ } -} diff --git a/test/files/scalap/cbnParam.check b/test/files/scalap/cbnParam.check new file mode 100644 index 0000000000..abe01297b9 --- /dev/null +++ b/test/files/scalap/cbnParam.check @@ -0,0 +1,3 @@ +class CbnParam extends scala.AnyRef { + def this(s: => scala.Predef.String) = { /* compiled code */ } +} diff --git a/test/files/scalap/cbnParam.scala b/test/files/scalap/cbnParam.scala new file mode 100644 index 0000000000..978a718032 --- /dev/null +++ b/test/files/scalap/cbnParam.scala @@ -0,0 +1 @@ +class CbnParam(s: => String) diff --git a/test/files/scalap/cbnParam/A.scala b/test/files/scalap/cbnParam/A.scala deleted file mode 100644 index 2f366df64a..0000000000 --- a/test/files/scalap/cbnParam/A.scala +++ /dev/null @@ -1 +0,0 @@ -class CbnParam(s: => String) diff --git a/test/files/scalap/cbnParam/result.test b/test/files/scalap/cbnParam/result.test deleted file mode 100644 index 52ecb6ae66..0000000000 --- a/test/files/scalap/cbnParam/result.test +++ /dev/null @@ -1,3 +0,0 @@ -class CbnParam extends scala.AnyRef { - def this(s : => scala.Predef.String) = { /* compiled code */ } -} diff --git a/test/files/scalap/classPrivate.check b/test/files/scalap/classPrivate.check new file mode 100644 index 0000000000..cf0ffe0cb2 --- /dev/null +++ b/test/files/scalap/classPrivate.check @@ -0,0 +1,10 @@ +class ClassPrivate extends scala.AnyRef { + def this() = { /* compiled code */ } + def baz: scala.Int = { /* compiled code */ } + class Outer extends scala.AnyRef { + def this() = { /* compiled code */ } + private[ClassPrivate] def qux: scala.Int = { /* compiled code */ } + } + protected def quux: scala.Int = { /* compiled code */ } + private[ClassPrivate] def bar: scala.Int = { /* compiled code */ } +} diff --git a/test/files/scalap/classPrivate/A.scala b/test/files/scalap/classPrivate.scala index 9f1bd34a6a..9f1bd34a6a 100644 --- a/test/files/scalap/classPrivate/A.scala +++ b/test/files/scalap/classPrivate.scala diff --git a/test/files/scalap/classPrivate/result.test b/test/files/scalap/classPrivate/result.test deleted file mode 100644 index ab2d40cdaf..0000000000 --- a/test/files/scalap/classPrivate/result.test +++ /dev/null @@ -1,10 +0,0 @@ -class ClassPrivate extends scala.AnyRef { - def this() = { /* compiled code */ } - def baz : scala.Int = { /* compiled code */ } - class Outer extends scala.AnyRef { - def this() = { /* compiled code */ } - private[ClassPrivate] def qux : scala.Int = { /* compiled code */ } - } - protected def quux : scala.Int = { /* compiled code */ } - private[ClassPrivate] def bar : scala.Int = { /* compiled code */ } -} diff --git a/test/files/scalap/classWithExistential.check b/test/files/scalap/classWithExistential.check new file mode 100644 index 0000000000..7df6bfb765 --- /dev/null +++ b/test/files/scalap/classWithExistential.check @@ -0,0 +1,4 @@ +class ClassWithExistential extends scala.AnyRef { + def this() = { /* compiled code */ } + def foo[A, B]: scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ } +} diff --git a/test/files/scalap/classWithExistential/A.scala b/test/files/scalap/classWithExistential.scala index 4a5213f963..4a5213f963 100644 --- a/test/files/scalap/classWithExistential/A.scala +++ b/test/files/scalap/classWithExistential.scala diff --git a/test/files/scalap/classWithExistential/result.test b/test/files/scalap/classWithExistential/result.test deleted file mode 100644 index caee3fd6de..0000000000 --- a/test/files/scalap/classWithExistential/result.test +++ /dev/null @@ -1,4 +0,0 @@ -class ClassWithExistential extends scala.AnyRef { - def this() = { /* compiled code */ } - def foo[A, B] : scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ } -} diff --git a/test/files/scalap/classWithSelfAnnotation.check b/test/files/scalap/classWithSelfAnnotation.check new file mode 100644 index 0000000000..7a1c206e33 --- /dev/null +++ b/test/files/scalap/classWithSelfAnnotation.check @@ -0,0 +1,5 @@ +class ClassWithSelfAnnotation extends scala.AnyRef { + this: ClassWithSelfAnnotation with java.lang.CharSequence => + def this() = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } +} diff --git a/test/files/scalap/classWithSelfAnnotation/A.scala b/test/files/scalap/classWithSelfAnnotation.scala index 9e0398622a..9e0398622a 100644 --- a/test/files/scalap/classWithSelfAnnotation/A.scala +++ b/test/files/scalap/classWithSelfAnnotation.scala diff --git a/test/files/scalap/classWithSelfAnnotation/result.test b/test/files/scalap/classWithSelfAnnotation/result.test deleted file mode 100644 index 82bbd9e8df..0000000000 --- a/test/files/scalap/classWithSelfAnnotation/result.test +++ /dev/null @@ -1,5 +0,0 @@ -class ClassWithSelfAnnotation extends scala.AnyRef { - this : ClassWithSelfAnnotation with java.lang.CharSequence => - def this() = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } -} diff --git a/test/files/scalap/covariantParam/result.test b/test/files/scalap/covariantParam.check index f7a3c98966..85b1400fce 100644 --- a/test/files/scalap/covariantParam/result.test +++ b/test/files/scalap/covariantParam.check @@ -1,4 +1,4 @@ class CovariantParam[+A] extends scala.AnyRef { def this() = { /* compiled code */ } - def foo[A](a : A) : scala.Int = { /* compiled code */ } + def foo[A](a: A): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/covariantParam/A.scala b/test/files/scalap/covariantParam.scala index 5b2c24d6fa..5b2c24d6fa 100644 --- a/test/files/scalap/covariantParam/A.scala +++ b/test/files/scalap/covariantParam.scala diff --git a/test/files/scalap/defaultParameter/result.test b/test/files/scalap/defaultParameter.check index 0c775ea7b5..4e244d18f1 100644 --- a/test/files/scalap/defaultParameter/result.test +++ b/test/files/scalap/defaultParameter.check @@ -1,3 +1,3 @@ trait DefaultParameter extends scala.AnyRef { - def foo(s : scala.Predef.String) : scala.Unit + def foo(s: scala.Predef.String): scala.Unit } diff --git a/test/files/scalap/defaultParameter/A.scala b/test/files/scalap/defaultParameter.scala index d3514952f4..d3514952f4 100644 --- a/test/files/scalap/defaultParameter/A.scala +++ b/test/files/scalap/defaultParameter.scala diff --git a/test/files/scalap/implicitParam.check b/test/files/scalap/implicitParam.check new file mode 100644 index 0000000000..46e995652e --- /dev/null +++ b/test/files/scalap/implicitParam.check @@ -0,0 +1,4 @@ +class ImplicitParam extends scala.AnyRef { + def this() = { /* compiled code */ } + def foo(i: scala.Int)(implicit f: scala.Float, d: scala.Double): scala.Int = { /* compiled code */ } +} diff --git a/test/files/scalap/implicitParam/A.scala b/test/files/scalap/implicitParam.scala index 80657218d9..80657218d9 100644 --- a/test/files/scalap/implicitParam/A.scala +++ b/test/files/scalap/implicitParam.scala diff --git a/test/files/scalap/implicitParam/result.test b/test/files/scalap/implicitParam/result.test deleted file mode 100644 index a2cfd6092d..0000000000 --- a/test/files/scalap/implicitParam/result.test +++ /dev/null @@ -1,4 +0,0 @@ -class ImplicitParam extends scala.AnyRef { - def this() = { /* compiled code */ } - def foo(i : scala.Int)(implicit f : scala.Float, d : scala.Double) : scala.Int = { /* compiled code */ } -} diff --git a/test/files/scalap/packageObject/result.test b/test/files/scalap/packageObject.check index 5732d92958..d1d0bbf122 100644 --- a/test/files/scalap/packageObject/result.test +++ b/test/files/scalap/packageObject.check @@ -1,5 +1,5 @@ package object PackageObject extends scala.AnyRef { def this() = { /* compiled code */ } type A = scala.Predef.String - def foo(i : scala.Int) : scala.Int = { /* compiled code */ } + def foo(i: scala.Int): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/packageObject/A.scala b/test/files/scalap/packageObject.scala index 7e429c9935..7e429c9935 100644 --- a/test/files/scalap/packageObject/A.scala +++ b/test/files/scalap/packageObject.scala diff --git a/test/files/scalap/paramClauses.check b/test/files/scalap/paramClauses.check new file mode 100644 index 0000000000..11c5e4bbd6 --- /dev/null +++ b/test/files/scalap/paramClauses.check @@ -0,0 +1,4 @@ +class ParamClauses extends scala.AnyRef { + def this() = { /* compiled code */ } + def foo(i: scala.Int)(s: scala.Predef.String)(t: scala.Double): scala.Int = { /* compiled code */ } +} diff --git a/test/files/scalap/paramClauses/A.scala b/test/files/scalap/paramClauses.scala index f9d1917402..f9d1917402 100644 --- a/test/files/scalap/paramClauses/A.scala +++ b/test/files/scalap/paramClauses.scala diff --git a/test/files/scalap/paramClauses/result.test b/test/files/scalap/paramClauses/result.test deleted file mode 100644 index 3a141e8faf..0000000000 --- a/test/files/scalap/paramClauses/result.test +++ /dev/null @@ -1,4 +0,0 @@ -class ParamClauses extends scala.AnyRef { - def this() = { /* compiled code */ } - def foo(i : scala.Int)(s : scala.Predef.String)(t : scala.Double) : scala.Int = { /* compiled code */ } -} diff --git a/test/files/scalap/paramNames.check b/test/files/scalap/paramNames.check new file mode 100644 index 0000000000..836b3d0e7b --- /dev/null +++ b/test/files/scalap/paramNames.check @@ -0,0 +1,4 @@ +class ParamNames extends scala.AnyRef { + def this() = { /* compiled code */ } + def foo(s: => scala.Seq[scala.Int], s2: => scala.Seq[scala.Any]): scala.Unit = { /* compiled code */ } +} diff --git a/test/files/scalap/paramNames/A.scala b/test/files/scalap/paramNames.scala index 7ba9ff0feb..7ba9ff0feb 100644 --- a/test/files/scalap/paramNames/A.scala +++ b/test/files/scalap/paramNames.scala diff --git a/test/files/scalap/paramNames/result.test b/test/files/scalap/paramNames/result.test deleted file mode 100644 index 85e37f858d..0000000000 --- a/test/files/scalap/paramNames/result.test +++ /dev/null @@ -1,4 +0,0 @@ -class ParamNames extends scala.AnyRef { - def this() = { /* compiled code */ } - def foo(s : => scala.Seq[scala.Int], s2 : => scala.Seq[scala.Any]) : scala.Unit = { /* compiled code */ } -} diff --git a/test/files/scalap/sequenceParam.check b/test/files/scalap/sequenceParam.check new file mode 100644 index 0000000000..f7bf83f6b2 --- /dev/null +++ b/test/files/scalap/sequenceParam.check @@ -0,0 +1,3 @@ +class SequenceParam extends scala.AnyRef { + def this(s: scala.Predef.String, i: scala.Int*) = { /* compiled code */ } +} diff --git a/test/files/scalap/sequenceParam/A.scala b/test/files/scalap/sequenceParam.scala index 86e13340b9..86e13340b9 100644 --- a/test/files/scalap/sequenceParam/A.scala +++ b/test/files/scalap/sequenceParam.scala diff --git a/test/files/scalap/sequenceParam/result.test b/test/files/scalap/sequenceParam/result.test deleted file mode 100644 index 142d92fea3..0000000000 --- a/test/files/scalap/sequenceParam/result.test +++ /dev/null @@ -1,3 +0,0 @@ -class SequenceParam extends scala.AnyRef { - def this(s : scala.Predef.String, i : scala.Int*) = { /* compiled code */ } -} diff --git a/test/files/scalap/simpleClass/result.test b/test/files/scalap/simpleClass.check index 4fdf25d1cf..4675cbf665 100644 --- a/test/files/scalap/simpleClass/result.test +++ b/test/files/scalap/simpleClass.check @@ -1,4 +1,4 @@ class SimpleClass extends scala.AnyRef { def this() = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/simpleClass/A.scala b/test/files/scalap/simpleClass.scala index fa82e62680..fa82e62680 100644 --- a/test/files/scalap/simpleClass/A.scala +++ b/test/files/scalap/simpleClass.scala diff --git a/test/files/scalap/traitObject.check b/test/files/scalap/traitObject.check new file mode 100644 index 0000000000..f7ae4fd2f4 --- /dev/null +++ b/test/files/scalap/traitObject.check @@ -0,0 +1,8 @@ +trait TraitObject extends scala.AnyRef { + def $init$(): scala.Unit = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } +} +object TraitObject extends scala.AnyRef { + def this() = { /* compiled code */ } + def bar: scala.Int = { /* compiled code */ } +} diff --git a/test/files/scalap/traitObject/A.scala b/test/files/scalap/traitObject.scala index d5f43181c1..d5f43181c1 100644 --- a/test/files/scalap/traitObject/A.scala +++ b/test/files/scalap/traitObject.scala diff --git a/test/files/scalap/traitObject/result.test b/test/files/scalap/traitObject/result.test deleted file mode 100644 index 104ba14f1a..0000000000 --- a/test/files/scalap/traitObject/result.test +++ /dev/null @@ -1,8 +0,0 @@ -trait TraitObject extends scala.AnyRef { - def $init$() : scala.Unit = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } -} -object TraitObject extends scala.AnyRef { - def this() = { /* compiled code */ } - def bar : scala.Int = { /* compiled code */ } -} diff --git a/test/files/scalap/typeAnnotations/result.test b/test/files/scalap/typeAnnotations.check index 407b0235c6..cba69f8e41 100644 --- a/test/files/scalap/typeAnnotations/result.test +++ b/test/files/scalap/typeAnnotations.check @@ -1,8 +1,8 @@ abstract class TypeAnnotations[@scala.specialized R] extends scala.AnyRef { def this() = { /* compiled code */ } @scala.specialized - val x : scala.Int = { /* compiled code */ } + val x: scala.Int = { /* compiled code */ } @scala.specialized type T - def compose[@scala.specialized A](x : A, y : R) : A = { /* compiled code */ } + def compose[@scala.specialized A](x: A, y: R): A = { /* compiled code */ } } diff --git a/test/files/scalap/typeAnnotations/A.scala b/test/files/scalap/typeAnnotations.scala index ff2445edc9..ff2445edc9 100644 --- a/test/files/scalap/typeAnnotations/A.scala +++ b/test/files/scalap/typeAnnotations.scala diff --git a/test/files/scalap/valAndVar.check b/test/files/scalap/valAndVar.check new file mode 100644 index 0000000000..98eae5192d --- /dev/null +++ b/test/files/scalap/valAndVar.check @@ -0,0 +1,5 @@ +class ValAndVar extends scala.AnyRef { + def this() = { /* compiled code */ } + val foo: java.lang.String = { /* compiled code */ } + var bar: scala.Int = { /* compiled code */ } +} diff --git a/test/files/scalap/valAndVar/A.scala b/test/files/scalap/valAndVar.scala index 2d89348401..2d89348401 100644 --- a/test/files/scalap/valAndVar/A.scala +++ b/test/files/scalap/valAndVar.scala diff --git a/test/files/scalap/valAndVar/result.test b/test/files/scalap/valAndVar/result.test deleted file mode 100644 index e940da9801..0000000000 --- a/test/files/scalap/valAndVar/result.test +++ /dev/null @@ -1,5 +0,0 @@ -class ValAndVar extends scala.AnyRef { - def this() = { /* compiled code */ } - val foo : java.lang.String = { /* compiled code */ } - var bar : scala.Int = { /* compiled code */ } -} diff --git a/test/files/scalap/wildcardType.check b/test/files/scalap/wildcardType.check new file mode 100644 index 0000000000..6ea696647e --- /dev/null +++ b/test/files/scalap/wildcardType.check @@ -0,0 +1,3 @@ +class WildcardType extends scala.AnyRef { + def this(f: scala.Function1[scala.Int, _]) = { /* compiled code */ } +} diff --git a/test/files/scalap/wildcardType/A.scala b/test/files/scalap/wildcardType.scala index 4bb0d14de5..4bb0d14de5 100644 --- a/test/files/scalap/wildcardType/A.scala +++ b/test/files/scalap/wildcardType.scala diff --git a/test/files/scalap/wildcardType/result.test b/test/files/scalap/wildcardType/result.test deleted file mode 100644 index e43261db32..0000000000 --- a/test/files/scalap/wildcardType/result.test +++ /dev/null @@ -1,3 +0,0 @@ -class WildcardType extends scala.AnyRef { - def this(f : scala.Function1[scala.Int, _]) = { /* compiled code */ } -} diff --git a/test/files/specialized/SI-7343.scala b/test/files/specialized/SI-7343.scala index 5ee683064c..8d14a2c1c5 100644 --- a/test/files/specialized/SI-7343.scala +++ b/test/files/specialized/SI-7343.scala @@ -1,4 +1,4 @@ -class Parent[@specialized(Int) T] +class Parent[@specialized(Int) T] object Test extends App { diff --git a/test/files/specialized/SI-7344.scala b/test/files/specialized/SI-7344.scala index 1040460bd1..624adb6bbb 100644 --- a/test/files/specialized/SI-7344.scala +++ b/test/files/specialized/SI-7344.scala @@ -1,13 +1,13 @@ /* Test for SI-7344, where specialized methods inside the bodies of other * methods are not specialized, although they might as well be. The name - * for the specialized method should not be different depending on the + * for the specialized method should not be different depending on the * outside method/class' specialization. */ class Test[@specialized(Int, Double) X](val x: X) { def checkSpecialization[Y](@specialized(Int, Double) y: Y): X = { - // checking the specialization using the method name, which we can + // checking the specialization using the method name, which we can // extract from an exception's stack trace. We can match just the // prefix, since the compiler will add a suffix to the method name // during lambdalift, when it lifts the local methods outside. @@ -33,7 +33,7 @@ object Test extends App { val t2 = new Test(123) val t3 = new Test(1.3) - // we want specialization to rewire these, + // we want specialization to rewire these, // that's why they're not in a for loop: t1.checkSpecialization("x") @@ -49,5 +49,5 @@ object Test extends App { // t2.checkSpecialization(1.3) // t3.checkSpecialization("x") // t3.checkSpecialization(123) - // t3.checkSpecialization(1.3) + // t3.checkSpecialization(1.3) } diff --git a/test/files/specialized/arrays-traits.scala b/test/files/specialized/arrays-traits.scala index 34a1c37a01..9183d7a190 100644 --- a/test/files/specialized/arrays-traits.scala +++ b/test/files/specialized/arrays-traits.scala @@ -23,7 +23,7 @@ object Test { (new BaseS(new Array[String](1)): SuperS[String]).bar(new Array[String](1)) println(arrayApplyCount) println(arrayUpdateCount) - + (new BaseG(new Array[String](1)): SuperG[String]).foo println(arrayApplyCount) (new BaseG(new Array[String](1)): SuperG[String]).bar(new Array[String](1)) diff --git a/test/files/specialized/arrays.scala b/test/files/specialized/arrays.scala index c946a8fc55..505f482486 100644 --- a/test/files/specialized/arrays.scala +++ b/test/files/specialized/arrays.scala @@ -15,23 +15,23 @@ class Spec[@specialized(AnyRef) T](a: Array[T]) { object Test { - + def main(args: Array[String]) { val len = 50 - + testSpec(new Array[String](len)) println(arrayApplyCount) - + (new Spec(new Array[String](len)))() println(arrayApplyCount) - + testGeneric(new Array[String](len)) println(arrayApplyCount) - + (new Generic(new Array[String](len)))() println(arrayApplyCount) } - + def testGeneric[T](a: Array[T]) = { var i = 0 var sum = 0 @@ -41,7 +41,7 @@ object Test { } sum } - + def testSpec[@specialized(AnyRef) T](a: Array[T]) = { var i = 0 var sum = 0 @@ -51,5 +51,5 @@ object Test { } sum } - + } diff --git a/test/files/specialized/fft.scala b/test/files/specialized/fft.scala index 62a6a2abb9..76029832a9 100644 --- a/test/files/specialized/fft.scala +++ b/test/files/specialized/fft.scala @@ -1,13 +1,13 @@ /* * http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/dft/ - Modification of Paul Bourkes FFT code by Peter Cusack + Modification of Paul Bourkes FFT code by Peter Cusack to utilise the Microsoft complex type. - This computes an in-place complex-to-complex FFT + This computes an in-place complex-to-complex FFT x and y are the real and imaginary arrays of 2^m points. dir = 1 gives forward transform - dir = -1 gives reverse transform + dir = -1 gives reverse transform */ import Math.{sqrt, pow} @@ -24,19 +24,19 @@ object Test { x(j) = tmp } - def times(x: Complex, y: Complex): Complex = + def times(x: Complex, y: Complex): Complex = (x._1 * y._1 - x._2 * y._2, x._1 * y._2 + x._2 * y._1) - + def div(x: Complex, y: Complex): Complex = { val num = pow(y._1, 2) + pow(y._2, 2) ((x._1 * y._1 + x._2 * y._2)/num, (x._2 * y._1 - x._1 * y._2)/num) } - def div(x: Complex, y: Long) = + def div(x: Complex, y: Long) = (x._1 / y, x._2 / y) - def add(x: Complex, y: Complex) = + def add(x: Complex, y: Complex) = (x._1 + y._1, x._2 + y._2) def minus(x: Complex, y: Complex) = @@ -49,8 +49,8 @@ object Test { /*Calculate the number of points */ n = 1 - for (i <- 0l until m) - n <<= 1 + for (i <- 0l until m) + n <<= 1 /* Do the bit reversal */ i2 = n >> 1 @@ -86,7 +86,7 @@ object Test { for (i <- j.until(n, l2)) { i1 = i + l1; t1 = times(u, x(i1.toInt)) - x(i1.toInt) = minus(x(i.toInt), t1) + x(i1.toInt) = minus(x(i.toInt), t1) x(i.toInt) = add(x(i.toInt), t1) } @@ -97,7 +97,7 @@ object Test { c = (c._1, sqrt( (1.0 - c._1) / 2.0 )) // if (dir == 1) // c.imag(-c.imag()); - if (dir == 1) + if (dir == 1) c = (c._1, -c._2) // c.real(sqrt((1.0 + c.real()) / 2.0)); @@ -107,8 +107,8 @@ object Test { /* Scaling for forward transform */ if (dir == 1) { for (i <- 0l until n) - x(i.toInt) = div(x(i.toInt), n) - } + x(i.toInt) = div(x(i.toInt), n) + } } def run() { diff --git a/test/files/specialized/spec-ame.scala b/test/files/specialized/spec-ame.scala index 129fb9f447..017d5dfa37 100644 --- a/test/files/specialized/spec-ame.scala +++ b/test/files/specialized/spec-ame.scala @@ -1,13 +1,13 @@ // ticket #3432 object Test { trait B[@specialized(Int) T] { - def value: T + def value: T } - class A[@specialized(Int) T](x: T) { - def foo: B[T] = new B[T] { - def value = x - } + class A[@specialized(Int) T](x: T) { + def foo: B[T] = new B[T] { + def value = x + } } def main(args: Array[String]) { diff --git a/test/files/specialized/spec-hlists.scala b/test/files/specialized/spec-hlists.scala index 8c4ac8f610..82e3bf74c5 100644 --- a/test/files/specialized/spec-hlists.scala +++ b/test/files/specialized/spec-hlists.scala @@ -4,7 +4,7 @@ sealed trait HList { type Self <: HList - + type |: [E] = HCons[E, Self] final def |: [@specialized E](elem: E): |: [E] = new HCons[E, Self](elem, this.asInstanceOf[Self]) @@ -23,7 +23,7 @@ final object HNil extends HList { object Test extends App { val l1 = new HCons(42, "foo" |: HNil) println(l1.getClass) - + val l2 = 42 |: "abc" |: HNil println(l2.getClass) } diff --git a/test/files/specialized/spec-init.scala b/test/files/specialized/spec-init.scala index 5f27062ed2..94cd0ee82b 100644 --- a/test/files/specialized/spec-init.scala +++ b/test/files/specialized/spec-init.scala @@ -36,7 +36,7 @@ object Test { (new TouchGlobal(new Object)) Global.msg = "ok" // reset the value (new TouchGlobal(42)) - + println(runtime.BoxesRunTime.integerBoxCount) } } diff --git a/test/files/specialized/spec-matrix-old.scala b/test/files/specialized/spec-matrix-old.scala index 98735c8c03..4e3d3f1377 100644 --- a/test/files/specialized/spec-matrix-old.scala +++ b/test/files/specialized/spec-matrix-old.scala @@ -1,9 +1,10 @@ /** Test matrix multiplication with specialization. */ +@deprecated("Suppress warnings", since="2.11") class Matrix[@specialized A: ClassManifest](val rows: Int, val cols: Int) { private val arr: Array[Array[A]] = Array.ofDim[A](rows, cols) - + def apply(i: Int, j: Int): A = { if (i < 0 || i >= rows || j < 0 || j >= cols) throw new NoSuchElementException("Indexes out of bounds: " + (i, j)) @@ -25,11 +26,12 @@ class Matrix[@specialized A: ClassManifest](val rows: Int, val cols: Int) { } } +@deprecated("Suppress warnings", since="2.11") object Test { def main(args: Array[String]) { val m = randomMatrix(200, 100) val n = randomMatrix(100, 200) - + val p = mult(m, n) println(p(0, 0)) println("Boxed doubles: " + runtime.BoxesRunTime.doubleBoxCount) @@ -38,7 +40,7 @@ object Test { def randomMatrix(n: Int, m: Int) = { val r = new util.Random(10) - val x = new Matrix[Double](n, m) + val x = new Matrix[Double](n, m) for (i <- 0 until n; j <- 0 until m) x(i, j) = (r.nextInt % 1000).toDouble x @@ -46,7 +48,7 @@ object Test { def printMatrix[Double](m: Matrix[Double]) { for (i <- 0 until m.rows) { - for (j <- 0 until m.cols) + for (j <- 0 until m.cols) print("%5.3f ".format(m(i, j))) println } @@ -56,7 +58,7 @@ object Test { val p = new Matrix[T](m.rows, n.cols) import num._ - for (i <- 0 until m.rows) + for (i <- 0 until m.rows) for (j <- 0 until n.cols) { var sum = num.zero for (k <- 0 until n.rows) @@ -68,7 +70,7 @@ object Test { def mult(m: Matrix[Double], n: Matrix[Double]) = { val p = new Matrix[Double](m.rows, n.cols) - for (i <- 0 until m.rows) + for (i <- 0 until m.rows) for (j <- 0 until n.cols) { var sum = 0.0 for (k <- 0 until n.rows) diff --git a/test/files/specialized/spec-overrides.scala b/test/files/specialized/spec-overrides.scala index 90dd5a4e72..994dd9d245 100644 --- a/test/files/specialized/spec-overrides.scala +++ b/test/files/specialized/spec-overrides.scala @@ -17,6 +17,6 @@ object Test extends App { assert(d2.default == 1.0, d2.default) assert((d2: Base[_]).default == 1.0, (d2: Base[_]).default) assert((d2: D1).default == 1.0, (d2: D1).default) - + println(runtime.BoxesRunTime.integerBoxCount) } diff --git a/test/files/specialized/spec-patmatch.scala b/test/files/specialized/spec-patmatch.scala index 979d143fe2..909629455d 100644 --- a/test/files/specialized/spec-patmatch.scala +++ b/test/files/specialized/spec-patmatch.scala @@ -46,7 +46,7 @@ object Test { (new Foo).test(42.0) (new Foo).test(42.0f) (new Foo).test(new Object) - + println(runtime.BoxesRunTime.integerBoxCount) } diff --git a/test/files/specialized/spec-super.check b/test/files/specialized/spec-super.check index 4be83ca9e6..2f4d60018b 100644 --- a/test/files/specialized/spec-super.check +++ b/test/files/specialized/spec-super.check @@ -1,3 +1,6 @@ +spec-super.scala:18: warning: class Base must be a trait. Specialized version of class Extended will inherit generic Base[Int] +class Extended [@specialized(Int) T](t: T) extends Base[T](t) { + ^ s 1 -2
\ No newline at end of file +2 diff --git a/test/files/specialized/spec-super.scala b/test/files/specialized/spec-super.scala index a77f65b2cf..056a7712f0 100644 --- a/test/files/specialized/spec-super.scala +++ b/test/files/specialized/spec-super.scala @@ -7,13 +7,13 @@ object Test { val i = new Extended(1) println(i.foo) //infinite loop with StackOverflowError - + println(runtime.BoxesRunTime.integerBoxCount) } } -class Base[@specialized(Int) T](val t: T) { - def foo() :T = t +class Base[@specialized(Int) T](val t: T) { + def foo() :T = t } class Extended [@specialized(Int) T](t: T) extends Base[T](t) { override def foo() :T = super.foo diff --git a/test/files/specialized/spec-t3896.scala b/test/files/specialized/spec-t3896.scala index 605ed0df9d..3c849036c1 100644 --- a/test/files/specialized/spec-t3896.scala +++ b/test/files/specialized/spec-t3896.scala @@ -1,7 +1,7 @@ // see ticket #3896. Tests interaction between overloading, specialization and default params trait Atomic[@specialized(Boolean) T] { def x: T - + // crash depends on the overloading: if second method is "g", no crash. def f(fn: T => T): Boolean = f(fn(x)) def f[R](a: T, b: R = true) = b @@ -12,9 +12,9 @@ object Test { def main(args: Array[String]): Unit = { val e = new AtomicBoolean(false) val x = e.f( (a : Boolean) => !a ) // ok - println( e.f( (a : Boolean) => !a ) toString ) // ok + println( e.f( (a : Boolean) => !a ).toString ) // ok println( e.f( (a : Boolean) => !a) ) // compiler crash - + println(runtime.BoxesRunTime.integerBoxCount) } } diff --git a/test/files/specialized/tb3651.check b/test/files/specialized/tb3651.check index c227083464..8a3f686ef5 100644 --- a/test/files/specialized/tb3651.check +++ b/test/files/specialized/tb3651.check @@ -1 +1,4 @@ -0
\ No newline at end of file +tb3651.scala:8: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + lk.a + ^ +0 diff --git a/test/files/specialized/tc3651.check b/test/files/specialized/tc3651.check index c227083464..e2dbadf22c 100644 --- a/test/files/specialized/tc3651.check +++ b/test/files/specialized/tc3651.check @@ -1 +1,4 @@ -0
\ No newline at end of file +tc3651.scala:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + lk.a + ^ +0 diff --git a/test/files/specialized/td3651.check b/test/files/specialized/td3651.check index 9aea9e0ce5..1a709fd0a7 100644 --- a/test/files/specialized/td3651.check +++ b/test/files/specialized/td3651.check @@ -1,2 +1,8 @@ +td3651.scala:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + b.a + ^ +td3651.scala:16: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + der.a + ^ +0 0 -0
\ No newline at end of file diff --git a/test/files/specialized/td3651.scala b/test/files/specialized/td3651.scala index 19a4ab616c..117710b6dc 100644 --- a/test/files/specialized/td3651.scala +++ b/test/files/specialized/td3651.scala @@ -11,7 +11,7 @@ object Test { val b: Base[Double] = new Derived(10) b.a println(runtime.BoxesRunTime.doubleBoxCount) - + val der = new Derived(10) der.a println(runtime.BoxesRunTime.doubleBoxCount) diff --git a/test/flaky/pos/t2868.cmds b/test/flaky/pos/t2868.cmds deleted file mode 100644 index ed8124a9e0..0000000000 --- a/test/flaky/pos/t2868.cmds +++ /dev/null @@ -1,3 +0,0 @@ -javac Jann.java Nest.java -scalac pick_1.scala -scalac test_2.scala diff --git a/test/junit/scala/collection/TraversableOnceTest.scala b/test/junit/scala/collection/TraversableOnceTest.scala new file mode 100644 index 0000000000..56d8312336 --- /dev/null +++ b/test/junit/scala/collection/TraversableOnceTest.scala @@ -0,0 +1,70 @@ +package scala.collection + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import scala.util.Random + +@RunWith(classOf[JUnit4]) +/* Test for SI-7614 */ +class TraversableOnceTest { + val list = List.fill(1000)(scala.util.Random.nextInt(10000) - 5000) + + // Basic emptiness check + @Test + def checkEmpty { + def hasException(code: => Any): Boolean = try { + code + false + } catch { + case u: UnsupportedOperationException => true + case t: Throwable => false + } + assert(hasException({ List[Int]().maxBy(_ * 3) }), "maxBy: on empty list should throw UnsupportedOperationException.") + assert(hasException({ List[Int]().minBy(_ * 3) }), "minBy: on empty list should throw UnsupportedOperationException.") + } + + // Basic definition of minBy/maxBy. + @Test + def testCorrectness() = { + def f(x: Int) = -1 * x + val max = list.maxBy(f) + assert(list.forall(f(_) <= f(max)), "f(list.maxBy(f)) should ≥ f(x) where x is any element of list.") + + val min = list.minBy(f) + assert(list.forall(f(_) >= f(min)), "f(list.minBy(f)) should ≤ f(x) where x is any element of list.") + } + + // Ensure that it always returns the first match if more than one element have the same largest/smallest f(x). + // Note that this behavior is not explicitly stated before. + // To make it compatible with the previous implementation, I add this behavior to docs. + @Test + def testReturnTheFirstMatch() = { + val d = List(1, 2, 3, 4, 5, 6, 7, 8) + def f(x: Int) = x % 3; + assert(d.maxBy(f) == 2, "If multiple elements evaluted to the largest value, maxBy should return the first one.") + assert(d.minBy(f) == 3, "If multiple elements evaluted to the largest value, minBy should return the first one.") + } + + // Make sure it evaluates f no more than list.length times. + @Test + def testOnlyEvaluateOnce() = { + var evaluatedCountOfMaxBy = 0 + + val max = list.maxBy(x => { + evaluatedCountOfMaxBy += 1 + x * 10 + }) + assert(evaluatedCountOfMaxBy == list.length, s"maxBy: should evaluate f only ${list.length} times, but it evaluted $evaluatedCountOfMaxBy times.") + + var evaluatedCountOfMinBy = 0 + + val min = list.minBy(x => { + evaluatedCountOfMinBy += 1 + x * 10 + }) + assert(evaluatedCountOfMinBy == list.length, s"minBy: should evaluate f only ${list.length} times, but it evaluted $evaluatedCountOfMinBy times.") + } + +} diff --git a/test/junit/scala/reflect/internal/util/WeakHashSetTest.scala b/test/junit/scala/reflect/internal/util/WeakHashSetTest.scala new file mode 100644 index 0000000000..7e3b35c7d6 --- /dev/null +++ b/test/junit/scala/reflect/internal/util/WeakHashSetTest.scala @@ -0,0 +1,171 @@ +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 WeakHashSetTest { + + // a class guaranteed to provide hash collisions + case class Collider(x : String) extends Comparable[Collider] with Serializable { + override def hashCode = 0 + def compareTo(y : Collider) = this.x compareTo y.x + } + + // basic emptiness check + @Test + def checkEmpty { + val hs = new WeakHashSet[String]() + assert(hs.size == 0) + hs.diagnostics.fullyValidate + } + + // make sure += works + @Test + def checkPlusEquals { + val hs = new WeakHashSet[String]() + val elements = List("hello", "goodbye") + elements foreach (hs += _) + assert(hs.size == 2) + assert(hs contains "hello") + assert(hs contains "goodbye") + hs.diagnostics.fullyValidate + } + + // make sure += works when there are collisions + @Test + def checkPlusEqualsCollisions { + val hs = new WeakHashSet[Collider]() + val elements = List("hello", "goodbye") map Collider + elements foreach (hs += _) + assert(hs.size == 2) + assert(hs contains Collider("hello")) + assert(hs contains Collider("goodbye")) + hs.diagnostics.fullyValidate + } + + // add a large number of elements to force rehashing and then validate + @Test + def checkRehashing { + val size = 200 + val hs = new WeakHashSet[String]() + val elements = (0 until size).toList map ("a" + _) + elements foreach (hs += _) + elements foreach {i => assert(hs contains i)} + hs.diagnostics.fullyValidate + } + + // make sure rehashing works properly when the set is rehashed + @Test + def checkRehashCollisions { + val size = 200 + val hs = new WeakHashSet[Collider]() + val elements = (0 until size).toList map {x => Collider("a" + x)} + elements foreach (hs += _) + elements foreach {i => assert(hs contains i)} + hs.diagnostics.fullyValidate + } + + // test that unreferenced objects are removed + // not run in an automated environment because gc behavior can't be relied on + //@Test + def checkRemoveUnreferencedObjects { + val size = 200 + val hs = new WeakHashSet[Collider]() + val elements = (0 until size).toList map {x => Collider("a" + x)} + elements foreach (hs += _) + // don't throw the following into a retained collection so gc + // can remove them + for (i <- 0 until size) { + hs += Collider("b" + i) + } + System.gc() + Thread.sleep(1000) + assert(hs.size == 200) + elements foreach {i => assert(hs contains i)} + for (i <- 0 until size) { + assert(!(hs contains Collider("b" + i))) + } + hs.diagnostics.fullyValidate + } + + // make sure findOrUpdate returns the originally entered element + @Test + def checkFindOrUpdate { + val size = 200 + val hs = new WeakHashSet[Collider]() + val elements = (0 until size).toList map {x => Collider("a" + x)} + elements foreach {x => assert(hs findEntryOrUpdate x eq x)} + for (i <- 0 until size) { + // when we do a lookup the result should be the same reference we + // original put in + assert(hs findEntryOrUpdate(Collider("a" + i)) eq elements(i)) + } + hs.diagnostics.fullyValidate + } + + // check -= functionality + @Test + def checkMinusEquals { + val hs = new WeakHashSet[String]() + val elements = List("hello", "goodbye") + elements foreach (hs += _) + hs -= "goodbye" + assert(hs.size == 1) + assert(hs contains "hello") + assert(!(hs contains "goodbye")) + hs.diagnostics.fullyValidate + } + + // check -= when there are collisions + @Test + def checkMinusEqualsCollisions { + val hs = new WeakHashSet[Collider] + val elements = List(Collider("hello"), Collider("goodbye")) + elements foreach (hs += _) + hs -= Collider("goodbye") + assert(hs.size == 1) + assert(hs contains Collider("hello")) + assert(!(hs contains Collider("goodbye"))) + hs -= Collider("hello") + assert(hs.size == 0) + assert(!(hs contains Collider("hello"))) + hs.diagnostics.fullyValidate + } + + // check that the clear method actually cleans everything + @Test + def checkClear { + val size = 200 + val hs = new WeakHashSet[String]() + val elements = (0 until size).toList map ("a" + _) + elements foreach (hs += _) + hs.clear() + assert(hs.size == 0) + elements foreach {i => assert(!(hs contains i))} + hs.diagnostics.fullyValidate + } + + // check that the iterator covers all the contents + @Test + def checkIterator { + val hs = new WeakHashSet[String]() + val elements = (0 until 20).toList map ("a" + _) + elements foreach (hs += _) + assert(elements.iterator.toList.sorted == elements.sorted) + hs.diagnostics.fullyValidate + } + + // check that the iterator covers all the contents even when there is a collision + @Test + def checkIteratorCollisions { + val hs = new WeakHashSet[Collider] + val elements = (0 until 20).toList map {x => Collider("a" + x)} + elements foreach (hs += _) + assert(elements.iterator.toList.sorted == elements.sorted) + hs.diagnostics.fullyValidate + } + +} diff --git a/test/junit/scala/reflect/io/ZipArchiveTest.scala b/test/junit/scala/reflect/io/ZipArchiveTest.scala new file mode 100644 index 0000000000..1bcd06f5a7 --- /dev/null +++ b/test/junit/scala/reflect/io/ZipArchiveTest.scala @@ -0,0 +1,37 @@ +package scala.reflect.io + +import java.io.{IOException, File => JFile} +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class ZipArchiveTest { + + @Test + def corruptZip { + val f = JFile.createTempFile("test", ".jar") + val fza = new FileZipArchive(f) + try { + fza.iterator + } catch { + case x: IOException => + assertTrue(x.getMessage, x.getMessage.contains(f.getPath)) + } finally { + f.delete() + } + } + + @Test + def missingFile { + val f = new JFile("xxx.does.not.exist") + val fza = new FileZipArchive(f) + try { + fza.iterator + } catch { + case x: IOException => + assertTrue(x.getMessage, x.getMessage.contains(f.getPath)) + } + } +} diff --git a/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala b/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala new file mode 100644 index 0000000000..355771bf04 --- /dev/null +++ b/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala @@ -0,0 +1,67 @@ +package scala.tools.nsc +package symtab + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +import scala.tools.testing.AssertUtil.assertThrows +import scala.reflect.internal.util.OffsetPosition + +@RunWith(classOf[JUnit4]) +class CannotHaveAttrsTest { + object symbolTable extends SymbolTableForUnitTesting { + object CHA extends CannotHaveAttrs { + def canEqual(that: Any): Boolean = ??? + def productArity: Int = ??? + def productElement(n: Int): Any = ??? + } + val attrlessTrees = List(CHA, EmptyTree, emptyValDef, pendingSuperCall) + } + import symbolTable._ + + @Test + def canHaveAttrsIsFalse = + attrlessTrees.foreach { t => + assertFalse(t.canHaveAttrs) + } + + @Test + def defaultPosAssignment = + attrlessTrees.foreach { t => + assertEquals(t.pos, NoPosition) + t.pos = NoPosition + assertEquals(t.pos, NoPosition) + t.setPos(NoPosition) + assertEquals(t.pos, NoPosition) + } + + @Test + def defaultTpeAssignment = + attrlessTrees.foreach { t => + assertEquals(t.tpe, NoType) + t.tpe = NoType + assertEquals(t.tpe, NoType) + t.setType(NoType) + assertEquals(t.tpe, NoType) + } + + @Test + def nonDefaultPosAssignmentFails = { + val pos = new OffsetPosition(null, 0) + attrlessTrees.foreach { t => + assertThrows[IllegalArgumentException] { t.pos = pos } + assertThrows[IllegalArgumentException] { t.setPos(pos) } + } + } + + @Test + def nonDefaultTpeAssignmentFails = { + val tpe = typeOf[Int] + attrlessTrees.foreach { t => + assertThrows[IllegalArgumentException] { t.tpe = tpe } + assertThrows[IllegalArgumentException] { t.setType(tpe) } + } + } +} diff --git a/test/junit/scala/tools/nsc/symtab/StdNamesTest.scala b/test/junit/scala/tools/nsc/symtab/StdNamesTest.scala new file mode 100644 index 0000000000..05e69978c6 --- /dev/null +++ b/test/junit/scala/tools/nsc/symtab/StdNamesTest.scala @@ -0,0 +1,46 @@ +package scala.tools.nsc +package symtab + +import org.junit.Assert._ +import scala.tools.testing.AssertUtil._ +import org.junit.{Ignore, Test} +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class StdNamesTest { + object symbolTable extends SymbolTableForUnitTesting + import symbolTable._ + import nme.{SPECIALIZED_SUFFIX, unspecializedName, splitSpecializedName} + + @Test + def testNewTermNameInvalid(): Unit = { + assertThrows[IllegalArgumentException](newTermName("foo".toCharArray, 0, -1)) + assertThrows[IllegalArgumentException](newTermName("foo".toCharArray, 0, 0)) + assertThrows[IllegalArgumentException](newTermName("foo".toCharArray, -1, 1)) + } + + @Test + def testUnspecializedName(): Unit = { + def test(expected: Name, nme: Name) { + assertEquals(expected, unspecializedName(nme)) + } + test(TermName("Tuple2"), TermName("Tuple2$mcII" + SPECIALIZED_SUFFIX)) + test(TermName("foo"), TermName("foo$mIcD" + SPECIALIZED_SUFFIX)) + test(TermName("foo"), TermName("foo$mIc" + SPECIALIZED_SUFFIX)) + test(TermName("T1"), TermName(s"T1$SPECIALIZED_SUFFIX")) + test(TermName(""), SPECIALIZED_SUFFIX) + } + + @Test + def testSplitSpecializedName(): Unit = { + def test(expected: (Name, String, String), nme: Name) { + assertEquals(expected, splitSpecializedName(nme)) + } + test((TermName("Tuple2"), "II", ""), TermName("Tuple2$mcII" + SPECIALIZED_SUFFIX)) + test((TermName("foo"), "D", "I"), TermName("foo$mIcD" + SPECIALIZED_SUFFIX)) + test((TermName("foo"), "", "I"), TermName("foo$mIc" + SPECIALIZED_SUFFIX)) + test((TermName("T1"), "", ""), TermName(s"T1$SPECIALIZED_SUFFIX")) + test((TermName(""), "", ""), SPECIALIZED_SUFFIX) + } +} diff --git a/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala new file mode 100644 index 0000000000..285e87e3b2 --- /dev/null +++ b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala @@ -0,0 +1,89 @@ +package scala.tools.nsc +package symtab + +import scala.reflect.internal.{Phase, NoPhase, SomePhase} +import scala.tools.util.PathResolver +import util.ClassPath +import io.AbstractFile + +/** + * A complete SymbolTable implementation designed to be used in JUnit tests. + * + * It enables `usejavacp` setting so classpath of JUnit runner is being used + * for symbol table's classpath. + * + * This class contains enough of logic implemented to make it possible to + * initialize definitions and inspect symbols. + */ +class SymbolTableForUnitTesting extends SymbolTable { + // Members declared in scala.reflect.api.Trees + override def newStrictTreeCopier: TreeCopier = new StrictTreeCopier + override def newLazyTreeCopier: TreeCopier = new LazyTreeCopier + trait TreeCopier extends InternalTreeCopierOps + // these should be mocks + class StrictTreeCopier extends super.StrictTreeCopier with TreeCopier + class LazyTreeCopier extends super.LazyTreeCopier with TreeCopier + + override def isCompilerUniverse: Boolean = true + def classPath = new PathResolver(settings).result + + object platform extends backend.Platform { + val symbolTable: SymbolTableForUnitTesting.this.type = SymbolTableForUnitTesting.this + lazy val loaders: SymbolTableForUnitTesting.this.loaders.type = SymbolTableForUnitTesting.this.loaders + def platformPhases: List[SubComponent] = Nil + val classPath: ClassPath[AbstractFile] = new PathResolver(settings).result + def doLoad(cls: ClassPath[AbstractFile]#ClassRep): Boolean = true + def isMaybeBoxed(sym: Symbol): Boolean = ??? + def needCompile(bin: AbstractFile, src: AbstractFile): Boolean = ??? + def externalEquals: Symbol = ??? + def updateClassPath(subst: Map[ClassPath[AbstractFile], ClassPath[AbstractFile]]): Unit = ??? + } + + object loaders extends symtab.SymbolLoaders { + val symbolTable: SymbolTableForUnitTesting.this.type = SymbolTableForUnitTesting.this + lazy val platform: symbolTable.platform.type = symbolTable.platform + def lookupMemberAtTyperPhaseIfPossible(sym: Symbol, name: Name): Symbol = + sym.info.member(name) + protected override def compileLate(srcfile: AbstractFile): Unit = + sys.error(s"We do not expect compileLate to be called in SymbolTableTest. The srcfile passed in is $srcfile") + } + + class GlobalMirror extends Roots(NoSymbol) { + val universe: SymbolTableForUnitTesting.this.type = SymbolTableForUnitTesting.this + def rootLoader: LazyType = new loaders.PackageLoader(classPath) + override def toString = "compiler mirror" + } + + lazy val rootMirror: Mirror = { + val rm = new GlobalMirror + rm.init() + rm.asInstanceOf[Mirror] + } + + def settings: Settings = { + val s = new Settings + // initialize classpath using java classpath + s.usejavacp.value = true + s + } + + // Members declared in scala.reflect.internal.Required + def picklerPhase: scala.reflect.internal.Phase = SomePhase + + // Members declared in scala.reflect.internal.SymbolTable + def currentRunId: Int = 1 + def log(msg: => AnyRef): Unit = println(msg) + def mirrorThatLoaded(sym: Symbol): Mirror = rootMirror + val phases: Seq[Phase] = List(NoPhase, SomePhase) + val phaseWithId: Array[Phase] = { + val maxId = phases.map(_.id).max + val phasesArray = Array.ofDim[Phase](maxId+1) + phases foreach { phase => + phasesArray(phase.id) = phase + } + phasesArray + } + lazy val treeInfo: scala.reflect.internal.TreeInfo{val global: SymbolTableForUnitTesting.this.type} = ??? + + phase = SomePhase +} diff --git a/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala b/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala new file mode 100644 index 0000000000..11e955a4bb --- /dev/null +++ b/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala @@ -0,0 +1,47 @@ +package scala.tools.nsc +package symtab + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class SymbolTableTest { + object symbolTable extends SymbolTableForUnitTesting + + @Test + def initDefinitions = { + symbolTable.definitions.init() + } + + @Test + def basicSubTypeCheck = { + symbolTable.definitions.init() + val listClassTpe = symbolTable.definitions.ListClass.tpe + val seqClassTpe = symbolTable.definitions.SeqClass.tpe + assertTrue("List should be subclass of Seq", listClassTpe <:< seqClassTpe) + } + + /** + * Demonstrates how one can create symbols and type completely + * from scratch and perform sub type check. + */ + @Test + def customClassesSubTypeCheck: Unit = { + import symbolTable._ + symbolTable.definitions.init() + val rootClass = symbolTable.rootMirror.RootClass + val fooSymbol = rootClass.newClassSymbol("Foo": TypeName, NoPosition, 0) + val fooType = new ClassInfoType(Nil, EmptyScope, fooSymbol) + fooSymbol.info = fooType + val barSymbol = rootClass.newClassSymbol("Bar": TypeName, NoPosition, 0) + val fooTypeRef = TypeRef(fooSymbol.owner.tpe, fooSymbol, Nil) + val barType = new ClassInfoType(List(fooTypeRef), EmptyScope, barSymbol) + barSymbol.info = barType + assertTrue("Bar should be subclass of Foo", barSymbol.tpe <:< fooSymbol.tpe) + assertFalse("Foo should be a superclass of Foo", fooSymbol.tpe <:< barSymbol.tpe) + } + +} diff --git a/test/junit/scala/tools/nsc/util/StackTraceTest.scala b/test/junit/scala/tools/nsc/util/StackTraceTest.scala new file mode 100644 index 0000000000..e7654244c5 --- /dev/null +++ b/test/junit/scala/tools/nsc/util/StackTraceTest.scala @@ -0,0 +1,159 @@ + +package scala.tools.nsc.util + +import scala.language.reflectiveCalls +import scala.util._ +import PartialFunction.cond +import Properties.isJavaAtLeast + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +trait Expecting { + /* + import org.expecty.Expecty + final val expect = new Expecty + */ +} + + +@RunWith(classOf[JUnit4]) +class StackTraceTest extends Expecting { + // formerly an enum + val CausedBy = "Caused by: " + val Suppressed = "Suppressed: " + + // throws + def sample = throw new RuntimeException("Point of failure") + def sampler: String = sample + + // repackage with message + def resample: String = try { sample } catch { case e: Throwable => throw new RuntimeException("resample", e) } + def resampler: String = resample + + // simple wrapper + def wrapper: String = try { sample } catch { case e: Throwable => throw new RuntimeException(e) } + // another onion skin + def rewrapper: String = try { wrapper } catch { case e: Throwable => throw new RuntimeException(e) } + def rewrapperer: String = rewrapper + + // only an insane wretch would do this + def insane: String = try { sample } catch { + case e: Throwable => + val t = new RuntimeException(e) + e initCause t + throw t + } + def insaner: String = insane + + /** Java 7 */ + val suppressable = isJavaAtLeast("1.7") + type Suppressing = { def addSuppressed(t: Throwable): Unit } + + def repressed: String = try { sample } catch { + case e: Throwable => + val t = new RuntimeException("My problem") + if (suppressable) { + t.asInstanceOf[Suppressing] addSuppressed e + } + throw t + } + def represser: String = repressed + + // evaluating s should throw, p trims stack trace, t is the test of resulting trace string + def probe(s: =>String)(p: StackTraceElement => Boolean)(t: String => Unit): Unit = { + Try(s) recover { case e => e stackTracePrefixString p } match { + case Success(s) => t(s) + case Failure(e) => throw e + } + } + + @Test def showsAllTrace() { + probe(sampler)(_ => true) { s => + val res = s.lines.toList + /* + expect { + res.length > 5 // many lines + // these expectations may be framework-specific + //s contains "sbt.TestFramework" + //res.last contains "java.lang.Thread" + } + */ + assert (res.length > 5) + } + } + @Test def showsOnlyPrefix() = probe(sample)(_.getMethodName == "sample") { s => + val res = s.lines.toList + /* + expect { + res.length == 3 // summary + one frame + elision + } + */ + assert (res.length == 3) + } + @Test def showsCause() = probe(resampler)(_.getMethodName != "resampler") { s => + val res = s.lines.toList + /* + expect { + res.length == 6 // summary + one frame + elision, caused by + one frame + elision + res exists (_ startsWith CausedBy.toString) + } + */ + assert (res.length == 6) + assert (res exists (_ startsWith CausedBy.toString)) + } + @Test def showsWrappedExceptions() = probe(rewrapperer)(_.getMethodName != "rewrapperer") { s => + val res = s.lines.toList + /* + expect { + res.length == 9 // summary + one frame + elision times three + res exists (_ startsWith CausedBy.toString) + (res collect { + case s if s startsWith CausedBy.toString => s + }).size == 2 + } + */ + assert (res.length == 9) + assert (res exists (_ startsWith CausedBy.toString)) + assert ((res collect { + case s if s startsWith CausedBy.toString => s + }).size == 2) + } + @Test def dontBlowOnCycle() = probe(insaner)(_.getMethodName != "insaner") { s => + val res = s.lines.toList + /* + expect { + res.length == 7 // summary + one frame + elision times two with extra frame + res exists (_ startsWith CausedBy.toString) + } + */ + assert (res.length == 7) + assert (res exists (_ startsWith CausedBy.toString)) + } + + /** Java 7, but shouldn't bomb on Java 6. + * +java.lang.RuntimeException: My problem + at scala.tools.nsc.util.StackTraceTest.repressed(StackTraceTest.scala:56) + ... 27 elided + Suppressed: java.lang.RuntimeException: Point of failure + at scala.tools.nsc.util.StackTraceTest.sample(StackTraceTest.scala:29) + at scala.tools.nsc.util.StackTraceTest.repressed(StackTraceTest.scala:54) + ... 27 more + */ + @Test def showsSuppressed() = probe(represser)(_.getMethodName != "represser") { s => + val res = s.lines.toList + if (suppressable) { + assert (res.length == 7) + assert (res exists (_.trim startsWith Suppressed.toString)) + } + /* + expect { + res.length == 7 + res exists (_ startsWith " " + Suppressed.toString) + } + */ + } +} diff --git a/test/junit/scala/tools/testing/AssertThrowsTest.scala b/test/junit/scala/tools/testing/AssertThrowsTest.scala new file mode 100644 index 0000000000..a70519e63c --- /dev/null +++ b/test/junit/scala/tools/testing/AssertThrowsTest.scala @@ -0,0 +1,34 @@ +package scala.tools +package testing + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import AssertUtil.assertThrows + +@RunWith(classOf[JUnit4]) +class AssertThrowsTest { + class Foo extends Exception + class SubFoo extends Foo + class Bar extends Exception + + @Test + def catchFoo = assertThrows[Foo] { throw new Foo } + + @Test + def catchSubclass = assertThrows[Foo] { throw new SubFoo } + + @Test + def rethrowBar = + assertTrue("exception wasn't rethrown", { + try { + assertThrows[Foo] { throw new Bar } + false + } catch { + case bar: Bar => true + case e: Throwable => fail(s"expected Bar but got $e"); false + } + }) + +}
\ No newline at end of file diff --git a/test/junit/scala/tools/testing/AssertUtil.scala b/test/junit/scala/tools/testing/AssertUtil.scala new file mode 100644 index 0000000000..9efac64a97 --- /dev/null +++ b/test/junit/scala/tools/testing/AssertUtil.scala @@ -0,0 +1,19 @@ +package scala.tools +package testing + +/** This module contains additional higher-level assert statements + * that are ultimately based on junit.Assert primitives. + */ +object AssertUtil { + /** Check if exception T (or a subclass) was thrown during evaluation of f. + * If any other exception or throwable is found instead it will be re-thrown. + */ + def assertThrows[T <: Exception](f: => Any)(implicit manifest: Manifest[T]): Unit = + try f + catch { + case e: Exception => + val clazz = manifest.erasure.asInstanceOf[Class[T]] + if (!clazz.isAssignableFrom(e.getClass)) + throw e + } +}
\ No newline at end of file diff --git a/test/junit/scala/util/matching/regextract-char.scala b/test/junit/scala/util/matching/regextract-char.scala new file mode 100644 index 0000000000..50fdcd9d46 --- /dev/null +++ b/test/junit/scala/util/matching/regextract-char.scala @@ -0,0 +1,58 @@ + +package scala.util.matching + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +import PartialFunction._ + +/** Regex can match a Char. + * If the pattern includes a group, + * always return a single char. + */ +@RunWith(classOf[JUnit4]) +class CharRegexTest { + implicit class Averrable(val b: Boolean) /*extends AnyVal*/ { + def yes = assert(b) + def no = assert(!b) + } + val c: Char = 'c' // "cat"(0) + val d: Char = 'D' // "Dog"(0) + + @Test def comparesGroupCorrectly(): Unit = { + val r = """(\p{Lower})""".r + cond(c) { case r(x) => true } .yes + cond(c) { case r(_) => true } .yes + cond(c) { case r(_*) => true } .yes + cond(c) { case r() => true } .no + + cond(d) { case r(x) => true } .no + cond(d) { case r(_) => true } .no + cond(d) { case r(_*) => true } .no + cond(d) { case r() => true } .no + } + + @Test def comparesNoGroupCorrectly(): Unit = { + val rnc = """\p{Lower}""".r + cond(c) { case rnc(x) => true } .no + cond(c) { case rnc(_) => true } .no + cond(c) { case rnc(_*) => true } .yes + cond(c) { case rnc() => true } .yes + + cond(d) { case rnc(x) => true } .no + cond(d) { case rnc(_) => true } .no + cond(d) { case rnc(_*) => true } .no + cond(d) { case rnc() => true } .no + } + + @Test(expected = classOf[MatchError]) + def failCorrectly(): Unit = { + val headAndTail = """(\p{Lower})([a-z]+)""".r + val n = "cat"(0) match { + case headAndTail(ht @ _*) => ht.size + } + assert(false, s"Match size $n") + } +} diff --git a/test/pending/junit/scala/util/t7265.scala b/test/junit/scala/util/t7265.scala index 3b8fa80dbe..71f085d21d 100644 --- a/test/pending/junit/scala/util/t7265.scala +++ b/test/junit/scala/util/t7265.scala @@ -30,6 +30,7 @@ class SpecVersionTest { assert(sut isJavaAtLeast "1.6") assert(sut isJavaAtLeast "1.7") assert(!(sut isJavaAtLeast "1.8")) + assert(!(sut isJavaAtLeast "1.71")) } @Test(expected = classOf[NumberFormatException]) def badVersion(): Unit = { @@ -40,6 +41,18 @@ class SpecVersionTest { sut isJavaAtLeast "1" } @Test(expected = classOf[NumberFormatException]) + def noVersion(): Unit = { + sut isJavaAtLeast "" + } + @Test(expected = classOf[NumberFormatException]) + def dotOnly(): Unit = { + sut isJavaAtLeast "." + } + @Test(expected = classOf[NumberFormatException]) + def leadingDot(): Unit = { + sut isJavaAtLeast ".5" + } + @Test(expected = classOf[NumberFormatException]) def notASpec(): Unit = { sut isJavaAtLeast "1.7.1" } diff --git a/test/osgi/src/BasicReflection.scala b/test/osgi/src/BasicReflection.scala index 8a0a05d531..68fedb7c83 100644 --- a/test/osgi/src/BasicReflection.scala +++ b/test/osgi/src/BasicReflection.scala @@ -1,10 +1,10 @@ package tools.test.osgi package reflection package basic - + import org.junit.Assert._ import org.ops4j.pax.exam.CoreOptions._ - + import org.junit.Test import org.junit.runner.RunWith import org.ops4j.pax.exam @@ -41,15 +41,15 @@ object M class BasicReflectionTest extends ScalaOsgiHelper { @Configuration - def config(): Array[exam.Option] = + def config(): Array[exam.Option] = justReflectionOptions // Ensure Pax-exam requires C/M in our module def dummy = { new C - M.toString + M.toString } - + @Test def basicMirrorThroughOsgi(): Unit = { // Note for now just assert that we can do this stuff. @@ -57,10 +57,10 @@ class BasicReflectionTest extends ScalaOsgiHelper { val cm = runtimeMirror(classOf[C].getClassLoader) val im = cm.reflect(new C) assertEquals("Unable to reflect field name!", - "value f1", - im.reflectField(typeOf[C].member(newTermName("f1")).asTerm).symbol.toString) + "value f1", + im.reflectField(typeOf[C].member(TermName("f1")).asTerm).symbol.toString) assertEquals("Unable to reflect value!", - 2, - im.reflectField(typeOf[C].member(newTermName("f1")).asTerm).get) + 2, + im.reflectField(typeOf[C].member(TermName("f1")).asTerm).get) } } diff --git a/test/partest b/test/partest index 842d2903b7..f396459c6d 100755 --- a/test/partest +++ b/test/partest @@ -1,15 +1,36 @@ -#!/bin/sh - +#!/usr/bin/env bash +# ############################################################################## -# Scala test runner 2.8.0 +# Scala test runner 2.10.0 ############################################################################## -# (c) 2002-2011 LAMP/EPFL +# (c) 2002-2013 LAMP/EPFL # # This is free software; see the distribution for copying conditions. # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. ############################################################################## +findScalaHome () { + # see SI-2092 and SI-5792 + local source="${BASH_SOURCE[0]}" + while [ -h "$source" ] ; do + local linked="$(readlink "$source")" + local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pwd )" + source="$dir/$(basename "$linked")" + done + ( ( cd -P "$(dirname "$source")/.." > /dev/null ) && pwd ) +} + +# Use tput to detect color-capable terminal. +term_colors=$(tput colors 2>/dev/null) +if [[ $? == 0 ]] && [[ $term_colors -gt 2 ]]; then + git_diff_options="--color=always --word-diff" + color_opts="-Dpartest.colors=$term_colors" +else + unset color_opts + git_diff_options="--nocolor" +fi + cygwin=false; darwin=false; case "`uname`" in @@ -18,49 +39,60 @@ case "`uname`" in esac # Finding the root folder for this Scala distribution -SOURCE=$0; -SCRIPT=`basename "$SOURCE"`; -while [ -h "$SOURCE" ]; do - SCRIPT=`basename "$SOURCE"`; - LOOKUP=`ls -ld "$SOURCE"`; - TARGET=`expr "$LOOKUP" : '.*-> \(.*\)$'`; - if expr "${TARGET:-.}/" : '/.*/$' > /dev/null; then - SOURCE=${TARGET:-.}; - else - SOURCE=`dirname "$SOURCE"`/${TARGET:-.}; - fi; -done; - -# see #2092 -SCALA_HOME=`dirname "$SOURCE"` -SCALA_HOME=`cd "$SCALA_HOME"; pwd -P` -SCALA_HOME=`cd "$SCALA_HOME"/..; pwd` +SCALA_HOME="$(findScalaHome)" if $cygwin; then SCALA_HOME=`cygpath --windows --short-name "$SCALA_HOME"` SCALA_HOME=`cygpath --unix "$SCALA_HOME"` fi -# Constructing the extension classpath -EXT_CLASSPATH="" -if [ -z "$EXT_CLASSPATH" ] ; then - if [ -f "$SCALA_HOME/lib/scala-partest.jar" ] ; then - for ext in "$SCALA_HOME"/lib/* ; do - if [ -z "$EXT_CLASSPATH" ] ; then - EXT_CLASSPATH="$ext" - else - EXT_CLASSPATH="$EXT_CLASSPATH:$ext" - fi - done - elif [ -f "$SCALA_HOME/build/pack/lib/scala-partest.jar" ] ; then - for lib in `echo "scala-partest scala-library scala-reflect scala-compiler diffutils"`; do - ext="$SCALA_HOME/build/pack/lib/$lib.jar" - if [ -z "$EXT_CLASSPATH" ] ; then - EXT_CLASSPATH="$ext" - else - EXT_CLASSPATH="$EXT_CLASSPATH:$ext" - fi - done +# Let ant construct the classpath used to run partest (downloading partest from maven if necessary) +# PARTEST_CLASSPATH="" +if [ -z "$PARTEST_CLASSPATH" ] ; then + if [ ! -f "$SCALA_HOME/build/pack/partest.properties" ] ; then + (cd "$SCALA_HOME" && ant -q test.suite.init) # builds pack, downloads partest and writes classpath to build/pack/partest.properties + fi + + PARTEST_CLASSPATH=$( cat "$SCALA_HOME/build/pack/partest.properties" | grep partest.classpath | sed -e 's/\\:/:/g' | cut -f2- -d= ) + + # sanity check, disabled to save time + # $( javap -classpath $PARTEST_CLASSPATH scala.tools.partest.nest.NestRunner &> /dev/null ) || unset PARTEST_CLASSPATH +fi + +# if [ -z "$PARTEST_CLASSPATH" ] ; then +# if [ -f "$SCALA_HOME/lib/scala-partest.jar" ] ; then +# for ext in "$SCALA_HOME"/lib/* ; do +# if [ -z "$PARTEST_CLASSPATH" ] ; then +# PARTEST_CLASSPATH="$ext" +# else +# PARTEST_CLASSPATH="$PARTEST_CLASSPATH:$ext" +# fi +# done +# elif [ -f "$SCALA_HOME/build/pack/lib/scala-partest.jar" ] ; then +# for lib in `echo "scala-partest scala-library scala-parser-combinators scala-xml scala-reflect scala-compiler diffutils"`; do +# ext="$SCALA_HOME/build/pack/lib/$lib.jar" +# if [ -z "$PARTEST_CLASSPATH" ] ; then +# PARTEST_CLASSPATH="$ext" +# else +# PARTEST_CLASSPATH="$PARTEST_CLASSPATH:$ext" +# fi +# done +# fi +# fi + +# Locate a javac command +# Try: JAVA_HOME, sibling to specific JAVACMD, or PATH +# Don't fail if there is no javac, since not all tests require it. +if [ -z "$JAVAC_CMD" ] ; then + if [ -n "${JAVA_HOME}" ] && [ -f "${JAVA_HOME}/bin/javac" ] ; then + JAVAC_CMD="${JAVA_HOME}/bin/javac" + fi + if [ -z "$JAVAC_CMD" ] && [ -n "$JAVACMD" ] ; then + JDIR=`dirname "${JAVACMD}"` + JAVAC_CMD="${JDIR}/javac" + fi + if [ -z "$JAVAC_CMD" ] ; then + JAVAC_CMD=`type -p javac` fi fi @@ -70,26 +102,45 @@ if $cygwin; then else format=windows fi + if [ -n "${JAVA_HOME}" ] ; then + JAVA_HOME=`cygpath --$format "$JAVA_HOME"` + fi + if [ -n "${JAVACMD}" ] ; then + JAVACMD=`cygpath --$format "$JAVACMD"` + fi + if [ -n "${JAVAC_CMD}" ] ; then + JAVAC_CMD=`cygpath --$format "$JAVAC_CMD"` + fi SCALA_HOME=`cygpath --$format "$SCALA_HOME"` - EXT_CLASSPATH=`cygpath --path --$format "$EXT_CLASSPATH"` + PARTEST_CLASSPATH=`cygpath --path --$format "$PARTEST_CLASSPATH"` fi -# last arg wins, so if JAVA_OPTS already contains one of these options -# the supplied argument will be used. +# last arg wins, so if JAVA_OPTS already contains -Xmx or -Xms the +# supplied argument will be used. # At this writing it is reported test/partest --all requires 108m permgen. JAVA_OPTS="-Xmx1024M -Xms64M -XX:MaxPermSize=128M $JAVA_OPTS" +# the ant task doesn't supply any options by default, +# so don't do that here either -- note that you may want to pass -optimise +# to mimic what happens during nightlies. +# [ -n "$SCALAC_OPTS" ] || SCALAC_OPTS="-deprecation" + partestDebugStr="" if [ ! -z "${PARTEST_DEBUG}" ] ; then partestDebugStr="-Dpartest.debug=${PARTEST_DEBUG}" fi -${JAVACMD:=java} \ - $JAVA_OPTS -cp "$EXT_CLASSPATH" \ +# note that variables which may intentionally be empty must not +# be quoted: otherwise an empty string will appear as a command line +# argument, and java will think that is the program to run. +"${JAVACMD:=java}" \ + $JAVA_OPTS -cp "$PARTEST_CLASSPATH" \ ${partestDebugStr} \ + ${color_opts} \ + -Dfile.encoding=UTF-8 \ -Dscala.home="${SCALA_HOME}" \ -Dpartest.javacmd="${JAVACMD}" \ -Dpartest.java_opts="${JAVA_OPTS}" \ -Dpartest.scalac_opts="${SCALAC_OPTS}" \ - -Dpartest.javac_cmd="${JAVA_HOME}/bin/javac" \ - scala.tools.partest.nest.NestRunner "$@" + -Dpartest.javac_cmd="${JAVAC_CMD}" \ + scala.tools.partest.nest.ConsoleRunner "$@" diff --git a/test/partest.bat b/test/partest.bat index b64347ce13..1806e80888 100755 --- a/test/partest.bat +++ b/test/partest.bat @@ -3,7 +3,7 @@ rem ########################################################################## rem # Scala code runner 2.9.1.final rem ########################################################################## -rem # (c) 2002-2011 LAMP/EPFL +rem # (c) 2002-2013 LAMP/EPFL rem # rem # This is free software; see the distribution for copying conditions. rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A diff --git a/test/pending/jvm/cf-attributes.scala b/test/pending/jvm/cf-attributes.scala index 9e0e9d95de..f4964b63b1 100644 --- a/test/pending/jvm/cf-attributes.scala +++ b/test/pending/jvm/cf-attributes.scala @@ -52,14 +52,14 @@ object anonymousFunctions { } object anonymousClasses { - //InnerClass: + //InnerClass: // public abstract #_= #_ of #_; //Foo=class anonymousClasses$Foo of class anonymousClasses$ // public abstract #_= #_ of #_; //Foo$class=class anonymousClasses$Foo$class of class anonymousClasses$ trait Foo { def foo() { println("foo"); } override def toString = getClass.getName } - //InnerClass: + //InnerClass: // public final #_; //class anonymousClasses$$anon$1 of class anonymousClasses$ val x = new Foo() { override def foo() { println("foo (overriden)"); } @@ -88,16 +88,16 @@ trait Test1 { trait Test2 { @throws(classOf[Exception]) - def printInnerClasses(cls: Class[_]) { - import java.io._, ch.epfl.lamp.fjbg._ - val fjbgContext = new FJBGContext(49, 0) - val outDir = System.getProperty("partest.output", "cf-attributes.obj") - val fileName = outDir+File.separator+cls.getName+".class" - val in = new DataInputStream(new FileInputStream(fileName)) - val jclass = fjbgContext.JClass(in) - println(jclass.getInnerClasses) - in.close() - } + // def printInnerClasses(cls: Class[_]) { + // import java.io._, ch.epfl.lamp.fjbg._ + // val fjbgContext = new FJBGContext(49, 0) + // val outDir = System.getProperty("partest.output", "cf-attributes.obj") + // val fileName = outDir+File.separator+cls.getName+".class" + // val in = new DataInputStream(new FileInputStream(fileName)) + // val jclass = fjbgContext.JClass(in) + // println(jclass.getInnerClasses) + // in.close() + // } def printClass(name: String) { try { printClass(Class.forName(name)) } catch { case e: Exception => println(e) } @@ -105,7 +105,7 @@ trait Test2 { def printClass(cls: Class[_]) { println("\n[[ "+cls.getName+" ]]"); try { printInnerClasses(cls) } - catch { case e: Exception => println(e) } + catch { case e: Exception => println(e) } } } diff --git a/test/pending/neg/plugin-after-terminal.flags b/test/pending/neg/plugin-after-terminal.flags deleted file mode 100644 index 6a44376213..0000000000 --- a/test/pending/neg/plugin-after-terminal.flags +++ /dev/null @@ -1,2 +0,0 @@ --Xplugin:files/neg/plugin-after-terminal/lib/plugins.jar - diff --git a/test/pending/neg/plugin-after-terminal/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-after-terminal/lib/plugins.jar.desired.sha1 deleted file mode 100644 index 3e382f3a12..0000000000 --- a/test/pending/neg/plugin-after-terminal/lib/plugins.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -f174c50c4363c492362a05c72dd45b0da18fdcd8 ?plugins.jar diff --git a/test/pending/neg/plugin-after-terminal/misc/build.sh b/test/pending/neg/plugin-after-terminal/misc/build.sh deleted file mode 100755 index 8899009d7f..0000000000 --- a/test/pending/neg/plugin-after-terminal/misc/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" - -BASE=`pwd` - -if [[ -d "${BASE}/src" ]] ; then - - mkdir -p build - ${SCALAC} -d build src/*.scala - jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . - rm -rf build -fi - diff --git a/test/pending/neg/plugin-after-terminal/testsource.scala b/test/pending/neg/plugin-after-terminal/testsource.scala deleted file mode 100644 index 519d162fdf..0000000000 --- a/test/pending/neg/plugin-after-terminal/testsource.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends Application { - println("afterterminal") -} - diff --git a/test/pending/neg/plugin-before-parser.flags b/test/pending/neg/plugin-before-parser.flags deleted file mode 100644 index 632530922c..0000000000 --- a/test/pending/neg/plugin-before-parser.flags +++ /dev/null @@ -1,2 +0,0 @@ --Xplugin:files/neg/plugin-before-parser/lib/plugins.jar - diff --git a/test/pending/neg/plugin-before-parser/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-before-parser/lib/plugins.jar.desired.sha1 deleted file mode 100644 index e82eed76ce..0000000000 --- a/test/pending/neg/plugin-before-parser/lib/plugins.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -d7b100ad483484b598b7cd643424bd2e33898a0d ?plugins.jar diff --git a/test/pending/neg/plugin-before-parser/misc/build.sh b/test/pending/neg/plugin-before-parser/misc/build.sh deleted file mode 100755 index 8899009d7f..0000000000 --- a/test/pending/neg/plugin-before-parser/misc/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" - -BASE=`pwd` - -if [[ -d "${BASE}/src" ]] ; then - - mkdir -p build - ${SCALAC} -d build src/*.scala - jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . - rm -rf build -fi - diff --git a/test/pending/neg/plugin-before-parser/testsource.scala b/test/pending/neg/plugin-before-parser/testsource.scala deleted file mode 100644 index 9928aaa83c..0000000000 --- a/test/pending/neg/plugin-before-parser/testsource.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends Application { - println("beforeparser") -} - diff --git a/test/pending/neg/plugin-cyclic-dependency.check b/test/pending/neg/plugin-cyclic-dependency.check deleted file mode 100644 index a29bc3f5be..0000000000 --- a/test/pending/neg/plugin-cyclic-dependency.check +++ /dev/null @@ -1,2 +0,0 @@ -error: fatal error: Cycle in compiler phase dependencies detected, phase cyclicdependency1 reacted twice! -one error found diff --git a/test/pending/neg/plugin-cyclic-dependency.flags b/test/pending/neg/plugin-cyclic-dependency.flags deleted file mode 100644 index 8716aaa65f..0000000000 --- a/test/pending/neg/plugin-cyclic-dependency.flags +++ /dev/null @@ -1,2 +0,0 @@ --Xplugin:files/neg/plugin-cyclic-dependency/lib/plugins.jar - diff --git a/test/pending/neg/plugin-cyclic-dependency/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-cyclic-dependency/lib/plugins.jar.desired.sha1 deleted file mode 100644 index 7e565e9e61..0000000000 --- a/test/pending/neg/plugin-cyclic-dependency/lib/plugins.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -7e6be9e33a87194e7061f94f6be115619f91ada2 ?plugins.jar diff --git a/test/pending/neg/plugin-cyclic-dependency/misc/build.sh b/test/pending/neg/plugin-cyclic-dependency/misc/build.sh deleted file mode 100755 index 8899009d7f..0000000000 --- a/test/pending/neg/plugin-cyclic-dependency/misc/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" - -BASE=`pwd` - -if [[ -d "${BASE}/src" ]] ; then - - mkdir -p build - ${SCALAC} -d build src/*.scala - jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . - rm -rf build -fi - diff --git a/test/pending/neg/plugin-cyclic-dependency/testsource.scala b/test/pending/neg/plugin-cyclic-dependency/testsource.scala deleted file mode 100644 index f1513ec9a0..0000000000 --- a/test/pending/neg/plugin-cyclic-dependency/testsource.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends Application { - println("cyclicdependency") -} - diff --git a/test/pending/neg/plugin-multiple-rafter.check b/test/pending/neg/plugin-multiple-rafter.check deleted file mode 100644 index c54f884feb..0000000000 --- a/test/pending/neg/plugin-multiple-rafter.check +++ /dev/null @@ -1,4 +0,0 @@ -error: fatal error: Multiple phases want to run right after the phase explicitouter -Phases: erasure, multi-rafter, -Re-run with -Xgenerate-phase-graph <filename> to better see the problem. -one error found diff --git a/test/pending/neg/plugin-multiple-rafter.flags b/test/pending/neg/plugin-multiple-rafter.flags deleted file mode 100644 index dcae7f2f96..0000000000 --- a/test/pending/neg/plugin-multiple-rafter.flags +++ /dev/null @@ -1,2 +0,0 @@ --Xplugin:files/neg/plugin-multiple-rafter/lib/plugins.jar - diff --git a/test/pending/neg/plugin-multiple-rafter/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-multiple-rafter/lib/plugins.jar.desired.sha1 deleted file mode 100644 index f4905fcbd4..0000000000 --- a/test/pending/neg/plugin-multiple-rafter/lib/plugins.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -2bda582b574287429ad5ee2e1d9a3effc88b0a5f ?plugins.jar diff --git a/test/pending/neg/plugin-multiple-rafter/misc/build.sh b/test/pending/neg/plugin-multiple-rafter/misc/build.sh deleted file mode 100755 index 8899009d7f..0000000000 --- a/test/pending/neg/plugin-multiple-rafter/misc/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" - -BASE=`pwd` - -if [[ -d "${BASE}/src" ]] ; then - - mkdir -p build - ${SCALAC} -d build src/*.scala - jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . - rm -rf build -fi - diff --git a/test/pending/neg/plugin-multiple-rafter/testsource.scala b/test/pending/neg/plugin-multiple-rafter/testsource.scala deleted file mode 100644 index f73db1eb60..0000000000 --- a/test/pending/neg/plugin-multiple-rafter/testsource.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends Application { - println("multi-rafter") -} - diff --git a/test/pending/neg/plugin-rafter-before-1.check b/test/pending/neg/plugin-rafter-before-1.check deleted file mode 100644 index 19ed4d2fba..0000000000 --- a/test/pending/neg/plugin-rafter-before-1.check +++ /dev/null @@ -1,2 +0,0 @@ -error: fatal error: phase erasure want to run right after explicitouter, but some phase has declared to run before erasure. Re-run with -Xgenerate-phase-graph <filename> to better see the problem. -one error found diff --git a/test/pending/neg/plugin-rafter-before-1.flags b/test/pending/neg/plugin-rafter-before-1.flags deleted file mode 100644 index 8bf03145b9..0000000000 --- a/test/pending/neg/plugin-rafter-before-1.flags +++ /dev/null @@ -1,2 +0,0 @@ --Xplugin:files/neg/plugin-rafter-before-1/lib/plugins.jar - diff --git a/test/pending/neg/plugin-rafter-before-1/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-rafter-before-1/lib/plugins.jar.desired.sha1 deleted file mode 100644 index 8ad591b6ea..0000000000 --- a/test/pending/neg/plugin-rafter-before-1/lib/plugins.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -af91fd67ccef349e7f8ea662615e17796a339485 ?plugins.jar diff --git a/test/pending/neg/plugin-rafter-before-1/misc/build.sh b/test/pending/neg/plugin-rafter-before-1/misc/build.sh deleted file mode 100755 index 8899009d7f..0000000000 --- a/test/pending/neg/plugin-rafter-before-1/misc/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" - -BASE=`pwd` - -if [[ -d "${BASE}/src" ]] ; then - - mkdir -p build - ${SCALAC} -d build src/*.scala - jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . - rm -rf build -fi - diff --git a/test/pending/neg/plugin-rafter-before-1/testsource.scala b/test/pending/neg/plugin-rafter-before-1/testsource.scala deleted file mode 100644 index 836459db22..0000000000 --- a/test/pending/neg/plugin-rafter-before-1/testsource.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends Application { - println("rafter-before-1") -} - diff --git a/test/pending/neg/plugin-rightafter-terminal.flags b/test/pending/neg/plugin-rightafter-terminal.flags deleted file mode 100644 index 948a318668..0000000000 --- a/test/pending/neg/plugin-rightafter-terminal.flags +++ /dev/null @@ -1,2 +0,0 @@ --Xplugin:files/neg/plugin-rightafter-terminal/lib/plugins.jar - diff --git a/test/pending/neg/plugin-rightafter-terminal/lib/plugins.jar.desired.sha1 b/test/pending/neg/plugin-rightafter-terminal/lib/plugins.jar.desired.sha1 deleted file mode 100644 index c2e2b9cd43..0000000000 --- a/test/pending/neg/plugin-rightafter-terminal/lib/plugins.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -8cccde4914da2058dca893783c231cda23855603 ?plugins.jar diff --git a/test/pending/neg/plugin-rightafter-terminal/misc/build.sh b/test/pending/neg/plugin-rightafter-terminal/misc/build.sh deleted file mode 100755 index 8899009d7f..0000000000 --- a/test/pending/neg/plugin-rightafter-terminal/misc/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -SCALAC="../../../../build/pack/bin/scalac -deprecation -cp ../../../../build/quick/classes/compiler/" - -BASE=`pwd` - -if [[ -d "${BASE}/src" ]] ; then - - mkdir -p build - ${SCALAC} -d build src/*.scala - jar cf lib/plugins.jar -C misc/ scalac-plugin.xml -C build . - rm -rf build -fi - diff --git a/test/pending/neg/plugin-rightafter-terminal/misc/scalac-plugin.xml b/test/pending/neg/plugin-rightafter-terminal/misc/scalac-plugin.xml deleted file mode 100644 index 90ff27dc2a..0000000000 --- a/test/pending/neg/plugin-rightafter-terminal/misc/scalac-plugin.xml +++ /dev/null @@ -1,5 +0,0 @@ -<plugin> - <name>beforeparser</name> - <classname>scala.test.plugins.ThePlugin</classname> -</plugin> - diff --git a/test/pending/neg/plugin-rightafter-terminal/testsource.scala b/test/pending/neg/plugin-rightafter-terminal/testsource.scala deleted file mode 100644 index 7af767b638..0000000000 --- a/test/pending/neg/plugin-rightafter-terminal/testsource.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends Application { - println("rightafterterminal") -} - diff --git a/test/pending/neg/t5353.check b/test/pending/neg/t5353.check deleted file mode 100644 index 75e2435600..0000000000 --- a/test/pending/neg/t5353.check +++ /dev/null @@ -1,4 +0,0 @@ -t5353.scala:2: error: this type parameter must be specified - def f(x: Boolean) = if (x) Array("abc") else Array() - ^ -one error found diff --git a/test/pending/neg/t5353.scala b/test/pending/neg/t5353.scala deleted file mode 100644 index 1ee869aac1..0000000000 --- a/test/pending/neg/t5353.scala +++ /dev/null @@ -1,3 +0,0 @@ -class A { - def f(x: Boolean) = if (x) Array("abc") else Array() -} diff --git a/test/files/neg/t5589neg.flags b/test/pending/neg/t5589neg.flags index dcc59ebe32..dcc59ebe32 100644 --- a/test/files/neg/t5589neg.flags +++ b/test/pending/neg/t5589neg.flags diff --git a/test/files/neg/t5589neg2.check b/test/pending/neg/t5589neg2.check index 6af4955a83..6af4955a83 100644 --- a/test/files/neg/t5589neg2.check +++ b/test/pending/neg/t5589neg2.check diff --git a/test/pending/neg/t6680a.scala b/test/pending/neg/t6680a.scala new file mode 100644 index 0000000000..745334b1cd --- /dev/null +++ b/test/pending/neg/t6680a.scala @@ -0,0 +1,13 @@ +case class Cell[A](var x: A) +object Test { + def f1(x: Any) = x match { case y @ Cell(_) => y } // Inferred type is Cell[Any] + // def f2(x: Cell[_]) = x match { case y @ Cell(_) => y } // Inferred type is Cell[_] + // def f3[A](x: Cell[A]) = x match { case y @ Cell(_) => y } // Inferred type is Cell[A] + + def main(args: Array[String]): Unit = { + // val x = new Cell(1) + // val y = f1(x) + // y.x = "abc" + // println(x.x + 1) + } +}
\ No newline at end of file diff --git a/test/pending/neg/t6680b.check b/test/pending/neg/t6680b.check new file mode 100644 index 0000000000..a16812d91d --- /dev/null +++ b/test/pending/neg/t6680b.check @@ -0,0 +1,6 @@ +t6680b.scala:8: error: type mismatch; + found : String("not what you\'d expect") + required: ?Hidden1 where type ?Hidden1 (this is a GADT skolem) + case Concrete(f) => f("not what you'd expect") + ^ +one error found diff --git a/test/pending/neg/t6680b.scala b/test/pending/neg/t6680b.scala new file mode 100644 index 0000000000..e9f6468315 --- /dev/null +++ b/test/pending/neg/t6680b.scala @@ -0,0 +1,10 @@ +trait Super[+A] +// `Hidden` must occur in both variance positions (covariant/contravariant) for the sneakiness to work +// this way type inference will infer Any for `Hidden` and `A` in the pattern below +case class Concrete[Hidden, +A](havoc: Hidden => Hidden) extends Super[A] + +object Test extends App { + (Concrete((x: Int) => x): Super[Any]) match { + case Concrete(f) => f("not what you'd expect") + } +}
\ No newline at end of file diff --git a/test/pending/neg/t6680c.scala b/test/pending/neg/t6680c.scala new file mode 100644 index 0000000000..f69663a71b --- /dev/null +++ b/test/pending/neg/t6680c.scala @@ -0,0 +1,17 @@ +package s + +trait Stream[+A] +case class Unfold[S,+A](s: S, f: S => Option[(A,S)]) extends Stream[A] + +object Stream { + def fromList[A](a: List[A]): Stream[A] = + Unfold(a, (l:List[A]) => l.headOption.map((_,l.tail))) +} + +object Test { + def main(args: Array[String]): Unit = { + val res = Stream.fromList(List(1,2,3,4)) + + res match { case Unfold(s, f) => f("a string!") } + } +} diff --git a/test/pending/pos/no-widen-locals.flags b/test/pending/pos/no-widen-locals.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/pending/pos/no-widen-locals.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/pending/pos/overloading-boundaries.scala b/test/pending/pos/overloading-boundaries.scala new file mode 100644 index 0000000000..d2e9fdbb12 --- /dev/null +++ b/test/pending/pos/overloading-boundaries.scala @@ -0,0 +1,37 @@ +package bar { + object bippy extends (Double => String) { + def apply(x: Double): String = "Double" + } +} + +package object bar { + def bippy(x: Int, y: Int, z: Int) = "(Int, Int, Int)" +} + +object Test { + def main(args: Array[String]): Unit = { + println(bar.bippy(5.5d)) + println(bar.bippy(1, 2, 3)) + } +} + +/**** + +% scalac3 a.scala +a.scala:13: error: not enough arguments for method bippy: (x: Int, y: Int, z: Int)String. +Unspecified value parameters y, z. + println(bar.bippy(5.5d)) + ^ +one error found + +# Comment out the call to bar.bippy(5.5d) - compiles +% scalac3 a.scala + +# Compiles only from pure source though - if classes are present, fails. +% scalac3 a.scala +a.scala:2: error: bippy is already defined as method bippy in package object bar + object bippy extends (Double => String) { + ^ +one error found + +****/ diff --git a/test/pending/pos/t1751.cmds b/test/pending/pos/t1751.cmds deleted file mode 100644 index d4a4898ffd..0000000000 --- a/test/pending/pos/t1751.cmds +++ /dev/null @@ -1,3 +0,0 @@ -javac SuiteClasses.java -scalac A2_1.scala -scalac A1_2.scala diff --git a/test/pending/pos/t1782.cmds b/test/pending/pos/t1782.cmds deleted file mode 100644 index 61f3d3788e..0000000000 --- a/test/pending/pos/t1782.cmds +++ /dev/null @@ -1,2 +0,0 @@ -javac Ann.java Days.java ImplementedBy.java -scalac Test_1.scala diff --git a/test/pending/pos/t1786.scala b/test/pending/pos/t1786.scala deleted file mode 100644 index dca2edaab4..0000000000 --- a/test/pending/pos/t1786.scala +++ /dev/null @@ -1,20 +0,0 @@ -/** This a consequence of the current type checking algorithm, where bounds - * are checked only after variables are instantiated. I believe this will change once we go to contraint-based type inference. Assigning low priority until then. - * - * - */ -class SomeClass(val intValue:Int) -class MyClass[T <: SomeClass](val myValue:T) - -object Test extends Application { - def myMethod(i:MyClass[_]) { - i.myValue.intValue/2 // << error i is of type Any - } - - def myMethod(i:MyClass[_ <: SomeClass]) { - i.myValue.intValue/2 // << works - } -} -/* -The below code shows a compiler flaw in that the wildcard "_" as value for a bounded type parameter either breaks the boundry - as it result in Any - or doesnt (as id hoped it to be) evaluates to the boundy. -*/ diff --git a/test/pending/pos/t1832.scala b/test/pending/pos/t1832.scala deleted file mode 100644 index bca863f4bd..0000000000 --- a/test/pending/pos/t1832.scala +++ /dev/null @@ -1,10 +0,0 @@ -// Edit by paulp: reduced. -trait Cloning { - trait Foo - def fn(g: Int => Unit): Foo - - implicit def mkStar(i: Int) = new { def *(a: Foo): Foo = null } - - val pool1 = 4 * fn { case i => i * 2 } - val pool2 = 4 * fn { case i: Int => i * 2 } -} diff --git a/test/pending/pos/t294.cmds b/test/pending/pos/t294.cmds deleted file mode 100644 index 62c9a5a068..0000000000 --- a/test/pending/pos/t294.cmds +++ /dev/null @@ -1,3 +0,0 @@ -javac Ann.java Ann2.java -scalac Test_1.scala -scalac Test_2.scala diff --git a/test/pending/pos/t4612.scala b/test/pending/pos/t4612.scala new file mode 100644 index 0000000000..a93c12ef01 --- /dev/null +++ b/test/pending/pos/t4612.scala @@ -0,0 +1,15 @@ +class CyclicReferenceCompilerBug { + trait Trait[A] { + def foo: A + } + + class Class extends Trait[Class] { + def foo = new Class + + trait OtherTrait extends Trait[OtherTrait] { + self: Class => + + def foo = new Class + } + } +} diff --git a/test/pending/pos/t4695/T_1.scala b/test/pending/pos/t4695/T_1.scala new file mode 100644 index 0000000000..70fb1a7f21 --- /dev/null +++ b/test/pending/pos/t4695/T_1.scala @@ -0,0 +1,4 @@ +package foo + +class Bar { } +package object Bar { } diff --git a/test/pending/pos/t4695/T_2.scala b/test/pending/pos/t4695/T_2.scala new file mode 100644 index 0000000000..70fb1a7f21 --- /dev/null +++ b/test/pending/pos/t4695/T_2.scala @@ -0,0 +1,4 @@ +package foo + +class Bar { } +package object Bar { } diff --git a/test/pending/pos/t4717.scala b/test/pending/pos/t4717.scala deleted file mode 100644 index 7eaa3dd487..0000000000 --- a/test/pending/pos/t4717.scala +++ /dev/null @@ -1,7 +0,0 @@ -trait Bounds[@specialized A] { - // okay without `>: A` - def x[B >: A]: Unit = new Bounds[B] { - lazy val it = ??? // def or val okay - it - } -}
\ No newline at end of file diff --git a/test/pending/pos/t5082.scala b/test/pending/pos/t5082.scala new file mode 100644 index 0000000000..20a6cfc55f --- /dev/null +++ b/test/pending/pos/t5082.scala @@ -0,0 +1,8 @@ +object Test { + sealed trait A + case object A1 extends A +} + +trait Something[T] + +case class Test() extends Something[Test.A] diff --git a/test/pending/pos/t5259.scala b/test/pending/pos/t5259.scala deleted file mode 100644 index 317e28a9dc..0000000000 --- a/test/pending/pos/t5259.scala +++ /dev/null @@ -1,14 +0,0 @@ -object DefaultArgBogusTypeMismatch { - - class A[T] - class B { - type T = this.type - def m(implicit a : A[T] = new A[T]) = a - } - - def newB = new B - val a1 = newB.m // Bogus type mismatch - - val stableB = new B - val a2 = stableB.m // OK -} diff --git a/test/pending/pos/t5399.scala b/test/pending/pos/t5399.scala deleted file mode 100644 index 89caba39c1..0000000000 --- a/test/pending/pos/t5399.scala +++ /dev/null @@ -1,8 +0,0 @@ -class Test { - class A[T] - class B[T](val a: A[T]) - - case class CaseClass[T](x: T) - - def break(existB: B[_]) = CaseClass(existB.a) match { case CaseClass(_) => } -} diff --git a/test/pending/pos/t5626.scala b/test/pending/pos/t5626.scala deleted file mode 100644 index 7ab3881827..0000000000 --- a/test/pending/pos/t5626.scala +++ /dev/null @@ -1,12 +0,0 @@ -object Test { - val blob0 = new { - case class Foo(i : Int) - } - val foo0 = blob0.Foo(22) - - val blob1 = new { - class Foo(i: Int) - object Foo { def apply(i: Int): Foo = new Foo(i) } - } - val foo1 = blob1.Foo(22) -} diff --git a/test/pending/pos/t5654.scala b/test/pending/pos/t5654.scala deleted file mode 100644 index eb711a5f37..0000000000 --- a/test/pending/pos/t5654.scala +++ /dev/null @@ -1,4 +0,0 @@ -case class Bomb(a: Array[_]) -case class Bomb2(a: Array[T] forSome { type T }) -class Okay1(a: Array[_]) -case class Okay2(s: Seq[_])
\ No newline at end of file diff --git a/test/pending/pos/t5877.scala b/test/pending/pos/t5877.scala new file mode 100644 index 0000000000..b77605f7f2 --- /dev/null +++ b/test/pending/pos/t5877.scala @@ -0,0 +1,5 @@ +package foo { } + +package object foo { + implicit class Foo(val s: String) { } +} diff --git a/test/pending/pos/t5954/T_1.scala b/test/pending/pos/t5954/T_1.scala new file mode 100644 index 0000000000..0064c596b6 --- /dev/null +++ b/test/pending/pos/t5954/T_1.scala @@ -0,0 +1,8 @@ +package p { + package base { + class X + } + package object base { + case class B() + } +} diff --git a/test/pending/pos/t5954/T_2.scala b/test/pending/pos/t5954/T_2.scala new file mode 100644 index 0000000000..0064c596b6 --- /dev/null +++ b/test/pending/pos/t5954/T_2.scala @@ -0,0 +1,8 @@ +package p { + package base { + class X + } + package object base { + case class B() + } +} diff --git a/test/pending/pos/t5954/T_3.scala b/test/pending/pos/t5954/T_3.scala new file mode 100644 index 0000000000..0064c596b6 --- /dev/null +++ b/test/pending/pos/t5954/T_3.scala @@ -0,0 +1,8 @@ +package p { + package base { + class X + } + package object base { + case class B() + } +} diff --git a/test/pending/pos/t6225.scala b/test/pending/pos/t6225.scala new file mode 100644 index 0000000000..d7dff3c419 --- /dev/null +++ b/test/pending/pos/t6225.scala @@ -0,0 +1,11 @@ +package library.x { + class X { + class Foo + implicit val foo = new Foo + } +} +package library { package object x extends X } +package app { + import library.x._ + object App { implicitly[Foo] } +} diff --git a/test/pending/pos/those-kinds-are-high.scala b/test/pending/pos/those-kinds-are-high.scala index 434e64cefb..78367cb746 100644 --- a/test/pending/pos/those-kinds-are-high.scala +++ b/test/pending/pos/those-kinds-are-high.scala @@ -4,18 +4,18 @@ class A { class C1[T] extends Template[C1] with Container[T] class C2[T] extends Template[C2] with Container[T] - + /** Target expression: * List(new C1[String], new C2[String]) */ - + // Here's what would ideally be inferred. // // scala> :type List[Template[Container] with Container[String]](new C1[String], new C2[String]) // List[Template[Container] with Container[java.lang.String]] // // Here's what it does infer. - // + // // scala> :type List(new C1[String], new C2[String]) // <console>:8: error: type mismatch; // found : C1[String] @@ -43,11 +43,54 @@ class A { // def fFail = List(new C1[String], new C2[String]) // ^ // two errors found - + /** Working version explicitly typed. */ def fExplicit = List[Template[Container] with Container[String]](new C1[String], new C2[String]) - + // nope def fFail = List(new C1[String], new C2[String]) } + + +trait Other { + trait GenBar[+A] + trait Bar[+A] extends GenBar[A] + trait Templ[+A, +CC[X] <: GenBar[X]] + + abstract class CC1[+A] extends Templ[A, CC1] with Bar[A] + abstract class CC2[+A] extends Templ[A, CC2] with Bar[A] + + // Compiles + class A1 { + abstract class BarFactory[CC[X] <: Bar[X]] + + def f(x: Boolean) = if (x) (null: BarFactory[CC1]) else (null: BarFactory[CC2]) + } + + // Fails - only difference is CC covariant. + class A2 { + abstract class BarFactory[+CC[X] <: Bar[X]] + + def f(x: Boolean) = if (x) (null: BarFactory[CC1]) else (null: BarFactory[CC2]) + // c.scala:23: error: kinds of the type arguments (Bar with Templ[Any,Bar]) do not conform to the expected kinds of the type parameters (type CC) in class BarFactory. + // Bar with Templ[Any,Bar]'s type parameters do not match type CC's expected parameters: + // <empty> has no type parameters, but type CC has one + // def f(x: Boolean) = if (x) (null: BarFactory[CC1]) else (null: BarFactory[CC2]) + // ^ + // one error found + } + + // Compiles - CC contravariant. + class A3 { + abstract class BarFactory[-CC[X] <: Bar[X]] // with Templ[X, CC]] + + def f(x: Boolean) = if (x) (null: BarFactory[CC1]) else (null: BarFactory[CC2]) + // c.scala:23: error: kinds of the type arguments (Bar with Templ[Any,Bar]) do not conform to the expected kinds of the type parameters (type CC) in class BarFactory. + // Bar with Templ[Any,Bar]'s type parameters do not match type CC's expected parameters: + // <empty> has no type parameters, but type CC has one + // def f(x: Boolean) = if (x) (null: BarFactory[CC1]) else (null: BarFactory[CC2]) + // ^ + // one error found + } +} diff --git a/test/pending/pos/treecheckers.flags b/test/pending/pos/treecheckers.flags new file mode 100644 index 0000000000..5319681590 --- /dev/null +++ b/test/pending/pos/treecheckers.flags @@ -0,0 +1 @@ +-Ycheck:all
\ No newline at end of file diff --git a/test/pending/pos/treecheckers/c1.scala b/test/pending/pos/treecheckers/c1.scala new file mode 100644 index 0000000000..b936839039 --- /dev/null +++ b/test/pending/pos/treecheckers/c1.scala @@ -0,0 +1,12 @@ +object Test1 { + def f[T](xs: Array[T]): Array[T] = xs match { case xs => xs } + // [check: patmat] The symbol, tpe or info of tree `(x) : Array[T]` refers to a out-of-scope symbol, type T. tree.symbol.ownerChain: value x + // [check: patmat] The symbol, tpe or info of tree `(x) : Array[T]` refers to a out-of-scope symbol, type T. tree.symbol.ownerChain: value x + + def g[T](xs: Array[T]): Array[T] = { + val x1: Array[T] = xs + def case4() = matchEnd3(x1) + def matchEnd3(x: Array[T]) = x + case4() + } +} diff --git a/test/pending/pos/treecheckers/c2.scala b/test/pending/pos/treecheckers/c2.scala new file mode 100644 index 0000000000..c893a5c922 --- /dev/null +++ b/test/pending/pos/treecheckers/c2.scala @@ -0,0 +1 @@ +class Test2(val valueVal: Int) extends AnyVal diff --git a/test/pending/pos/treecheckers/c3.scala b/test/pending/pos/treecheckers/c3.scala new file mode 100644 index 0000000000..e480bbfb08 --- /dev/null +++ b/test/pending/pos/treecheckers/c3.scala @@ -0,0 +1,8 @@ +import scala.collection.mutable.ArrayOps + +object Test3 { + implicit def genericArrayOps[T](xs: Array[T]): ArrayOps[T] = (xs match { + case x: Array[AnyRef] => refArrayOps[AnyRef](x) + case x: Array[Boolean] => booleanArrayOps(x) + }).asInstanceOf[ArrayOps[T]] +} diff --git a/test/pending/pos/treecheckers/c4.scala b/test/pending/pos/treecheckers/c4.scala new file mode 100644 index 0000000000..2328131770 --- /dev/null +++ b/test/pending/pos/treecheckers/c4.scala @@ -0,0 +1,9 @@ +sealed trait Message[+A] +class Script[A] extends Message[A] { + def iterator: Iterator[Message[A]] = ??? +} + +trait Test4[A] { + def f(cmd: Message[A]): Iterator[A] = cmd match { case s: Script[t] => s.iterator flatMap f } + def g(cmd: Message[A]) = cmd match { case s: Script[t] => s } +} diff --git a/test/pending/pos/treecheckers/c5.scala b/test/pending/pos/treecheckers/c5.scala new file mode 100644 index 0000000000..43cbb65d74 --- /dev/null +++ b/test/pending/pos/treecheckers/c5.scala @@ -0,0 +1,3 @@ +trait Factory[CC[X] <: Traversable[X]] + +object Test5 extends Factory[Traversable] diff --git a/test/pending/pos/treecheckers/c6.scala b/test/pending/pos/treecheckers/c6.scala new file mode 100644 index 0000000000..8283655f3a --- /dev/null +++ b/test/pending/pos/treecheckers/c6.scala @@ -0,0 +1,4 @@ +object Test6 { + import scala.reflect.ClassTag + def f[T: ClassTag] = implicitly[ClassTag[T]].runtimeClass match { case x => x } +} diff --git a/test/pending/pos/z1720.scala b/test/pending/pos/z1720.scala deleted file mode 100644 index 6050f3ff88..0000000000 --- a/test/pending/pos/z1720.scala +++ /dev/null @@ -1,16 +0,0 @@ -package test - -class Thing { - def info: Info[this.type] = InfoRepository.getInfo(this) - def info2: Info[this.type] = { - def self: this.type = this - InfoRepository.getInfo(self) - } -} - -trait Info[T] -case class InfoImpl[T](thing: T) extends Info[T] - -object InfoRepository { - def getInfo(t: Thing): Info[t.type] = InfoImpl(t) -}
\ No newline at end of file diff --git a/test/pending/run/hk-lub-fail.scala b/test/pending/run/hk-lub-fail.scala index b58a86ee75..0ac4fdd841 100644 --- a/test/pending/run/hk-lub-fail.scala +++ b/test/pending/run/hk-lub-fail.scala @@ -25,12 +25,12 @@ object Test { // A repl session to get you started. /* - val quux1 = EmptyPackageClass.tpe.member(newTermName("Quux1")) - val quux2 = EmptyPackageClass.tpe.member(newTermName("Quux2")) + val quux1 = EmptyPackageClass.tpe.member(TermName("Quux1")) + val quux2 = EmptyPackageClass.tpe.member(TermName("Quux2")) val tps = List(quux1, quux2) map (_.tpe) - val test = EmptyPackageClass.tpe.member(newTermName("Test")) - val f = test.tpe.member(newTypeName("F")).tpe - + val test = EmptyPackageClass.tpe.member(TermName("Test")) + val f = test.tpe.member(TypeName("F")).tpe + val fn = f.normalize.asInstanceOf[ExistentialType] val fn2 = fn.underlying.asInstanceOf[TypeRef] */ diff --git a/test/pending/run/macro-expand-default/Impls_1.scala b/test/pending/run/macro-expand-default/Impls_1.scala index 7cf8d59c75..bb55f02ab2 100644 --- a/test/pending/run/macro-expand-default/Impls_1.scala +++ b/test/pending/run/macro-expand-default/Impls_1.scala @@ -3,8 +3,8 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._ - val sum = Apply(Select(x.tree, newTermName("$minus")), List(y.tree)) - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + val sum = Apply(Select(x.tree, TermName("$minus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala b/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala index be00fd0d8a..eed68280cd 100644 --- a/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala +++ b/test/pending/run/macro-expand-macro-has-context-bound/Impls_1.scala @@ -3,8 +3,8 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo[U](c: Ctx)(x: c.Expr[U])(evidence: c.Expr[Numeric[U]]) = { import c.universe._ - val plusOne = Apply(Select(evidence.tree, newTermName("plus")), List(x.tree, Literal(Constant(1)))) - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(plusOne)) + val plusOne = Apply(Select(evidence.tree, TermName("plus")), List(x.tree, Literal(Constant(1)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(plusOne)) Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/pending/run/macro-expand-named/Impls_1.scala b/test/pending/run/macro-expand-named/Impls_1.scala index 7cf8d59c75..bb55f02ab2 100644 --- a/test/pending/run/macro-expand-named/Impls_1.scala +++ b/test/pending/run/macro-expand-named/Impls_1.scala @@ -3,8 +3,8 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._ - val sum = Apply(Select(x.tree, newTermName("$minus")), List(y.tree)) - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + val sum = Apply(Select(x.tree, TermName("$minus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala index 26de70cc12..487ac79673 100644 --- a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala @@ -4,9 +4,9 @@ object Impls { def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } }
\ No newline at end of file diff --git a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala index 26de70cc12..487ac79673 100644 --- a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala @@ -4,9 +4,9 @@ object Impls { def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } }
\ No newline at end of file diff --git a/test/pending/run/macro-reify-tagless-b/Test_2.scala b/test/pending/run/macro-reify-tagless-b/Test_2.scala index 10487b1515..09ca6ba30e 100644 --- a/test/pending/run/macro-reify-tagless-b/Test_2.scala +++ b/test/pending/run/macro-reify-tagless-b/Test_2.scala @@ -6,8 +6,8 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tpt = AppliedTypeTree(Ident(definitions.ListClass), List(Ident(definitions.StringClass))) - val rhs = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant("hello world")))) - val list = ValDef(NoMods, newTermName("list"), tpt, rhs) - val tree = Block(list, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name)))) + val rhs = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant("hello world")))) + val list = ValDef(NoMods, TermName("list"), tpt, rhs) + val tree = Block(list, Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Ident(list.name)))) println(cm.mkToolBox().eval(tree)) } diff --git a/test/pending/run/macro-term-declared-in-anonymous-explicit-import.check b/test/pending/run/macro-term-declared-in-anonymous-explicit-import.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/pending/run/macro-term-declared-in-anonymous-explicit-import.check diff --git a/test/pending/run/macro-term-declared-in-anonymous-explicit-import/Impls_1.scala b/test/pending/run/macro-term-declared-in-anonymous-explicit-import/Impls_1.scala new file mode 100644 index 0000000000..348f3420f2 --- /dev/null +++ b/test/pending/run/macro-term-declared-in-anonymous-explicit-import/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-anonymous/Macros_Test_2.scala b/test/pending/run/macro-term-declared-in-anonymous-explicit-import/Macros_Test_2.scala index 8bd8c172c9..dd2317b1b7 100644 --- a/test/files/run/macro-declared-in-anonymous/Macros_Test_2.scala +++ b/test/pending/run/macro-term-declared-in-anonymous-explicit-import/Macros_Test_2.scala @@ -1,3 +1,5 @@ +import language.experimental.macros + object Test extends App { val macros = new { def foo = macro Impls.foo } macros.foo diff --git a/test/pending/run/t5427a.scala b/test/pending/run/t5427a.scala index f7cd05158d..a7d20922db 100644 --- a/test/pending/run/t5427a.scala +++ b/test/pending/run/t5427a.scala @@ -4,7 +4,7 @@ object Foo { val bar = 2 } object Test extends App { val tpe = getType(Foo) - val bar = tpe.nonPrivateMember(newTermName("bar")) + val bar = tpe.nonPrivateMember(TermName("bar")) val value = getValue(Foo, bar) println(value) }
\ No newline at end of file diff --git a/test/pending/run/t5427b.scala b/test/pending/run/t5427b.scala index e80bd12369..af1ae6ea2f 100644 --- a/test/pending/run/t5427b.scala +++ b/test/pending/run/t5427b.scala @@ -5,7 +5,7 @@ class Foo { val bar = 2 } object Test extends App { val foo = new Foo val tpe = getType(foo) - val bar = tpe.nonPrivateMember(newTermName("bar")) + val bar = tpe.nonPrivateMember(TermName("bar")) val value = getValue(foo, bar) println(value) }
\ No newline at end of file diff --git a/test/pending/run/t5427c.scala b/test/pending/run/t5427c.scala index 7095158e85..ba71803080 100644 --- a/test/pending/run/t5427c.scala +++ b/test/pending/run/t5427c.scala @@ -5,7 +5,7 @@ class Foo(bar: Int) object Test extends App { val foo = new Foo(2) val tpe = getType(foo) - val bar = tpe.nonPrivateMember(newTermName("bar")) + val bar = tpe.nonPrivateMember(TermName("bar")) bar match { case NoSymbol => println("no public member") case _ => println("i'm screwed") diff --git a/test/pending/run/t5427d.scala b/test/pending/run/t5427d.scala index f0cc07d27e..1d37dbdde3 100644 --- a/test/pending/run/t5427d.scala +++ b/test/pending/run/t5427d.scala @@ -5,7 +5,7 @@ class Foo(val bar: Int) object Test extends App { val foo = new Foo(2) val tpe = getType(foo) - val bar = tpe.nonPrivateMember(newTermName("bar")) + val bar = tpe.nonPrivateMember(TermName("bar")) val value = getValue(foo, bar) println(value) }
\ No newline at end of file diff --git a/test/files/run/t7733.check b/test/pending/run/t7733.check index 19765bd501..19765bd501 100644 --- a/test/files/run/t7733.check +++ b/test/pending/run/t7733.check diff --git a/test/files/run/t7733/Separate_1.scala b/test/pending/run/t7733/Separate_1.scala index a326ecd53e..a326ecd53e 100644 --- a/test/files/run/t7733/Separate_1.scala +++ b/test/pending/run/t7733/Separate_1.scala diff --git a/test/files/run/t7733/Test_2.scala b/test/pending/run/t7733/Test_2.scala index 28358574ec..28358574ec 100644 --- a/test/files/run/t7733/Test_2.scala +++ b/test/pending/run/t7733/Test_2.scala diff --git a/test/postreview.py b/test/postreview.py deleted file mode 100644 index 2e2518f7ee..0000000000 --- a/test/postreview.py +++ /dev/null @@ -1,2540 +0,0 @@ -#!/usr/bin/env python -import cookielib -import difflib -import getpass -import marshal -import mimetools -import ntpath -import os -import re -import socket -import stat -import subprocess -import sys -import tempfile -import urllib -import urllib2 -from optparse import OptionParser -from tempfile import mkstemp -from urlparse import urljoin, urlparse - -try: - from hashlib import md5 -except ImportError: - # Support Python versions before 2.5. - from md5 import md5 - -try: - import json -except ImportError: - import simplejson as json - -# This specific import is necessary to handle the paths for -# cygwin enabled machines. -if (sys.platform.startswith('win') - or sys.platform.startswith('cygwin')): - import ntpath as cpath -else: - import posixpath as cpath - -### -# Default configuration -- user-settable variables follow. -### - -# The following settings usually aren't needed, but if your Review -# Board crew has specific preferences and doesn't want to express -# them with command line switches, set them here and you're done. -# In particular, setting the REVIEWBOARD_URL variable will allow -# you to make it easy for people to submit reviews regardless of -# their SCM setup. -# -# Note that in order for this script to work with a reviewboard site -# that uses local paths to access a repository, the 'Mirror path' -# in the repository setup page must be set to the remote URL of the -# repository. - -# -# Reviewboard URL. -# -# Set this if you wish to hard-code a default server to always use. -# It's generally recommended to set this using your SCM repository -# (for those that support it -- currently only SVN, Git, and Perforce). -# -# For example, on SVN: -# $ svn propset reviewboard:url http://reviewboard.example.com . -# -# Or with Git: -# $ git config reviewboard.url http://reviewboard.example.com -# -# On Perforce servers version 2008.1 and above: -# $ p4 counter reviewboard.url http://reviewboard.example.com -# -# Older Perforce servers only allow numerical counters, so embedding -# the url in the counter name is also supported: -# $ p4 counter reviewboard.url.http:\|\|reviewboard.example.com 1 -# -# Note that slashes are not allowed in Perforce counter names, so replace them -# with pipe characters (they are a safe substitute as they are not used -# unencoded in URLs). You may need to escape them when issuing the p4 counter -# command as above. -# -# If this is not possible or desired, setting the value here will let -# you get started quickly. -# -# For all other repositories, a .reviewboardrc file present at the top of -# the checkout will also work. For example: -# -# $ cat .reviewboardrc -# REVIEWBOARD_URL = "http://reviewboard.example.com" -# -REVIEWBOARD_URL = None - -# Default submission arguments. These are all optional; run this -# script with --help for descriptions of each argument. -TARGET_GROUPS = None -TARGET_PEOPLE = None -SUBMIT_AS = None -PUBLISH = False -OPEN_BROWSER = False - -# Debugging. For development... -DEBUG = False - -### -# End user-settable variables. -### - - -VERSION = "0.8" - -user_config = None -tempfiles = [] -options = None - - -class APIError(Exception): - pass - - -class RepositoryInfo: - """ - A representation of a source code repository. - """ - def __init__(self, path=None, base_path=None, supports_changesets=False, - supports_parent_diffs=False): - self.path = path - self.base_path = base_path - self.supports_changesets = supports_changesets - self.supports_parent_diffs = supports_parent_diffs - debug("repository info: %s" % self) - - def __str__(self): - return "Path: %s, Base path: %s, Supports changesets: %s" % \ - (self.path, self.base_path, self.supports_changesets) - - def set_base_path(self, base_path): - if not base_path.startswith('/'): - base_path = '/' + base_path - debug("changing repository info base_path from %s to %s" % \ - (self.base_path, base_path)) - self.base_path = base_path - - def find_server_repository_info(self, server): - """ - Try to find the repository from the list of repositories on the server. - For Subversion, this could be a repository with a different URL. For - all other clients, this is a noop. - """ - return self - - -class SvnRepositoryInfo(RepositoryInfo): - """ - A representation of a SVN source code repository. This version knows how to - find a matching repository on the server even if the URLs differ. - """ - def __init__(self, path, base_path, uuid, supports_parent_diffs=False): - RepositoryInfo.__init__(self, path, base_path, - supports_parent_diffs=supports_parent_diffs) - self.uuid = uuid - - def find_server_repository_info(self, server): - """ - The point of this function is to find a repository on the server that - matches self, even if the paths aren't the same. (For example, if self - uses an 'http' path, but the server uses a 'file' path for the same - repository.) It does this by comparing repository UUIDs. If the - repositories use the same path, you'll get back self, otherwise you'll - get a different SvnRepositoryInfo object (with a different path). - """ - repositories = server.get_repositories() - - for repository in repositories: - if repository['tool'] != 'Subversion': - continue - - info = self._get_repository_info(server, repository) - - if not info or self.uuid != info['uuid']: - continue - - repos_base_path = info['url'][len(info['root_url']):] - relpath = self._get_relative_path(self.base_path, repos_base_path) - if relpath: - return SvnRepositoryInfo(info['url'], relpath, self.uuid) - - # We didn't find a matching repository on the server. We'll just return - # self and hope for the best. - return self - - def _get_repository_info(self, server, repository): - try: - return server.get_repository_info(repository['id']) - except APIError, e: - # If the server couldn't fetch the repository info, it will return - # code 210. Ignore those. - # Other more serious errors should still be raised, though. - rsp = e.args[0] - if rsp['err']['code'] == 210: - return None - - raise e - - def _get_relative_path(self, path, root): - pathdirs = self._split_on_slash(path) - rootdirs = self._split_on_slash(root) - - # root is empty, so anything relative to that is itself - if len(rootdirs) == 0: - return path - - # If one of the directories doesn't match, then path is not relative - # to root. - if rootdirs != pathdirs: - return None - - # All the directories matched, so the relative path is whatever - # directories are left over. The base_path can't be empty, though, so - # if the paths are the same, return '/' - if len(pathdirs) == len(rootdirs): - return '/' - else: - return '/'.join(pathdirs[len(rootdirs):]) - - def _split_on_slash(self, path): - # Split on slashes, but ignore multiple slashes and throw away any - # trailing slashes. - split = re.split('/*', path) - if split[-1] == '': - split = split[0:-1] - return split - - -class ReviewBoardHTTPPasswordMgr(urllib2.HTTPPasswordMgr): - """ - Adds HTTP authentication support for URLs. - - Python 2.4's password manager has a bug in http authentication when the - target server uses a non-standard port. This works around that bug on - Python 2.4 installs. This also allows post-review to prompt for passwords - in a consistent way. - - See: http://bugs.python.org/issue974757 - """ - def __init__(self, reviewboard_url): - self.passwd = {} - self.rb_url = reviewboard_url - self.rb_user = None - self.rb_pass = None - - def find_user_password(self, realm, uri): - if uri.startswith(self.rb_url): - if self.rb_user is None or self.rb_pass is None: - print "==> HTTP Authentication Required" - print 'Enter username and password for "%s" at %s' % \ - (realm, urlparse(uri)[1]) - self.rb_user = raw_input('Username: ') - self.rb_pass = getpass.getpass('Password: ') - - return self.rb_user, self.rb_pass - else: - # If this is an auth request for some other domain (since HTTP - # handlers are global), fall back to standard password management. - return urllib2.HTTPPasswordMgr.find_user_password(self, realm, uri) - - -class ReviewBoardServer(object): - """ - An instance of a Review Board server. - """ - def __init__(self, url, info, cookie_file): - self.url = url - if self.url[-1] != '/': - self.url += '/' - self._info = info - self._server_info = None - self.cookie_file = cookie_file - self.cookie_jar = cookielib.MozillaCookieJar(self.cookie_file) - - # Set up the HTTP libraries to support all of the features we need. - cookie_handler = urllib2.HTTPCookieProcessor(self.cookie_jar) - password_mgr = ReviewBoardHTTPPasswordMgr(self.url) - auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr) - - opener = urllib2.build_opener(cookie_handler, auth_handler) - opener.addheaders = [('User-agent', 'post-review/' + VERSION)] - urllib2.install_opener(opener) - - def login(self, force=False): - """ - Logs in to a Review Board server, prompting the user for login - information if needed. - """ - if not force and self.has_valid_cookie(): - return - - print "==> Review Board Login Required" - print "Enter username and password for Review Board at %s" % self.url - if options.username: - username = options.username - elif options.submit_as: - username = options.submit_as - else: - username = raw_input('Username: ') - - if not options.password: - password = getpass.getpass('Password: ') - else: - password = options.password - - debug('Logging in with username "%s"' % username) - try: - self.api_post('api/json/accounts/login/', { - 'username': username, - 'password': password, - }) - except APIError, e: - rsp, = e.args - - die("Unable to log in: %s (%s)" % (rsp["err"]["msg"], - rsp["err"]["code"])) - - debug("Logged in.") - - def has_valid_cookie(self): - """ - Load the user's cookie file and see if they have a valid - 'rbsessionid' cookie for the current Review Board server. Returns - true if so and false otherwise. - """ - try: - parsed_url = urlparse(self.url) - host = parsed_url[1] - path = parsed_url[2] or '/' - - # Cookie files don't store port numbers, unfortunately, so - # get rid of the port number if it's present. - host = host.split(":")[0] - - debug("Looking for '%s %s' cookie in %s" % \ - (host, path, self.cookie_file)) - self.cookie_jar.load(self.cookie_file, ignore_expires=True) - - try: - cookie = self.cookie_jar._cookies[host][path]['rbsessionid'] - - if not cookie.is_expired(): - debug("Loaded valid cookie -- no login required") - return True - - debug("Cookie file loaded, but cookie has expired") - except KeyError: - debug("Cookie file loaded, but no cookie for this server") - except IOError, error: - debug("Couldn't load cookie file: %s" % error) - - return False - - def new_review_request(self, changenum, submit_as=None): - """ - Creates a review request on a Review Board server, updating an - existing one if the changeset number already exists. - - If submit_as is provided, the specified user name will be recorded as - the submitter of the review request (given that the logged in user has - the appropriate permissions). - """ - try: - debug("Attempting to create review request for %s" % changenum) - data = { 'repository_path': self.info.path } - - if changenum: - data['changenum'] = changenum - - if submit_as: - debug("Submitting the review request as %s" % submit_as) - data['submit_as'] = submit_as - - rsp = self.api_post('api/json/reviewrequests/new/', data) - except APIError, e: - rsp, = e.args - - if not options.diff_only: - if rsp['err']['code'] == 204: # Change number in use - debug("Review request already exists. Updating it...") - rsp = self.api_post( - 'api/json/reviewrequests/%s/update_from_changenum/' % - rsp['review_request']['id']) - else: - raise e - - debug("Review request created") - return rsp['review_request'] - - def set_review_request_field(self, review_request, field, value): - """ - Sets a field in a review request to the specified value. - """ - rid = review_request['id'] - - debug("Attempting to set field '%s' to '%s' for review request '%s'" % - (field, value, rid)) - - self.api_post('api/json/reviewrequests/%s/draft/set/' % rid, { - field: value, - }) - - def get_review_request(self, rid): - """ - Returns the review request with the specified ID. - """ - rsp = self.api_get('api/json/reviewrequests/%s/' % rid) - return rsp['review_request'] - - def get_repositories(self): - """ - Returns the list of repositories on this server. - """ - rsp = self.api_get('/api/json/repositories/') - return rsp['repositories'] - - def get_repository_info(self, rid): - """ - Returns detailed information about a specific repository. - """ - rsp = self.api_get('/api/json/repositories/%s/info/' % rid) - return rsp['info'] - - def save_draft(self, review_request): - """ - Saves a draft of a review request. - """ - self.api_post("api/json/reviewrequests/%s/draft/save/" % - review_request['id']) - debug("Review request draft saved") - - def upload_diff(self, review_request, diff_content, parent_diff_content): - """ - Uploads a diff to a Review Board server. - """ - debug("Uploading diff, size: %d" % len(diff_content)) - - if parent_diff_content: - debug("Uploading parent diff, size: %d" % len(parent_diff_content)) - - fields = {} - files = {} - - if self.info.base_path: - fields['basedir'] = self.info.base_path - - files['path'] = { - 'filename': 'diff', - 'content': diff_content - } - - if parent_diff_content: - files['parent_diff_path'] = { - 'filename': 'parent_diff', - 'content': parent_diff_content - } - - self.api_post('api/json/reviewrequests/%s/diff/new/' % - review_request['id'], fields, files) - - def publish(self, review_request): - """ - Publishes a review request. - """ - debug("Publishing") - self.api_post('api/json/reviewrequests/%s/publish/' % - review_request['id']) - - def _get_server_info(self): - if not self._server_info: - self._server_info = self._info.find_server_repository_info(self) - - return self._server_info - - info = property(_get_server_info) - - def process_json(self, data): - """ - Loads in a JSON file and returns the data if successful. On failure, - APIError is raised. - """ - rsp = json.loads(data) - - if rsp['stat'] == 'fail': - raise APIError, rsp - - return rsp - - def http_get(self, path): - """ - Performs an HTTP GET on the specified path, storing any cookies that - were set. - """ - debug('HTTP GETting %s' % path) - - url = self._make_url(path) - - try: - rsp = urllib2.urlopen(url).read() - self.cookie_jar.save(self.cookie_file) - return rsp - except urllib2.HTTPError, e: - print "Unable to access %s (%s). The host path may be invalid" % \ - (url, e.code) - try: - debug(e.read()) - except AttributeError: - pass - die() - - def _make_url(self, path): - """Given a path on the server returns a full http:// style url""" - app = urlparse(self.url)[2] - if path[0] == '/': - url = urljoin(self.url, app[:-1] + path) - else: - url = urljoin(self.url, app + path) - - if not url.startswith('http'): - url = 'http://%s' % url - return url - - def api_get(self, path): - """ - Performs an API call using HTTP GET at the specified path. - """ - return self.process_json(self.http_get(path)) - - def http_post(self, path, fields, files=None): - """ - Performs an HTTP POST on the specified path, storing any cookies that - were set. - """ - if fields: - debug_fields = fields.copy() - else: - debug_fields = {} - - if 'password' in debug_fields: - debug_fields["password"] = "**************" - url = self._make_url(path) - debug('HTTP POSTing to %s: %s' % (url, debug_fields)) - - content_type, body = self._encode_multipart_formdata(fields, files) - headers = { - 'Content-Type': content_type, - 'Content-Length': str(len(body)) - } - - try: - r = urllib2.Request(url, body, headers) - data = urllib2.urlopen(r).read() - self.cookie_jar.save(self.cookie_file) - return data - except urllib2.URLError, e: - try: - debug(e.read()) - except AttributeError: - pass - - die("Unable to access %s. The host path may be invalid\n%s" % \ - (url, e)) - except urllib2.HTTPError, e: - die("Unable to access %s (%s). The host path may be invalid\n%s" % \ - (url, e.code, e.read())) - - def api_post(self, path, fields=None, files=None): - """ - Performs an API call using HTTP POST at the specified path. - """ - return self.process_json(self.http_post(path, fields, files)) - - def _encode_multipart_formdata(self, fields, files): - """ - Encodes data for use in an HTTP POST. - """ - BOUNDARY = mimetools.choose_boundary() - content = "" - - fields = fields or {} - files = files or {} - - for key in fields: - content += "--" + BOUNDARY + "\r\n" - content += "Content-Disposition: form-data; name=\"%s\"\r\n" % key - content += "\r\n" - content += fields[key] + "\r\n" - - for key in files: - filename = files[key]['filename'] - value = files[key]['content'] - content += "--" + BOUNDARY + "\r\n" - content += "Content-Disposition: form-data; name=\"%s\"; " % key - content += "filename=\"%s\"\r\n" % filename - content += "\r\n" - content += value + "\r\n" - - content += "--" + BOUNDARY + "--\r\n" - content += "\r\n" - - content_type = "multipart/form-data; boundary=%s" % BOUNDARY - - return content_type, content - - -class SCMClient(object): - """ - A base representation of an SCM tool for fetching repository information - and generating diffs. - """ - def get_repository_info(self): - return None - - def scan_for_server(self, repository_info): - """ - Scans the current directory on up to find a .reviewboard file - containing the server path. - """ - server_url = self._get_server_from_config(user_config, repository_info) - if server_url: - return server_url - - for path in walk_parents(os.getcwd()): - filename = os.path.join(path, ".reviewboardrc") - if os.path.exists(filename): - config = load_config_file(filename) - server_url = self._get_server_from_config(config, - repository_info) - if server_url: - return server_url - - return None - - def diff(self, args): - """ - Returns the generated diff and optional parent diff for this - repository. - - The returned tuple is (diff_string, parent_diff_string) - """ - return (None, None) - - def diff_between_revisions(self, revision_range, args, repository_info): - """ - Returns the generated diff between revisions in the repository. - """ - return None - - def _get_server_from_config(self, config, repository_info): - if 'REVIEWBOARD_URL' in config: - return config['REVIEWBOARD_URL'] - elif 'TREES' in config: - trees = config['TREES'] - if not isinstance(trees, dict): - die("Warning: 'TREES' in config file is not a dict!") - - if repository_info.path in trees and \ - 'REVIEWBOARD_URL' in trees[repository_info.path]: - return trees[repository_info.path]['REVIEWBOARD_URL'] - - return None - - -class CVSClient(SCMClient): - """ - A wrapper around the cvs tool that fetches repository - information and generates compatible diffs. - """ - def get_repository_info(self): - if not check_install("cvs"): - return None - - cvsroot_path = os.path.join("CVS", "Root") - - if not os.path.exists(cvsroot_path): - return None - - fp = open(cvsroot_path, "r") - repository_path = fp.read().strip() - fp.close() - - i = repository_path.find("@") - if i != -1: - repository_path = repository_path[i + 1:] - - i = repository_path.find(":") - if i != -1: - host = repository_path[:i] - try: - canon = socket.getfqdn(host) - repository_path = repository_path.replace('%s:' % host, - '%s:' % canon) - except socket.error, msg: - debug("failed to get fqdn for %s, msg=%s" % (host, msg)) - - return RepositoryInfo(path=repository_path) - - def diff(self, files): - """ - Performs a diff across all modified files in a CVS repository. - - CVS repositories do not support branches of branches in a way that - makes parent diffs possible, so we never return a parent diff - (the second value in the tuple). - """ - return (self.do_diff(files), None) - - def diff_between_revisions(self, revision_range, args, repository_info): - """ - Performs a diff between 2 revisions of a CVS repository. - """ - revs = [] - - for rev in revision_range.split(":"): - revs += ["-r", rev] - - return self.do_diff(revs) - - def do_diff(self, params): - """ - Performs the actual diff operation through cvs diff, handling - fake errors generated by CVS. - """ - # Diff returns "1" if differences were found. - return execute(["cvs", "diff", "-uN"] + params, - extra_ignore_errors=(1,)) - - -class ClearCaseClient(SCMClient): - """ - A wrapper around the clearcase tool that fetches repository - information and generates compatible diffs. - This client assumes that cygwin is installed on windows. - """ - ccroot_path = "/view/reviewboard.diffview/vobs/" - viewinfo = "" - viewtype = "snapshot" - - def get_filename_hash(self, fname): - # Hash the filename string so its easy to find the file later on. - return md5(fname).hexdigest() - - def get_repository_info(self): - if not check_install('cleartool help'): - return None - - # We must be running this from inside a view. - # Otherwise it doesn't make sense. - self.viewinfo = execute(["cleartool", "pwv", "-short"]) - if self.viewinfo.startswith('\*\* NONE'): - return None - - # Returning the hardcoded clearcase root path to match the server - # respository path. - # There is no reason to have a dynamic path unless you have - # multiple clearcase repositories. This should be implemented. - return RepositoryInfo(path=self.ccroot_path, - base_path=self.ccroot_path, - supports_parent_diffs=False) - - def get_previous_version(self, files): - file = [] - curdir = os.getcwd() - - # Cygwin case must transform a linux-like path to windows like path - # including drive letter. - if 'cygdrive' in curdir: - where = curdir.index('cygdrive') + 9 - drive_letter = curdir[where:where+1] - curdir = drive_letter + ":\\" + curdir[where+2:len(curdir)] - - for key in files: - # Sometimes there is a quote in the filename. It must be removed. - key = key.replace('\'', '') - elem_path = cpath.normpath(os.path.join(curdir, key)) - - # Removing anything before the last /vobs - # because it may be repeated. - elem_path_idx = elem_path.rfind("/vobs") - if elem_path_idx != -1: - elem_path = elem_path[elem_path_idx:len(elem_path)].strip("\"") - - # Call cleartool to get this version and the previous version - # of the element. - curr_version, pre_version = execute( - ["cleartool", "desc", "-pre", elem_path]) - curr_version = cpath.normpath(curr_version) - pre_version = pre_version.split(':')[1].strip() - - # If a specific version was given, remove it from the path - # to avoid version duplication - if "@@" in elem_path: - elem_path = elem_path[:elem_path.rfind("@@")] - file.append(elem_path + "@@" + pre_version) - file.append(curr_version) - - # Determnine if the view type is snapshot or dynamic. - if os.path.exists(file[0]): - self.viewtype = "dynamic" - - return file - - def get_extended_namespace(self, files): - """ - Parses the file path to get the extended namespace - """ - versions = self.get_previous_version(files) - - evfiles = [] - hlist = [] - - for vkey in versions: - # Verify if it is a checkedout file. - if "CHECKEDOUT" in vkey: - # For checkedout files just add it to the file list - # since it cannot be accessed outside the view. - splversions = vkey[:vkey.rfind("@@")] - evfiles.append(splversions) - else: - # For checkedin files. - ext_path = [] - ver = [] - fname = "" # fname holds the file name without the version. - (bpath, fpath) = cpath.splitdrive(vkey) - if bpath : - # Windows. - # The version (if specified like file.c@@/main/1) - # should be kept as a single string - # so split the path and concat the file name - # and version in the last position of the list. - ver = fpath.split("@@") - splversions = fpath[:vkey.rfind("@@")].split("\\") - fname = splversions.pop() - splversions.append(fname + ver[1]) - else : - # Linux. - bpath = vkey[:vkey.rfind("vobs")+4] - fpath = vkey[vkey.rfind("vobs")+5:] - ver = fpath.split("@@") - splversions = ver[0][:vkey.rfind("@@")].split("/") - fname = splversions.pop() - splversions.append(fname + ver[1]) - - filename = splversions.pop() - bpath = cpath.normpath(bpath + "/") - elem_path = bpath - - for key in splversions: - # For each element (directory) in the path, - # get its version from clearcase. - elem_path = cpath.join(elem_path, key) - - # This is the version to be appended to the extended - # path list. - this_version = execute( - ["cleartool", "desc", "-fmt", "%Vn", - cpath.normpath(elem_path)]) - if this_version: - ext_path.append(key + "/@@" + this_version + "/") - else: - ext_path.append(key + "/") - - # This must be done in case we haven't specified - # the version on the command line. - ext_path.append(cpath.normpath(fname + "/@@" + - vkey[vkey.rfind("@@")+2:len(vkey)])) - epstr = cpath.join(bpath, cpath.normpath(''.join(ext_path))) - evfiles.append(epstr) - - """ - In windows, there is a problem with long names(> 254). - In this case, we hash the string and copy the unextended - filename to a temp file whose name is the hash. - This way we can get the file later on for diff. - The same problem applies to snapshot views where the - extended name isn't available. - The previous file must be copied from the CC server - to a local dir. - """ - if cpath.exists(epstr) : - pass - else: - if len(epstr) > 254 or self.viewtype == "snapshot": - name = self.get_filename_hash(epstr) - # Check if this hash is already in the list - try: - i = hlist.index(name) - die("ERROR: duplicate value %s : %s" % - (name, epstr)) - except ValueError: - hlist.append(name) - - normkey = cpath.normpath(vkey) - td = tempfile.gettempdir() - # Cygwin case must transform a linux-like path to - # windows like path including drive letter - if 'cygdrive' in td: - where = td.index('cygdrive') + 9 - drive_letter = td[where:where+1] + ":" - td = cpath.join(drive_letter, td[where+1:]) - tf = cpath.normpath(cpath.join(td, name)) - if cpath.exists(tf): - debug("WARNING: FILE EXISTS") - os.unlink(tf) - execute(["cleartool", "get", "-to", tf, normkey]) - else: - die("ERROR: FILE NOT FOUND : %s" % epstr) - - return evfiles - - def get_files_from_label(self, label): - voblist=[] - # Get the list of vobs for the current view - allvoblist = execute(["cleartool", "lsvob", "-short"]).split() - # For each vob, find if the label is present - for vob in allvoblist: - try: - execute(["cleartool", "describe", "-local", - "lbtype:%s@%s" % (label, vob)]).split() - voblist.append(vob) - except: - pass - - filelist=[] - # For each vob containing the label, get the file list - for vob in voblist: - try: - res = execute(["cleartool", "find", vob, "-all", "-version", - "lbtype(%s)" % label, "-print"]) - filelist.extend(res.split()) - except : - pass - - # Return only the unique itens - return set(filelist) - - def diff(self, files): - """ - Performs a diff of the specified file and its previous version. - """ - # We must be running this from inside a view. - # Otherwise it doesn't make sense. - return self.do_diff(self.get_extended_namespace(files)) - - def diff_label(self, label): - """ - Get the files that are attached to a label and diff them - TODO - """ - return self.diff(self.get_files_from_label(label)) - - def diff_between_revisions(self, revision_range, args, repository_info): - """ - Performs a diff between 2 revisions of a CC repository. - """ - rev_str = '' - - for rev in revision_range.split(":"): - rev_str += "-r %s " % rev - - return self.do_diff(rev_str) - - def do_diff(self, params): - # Diff returns "1" if differences were found. - # Add the view name and view type to the description - if options.description: - options.description = ("VIEW: " + self.viewinfo + - "VIEWTYPE: " + self.viewtype + "\n" + options.description) - else: - options.description = (self.viewinfo + - "VIEWTYPE: " + self.viewtype + "\n") - - o = [] - Feol = False - while len(params) > 0: - # Read both original and modified files. - onam = params.pop(0) - mnam = params.pop(0) - file_data = [] - do_rem = False - # If the filename length is greater than 254 char for windows, - # we copied the file to a temp file - # because the open will not work for path greater than 254. - # This is valid for the original and - # modified files if the name size is > 254. - for filenam in (onam, mnam) : - if cpath.exists(filenam) and self.viewtype == "dynamic": - do_rem = False - fn = filenam - elif len(filenam) > 254 or self.viewtype == "snapshot": - fn = self.get_filename_hash(filenam) - fn = cpath.join(tempfile.gettempdir(), fn) - do_rem = True - fd = open(cpath.normpath(fn)) - fdata = fd.readlines() - fd.close() - file_data.append(fdata) - # If the file was temp, it should be removed. - if do_rem: - os.remove(filenam) - - modi = file_data.pop() - orig = file_data.pop() - - # For snapshot views, the local directories must be removed because - # they will break the diff on the server. Just replacing - # everything before the view name (including the view name) for - # vobs do the work. - if (self.viewtype == "snapshot" - and (sys.platform.startswith('win') - or sys.platform.startswith('cygwin'))): - vinfo = self.viewinfo.rstrip("\r\n") - mnam = "c:\\\\vobs" + mnam[mnam.rfind(vinfo) + len(vinfo):] - onam = "c:\\\\vobs" + onam[onam.rfind(vinfo) + len(vinfo):] - # Call the diff lib to generate a diff. - # The dates are bogus, since they don't natter anyway. - # The only thing is that two spaces are needed to the server - # so it can identify the heades correctly. - diff = difflib.unified_diff(orig, modi, onam, mnam, - ' 2002-02-21 23:30:39.942229878 -0800', - ' 2002-02-21 23:30:50.442260588 -0800', lineterm=' \n') - # Transform the generator output into a string output - # Use a comprehension instead of a generator, - # so 2.3.x doesn't fail to interpret. - diffstr = ''.join([str(l) for l in diff]) - # Workaround for the difflib no new line at end of file - # problem. - if not diffstr.endswith('\n'): - diffstr = diffstr + ("\n\\ No newline at end of file\n") - o.append(diffstr) - - ostr = ''.join(o) - return (ostr, None) # diff, parent_diff (not supported) - - -class SVNClient(SCMClient): - """ - A wrapper around the svn Subversion tool that fetches repository - information and generates compatible diffs. - """ - def get_repository_info(self): - if not check_install('svn help'): - return None - - # Get the SVN repository path (either via a working copy or - # a supplied URI) - svn_info_params = ["svn", "info"] - if options.repository_url: - svn_info_params.append(options.repository_url) - data = execute(svn_info_params, - ignore_errors=True) - m = re.search(r'^Repository Root: (.+)$', data, re.M) - if not m: - return None - - path = m.group(1) - - m = re.search(r'^URL: (.+)$', data, re.M) - if not m: - return None - - base_path = m.group(1)[len(path):] or "/" - - m = re.search(r'^Repository UUID: (.+)$', data, re.M) - if not m: - return None - - return SvnRepositoryInfo(path, base_path, m.group(1)) - - def scan_for_server(self, repository_info): - # Scan first for dot files, since it's faster and will cover the - # user's $HOME/.reviewboardrc - server_url = super(SVNClient, self).scan_for_server(repository_info) - if server_url: - return server_url - - return self.scan_for_server_property(repository_info) - - def scan_for_server_property(self, repository_info): - def get_url_prop(path): - url = execute(["svn", "propget", "reviewboard:url", path]).strip() - return url or None - - for path in walk_parents(os.getcwd()): - if not os.path.exists(os.path.join(path, ".svn")): - break - - prop = get_url_prop(path) - if prop: - return prop - - return get_url_prop(repository_info.path) - - def diff(self, files): - """ - Performs a diff across all modified files in a Subversion repository. - - SVN repositories do not support branches of branches in a way that - makes parent diffs possible, so we never return a parent diff - (the second value in the tuple). - """ - return (self.do_diff(["svn", "diff", "--diff-cmd=diff"] + files), - None) - - def diff_between_revisions(self, revision_range, args, repository_info): - """ - Performs a diff between 2 revisions of a Subversion repository. - """ - if options.repository_url: - revisions = revision_range.split(':') - if len(revisions) < 1: - return None - elif len(revisions) == 1: - revisions.append('HEAD') - - # if a new path was supplied at the command line, set it - if len(args): - repository_info.set_base_path(args[0]) - - url = repository_info.path + repository_info.base_path - - old_url = url + '@' + revisions[0] - new_url = url + '@' + revisions[1] - - return self.do_diff(["svn", "diff", "--diff-cmd=diff", old_url, - new_url], - repository_info) - # Otherwise, perform the revision range diff using a working copy - else: - return self.do_diff(["svn", "diff", "--diff-cmd=diff", "-r", - revision_range], - repository_info) - - def do_diff(self, cmd, repository_info=None): - """ - Performs the actual diff operation, handling renames and converting - paths to absolute. - """ - diff = execute(cmd, split_lines=True) - diff = self.handle_renames(diff) - diff = self.convert_to_absolute_paths(diff, repository_info) - - return ''.join(diff) - - def handle_renames(self, diff_content): - """ - The output of svn diff is incorrect when the file in question came - into being via svn mv/cp. Although the patch for these files are - relative to its parent, the diff header doesn't reflect this. - This function fixes the relevant section headers of the patch to - portray this relationship. - """ - - # svn diff against a repository URL on two revisions appears to - # handle moved files properly, so only adjust the diff file names - # if they were created using a working copy. - if options.repository_url: - return diff_content - - result = [] - - from_line = "" - for line in diff_content: - if line.startswith('--- '): - from_line = line - continue - - # This is where we decide how mangle the previous '--- ' - if line.startswith('+++ '): - to_file, _ = self.parse_filename_header(line[4:]) - info = self.svn_info(to_file) - if info.has_key("Copied From URL"): - url = info["Copied From URL"] - root = info["Repository Root"] - from_file = urllib.unquote(url[len(root):]) - result.append(from_line.replace(to_file, from_file)) - else: - result.append(from_line) #as is, no copy performed - - # We only mangle '---' lines. All others get added straight to - # the output. - result.append(line) - - return result - - - def convert_to_absolute_paths(self, diff_content, repository_info): - """ - Converts relative paths in a diff output to absolute paths. - This handles paths that have been svn switched to other parts of the - repository. - """ - - result = [] - - for line in diff_content: - front = None - if line.startswith('+++ ') or line.startswith('--- ') or line.startswith('Index: '): - front, line = line.split(" ", 1) - - if front: - if line.startswith('/'): #already absolute - line = front + " " + line - else: - # filename and rest of line (usually the revision - # component) - file, rest = self.parse_filename_header(line) - - # If working with a diff generated outside of a working - # copy, then file paths are already absolute, so just - # add initial slash. - if options.repository_url: - path = urllib.unquote( - "%s/%s" % (repository_info.base_path, file)) - else: - info = self.svn_info(file) - url = info["URL"] - root = info["Repository Root"] - path = urllib.unquote(url[len(root):]) - - line = front + " " + path + rest - - result.append(line) - - return result - - def svn_info(self, path): - """Return a dict which is the result of 'svn info' at a given path.""" - svninfo = {} - for info in execute(["svn", "info", path], - split_lines=True): - parts = info.strip().split(": ", 1) - if len(parts) == 2: - key, value = parts - svninfo[key] = value - - return svninfo - - # Adapted from server code parser.py - def parse_filename_header(self, s): - parts = None - if "\t" in s: - # There's a \t separating the filename and info. This is the - # best case scenario, since it allows for filenames with spaces - # without much work. - parts = s.split("\t") - - # There's spaces being used to separate the filename and info. - # This is technically wrong, so all we can do is assume that - # 1) the filename won't have multiple consecutive spaces, and - # 2) there's at least 2 spaces separating the filename and info. - if " " in s: - parts = re.split(r" +", s) - - if parts: - parts[1] = '\t' + parts[1] - return parts - - # strip off ending newline, and return it as the second component - return [s.split('\n')[0], '\n'] - - -class PerforceClient(SCMClient): - """ - A wrapper around the p4 Perforce tool that fetches repository information - and generates compatible diffs. - """ - def get_repository_info(self): - if not check_install('p4 help'): - return None - - data = execute(["p4", "info"], ignore_errors=True) - - m = re.search(r'^Server address: (.+)$', data, re.M) - if not m: - return None - - repository_path = m.group(1).strip() - - try: - hostname, port = repository_path.split(":") - info = socket.gethostbyaddr(hostname) - repository_path = "%s:%s" % (info[0], port) - except (socket.gaierror, socket.herror): - pass - - return RepositoryInfo(path=repository_path, supports_changesets=True) - - def scan_for_server(self, repository_info): - # Scan first for dot files, since it's faster and will cover the - # user's $HOME/.reviewboardrc - server_url = \ - super(PerforceClient, self).scan_for_server(repository_info) - - if server_url: - return server_url - - return self.scan_for_server_counter(repository_info) - - def scan_for_server_counter(self, repository_info): - """ - Checks the Perforce counters to see if the Review Board server's url - is specified. Since Perforce only started supporting non-numeric - counter values in server version 2008.1, we support both a normal - counter 'reviewboard.url' with a string value and embedding the url in - a counter name like 'reviewboard.url.http:||reviewboard.example.com'. - Note that forward slashes aren't allowed in counter names, so - pipe ('|') characters should be used. These should be safe because they - should not be used unencoded in urls. - """ - - counters_text = execute(["p4", "counters"]) - - # Try for a "reviewboard.url" counter first. - m = re.search(r'^reviewboard.url = (\S+)', counters_text, re.M) - - if m: - return m.group(1) - - # Next try for a counter of the form: - # reviewboard_url.http:||reviewboard.example.com - m2 = re.search(r'^reviewboard.url\.(\S+)', counters_text, re.M) - - if m2: - return m2.group(1).replace('|', '/') - - return None - - def get_changenum(self, args): - if len(args) == 1: - try: - return str(int(args[0])) - except ValueError: - pass - return None - - def diff(self, args): - """ - Goes through the hard work of generating a diff on Perforce in order - to take into account adds/deletes and to provide the necessary - revision information. - """ - # set the P4 enviroment: - if options.p4_client: - os.environ['P4CLIENT'] = options.p4_client - - if options.p4_port: - os.environ['P4PORT'] = options.p4_port - - changenum = self.get_changenum(args) - if changenum is None: - return self._path_diff(args) - else: - return self._changenum_diff(changenum) - - - def _path_diff(self, args): - """ - Process a path-style diff. See _changenum_diff for the alternate - version that handles specific change numbers. - - Multiple paths may be specified in `args`. The path styles supported - are: - - //path/to/file - Upload file as a "new" file. - - //path/to/dir/... - Upload all files as "new" files. - - //path/to/file[@#]rev - Upload file from that rev as a "new" file. - - //path/to/file[@#]rev,[@#]rev - Upload a diff between revs. - - //path/to/dir/...[@#]rev,[@#]rev - Upload a diff of all files between revs in that directory. - """ - r_revision_range = re.compile(r'^(?P<path>//[^@#]+)' + - r'(?P<revision1>[#@][^,]+)?' + - r'(?P<revision2>,[#@][^,]+)?$') - - empty_filename = make_tempfile() - tmp_diff_from_filename = make_tempfile() - tmp_diff_to_filename = make_tempfile() - - diff_lines = [] - - for path in args: - m = r_revision_range.match(path) - - if not m: - die('Path %r does not match a valid Perforce path.' % (path,)) - revision1 = m.group('revision1') - revision2 = m.group('revision2') - first_rev_path = m.group('path') - - if revision1: - first_rev_path += revision1 - records = self._run_p4(['files', first_rev_path]) - - # Make a map for convenience. - files = {} - - # Records are: - # 'rev': '1' - # 'func': '...' - # 'time': '1214418871' - # 'action': 'edit' - # 'type': 'ktext' - # 'depotFile': '...' - # 'change': '123456' - for record in records: - if record['action'] != 'delete': - if revision2: - files[record['depotFile']] = [record, None] - else: - files[record['depotFile']] = [None, record] - - if revision2: - # [1:] to skip the comma. - second_rev_path = m.group('path') + revision2[1:] - records = self._run_p4(['files', second_rev_path]) - for record in records: - if record['action'] != 'delete': - try: - m = files[record['depotFile']] - m[1] = record - except KeyError: - files[record['depotFile']] = [None, record] - - old_file = new_file = empty_filename - changetype_short = None - - for depot_path, (first_record, second_record) in files.items(): - old_file = new_file = empty_filename - if first_record is None: - self._write_file(depot_path + '#' + second_record['rev'], - tmp_diff_to_filename) - new_file = tmp_diff_to_filename - changetype_short = 'A' - base_revision = 0 - elif second_record is None: - self._write_file(depot_path + '#' + first_record['rev'], - tmp_diff_from_filename) - old_file = tmp_diff_from_filename - changetype_short = 'D' - base_revision = int(first_record['rev']) - else: - self._write_file(depot_path + '#' + first_record['rev'], - tmp_diff_from_filename) - self._write_file(depot_path + '#' + second_record['rev'], - tmp_diff_to_filename) - new_file = tmp_diff_to_filename - old_file = tmp_diff_from_filename - changetype_short = 'M' - base_revision = int(first_record['rev']) - - dl = self._do_diff(old_file, new_file, depot_path, - base_revision, changetype_short, - ignore_unmodified=True) - diff_lines += dl - - os.unlink(empty_filename) - os.unlink(tmp_diff_from_filename) - os.unlink(tmp_diff_to_filename) - return (''.join(diff_lines), None) - - def _run_p4(self, command): - """Execute a perforce command using the python marshal API. - - - command: A list of strings of the command to execute. - - The return type depends on the command being run. - """ - command = ['p4', '-G'] + command - p = subprocess.Popen(command, stdout=subprocess.PIPE) - result = [] - has_error = False - - while 1: - try: - data = marshal.load(p.stdout) - except EOFError: - break - else: - result.append(data) - if data.get('code', None) == 'error': - has_error = True - - rc = p.wait() - - if rc or has_error: - for record in result: - if 'data' in record: - print record['data'] - die('Failed to execute command: %s\n' % (command,)) - - return result - - def _changenum_diff(self, changenum): - """ - Process a diff for a particular change number. This handles both - pending and submitted changelists. - - See _path_diff for the alternate version that does diffs of depot - paths. - """ - # TODO: It might be a good idea to enhance PerforceDiffParser to - # understand that newFile could include a revision tag for post-submit - # reviewing. - cl_is_pending = False - - debug("Generating diff for changenum %s" % changenum) - - description = execute(["p4", "describe", "-s", changenum], - split_lines=True) - - if '*pending*' in description[0]: - cl_is_pending = True - - # Get the file list - for line_num, line in enumerate(description): - if 'Affected files ...' in line: - break - else: - # Got to the end of all the description lines and didn't find - # what we were looking for. - die("Couldn't find any affected files for this change.") - - description = description[line_num+2:] - - diff_lines = [] - - empty_filename = make_tempfile() - tmp_diff_from_filename = make_tempfile() - tmp_diff_to_filename = make_tempfile() - - for line in description: - line = line.strip() - if not line: - continue - - m = re.search(r'\.\.\. ([^#]+)#(\d+) (add|edit|delete|integrate|branch)', line) - if not m: - die("Unsupported line from p4 opened: %s" % line) - - depot_path = m.group(1) - base_revision = int(m.group(2)) - if not cl_is_pending: - # If the changelist is pending our base revision is the one that's - # currently in the depot. If we're not pending the base revision is - # actually the revision prior to this one - base_revision -= 1 - - changetype = m.group(3) - - debug('Processing %s of %s' % (changetype, depot_path)) - - old_file = new_file = empty_filename - old_depot_path = new_depot_path = None - changetype_short = None - - if changetype == 'edit' or changetype == 'integrate': - # A big assumption - new_revision = base_revision + 1 - - # We have an old file, get p4 to take this old version from the - # depot and put it into a plain old temp file for us - old_depot_path = "%s#%s" % (depot_path, base_revision) - self._write_file(old_depot_path, tmp_diff_from_filename) - old_file = tmp_diff_from_filename - - # Also print out the new file into a tmpfile - if cl_is_pending: - new_file = self._depot_to_local(depot_path) - else: - new_depot_path = "%s#%s" %(depot_path, new_revision) - self._write_file(new_depot_path, tmp_diff_to_filename) - new_file = tmp_diff_to_filename - - changetype_short = "M" - - elif changetype == 'add' or changetype == 'branch': - # We have a new file, get p4 to put this new file into a pretty - # temp file for us. No old file to worry about here. - if cl_is_pending: - new_file = self._depot_to_local(depot_path) - else: - self._write_file(depot_path, tmp_diff_to_filename) - new_file = tmp_diff_to_filename - changetype_short = "A" - - elif changetype == 'delete': - # We've deleted a file, get p4 to put the deleted file into a temp - # file for us. The new file remains the empty file. - old_depot_path = "%s#%s" % (depot_path, base_revision) - self._write_file(old_depot_path, tmp_diff_from_filename) - old_file = tmp_diff_from_filename - changetype_short = "D" - else: - die("Unknown change type '%s' for %s" % (changetype, depot_path)) - - dl = self._do_diff(old_file, new_file, depot_path, base_revision, changetype_short) - diff_lines += dl - - os.unlink(empty_filename) - os.unlink(tmp_diff_from_filename) - os.unlink(tmp_diff_to_filename) - return (''.join(diff_lines), None) - - def _do_diff(self, old_file, new_file, depot_path, base_revision, - changetype_short, ignore_unmodified=False): - """ - Do the work of producing a diff for Perforce. - - old_file - The absolute path to the "old" file. - new_file - The absolute path to the "new" file. - depot_path - The depot path in Perforce for this file. - base_revision - The base perforce revision number of the old file as - an integer. - changetype_short - The change type as a single character string. - ignore_unmodified - If True, will return an empty list if the file - is not changed. - - Returns a list of strings of diff lines. - """ - if hasattr(os, 'uname') and os.uname()[0] == 'SunOS': - diff_cmd = ["gdiff", "-urNp", old_file, new_file] - else: - diff_cmd = ["diff", "-urNp", old_file, new_file] - # Diff returns "1" if differences were found. - dl = execute(diff_cmd, extra_ignore_errors=(1,2), - translate_newlines=False) - - # If the input file has ^M characters at end of line, lets ignore them. - dl = dl.replace('\r\r\n', '\r\n') - dl = dl.splitlines(True) - - cwd = os.getcwd() - if depot_path.startswith(cwd): - local_path = depot_path[len(cwd) + 1:] - else: - local_path = depot_path - - # Special handling for the output of the diff tool on binary files: - # diff outputs "Files a and b differ" - # and the code below expects the output to start with - # "Binary files " - if len(dl) == 1 and \ - dl[0] == ('Files %s and %s differ'% (old_file, new_file)): - dl = ['Binary files %s and %s differ'% (old_file, new_file)] - - if dl == [] or dl[0].startswith("Binary files "): - if dl == []: - if ignore_unmodified: - return [] - else: - print "Warning: %s in your changeset is unmodified" % \ - local_path - - dl.insert(0, "==== %s#%s ==%s== %s ====\n" % \ - (depot_path, base_revision, changetype_short, local_path)) - dl.append('\n') - else: - m = re.search(r'(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)', dl[1]) - if m: - timestamp = m.group(1) - else: - # Thu Sep 3 11:24:48 2007 - m = re.search(r'(\w+)\s+(\w+)\s+(\d+)\s+(\d\d:\d\d:\d\d)\s+(\d\d\d\d)', dl[1]) - if not m: - die("Unable to parse diff header: %s" % dl[1]) - - month_map = { - "Jan": "01", - "Feb": "02", - "Mar": "03", - "Apr": "04", - "May": "05", - "Jun": "06", - "Jul": "07", - "Aug": "08", - "Sep": "09", - "Oct": "10", - "Nov": "11", - "Dec": "12", - } - month = month_map[m.group(2)] - day = m.group(3) - timestamp = m.group(4) - year = m.group(5) - - timestamp = "%s-%s-%s %s" % (year, month, day, timestamp) - - dl[0] = "--- %s\t%s#%s\n" % (local_path, depot_path, base_revision) - dl[1] = "+++ %s\t%s\n" % (local_path, timestamp) - - return dl - - def _write_file(self, depot_path, tmpfile): - """ - Grabs a file from Perforce and writes it to a temp file. p4 print sets - the file readonly and that causes a later call to unlink fail. So we - make the file read/write. - """ - debug('Writing "%s" to "%s"' % (depot_path, tmpfile)) - execute(["p4", "print", "-o", tmpfile, "-q", depot_path]) - os.chmod(tmpfile, stat.S_IREAD | stat.S_IWRITE) - - def _depot_to_local(self, depot_path): - """ - Given a path in the depot return the path on the local filesystem to - the same file. If there are multiple results, take only the last - result from the where command. - """ - where_output = self._run_p4(['where', depot_path]) - return where_output[-1]['path'] - - -class MercurialClient(SCMClient): - """ - A wrapper around the hg Mercurial tool that fetches repository - information and generates compatible diffs. - """ - def get_repository_info(self): - if not check_install('hg --help'): - return None - - data = execute(["hg", "root"], ignore_errors=True) - if data.startswith('abort:'): - # hg aborted => no mercurial repository here. - return None - - # Elsewhere, hg root output give us the repository path. - - # We save data here to use it as a fallback. See below - local_data = data.strip() - - svn = execute(["hg", "svn", "info", ], ignore_errors=True) - - if (not svn.startswith('abort:') and - not svn.startswith("hg: unknown command")): - self.type = 'svn' - m = re.search(r'^Repository Root: (.+)$', svn, re.M) - - if not m: - return None - - path = m.group(1) - m2 = re.match(r'^(svn\+ssh|http|https)://([-a-zA-Z0-9.]*@)(.*)$', - path) - if m2: - path = '%s://%s' % (m2.group(1), m2.group(3)) - - m = re.search(r'^URL: (.+)$', svn, re.M) - - if not m: - return None - - base_path = m.group(1)[len(path):] or "/" - return RepositoryInfo(path=path, - base_path=base_path, - supports_parent_diffs=True) - - self.type = 'hg' - - # We are going to search .hg/hgrc for the default path. - file_name = os.path.join(local_data,'.hg', 'hgrc') - - if not os.path.exists(file_name): - return RepositoryInfo(path=local_data, base_path='/', - supports_parent_diffs=True) - - f = open(file_name) - data = f.read() - f.close() - - m = re.search(r'^default\s+=\s+(.+)$', data, re.M) - - if not m: - # Return the local path, if no default value is found. - return RepositoryInfo(path=local_data, base_path='/', - supports_parent_diffs=True) - - path = m.group(1).strip() - - return RepositoryInfo(path=path, base_path='', - supports_parent_diffs=True) - - def diff(self, files): - """ - Performs a diff across all modified files in a Mercurial repository. - """ - # We don't support parent diffs with Mercurial yet, so we always - # return None for the parent diff. - if self.type == 'svn': - parent = execute(['hg', 'parent', '--svn', '--template', - '{node}\n']).strip() - - if options.parent_branch: - parent = options.parent_branch - - if options.guess_summary and not options.summary: - options.summary = execute(['hg', 'log', '-r.', '--template', - r'{desc|firstline}\n']) - - if options.guess_description and not options.description: - numrevs = len(execute(['hg', 'log', '-r.:%s' % parent, - '--follow', '--template', - r'{rev}\n']).strip().split('\n')) - options.description = execute(['hg', 'log', '-r.:%s' % parent, - '--follow', '--template', - r'{desc}\n\n', '--limit', - str(numrevs-1)]).strip() - - return (execute(["hg", "diff", "--svn", '-r%s:.' % parent]), None) - - return (execute(["hg", "diff"] + files), None) - - def diff_between_revisions(self, revision_range, args, repository_info): - """ - Performs a diff between 2 revisions of a Mercurial repository. - """ - if self.type != 'hg': - raise NotImplementedError - - r1, r2 = revision_range.split(':') - return execute(["hg", "diff", "-r", r1, "-r", r2]) - - -class GitClient(SCMClient): - """ - A wrapper around git that fetches repository information and generates - compatible diffs. This will attempt to generate a diff suitable for the - remote repository, whether git, SVN or Perforce. - """ - def get_repository_info(self): - if not check_install('git --help'): - return None - - git_dir = execute(["git", "rev-parse", "--git-dir"], - ignore_errors=True).strip() - - if git_dir.startswith("fatal:") or not os.path.isdir(git_dir): - return None - - # post-review in directories other than the top level of - # of a work-tree would result in broken diffs on the server - os.chdir(os.path.dirname(os.path.abspath(git_dir))) - - # We know we have something we can work with. Let's find out - # what it is. We'll try SVN first. - data = execute(["git", "svn", "info"], ignore_errors=True) - - m = re.search(r'^Repository Root: (.+)$', data, re.M) - if m: - path = m.group(1) - m = re.search(r'^URL: (.+)$', data, re.M) - - if m: - base_path = m.group(1)[len(path):] or "/" - m = re.search(r'^Repository UUID: (.+)$', data, re.M) - - if m: - uuid = m.group(1) - self.type = "svn" - - return SvnRepositoryInfo(path=path, base_path=base_path, - uuid=uuid, - supports_parent_diffs=True) - else: - # Versions of git-svn before 1.5.4 don't (appear to) support - # 'git svn info'. If we fail because of an older git install, - # here, figure out what version of git is installed and give - # the user a hint about what to do next. - version = execute(["git", "svn", "--version"], ignore_errors=True) - version_parts = re.search('version (\d+)\.(\d+)\.(\d+)', - version) - svn_remote = execute(["git", "config", "--get", - "svn-remote.svn.url"], ignore_errors=True) - - if (version_parts and - not self.is_valid_version((int(version_parts.group(1)), - int(version_parts.group(2)), - int(version_parts.group(3))), - (1, 5, 4)) and - svn_remote): - die("Your installation of git-svn must be upgraded to " + \ - "version 1.5.4 or later") - - # Okay, maybe Perforce. - # TODO - - # Nope, it's git then. - origin = execute(["git", "remote", "show", "origin"]) - m = re.search(r'URL: (.+)', origin) - if m: - url = m.group(1).rstrip('/') - if url: - self.type = "git" - return RepositoryInfo(path=url, base_path='', - supports_parent_diffs=True) - - return None - - def is_valid_version(self, actual, expected): - """ - Takes two tuples, both in the form: - (major_version, minor_version, micro_version) - Returns true if the actual version is greater than or equal to - the expected version, and false otherwise. - """ - return (actual[0] > expected[0]) or \ - (actual[0] == expected[0] and actual[1] > expected[1]) or \ - (actual[0] == expected[0] and actual[1] == expected[1] and \ - actual[2] >= expected[2]) - - def scan_for_server(self, repository_info): - # Scan first for dot files, since it's faster and will cover the - # user's $HOME/.reviewboardrc - server_url = super(GitClient, self).scan_for_server(repository_info) - - if server_url: - return server_url - - # TODO: Maybe support a server per remote later? Is that useful? - url = execute(["git", "config", "--get", "reviewboard.url"], - ignore_errors=True).strip() - if url: - return url - - if self.type == "svn": - # Try using the reviewboard:url property on the SVN repo, if it - # exists. - prop = SVNClient().scan_for_server_property(repository_info) - - if prop: - return prop - - return None - - def diff(self, args): - """ - Performs a diff across all modified files in the branch, taking into - account a parent branch. - """ - parent_branch = options.parent_branch or "master" - - diff_lines = self.make_diff(parent_branch) - - if parent_branch != "master": - parent_diff_lines = self.make_diff("master", parent_branch) - else: - parent_diff_lines = None - - if options.guess_summary and not options.summary: - options.summary = execute(["git", "log", "--pretty=format:%s", - "HEAD^.."], ignore_errors=True).strip() - - if options.guess_description and not options.description: - options.description = execute( - ["git", "log", "--pretty=format:%s%n%n%b", parent_branch + ".."], - ignore_errors=True).strip() - - return (diff_lines, parent_diff_lines) - - def make_diff(self, parent_branch, source_branch=""): - """ - Performs a diff on a particular branch range. - """ - if self.type == "svn": - diff_lines = execute(["git", "diff", "--no-color", "--no-prefix", - "-r", "-u", "%s..%s" % (parent_branch, - source_branch)], - split_lines=True) - return self.make_svn_diff(parent_branch, diff_lines) - elif self.type == "git": - return execute(["git", "diff", "--no-color", "--full-index", - parent_branch]) - - return None - - def make_svn_diff(self, parent_branch, diff_lines): - """ - Formats the output of git diff such that it's in a form that - svn diff would generate. This is needed so the SVNTool in Review - Board can properly parse this diff. - """ - rev = execute(["git", "svn", "find-rev", "master"]).strip() - - if not rev: - return None - - diff_data = "" - filename = "" - revision = "" - newfile = False - - for line in diff_lines: - if line.startswith("diff "): - # Grab the filename and then filter this out. - # This will be in the format of: - # - # diff --git a/path/to/file b/path/to/file - info = line.split(" ") - diff_data += "Index: %s\n" % info[2] - diff_data += "=" * 67 - diff_data += "\n" - elif line.startswith("index "): - # Filter this out. - pass - elif line.strip() == "--- /dev/null": - # New file - newfile = True - elif line.startswith("--- "): - newfile = False - diff_data += "--- %s\t(revision %s)\n" % \ - (line[4:].strip(), rev) - elif line.startswith("+++ "): - filename = line[4:].strip() - if newfile: - diff_data += "--- %s\t(revision 0)\n" % filename - diff_data += "+++ %s\t(revision 0)\n" % filename - else: - # We already printed the "--- " line. - diff_data += "+++ %s\t(working copy)\n" % filename - else: - diff_data += line - - return diff_data - - def diff_between_revisions(self, revision_range, args, repository_info): - pass - - -SCMCLIENTS = ( - SVNClient(), - CVSClient(), - GitClient(), - MercurialClient(), - PerforceClient(), - ClearCaseClient(), -) - -def debug(s): - """ - Prints debugging information if post-review was run with --debug - """ - if DEBUG or options and options.debug: - print ">>> %s" % s - - -def make_tempfile(): - """ - Creates a temporary file and returns the path. The path is stored - in an array for later cleanup. - """ - fd, tmpfile = mkstemp() - os.close(fd) - tempfiles.append(tmpfile) - return tmpfile - - -def check_install(command): - """ - Try executing an external command and return a boolean indicating whether - that command is installed or not. The 'command' argument should be - something that executes quickly, without hitting the network (for - instance, 'svn help' or 'git --version'). - """ - try: - p = subprocess.Popen(command.split(' '), - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - return True - except OSError: - return False - - -def execute(command, env=None, split_lines=False, ignore_errors=False, - extra_ignore_errors=(), translate_newlines=True): - """ - Utility function to execute a command and return the output. - """ - if isinstance(command, list): - debug(subprocess.list2cmdline(command)) - else: - debug(command) - - if env: - env.update(os.environ) - else: - env = os.environ.copy() - - env['LC_ALL'] = 'en_US.UTF-8' - env['LANGUAGE'] = 'en_US.UTF-8' - - if sys.platform.startswith('win'): - p = subprocess.Popen(command, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - shell=False, - universal_newlines=translate_newlines, - env=env) - else: - p = subprocess.Popen(command, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - shell=False, - close_fds=True, - universal_newlines=translate_newlines, - env=env) - if split_lines: - data = p.stdout.readlines() - else: - data = p.stdout.read() - rc = p.wait() - if rc and not ignore_errors and rc not in extra_ignore_errors: - die('Failed to execute command: %s\n%s' % (command, data)) - - return data - - -def die(msg=None): - """ - Cleanly exits the program with an error message. Erases all remaining - temporary files. - """ - for tmpfile in tempfiles: - try: - os.unlink(tmpfile) - except: - pass - - if msg: - print msg - - sys.exit(1) - - -def walk_parents(path): - """ - Walks up the tree to the root directory. - """ - while os.path.splitdrive(path)[1] != os.sep: - yield path - path = os.path.dirname(path) - - -def load_config_file(filename): - """ - Loads data from a config file. - """ - config = { - 'TREES': {}, - } - - if os.path.exists(filename): - try: - execfile(filename, config) - except: - pass - - return config - - -def tempt_fate(server, tool, changenum, diff_content=None, - parent_diff_content=None, submit_as=None, retries=3): - """ - Attempts to create a review request on a Review Board server and upload - a diff. On success, the review request path is displayed. - """ - try: - save_draft = False - - if options.rid: - review_request = server.get_review_request(options.rid) - else: - review_request = server.new_review_request(changenum, submit_as) - - if options.target_groups: - server.set_review_request_field(review_request, 'target_groups', - options.target_groups) - save_draft = True - - if options.target_people: - server.set_review_request_field(review_request, 'target_people', - options.target_people) - save_draft = True - - if options.summary: - server.set_review_request_field(review_request, 'summary', - options.summary) - save_draft = True - - if options.branch: - server.set_review_request_field(review_request, 'branch', - options.branch) - save_draft = True - - if options.bugs_closed: - server.set_review_request_field(review_request, 'bugs_closed', - options.bugs_closed) - save_draft = True - - if options.description: - server.set_review_request_field(review_request, 'description', - options.description) - save_draft = True - - if options.testing_done: - server.set_review_request_field(review_request, 'testing_done', - options.testing_done) - save_draft = True - - if save_draft: - server.save_draft(review_request) - except APIError, e: - rsp, = e.args - if rsp['err']['code'] == 103: # Not logged in - retries = retries - 1 - - # We had an odd issue where the server ended up a couple of - # years in the future. Login succeeds but the cookie date was - # "odd" so use of the cookie appeared to fail and eventually - # ended up at max recursion depth :-(. Check for a maximum - # number of retries. - if retries >= 0: - server.login(force=True) - tempt_fate(server, tool, changenum, diff_content, - parent_diff_content, submit_as, retries=retries) - return - - if options.rid: - die("Error getting review request %s: %s (code %s)" % \ - (options.rid, rsp['err']['msg'], rsp['err']['code'])) - else: - die("Error creating review request: %s (code %s)" % \ - (rsp['err']['msg'], rsp['err']['code'])) - - - if not server.info.supports_changesets or not options.change_only: - try: - server.upload_diff(review_request, diff_content, - parent_diff_content) - except APIError, e: - rsp, = e.args - print "Error uploading diff: %s (%s)" % (rsp['err']['msg'], - rsp['err']['code']) - debug(rsp) - die("Your review request still exists, but the diff is not " + - "attached.") - - if options.publish: - server.publish(review_request) - - request_url = 'r/' + str(review_request['id']) - review_url = urljoin(server.url, request_url) - - if not review_url.startswith('http'): - review_url = 'http://%s' % review_url - - print "Review request #%s posted." % (review_request['id'],) - print - print review_url - - return review_url - - -def parse_options(args): - parser = OptionParser(usage="%prog [-pond] [-r review_id] [changenum]", - version="%prog " + VERSION) - - parser.add_option("-p", "--publish", - dest="publish", action="store_true", default=PUBLISH, - help="publish the review request immediately after " - "submitting") - parser.add_option("-r", "--review-request-id", - dest="rid", metavar="ID", default=None, - help="existing review request ID to update") - parser.add_option("-o", "--open", - dest="open_browser", action="store_true", - default=OPEN_BROWSER, - help="open a web browser to the review request page") - parser.add_option("-n", "--output-diff", - dest="output_diff_only", action="store_true", - default=False, - help="outputs a diff to the console and exits. " - "Does not post") - parser.add_option("--server", - dest="server", default=REVIEWBOARD_URL, - metavar="SERVER", - help="specify a different Review Board server " - "to use") - parser.add_option("--diff-only", - dest="diff_only", action="store_true", default=False, - help="uploads a new diff, but does not update " - "info from changelist") - parser.add_option("--target-groups", - dest="target_groups", default=TARGET_GROUPS, - help="names of the groups who will perform " - "the review") - parser.add_option("--target-people", - dest="target_people", default=TARGET_PEOPLE, - help="names of the people who will perform " - "the review") - parser.add_option("--summary", - dest="summary", default=None, - help="summary of the review ") - parser.add_option("--description", - dest="description", default=None, - help="description of the review ") - parser.add_option("--description-file", - dest="description_file", default=None, - help="text file containing a description of the review") - parser.add_option("--guess-summary", - dest="guess_summary", action="store_true", - default=False, - help="guess summary from the latest commit (git/" - "hgsubversion only)") - parser.add_option("--guess-description", - dest="guess_description", action="store_true", - default=False, - help="guess description based on commits on this branch " - "(git/hgsubversion only)") - parser.add_option("--testing-done", - dest="testing_done", default=None, - help="details of testing done ") - parser.add_option("--testing-done-file", - dest="testing_file", default=None, - help="text file containing details of testing done ") - parser.add_option("--branch", - dest="branch", default=None, - help="affected branch ") - parser.add_option("--bugs-closed", - dest="bugs_closed", default=None, - help="list of bugs closed ") - parser.add_option("--revision-range", - dest="revision_range", default=None, - help="generate the diff for review based on given " - "revision range") - parser.add_option("--label", - dest="label", default=None, - help="label (ClearCase Only) ") - parser.add_option("--submit-as", - dest="submit_as", default=SUBMIT_AS, metavar="USERNAME", - help="user name to be recorded as the author of the " - "review request, instead of the logged in user") - parser.add_option("--username", - dest="username", default=None, metavar="USERNAME", - help="user name to be supplied to the reviewboard server") - parser.add_option("--password", - dest="password", default=None, metavar="PASSWORD", - help="password to be supplied to the reviewboard server") - parser.add_option("--change-only", - dest="change_only", action="store_true", - default=False, - help="updates info from changelist, but does " - "not upload a new diff (only available if your " - "repository supports changesets)") - parser.add_option("--parent", - dest="parent_branch", default=None, - metavar="PARENT_BRANCH", - help="the parent branch this diff should be against " - "(only available if your repository supports " - "parent diffs)") - parser.add_option("--p4-client", - dest="p4_client", default=None, - help="the Perforce client name that the review is in") - parser.add_option("--p4-port", - dest="p4_port", default=None, - help="the Perforce servers IP address that the review is on") - parser.add_option("--repository-url", - dest="repository_url", default=None, - help="the url for a repository for creating a diff " - "outside of a working copy (currently only supported " - "by Subversion). Requires --revision-range") - parser.add_option("-d", "--debug", - action="store_true", dest="debug", default=DEBUG, - help="display debug output") - - (globals()["options"], args) = parser.parse_args(args) - - if options.description and options.description_file: - sys.stderr.write("The --description and --description-file options " - "are mutually exclusive.\n") - sys.exit(1) - - if options.description_file: - if os.path.exists(options.description_file): - fp = open(options.description_file, "r") - options.description = fp.read() - fp.close() - else: - sys.stderr.write("The description file %s does not exist.\n" % - options.description_file) - sys.exit(1) - - if options.testing_done and options.testing_file: - sys.stderr.write("The --testing-done and --testing-done-file options " - "are mutually exclusive.\n") - sys.exit(1) - - if options.testing_file: - if os.path.exists(options.testing_file): - fp = open(options.testing_file, "r") - options.testing_done = fp.read() - fp.close() - else: - sys.stderr.write("The testing file %s does not exist.\n" % - options.testing_file) - sys.exit(1) - - if options.repository_url and not options.revision_range: - sys.stderr.write("The --repository-url option requires the " - "--revision-range option.\n") - sys.exit(1) - - return args - -def determine_client(): - - repository_info = None - tool = None - - # Try to find the SCM Client we're going to be working with. - for tool in SCMCLIENTS: - repository_info = tool.get_repository_info() - - if repository_info: - break - - if not repository_info: - if options.repository_url: - print "No supported repository could be access at the supplied url." - else: - print "The current directory does not contain a checkout from a" - print "supported source code repository." - sys.exit(1) - - # Verify that options specific to an SCM Client have not been mis-used. - if options.change_only and not repository_info.supports_changesets: - sys.stderr.write("The --change-only option is not valid for the " - "current SCM client.\n") - sys.exit(1) - - if options.parent_branch and not repository_info.supports_parent_diffs: - sys.stderr.write("The --parent option is not valid for the " - "current SCM client.\n") - sys.exit(1) - - if ((options.p4_client or options.p4_port) and \ - not isinstance(tool, PerforceClient)): - sys.stderr.write("The --p4-client and --p4-port options are not valid " - "for the current SCM client.\n") - sys.exit(1) - - return (repository_info, tool) - -def main(): - if 'USERPROFILE' in os.environ: - homepath = os.path.join(os.environ["USERPROFILE"], "Local Settings", - "Application Data") - elif 'HOME' in os.environ: - homepath = os.environ["HOME"] - else: - homepath = '' - - # Load the config and cookie files - globals()['user_config'] = \ - load_config_file(os.path.join(homepath, ".reviewboardrc")) - cookie_file = os.path.join(homepath, ".post-review-cookies.txt") - - args = parse_options(sys.argv[1:]) - - repository_info, tool = determine_client() - - # Try to find a valid Review Board server to use. - if options.server: - server_url = options.server - else: - server_url = tool.scan_for_server(repository_info) - - if not server_url: - print "Unable to find a Review Board server for this source code tree." - sys.exit(1) - - server = ReviewBoardServer(server_url, repository_info, cookie_file) - - if repository_info.supports_changesets: - changenum = tool.get_changenum(args) - else: - changenum = None - - if options.revision_range: - diff = tool.diff_between_revisions(options.revision_range, args, - repository_info) - parent_diff = None - elif options.label and isinstance(tool, ClearCaseClient): - diff, parent_diff = tool.diff_label(options.label) - else: - diff, parent_diff = tool.diff(args) - - if options.output_diff_only: - print diff - sys.exit(0) - - # Let's begin. - server.login() - - review_url = tempt_fate(server, tool, changenum, diff_content=diff, - parent_diff_content=parent_diff, - submit_as=options.submit_as) - - # Load the review up in the browser if requested to: - if options.open_browser: - try: - import webbrowser - if 'open_new_tab' in dir(webbrowser): - # open_new_tab is only in python 2.5+ - webbrowser.open_new_tab(review_url) - elif 'open_new' in dir(webbrowser): - webbrowser.open_new(review_url) - else: - os.system( 'start %s' % review_url ) - except: - print 'Error opening review URL: %s' % review_url - - -if __name__ == "__main__": - main() diff --git a/test/review b/test/review deleted file mode 100755 index e1ccb9c0af..0000000000 --- a/test/review +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -if [ -z $1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ] || [ "$1" = "-?" ]; then - echo "Usage: `basename $0` [rev] [args]\n" - echo " [rev] : either the revision number without leading 'r' (post-commit)," - echo " or '-loc' to create a review from current local changes (pre-commit)\n" - echo " [args] : optional arguments:" - echo " -r ID existing review request ID to update\n" - exit 1 -fi - -POSTREVIEW=`dirname $0`/postreview.py - -if [ "$1" = "-loc" ]; then - echo "creating review request from local changes..." - REVARG="" - LOG="" - SUMMARY="local changes" - REPO="" -else - REV=$1 - PREV=`expr $REV - 1` - if [ $? -ne 0 ]; then - echo "argument revision not a number: $REV" - exit 1 - fi - - echo "creating review request for changeset $REV..." - - LOG="`svn log http://lampsvn.epfl.ch/svn-repos/scala -c $REV`" - if [ $? -ne 0 ]; then - echo "could not get svn log for revision $REV" - exit 1 - fi - - REVARG="--revision-range=$PREV:$REV" - SUMMARY="r$REV" - REPO="--repository-url=http://lampsvn.epfl.ch/svn-repos/scala" -fi - - -shift # remove parameter $1 (revision) - -python $POSTREVIEW --server="https://chara2.epfl.ch" $REVARG --summary="$SUMMARY" --description="$LOG" $REPO -o $@ diff --git a/test/scaladoc/resources/SI_4715.scala b/test/scaladoc/resources/SI_4715.scala index 29daf43717..de286956bc 100644 --- a/test/scaladoc/resources/SI_4715.scala +++ b/test/scaladoc/resources/SI_4715.scala @@ -1,7 +1,7 @@ class SI_4715 { type :+:[X,Y] = Map[X,Y] - val withType: Int :+: Double = error("") + val withType: Int :+: Double = sys.error("") trait :-:[X,Y] - val withTrait: Int :-: Double = error("") + val withTrait: Int :-: Double = sys.error("") } diff --git a/test/scaladoc/resources/Trac4325.scala b/test/scaladoc/resources/Trac4325.scala index ffb968d571..ccc2f1900a 100644 --- a/test/scaladoc/resources/Trac4325.scala +++ b/test/scaladoc/resources/Trac4325.scala @@ -1,5 +1,5 @@ -case class WithSynthetic +case class WithSynthetic() -case class WithObject +case class WithObject() object WithObject diff --git a/test/scaladoc/resources/doc-root/Any.scala b/test/scaladoc/resources/doc-root/Any.scala index 031b7d9d8c..fd4c287b4f 100644 --- a/test/scaladoc/resources/doc-root/Any.scala +++ b/test/scaladoc/resources/doc-root/Any.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** diff --git a/test/scaladoc/resources/doc-root/AnyRef.scala b/test/scaladoc/resources/doc-root/AnyRef.scala index 7d8b9f9e76..362fbcf0f5 100644 --- a/test/scaladoc/resources/doc-root/AnyRef.scala +++ b/test/scaladoc/resources/doc-root/AnyRef.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** diff --git a/test/scaladoc/resources/doc-root/Nothing.scala b/test/scaladoc/resources/doc-root/Nothing.scala index eed6066039..57f6fac3f9 100644 --- a/test/scaladoc/resources/doc-root/Nothing.scala +++ b/test/scaladoc/resources/doc-root/Nothing.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** diff --git a/test/scaladoc/resources/doc-root/Null.scala b/test/scaladoc/resources/doc-root/Null.scala index 7455e78ae7..931beb2d1a 100644 --- a/test/scaladoc/resources/doc-root/Null.scala +++ b/test/scaladoc/resources/doc-root/Null.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** diff --git a/test/scaladoc/resources/implicits-base-res.scala b/test/scaladoc/resources/implicits-base-res.scala index d6c0332c10..1d17e9a6d3 100644 --- a/test/scaladoc/resources/implicits-base-res.scala +++ b/test/scaladoc/resources/implicits-base-res.scala @@ -11,21 +11,21 @@ trait MyNumeric[R] * - tests the complete type inference * - the following inherited methods should appear: * {{{ - * def convToGtColonDoubleA(x: Double) // pimpA3: with a constraint that T <: Double - * def convToIntA(x: Int) // pimpA2: with a constraint that T = Int - * def convToManifestA(x: T) // pimpA7: with 2 constraints: T: Manifest and T <: Double - * def convToMyNumericA(x: T) // pimpA6: with a constraint that there is x: MyNumeric[T] implicit in scope - * def convToNumericA(x: T) // pimpA1: with a constraint that there is x: Numeric[T] implicit in scope - * def convToPimpedA(x: Bar[Foo[T]]) // pimpA5: no constraints, SHADOWED - * def convToPimpedA(x: S) // pimpA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar, SHADOWED - * def convToPimpedA(x: T) // pimpA0: with no constraints, SHADOWED - * def convToTraversableOps(x: T) // pimpA7: with 2 constraints: T: Manifest and T <: Double + * def convToGtColonDoubleA(x: Double) // enrichA3: with a constraint that T <: Double + * def convToIntA(x: Int) // enrichA2: with a constraint that T = Int + * def convToManifestA(x: T) // enrichA7: with 2 constraints: T: Manifest and T <: Double + * def convToMyNumericA(x: T) // enrichA6: with a constraint that there is x: MyNumeric[T] implicit in scope + * def convToNumericA(x: T) // enrichA1: with a constraint that there is x: Numeric[T] implicit in scope + * def convToEnrichedA(x: Bar[Foo[T]]) // enrichA5: no constraints, SHADOWED + * def convToEnrichedA(x: S) // enrichA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar, SHADOWED + * def convToEnrichedA(x: T) // enrichA0: with no constraints, SHADOWED + * def convToTraversableOps(x: T) // enrichA7: with 2 constraints: T: Manifest and T <: Double * // should not be abstract! * }}} */ class A[T] { - /** This should prevent the implicitly inherited `def convToPimpedA: T` from `pimpA0` from showing up */ - def convToPimpedA(x: T): T = sys.error("Let's check it out!") + /** This should prevent the implicitly inherited `def convToEnrichedA: T` from `enrichA0` from showing up */ + def convToEnrichedA(x: T): T = sys.error("Let's check it out!") /** This should check implicit member elimination in the case of subtyping */ def foo(a: T, b: AnyRef): T } @@ -33,15 +33,15 @@ class A[T] { object A { import language.implicitConversions // according to SIP18 - implicit def pimpA0[V](a: A[V]) = new PimpedA(a) - implicit def pimpA1[ZBUR: Numeric](a: A[ZBUR]) = new NumericA[ZBUR](a) - implicit def pimpA2(a: A[Int]) = new IntA(a) - implicit def pimpA3(a: A[T] forSome { type T <: Double }) = new GtColonDoubleA(a) - implicit def pimpA4[S](a: A[Foo[Bar[S]]])(implicit foo: Foo[S], bar: Bar[S]): PimpedA[S] = sys.error("not implemented") - implicit def pimpA5[Z](a: A[Z]): PimpedA[Bar[Foo[Z]]] = sys.error("not implemented") - implicit def pimpA6[Z: MyNumeric](a: A[Z]) = new MyNumericA[Z](a) + implicit def enrichA0[V](a: A[V]) = new EnrichedA(a) + implicit def enrichA1[ZBUR: Numeric](a: A[ZBUR]) = new NumericA[ZBUR](a) + implicit def enrichA2(a: A[Int]) = new IntA(a) + implicit def enrichA3(a: A[T] forSome { type T <: Double }) = new GtColonDoubleA(a) + implicit def enrichA4[S](a: A[Foo[Bar[S]]])(implicit foo: Foo[S], bar: Bar[S]): EnrichedA[S] = sys.error("not implemented") + implicit def enrichA5[Z](a: A[Z]): EnrichedA[Bar[Foo[Z]]] = sys.error("not implemented") + implicit def enrichA6[Z: MyNumeric](a: A[Z]) = new MyNumericA[Z](a) // TODO: Add H <: Double and see why it crashes for C and D -- context bounds, need to check! - implicit def pimpA7[H <: Double : Manifest](a: A[H]) = new ManifestA[H](a) with MyTraversableOps[H] { def convToTraversableOps(x: H): H = sys.error("no") } + implicit def enrichA7[H <: Double : Manifest](a: A[H]) = new ManifestA[H](a) with MyTraversableOps[H] { def convToTraversableOps(x: H): H = sys.error("no") } } @@ -49,14 +49,14 @@ object A { * - tests the existential type solving * - the following inherited methods should appear: * {{{ - * def convToGtColonDoubleA(x: Double) // pimpA3: no constraints - * def convToManifestA(x: Double) // pimpA7: no constraints - * def convToMyNumericA(x: Double) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope - * def convToNumericA(x: Double) // pimpA1: no constraintsd - * def convToPimpedA(x: Bar[Foo[Double]]) // pimpA5: no constraints, SHADOWED - * def convToPimpedA(x: Double) // pimpA0: no constraints, SHADOWED - * def convToTraversableOps(x: Double) // pimpA7: no constraints - * // should not be abstract! + * def convToGtColonDoubleA(x: Double) // enrichA3: no constraints + * def convToManifestA(x: Double) // enrichA7: no constraints + * def convToMyNumericA(x: Double) // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope + * def convToNumericA(x: Double) // enrichA1: no constraintsd + * def convToEnrichedA(x: Bar[Foo[Double]]) // enrichA5: no constraints, SHADOWED + * def convToEnrichedA(x: Double) // enrichA0: no constraints, SHADOWED + * def convToTraversableOps(x: Double) // enrichA7: no constraints + * // should not be abstract! * }}} */ class B extends A[Double] @@ -67,11 +67,11 @@ object B extends A * - tests asSeenFrom * - the following inherited methods should appear: * {{{ - * def convToIntA(x: Int) // pimpA2: no constraints - * def convToMyNumericA(x: Int) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope - * def convToNumericA(x: Int) // pimpA1: no constraints - * def convToPimpedA(x: Int) // pimpA0: no constraints, SHADOWED - * def convToPimpedA(x: Bar[Foo[Int]]) // pimpA5: no constraints, SHADOWED + * def convToIntA(x: Int) // enrichA2: no constraints + * def convToMyNumericA(x: Int) // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope + * def convToNumericA(x: Int) // enrichA1: no constraints + * def convToEnrichedA(x: Int) // enrichA0: no constraints, SHADOWED + * def convToEnrichedA(x: Bar[Foo[Int]]) // enrichA5: no constraints, SHADOWED * }}} */ class C extends A[Int] @@ -82,10 +82,10 @@ object C extends A * - tests implicit elimination * - the following inherited methods should appear: * {{{ - * def convToMyNumericA(x: String) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope - * def convToNumericA(x: String) // pimpA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope - * def convToPimpedA(x: Bar[Foo[String]]) // pimpA5: no constraints, SHADOWED - * def convToPimpedA(x: String) // pimpA0: no constraints, SHADOWED + * def convToMyNumericA(x: String) // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope + * def convToNumericA(x: String) // enrichA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope + * def convToEnrichedA(x: Bar[Foo[String]]) // enrichA5: no constraints, SHADOWED + * def convToEnrichedA(x: String) // enrichA0: no constraints, SHADOWED * }}} */ class D extends A[String] @@ -93,12 +93,12 @@ class D extends A[String] object D extends A -/** PimpedA class <br/> +/** EnrichedA class <br/> * - tests simple inheritance and asSeenFrom * - A, B and C should be implicitly converted to this */ -class PimpedA[V](a: A[V]) { - /** The convToPimpedA: V documentation... */ - def convToPimpedA(x: V): V = sys.error("Not implemented") +class EnrichedA[V](a: A[V]) { + /** The convToEnrichedA: V documentation... */ + def convToEnrichedA(x: V): V = sys.error("Not implemented") } /** NumericA class <br/> diff --git a/test/scaladoc/resources/links.scala b/test/scaladoc/resources/links.scala index bd69665357..ecac9c63cf 100644 --- a/test/scaladoc/resources/links.scala +++ b/test/scaladoc/resources/links.scala @@ -25,6 +25,7 @@ package scala.test.scaladoc.links { object Target { type T = Int => Int type S = Int + type ::[X] = scala.collection.immutable.::[X] class C def foo(i: Int) = 2 def foo(z: String) = 3 @@ -46,6 +47,7 @@ package scala.test.scaladoc.links { * - [[[[Target!.foo[A[_[_]]]* trait Target -> def foo with 3 nested tparams]]]] (should exercise nested parens) * - [[Target$.T object Target -> type T]] * - [[Target$.S object Target -> type S]] + * - [[Target$.:: object Target -> type ::]] * - [[Target$.foo(z:Str* object Target -> def foo]] * - [[Target$.bar object Target -> def bar]] * - [[[[Target$.foo[A[_[_]]]* trait Target -> def foo with 3 nested tparams]]]] (should exercise nested parens) diff --git a/test/scaladoc/run/SI-191-deprecated.check b/test/scaladoc/run/SI-191-deprecated.check deleted file mode 100755 index 3925a0d464..0000000000 --- a/test/scaladoc/run/SI-191-deprecated.check +++ /dev/null @@ -1 +0,0 @@ -Done.
\ No newline at end of file diff --git a/test/scaladoc/run/SI-191-deprecated.scala b/test/scaladoc/run/SI-191-deprecated.scala deleted file mode 100755 index 4ed24ff8d1..0000000000 --- a/test/scaladoc/run/SI-191-deprecated.scala +++ /dev/null @@ -1,72 +0,0 @@ -import scala.tools.nsc.doc.model._ -import scala.tools.nsc.doc.base._ -import scala.tools.nsc.doc.base.comment._ -import scala.tools.partest.ScaladocModelTest -import java.net.{URI, URL} -import java.io.File - -object Test extends ScaladocModelTest { - - override def code = - """ - /** See: - * - [[scala.collection.Map]] Simple linking - * - [[scala.collection.immutable.::]] Linking with symbolic name - * - [[scala.Int]].toLong Linking to a class - * - [[scala.Predef]] Linking to an object - * - [[scala.Int.toLong]] Linking to a method - * - [[scala]] Linking to a package - * - [[scala.AbstractMethodError]] Linking to a member in the package object - * - [[scala.Predef.String]] Linking to a member in an object - * - * Don't look at: - * - [[scala.NoLink]] Not linking :) - */ - object Test { - def foo(param: Any) {} - def barr(l: scala.collection.immutable.List[Any]) {} - def bar(l: List[String]) {} // TODO: Should be able to link to type aliases - def baz(d: java.util.Date) {} // Should not be resolved - } - """ - - def scalaURL = "http://bog.us" - - override def scaladocSettings = "-no-link-warnings -external-urls scala=" + scalaURL - - def testModel(rootPackage: Package) { - import access._ - val test = rootPackage._object("Test") - - def check(memberDef: Def, expected: Int) { - val externals = memberDef.valueParams(0)(0).resultType.refEntity collect { - case (_, (LinkToExternal(name, url), _)) => assert(url.contains(scalaURL)); name - } - assert(externals.size == expected) - } - - check(test._method("foo"), 1) - check(test._method("bar"), 0) - check(test._method("barr"), 2) - check(test._method("baz"), 0) - - val expectedUrls = collection.mutable.Set[String]( - "scala.collection.Map", - "scala.collection.immutable.::", - "scala.Int", - "scala.Predef$", - "scala.Int@toLong:Long", - "scala.package", - "scala.package@AbstractMethodError=AbstractMethodError", - "scala.Predef$@String=String" - ).map(scalaURL + "/index.html#" + _) - - def isExpectedExternalLink(l: EntityLink) = l.link match { - case LinkToExternal(name, url) => assert(expectedUrls contains url, url); true - case _ => false - } - - assert(countLinks(test.comment.get, isExpectedExternalLink) == 8, - countLinks(test.comment.get, isExpectedExternalLink) + " == 8") - } -} diff --git a/test/scaladoc/run/SI-4676.scala b/test/scaladoc/run/SI-4676.scala index b83a59a472..99b3c5568a 100644 --- a/test/scaladoc/run/SI-4676.scala +++ b/test/scaladoc/run/SI-4676.scala @@ -21,6 +21,7 @@ object Test extends ScaladocModelTest { // check correct expansion of the use case signature val x = rootPackage._class("SI_4676")._method("x") - assert(x.valueParams(0)(0).resultType.name == "(String, String)", "parameter ss of method x has type (String, String") + val resultType = x.valueParams(0)(0).resultType.name + assert(resultType == "SS", s"parameter ss of method x has type $resultType, expected SS!") } }
\ No newline at end of file diff --git a/test/scaladoc/run/implicits-base.scala b/test/scaladoc/run/implicits-base.scala index 3d57306f5d..8f8652cdb3 100644 --- a/test/scaladoc/run/implicits-base.scala +++ b/test/scaladoc/run/implicits-base.scala @@ -25,54 +25,54 @@ object Test extends ScaladocModelTest { val A = base._class("A") - // def convToPimpedA(x: T) // pimpA0: with no constraints, SHADOWED - conv = A._conversion(A.qualifiedName + ".pimpA0") + // def convToEnrichedA(x: T) // enrichA0: with no constraints, SHADOWED + conv = A._conversion(A.qualifiedName + ".enrichA0") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "T") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "T") - // def convToNumericA: T // pimpA1: with a constraint that there is x: Numeric[T] implicit in scope - conv = A._conversion(A.qualifiedName + ".pimpA1") + // def convToNumericA: T // enrichA1: with a constraint that there is x: Numeric[T] implicit in scope + conv = A._conversion(A.qualifiedName + ".enrichA1") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToNumericA").resultType.name == "T") - // def convToIntA: Int // pimpA2: with a constraint that T = Int - conv = A._conversion(A.qualifiedName + ".pimpA2") + // def convToIntA: Int // enrichA2: with a constraint that T = Int + conv = A._conversion(A.qualifiedName + ".enrichA2") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToIntA").resultType.name == "Int") - // def convToGtColonDoubleA: Double // pimpA3: with a constraint that T <: Double - conv = A._conversion(A.qualifiedName + ".pimpA3") + // def convToGtColonDoubleA: Double // enrichA3: with a constraint that T <: Double + conv = A._conversion(A.qualifiedName + ".enrichA3") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToGtColonDoubleA").resultType.name == "Double") - // def convToPimpedA: S // pimpA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar - conv = A._conversion(A.qualifiedName + ".pimpA4") + // def convToEnrichedA: S // enrichA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar + conv = A._conversion(A.qualifiedName + ".enrichA4") assert(conv.members.length == 1) assert(conv.constraints.length == 3) - assert(conv._member("convToPimpedA").resultType.name == "S") + assert(conv._member("convToEnrichedA").resultType.name == "S") - // def convToPimpedA: Bar[Foo[T]] // pimpA5: no constraints - conv = A._conversion(A.qualifiedName + ".pimpA5") + // def convToEnrichedA: Bar[Foo[T]] // enrichA5: no constraints + conv = A._conversion(A.qualifiedName + ".enrichA5") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Bar[Foo[T]]") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Bar[Foo[T]]") - // def convToMyNumericA: T // pimpA6: with a constraint that there is x: MyNumeric[T] implicit in scope - conv = A._conversion(A.qualifiedName + ".pimpA6") + // def convToMyNumericA: T // enrichA6: with a constraint that there is x: MyNumeric[T] implicit in scope + conv = A._conversion(A.qualifiedName + ".enrichA6") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToMyNumericA").resultType.name == "T") - // def convToManifestA: T // pimpA7: with 2 constraints: T: Manifest and T <: Double - // def convToTraversableOps: T // pimpA7: with 2 constraints: T: Manifest and T <: Double + // def convToManifestA: T // enrichA7: with 2 constraints: T: Manifest and T <: Double + // def convToTraversableOps: T // enrichA7: with 2 constraints: T: Manifest and T <: Double // should not be abstract! - conv = A._conversion(A.qualifiedName + ".pimpA7") + conv = A._conversion(A.qualifiedName + ".enrichA7") assert(conv.members.length == 2) assert(conv.constraints.length == 2) assert(conv._member("convToManifestA").resultType.name == "T") @@ -84,45 +84,45 @@ object Test extends ScaladocModelTest { val B = base._class("B") // these conversions should not affect B - assert(B._conversions(A.qualifiedName + ".pimpA2").isEmpty) - assert(B._conversions(A.qualifiedName + ".pimpA4").isEmpty) + assert(B._conversions(A.qualifiedName + ".enrichA2").isEmpty) + assert(B._conversions(A.qualifiedName + ".enrichA4").isEmpty) - // def convToPimpedA(x: Double) // pimpA0: no constraints, SHADOWED - conv = B._conversion(A.qualifiedName + ".pimpA0") + // def convToEnrichedA(x: Double) // enrichA0: no constraints, SHADOWED + conv = B._conversion(A.qualifiedName + ".enrichA0") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Double") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Double") - // def convToNumericA: Double // pimpA1: no constraintsd - conv = B._conversion(A.qualifiedName + ".pimpA1") + // def convToNumericA: Double // enrichA1: no constraintsd + conv = B._conversion(A.qualifiedName + ".enrichA1") assert(conv.members.length == 1) assert(conv.constraints.length == 0) assert(conv._member("convToNumericA").resultType.name == "Double") - // def convToGtColonDoubleA: Double // pimpA3: no constraints - conv = B._conversion(A.qualifiedName + ".pimpA3") + // def convToGtColonDoubleA: Double // enrichA3: no constraints + conv = B._conversion(A.qualifiedName + ".enrichA3") assert(conv.members.length == 1) assert(conv.constraints.length == 0) assert(conv._member("convToGtColonDoubleA").resultType.name == "Double") - // def convToPimpedA: Bar[Foo[Double]] // pimpA5: no constraints - conv = B._conversion(A.qualifiedName + ".pimpA5") + // def convToEnrichedA: Bar[Foo[Double]] // enrichA5: no constraints + conv = B._conversion(A.qualifiedName + ".enrichA5") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Bar[Foo[Double]]") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Bar[Foo[Double]]") - // def convToMyNumericA: Double // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope - conv = B._conversion(A.qualifiedName + ".pimpA6") + // def convToMyNumericA: Double // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope + conv = B._conversion(A.qualifiedName + ".enrichA6") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToMyNumericA").resultType.name == "Double") - // def convToManifestA: Double // pimpA7: no constraints - // def convToTraversableOps: Double // pimpA7: no constraints + // def convToManifestA: Double // enrichA7: no constraints + // def convToTraversableOps: Double // enrichA7: no constraints // // should not be abstract! - conv = B._conversion(A.qualifiedName + ".pimpA7") + conv = B._conversion(A.qualifiedName + ".enrichA7") assert(conv.members.length == 2) assert(conv.constraints.length == 0) assert(conv._member("convToManifestA").resultType.name == "Double") @@ -134,38 +134,38 @@ object Test extends ScaladocModelTest { val C = base._class("C") // these conversions should not affect C - assert(C._conversions(A.qualifiedName + ".pimpA3").isEmpty) - assert(C._conversions(A.qualifiedName + ".pimpA4").isEmpty) - assert(C._conversions(A.qualifiedName + ".pimpA7").isEmpty) + assert(C._conversions(A.qualifiedName + ".enrichA3").isEmpty) + assert(C._conversions(A.qualifiedName + ".enrichA4").isEmpty) + assert(C._conversions(A.qualifiedName + ".enrichA7").isEmpty) - // def convToPimpedA(x: Int) // pimpA0: no constraints, SHADOWED - conv = C._conversion(A.qualifiedName + ".pimpA0") + // def convToEnrichedA(x: Int) // enrichA0: no constraints, SHADOWED + conv = C._conversion(A.qualifiedName + ".enrichA0") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Int") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Int") - // def convToNumericA: Int // pimpA1: no constraints - conv = C._conversion(A.qualifiedName + ".pimpA1") + // def convToNumericA: Int // enrichA1: no constraints + conv = C._conversion(A.qualifiedName + ".enrichA1") assert(conv.members.length == 1) assert(conv.constraints.length == 0) assert(conv._member("convToNumericA").resultType.name == "Int") - // def convToIntA: Int // pimpA2: no constraints - conv = C._conversion(A.qualifiedName + ".pimpA2") + // def convToIntA: Int // enrichA2: no constraints + conv = C._conversion(A.qualifiedName + ".enrichA2") assert(conv.members.length == 1) assert(conv.constraints.length == 0) assert(conv._member("convToIntA").resultType.name == "Int") - // def convToPimpedA: Bar[Foo[Int]] // pimpA5: no constraints - conv = C._conversion(A.qualifiedName + ".pimpA5") + // def convToEnrichedA: Bar[Foo[Int]] // enrichA5: no constraints + conv = C._conversion(A.qualifiedName + ".enrichA5") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Bar[Foo[Int]]") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Bar[Foo[Int]]") - // def convToMyNumericA: Int // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope - conv = C._conversion(A.qualifiedName + ".pimpA6") + // def convToMyNumericA: Int // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope + conv = C._conversion(A.qualifiedName + ".enrichA6") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToMyNumericA").resultType.name == "Int") @@ -175,33 +175,33 @@ object Test extends ScaladocModelTest { val D = base._class("D") // these conversions should not affect D - assert(D._conversions(A.qualifiedName + ".pimpA2").isEmpty) - assert(D._conversions(A.qualifiedName + ".pimpA3").isEmpty) - assert(D._conversions(A.qualifiedName + ".pimpA4").isEmpty) - assert(D._conversions(A.qualifiedName + ".pimpA7").isEmpty) + assert(D._conversions(A.qualifiedName + ".enrichA2").isEmpty) + assert(D._conversions(A.qualifiedName + ".enrichA3").isEmpty) + assert(D._conversions(A.qualifiedName + ".enrichA4").isEmpty) + assert(D._conversions(A.qualifiedName + ".enrichA7").isEmpty) - // def convToPimpedA(x: String) // pimpA0: no constraints, SHADOWED - conv = D._conversion(A.qualifiedName + ".pimpA0") + // def convToEnrichedA(x: String) // enrichA0: no constraints, SHADOWED + conv = D._conversion(A.qualifiedName + ".enrichA0") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "String") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "String") - // def convToNumericA: String // pimpA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope - conv = D._conversion(A.qualifiedName + ".pimpA1") + // def convToNumericA: String // enrichA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope + conv = D._conversion(A.qualifiedName + ".enrichA1") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToNumericA").resultType.name == "String") - // def convToPimpedA: Bar[Foo[String]] // pimpA5: no constraints - conv = D._conversion(A.qualifiedName + ".pimpA5") + // def convToEnrichedA: Bar[Foo[String]] // enrichA5: no constraints + conv = D._conversion(A.qualifiedName + ".enrichA5") assert(conv.members.length == 1) assert(conv.constraints.length == 0) - assert(isShadowed(conv._member("convToPimpedA"))) - assert(conv._member("convToPimpedA").resultType.name == "Bar[Foo[String]]") + assert(isShadowed(conv._member("convToEnrichedA"))) + assert(conv._member("convToEnrichedA").resultType.name == "Bar[Foo[String]]") - // def convToMyNumericA: String // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope - conv = D._conversion(A.qualifiedName + ".pimpA6") + // def convToMyNumericA: String // enrichA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope + conv = D._conversion(A.qualifiedName + ".enrichA6") assert(conv.members.length == 1) assert(conv.constraints.length == 1) assert(conv._member("convToMyNumericA").resultType.name == "String") diff --git a/test/scaladoc/run/links.scala b/test/scaladoc/run/links.scala index fde24edb2a..64441c2d95 100644 --- a/test/scaladoc/run/links.scala +++ b/test/scaladoc/run/links.scala @@ -26,7 +26,7 @@ object Test extends ScaladocModelTest { val memberLinks = countLinks(TEST.comment.get, _.link.isInstanceOf[LinkToMember[_, _]]) val templateLinks = countLinks(TEST.comment.get, _.link.isInstanceOf[LinkToTpl[_]]) - assert(memberLinks == 17, memberLinks + " == 17 (the member links in object TEST)") + assert(memberLinks == 18, memberLinks + " == 18 (the member links in object TEST)") assert(templateLinks == 6, templateLinks + " == 6 (the template links in object TEST)") } } diff --git a/test/files/run/t5527.check b/test/scaladoc/run/t5527.check index 36bee9bb55..bfaa4ad0ed 100644 --- a/test/files/run/t5527.check +++ b/test/scaladoc/run/t5527.check @@ -1,3 +1,12 @@ +newSource1.scala:47: warning: discarding unmoored doc comment + /** Document this crucial constant for posterity. + ^ +newSource1.scala:64: warning: discarding unmoored doc comment + /*************************\ + ^ +newSource1.scala:73: warning: discarding unmoored doc comment + val i = 10 */** Important! + ^ [[syntax trees at end of parser]] // newSource1.scala package <empty> { object UselessComments extends scala.AnyRef { @@ -39,6 +48,26 @@ package <empty> { val test4 = 'a' match { case ('0'| '1'| '2'| '3'| '4'| '5'| '6'| '7'| '8'| '9') => true case _ => false + }; + def test5: scala.Unit = if (true) + $qmark$qmark$qmark + else + (); + def test6 = { + val u = 4; + 0.to(u).foreach(((i) => println(i))) + }; + def test7 = { + val u = 4; + 0.to(u).foreach(((i) => println(i))) + }; + def test8 = { + val z = "fancy"; + z.replace("fanc", "arts") + }; + def test9 = { + val i = 10.$times(10); + assert(i.$eq$eq(100)) } }; /** comments that we should keep */ @@ -66,7 +95,7 @@ package <empty> { () }; /** T */ - type T >: _root_.scala.Nothing <: _root_.scala.Any; + type T; /** f */ def f(i: Int): scala.Unit; /** v */ @@ -93,7 +122,11 @@ package <empty> { super.<init>(); () } - } + }; + /** Get the simple value. + * @return the default value + */ + def value: Int = 7 } } diff --git a/test/files/run/t5527.scala b/test/scaladoc/run/t5527.scala index 2449ff60c3..770d4ad13f 100644 --- a/test/files/run/t5527.scala +++ b/test/scaladoc/run/t5527.scala @@ -1,7 +1,7 @@ import scala.tools.partest._ import java.io._ import scala.tools.nsc._ -import scala.tools.nsc.util.CommandLineParser +import scala.tools.cmd.CommandLineParser import scala.tools.nsc.doc.{Settings, DocFactory} import scala.tools.nsc.reporters.ConsoleReporter @@ -49,6 +49,47 @@ object Test extends DirectTest { case _ => false } + + def test5 { + /** @martin is this right? It shouldn't flag me as scaladoc. */ + if (true) ??? + } + + def test6 = { + /** Document this crucial constant for posterity. + * Don't forget to dedoc this comment if you refactor to a local. + * @author Paul Phillips + */ + val u = 4 + for (i <- 0 to u) + println(i) + } + def test7 = { + /** Some standard tags are tolerated locally and shouldn't trigger a warning. + * @note Don't change this unless you know what you're doing. This means you. + */ + val u = 4 + for (i <- 0 to u) + println(i) + } + def test8 = { + /*************************\ + * Fancy ASCII Art Block * + * @author som-snytt * + \*************************/ + // this is just a local + val z = "fancy" + z replace ("fanc", "arts") + } + def test9 = { + val i = 10 */** Important! + * We have to multiply here! + * @author community + * @see SI-1234 + */ + 10 + assert(i == 100) + } } /** comments that we should keep */ @@ -85,6 +126,13 @@ object Test extends DirectTest { /** class D */ @deprecated("use ... instead", "2.10.0") class D + + /** Get the simple value. + * @return the default value + */ + // an intervening line comment + /* I had more to say, but didn't want to pollute the scaladoc. */ + def value: Int = 7 } """.trim diff --git a/test/scaladoc/run/t7876.check b/test/scaladoc/run/t7876.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/t7876.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/t7876.scala b/test/scaladoc/run/t7876.scala new file mode 100644 index 0000000000..63c63f8a0c --- /dev/null +++ b/test/scaladoc/run/t7876.scala @@ -0,0 +1,19 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + override def code = """ + import language.higherKinds + trait T[M[_]] + class C extends T[Function0] + class D extends T[Tuple1] + """ + + def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + import access._ + // did not crash + } +} diff --git a/test/scaladoc/run/t7876b.check b/test/scaladoc/run/t7876b.check new file mode 100644 index 0000000000..21aaf3b295 --- /dev/null +++ b/test/scaladoc/run/t7876b.check @@ -0,0 +1,3 @@ +foo: FInt +foo: TInt +Done. diff --git a/test/scaladoc/run/t7876b.scala b/test/scaladoc/run/t7876b.scala new file mode 100644 index 0000000000..4d5b8c22cf --- /dev/null +++ b/test/scaladoc/run/t7876b.scala @@ -0,0 +1,24 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +// Don't dealias just to print a Function or Tuple type. +object Test extends ScaladocModelTest { + + override def code = """ + class Test { + type FInt = Function0[Int] + type TInt = Tuple1[Int] + def foo: FInt + def bar: TInt + } + """ + + def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + import access._ + List("foo", "bar").foreach { name => + println("foo: " + rootPackage._class("Test")._method(name).resultType.name) + } + } +} diff --git a/test/scaladoc/scalacheck/CommentFactoryTest.scala b/test/scaladoc/scalacheck/CommentFactoryTest.scala index 96174d29d1..ff64a25602 100644 --- a/test/scaladoc/scalacheck/CommentFactoryTest.scala +++ b/test/scaladoc/scalacheck/CommentFactoryTest.scala @@ -25,10 +25,10 @@ class Factory(val g: Global, val s: doc.Settings) } def parseComment(s: String): Option[Inline] = - strip(parse(s, "", scala.tools.nsc.util.NoPosition)) + strip(parse(s, "", scala.tools.nsc.util.NoPosition, null)) def createBody(s: String) = - parse(s, "", scala.tools.nsc.util.NoPosition).body + parse(s, "", scala.tools.nsc.util.NoPosition, null).body } object Test extends Properties("CommentFactory") { @@ -45,7 +45,7 @@ object Test extends Properties("CommentFactory") { with MemberLookup) } - def parse(src: String, dst: Inline) = { + def parse(src: String, dst: Inline): Boolean = { factory.parseComment(src) match { case Some(inline) => inline == dst diff --git a/test/scaladoc/scalacheck/HtmlFactoryTest.scala b/test/scaladoc/scalacheck/HtmlFactoryTest.scala index 13eacf79a5..03348b81d2 100644 --- a/test/scaladoc/scalacheck/HtmlFactoryTest.scala +++ b/test/scaladoc/scalacheck/HtmlFactoryTest.scala @@ -2,6 +2,8 @@ import org.scalacheck._ import org.scalacheck.Prop._ import java.net.{URLClassLoader, URLDecoder} +import scala.collection.mutable +import scala.xml.NodeSeq object XMLUtil { import scala.xml._ @@ -34,21 +36,24 @@ object Test extends Properties("HtmlFactory") { // this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths // does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no. // this test _will_ fail again some time in the future. - val paths = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs.map(u => URLDecoder.decode(u.getPath)) - val morepaths = Thread.currentThread.getContextClassLoader.getParent.asInstanceOf[URLClassLoader].getURLs.map(u => URLDecoder.decode(u.getPath)) - (paths ++ morepaths).mkString(java.io.File.pathSeparator) + // Footnote: java.lang.ClassCastException: org.apache.tools.ant.loader.AntClassLoader5 cannot be cast to java.net.URLClassLoader + val loader = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader] + val paths = loader.getURLs.map(u => URLDecoder.decode(u.getPath)) + paths mkString java.io.File.pathSeparator } def createFactory = { val settings = new Settings({Console.err.println(_)}) + settings.scaladocQuietRun = true + settings.nowarn.value = true settings.classpath.value = getClasspath val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings) new DocFactory(reporter, settings) } - def createTemplates(basename: String) = { - val result = scala.collection.mutable.Map[String, scala.xml.NodeSeq]() + def createTemplates(basename: String): collection.Map[String, NodeSeq] = { + val result = mutable.Map[String, NodeSeq]() createFactory.makeUniverse(Left(List(RESOURCES+basename))) match { case Some(universe) => { @@ -57,7 +62,7 @@ object Test extends Properties("HtmlFactory") { result += (page.absoluteLinkTo(page.path) -> page.body) }) } - case _ => ; + case _ => } result @@ -680,7 +685,7 @@ object Test extends Properties("HtmlFactory") { property("package object") = files("com/example/p1/package.html") match { case node: scala.xml.Node => - node.toString contains "com.example.p1.package#packageObjectMethod" + node.toString contains "com.example.p1#packageObjectMethod" case _ => false } diff --git a/test/scaladoc/scalacheck/IndexScriptTest.scala b/test/scaladoc/scalacheck/IndexScriptTest.scala index 5aef38e00a..b8b9f92965 100644 --- a/test/scaladoc/scalacheck/IndexScriptTest.scala +++ b/test/scaladoc/scalacheck/IndexScriptTest.scala @@ -8,14 +8,20 @@ import java.net.{URLClassLoader, URLDecoder} object Test extends Properties("IndexScript") { def getClasspath = { - val loader = Thread.currentThread.getContextClassLoader - val paths = loader.asInstanceOf[URLClassLoader].getURLs - val morepaths = loader.getParent.asInstanceOf[URLClassLoader].getURLs - (paths ++ morepaths).map(u => URLDecoder.decode(u.getPath)).mkString(java.io.File.pathSeparator) + // these things can be tricky + // this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths + // does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no. + // this test _will_ fail again some time in the future. + // Footnote: java.lang.ClassCastException: org.apache.tools.ant.loader.AntClassLoader5 cannot be cast to java.net.URLClassLoader + val loader = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader] + val paths = loader.getURLs.map(u => URLDecoder.decode(u.getPath)) + paths mkString java.io.File.pathSeparator } val docFactory = { val settings = new doc.Settings({Console.err.println(_)}) + settings.scaladocQuietRun = true + settings.nowarn.value = true settings.classpath.value = getClasspath val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings) new doc.DocFactory(reporter, settings) @@ -35,7 +41,7 @@ object Test extends Properties("IndexScript") { } property("allPackages") = { - createIndexScript("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match { + createIndexScript("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match { case Some(index) => index.allPackages.map(_.toString) == List( "scala", diff --git a/test/scaladoc/scalacheck/IndexTest.scala b/test/scaladoc/scalacheck/IndexTest.scala index e114767264..abc0e5da01 100644 --- a/test/scaladoc/scalacheck/IndexTest.scala +++ b/test/scaladoc/scalacheck/IndexTest.scala @@ -12,19 +12,19 @@ object Test extends Properties("Index") { // this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths // does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no. // this test _will_ fail again some time in the future. - val paths = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs.map(u => URLDecoder.decode(u.getPath)) - val morepaths = Thread.currentThread.getContextClassLoader.getParent.asInstanceOf[URLClassLoader].getURLs.map(u => URLDecoder.decode(u.getPath)) - (paths ++ morepaths).mkString(java.io.File.pathSeparator) + // Footnote: java.lang.ClassCastException: org.apache.tools.ant.loader.AntClassLoader5 cannot be cast to java.net.URLClassLoader + val loader = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader] + val paths = loader.getURLs.map(u => URLDecoder.decode(u.getPath)) + paths mkString java.io.File.pathSeparator } val docFactory = { val settings = new doc.Settings({Console.err.println(_)}) - + settings.scaladocQuietRun = true + settings.nowarn.value = true settings.classpath.value = getClasspath - println(settings.classpath.value) val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings) - new doc.DocFactory(reporter, settings) } @@ -56,7 +56,7 @@ object Test extends Properties("Index") { } property("path") = { - createIndex("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match { + createIndex("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match { case Some(index) => index.path == List("index.html") case None => false @@ -64,14 +64,21 @@ object Test extends Properties("Index") { } property("title") = { - createIndex("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match { + createIndex("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match { case Some(index) => index.title == "" case None => false } } + property("browser contants a script element") = { + createIndex("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match { + case Some(index) => + (index.browser \ "script").size == 1 + case None => false + } + } property("package objects in index") = { createIndex("test/scaladoc/resources/SI-5558.scala") match { case Some(index) => diff --git a/test/script-tests/jar-manifest/run-test.check b/test/script-tests/jar-manifest/run-test.check index ef59a6cbac..546bf6be9d 100644 --- a/test/script-tests/jar-manifest/run-test.check +++ b/test/script-tests/jar-manifest/run-test.check @@ -1,4 +1,4 @@ -Scala code runner version 2.10.0.r26038-b20111121102734 -- Copyright 2002-2011, LAMP/EPFL +Scala code runner version 2.10.0.r26038-b20111121102734 -- Copyright 2002-2013, LAMP/EPFL % pwd /scala/trunk/test/script-tests/jar-manifest/target |