summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2016-10-04 12:48:30 -0500
committerAdriaan Moors <adriaan@lightbend.com>2016-10-04 15:48:33 -0500
commit20896646122fa82dc81f1405173b09eac37ae7cc (patch)
tree6422d91f1142c7c393eed6433700ae226d3a2157 /spec
parent1f6006d0d4f8edf4db04915702f8b7e3c8ca1f5e (diff)
downloadscala-20896646122fa82dc81f1405173b09eac37ae7cc.tar.gz
scala-20896646122fa82dc81f1405173b09eac37ae7cc.tar.bz2
scala-20896646122fa82dc81f1405173b09eac37ae7cc.zip
SI-9943 final/sealed class does not yield SAM type
Cannot subclass such a class. (Well, we could subclass a sealed class in the same compilation unit. We ignore this for simplicity.) This is a bit of a sneaky fix for this bug, but our hand is pretty much forced by other constraints, in this intersection of overload resolution involving built-in function types and SAMs, and type inference for higher-order function literals (#5307). Luckily, in this particular issue, the overloading clash seems accidental. The `sealed` `<:<` class is not a SAM type as it cannot be subclassed outside of `Predef`. For simplicity, we don't consider where the SAM conversion occurs and exclude all sealed classes from yielding SAM types. Thanks to Miles for pointing out that `final` was missing in my first iteration of this fix.
Diffstat (limited to 'spec')
-rw-r--r--spec/06-expressions.md1
1 files changed, 1 insertions, 0 deletions
diff --git a/spec/06-expressions.md b/spec/06-expressions.md
index 2b238d149a..468d9f5fef 100644
--- a/spec/06-expressions.md
+++ b/spec/06-expressions.md
@@ -1361,6 +1361,7 @@ Note that a function literal that targets a SAM is not necessarily compiled to t
It follows that:
- if class `C` defines a constructor, it must be accessible and must define exactly one, empty, argument list;
+ - class `C` cannot be `final` or `sealed` (for simplicity we ignore the possibility of SAM conversion in the same compilation unit as the sealed class);
- `m` cannot be polymorphic;
- it must be possible to derive a fully-defined type `U` from `S` by inferring any unknown type parameters of `C`.