From bff6b093d28bfc6918fa86d640353ba60b1a24e4 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 14 Mar 2014 18:41:55 +0100 Subject: Add language feature mechanism Add a method "featureEnabled" that checks whether a feature is enabled. Features can be enabled by imports or by command-line options. The Scala 2.10 way of enabling features by implicits got dropped, because the use of the feature mechanism is now different. Previously, features imposed restrictions on what used to work. So it was important to offer way to avoid the restrictions it that was as smooth as possible, and implicits fit the bill. Furthermore, features did not change the way things were compiled, so it was OK to test them only once all types were compiled. Now, features are essentially switches that change compile time behavior. keepUnions and noAutoTupling, if on, will modify the way type inference works. So we need to interprete a switch on the spot, and doing an implicit search to determine a switch value is too dangerous in what concerns causing cyclic references. At the same time, because we are dealing with new functionality, there is less of a concern for being able to set or reset features for large pieces of code with some implicit. You could argue that's not even desirable, and that an explicit import or command line option is preferable. Conflicts: src/dotty/tools/dotc/core/SymDenotations.scala --- src/dotty/tools/dotc/core/StdNames.scala | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/dotty/tools/dotc/core/StdNames.scala') diff --git a/src/dotty/tools/dotc/core/StdNames.scala b/src/dotty/tools/dotc/core/StdNames.scala index 0cbcfa5a7..6cd9da4b5 100644 --- a/src/dotty/tools/dotc/core/StdNames.scala +++ b/src/dotty/tools/dotc/core/StdNames.scala @@ -375,6 +375,7 @@ object StdNames { val hashCode_ : N = "hashCode" val hash_ : N = "hash" val head: N = "head" + val higherKinds: N = "higherKinds" val identity: N = "identity" val implicitly: N = "implicitly" val in: N = "in" @@ -387,6 +388,7 @@ object StdNames { val isInstanceOf_ : N = "isInstanceOf" val isInstanceOf_Ob : N = "$isInstanceOf" val java: N = "java" + val keepUnions: N = "keepUnions" val key: N = "key" val lang: N = "lang" val length: N = "length" @@ -415,6 +417,7 @@ object StdNames { val next: N = "next" val nmeNewTermName: N = "newTermName" val nmeNewTypeName: N = "newTypeName" + val noAutoTupling: N = "noAutoTupling" val normalize: N = "normalize" val notifyAll_ : N = "notifyAll" val notify_ : N = "notify" -- cgit v1.2.3