summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-09-24 18:48:06 +0300
committerAdriaan Moors <adriaan.moors@typesafe.com>2016-03-26 09:31:13 -0700
commit4f4fb45d7bc41564c3ba0483c5a663172e063994 (patch)
tree1b48a486e1fe93ac92a8beda03c60911fefbd613
parent66b038976d435472b2e5c9720ff2e8cc42177b1a (diff)
downloadscala-4f4fb45d7bc41564c3ba0483c5a663172e063994.tar.gz
scala-4f4fb45d7bc41564c3ba0483c5a663172e063994.tar.bz2
scala-4f4fb45d7bc41564c3ba0483c5a663172e063994.zip
SI-9415 Turn on SAM by default
Initial work to change settings and test by Svyatoslav Ilinskiy Thanks! To avoid cycles during overload resolution (which showed up during bootstrapping), and to improve performance, I've guarded the detection of SAM types in `isCompatible` to cases when the LHS is potentially compatible.
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala4
-rw-r--r--test/files/neg/sammy_error_exist_no_crash.flags1
-rw-r--r--test/files/neg/sammy_restrictions.flags1
-rw-r--r--test/files/neg/sammy_wrong_arity.flags1
-rw-r--r--test/files/pos/sammy_exist.flags1
-rw-r--r--test/files/pos/sammy_overload.flags1
-rw-r--r--test/files/pos/sammy_override.flags1
-rw-r--r--test/files/pos/sammy_poly.flags1
-rw-r--r--test/files/pos/sammy_scope.flags1
-rw-r--r--test/files/pos/sammy_single.flags1
-rw-r--r--test/files/pos/sammy_twice.flags1
-rw-r--r--test/files/pos/t8310.flags1
-rw-r--r--test/files/run/sammy_java8.flags1
-rw-r--r--test/files/run/sammy_repeated.flags1
16 files changed, 3 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
index c6c9545391..807e0cc72f 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -262,7 +262,7 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
else {
// Phase travel necessary. For example, nullary methods (getter of an abstract val) get an
// empty parameter list in later phases and would therefore be picked as SAM.
- val samSym = exitingPickler(definitions.findSam(classSym.tpe))
+ val samSym = exitingPickler(definitions.samOf(classSym.tpe))
if (samSym == NoSymbol) None
else Some(samSym.javaSimpleName.toString + methodSymToDescriptor(samSym))
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 684cf788a4..84cf3c6475 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -295,7 +295,7 @@ trait Infer extends Checkable {
&& !isByNameParamType(tp)
&& isCompatible(tp, dropByName(pt))
)
- def isCompatibleSam(tp: Type, pt: Type): Boolean = {
+ def isCompatibleSam(tp: Type, pt: Type): Boolean = (definitions.isFunctionType(tp) || tp.isInstanceOf[MethodType] || tp.isInstanceOf[PolyType]) && {
val samFun = typer.samToFunctionType(pt)
(samFun ne NoType) && isCompatible(tp, samFun)
}
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 48caf3081a..a031f4f797 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -809,9 +809,7 @@ trait Definitions extends api.StandardDefinitions {
* The class defining the method is a supertype of `tp` that
* has a public no-arg primary constructor.
*/
- def samOf(tp: Type): Symbol = if (!settings.Xexperimental) NoSymbol else findSam(tp)
-
- def findSam(tp: Type): Symbol = {
+ def samOf(tp: Type): Symbol = {
// if tp has a constructor, it must be public and must not take any arguments
// (not even an implicit argument list -- to keep it simple for now)
val tpSym = tp.typeSymbol
diff --git a/test/files/neg/sammy_error_exist_no_crash.flags b/test/files/neg/sammy_error_exist_no_crash.flags
deleted file mode 100644
index e1b37447c9..0000000000
--- a/test/files/neg/sammy_error_exist_no_crash.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental \ No newline at end of file
diff --git a/test/files/neg/sammy_restrictions.flags b/test/files/neg/sammy_restrictions.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/neg/sammy_restrictions.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/neg/sammy_wrong_arity.flags b/test/files/neg/sammy_wrong_arity.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/neg/sammy_wrong_arity.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_exist.flags b/test/files/pos/sammy_exist.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_exist.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_overload.flags b/test/files/pos/sammy_overload.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_overload.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_override.flags b/test/files/pos/sammy_override.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_override.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_poly.flags b/test/files/pos/sammy_poly.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_poly.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_scope.flags b/test/files/pos/sammy_scope.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_scope.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_single.flags b/test/files/pos/sammy_single.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_single.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_twice.flags b/test/files/pos/sammy_twice.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_twice.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/t8310.flags b/test/files/pos/t8310.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/t8310.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/run/sammy_java8.flags b/test/files/run/sammy_java8.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/run/sammy_java8.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/run/sammy_repeated.flags b/test/files/run/sammy_repeated.flags
deleted file mode 100644
index e1b37447c9..0000000000
--- a/test/files/run/sammy_repeated.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental \ No newline at end of file