File tree 5 files changed +67
-1
lines changed
compiler/src/dotty/tools/dotc
neg-custom-args/no-experimental
5 files changed +67
-1
lines changed Original file line number Diff line number Diff line change @@ -3115,7 +3115,7 @@ object Parsers {
3115
3115
case Some (prefix) =>
3116
3116
in.languageImportContext = in.languageImportContext.importContext(imp, NoSymbol )
3117
3117
if prefix == nme.experimental
3118
- && selectors.exists(sel => Feature .experimental(sel.name) != Feature .scala2macros)
3118
+ && selectors.exists(sel => Feature .experimental(sel.name) != Feature .scala2macros && Feature .experimental(sel.name) != Feature .erasedDefinitions )
3119
3119
then
3120
3120
Feature .checkExperimentalFeature(" features" , imp.srcPos)
3121
3121
for
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import typer.RefChecks
12
12
import MegaPhase .MiniPhase
13
13
import StdNames .nme
14
14
import ast .tpd
15
+ import SymUtils ._
16
+ import config .Feature
15
17
16
18
/** This phase makes all erased term members of classes private so that they cannot
17
19
* conflict with non-erased members. This is needed so that subsequent phases like
@@ -39,13 +41,22 @@ class PruneErasedDefs extends MiniPhase with SymTransformer { thisTransform =>
39
41
else cpy.Apply (tree)(tree.fun, tree.args.map(trivialErasedTree))
40
42
41
43
override def transformValDef (tree : ValDef )(using Context ): Tree =
44
+ checkErasedInExperimental(tree.symbol)
42
45
if ! tree.symbol.isEffectivelyErased || tree.rhs.isEmpty then tree
43
46
else cpy.ValDef (tree)(rhs = trivialErasedTree(tree.rhs))
44
47
45
48
override def transformDefDef (tree : DefDef )(using Context ): Tree =
49
+ checkErasedInExperimental(tree.symbol)
46
50
if ! tree.symbol.isEffectivelyErased || tree.rhs.isEmpty then tree
47
51
else cpy.DefDef (tree)(rhs = trivialErasedTree(tree.rhs))
48
52
53
+ override def transformTypeDef (tree : TypeDef )(using Context ): Tree =
54
+ checkErasedInExperimental(tree.symbol)
55
+ tree
56
+
57
+ def checkErasedInExperimental (sym : Symbol )(using Context ): Unit =
58
+ if sym.is(Erased ) && sym != defn.Compiletime_erasedValue && ! sym.isInExperimentalScope then
59
+ Feature .checkExperimentalFeature(" erased" , sym.sourcePos)
49
60
}
50
61
51
62
object PruneErasedDefs {
Original file line number Diff line number Diff line change
1
+ import language .experimental .erasedDefinitions
2
+ import annotation .experimental
3
+
4
+ @ experimental
5
+ erased class Foo
6
+
7
+ erased class Bar // error
8
+
9
+ @ experimental
10
+ erased def foo = 2
11
+
12
+ erased def bar = 2 // error
13
+
14
+ @ experimental
15
+ erased val foo2 = 2
16
+
17
+ erased val bar2 = 2 // error
18
+
19
+ @ experimental
20
+ def foo3 (erased a : Int ) = 2
21
+
22
+ def bar3 (erased a : Int ) = 2 // error
Original file line number Diff line number Diff line change
1
+ import language .experimental .erasedDefinitions
2
+ import annotation .experimental
3
+
4
+ @ experimental
5
+ erased class Foo
6
+
7
+ erased class Bar
8
+
9
+ @ experimental
10
+ erased def foo = 2
11
+
12
+ erased def bar = 2
13
+
14
+ @ experimental
15
+ erased val foo2 = 2
16
+
17
+ erased val bar2 = 2
18
+
19
+ @ experimental
20
+ def foo3 (erased a : Int ) = 2
21
+
22
+ def bar3 (erased a : Int ) = 2
Original file line number Diff line number Diff line change
1
+ package scala
2
+ import language .experimental .erasedDefinitions
3
+ import annotation .{implicitNotFound , experimental }
4
+
5
+ @ experimental
6
+ @ implicitNotFound(" The capability to throw exception ${E} is missing.\n The capability can be provided by one of the following:\n - A using clause `(using CanThrow[${E}])`\n - A `throws` clause in a result type such as `X throws ${E}`\n - an enclosing `try` that catches ${E}" )
7
+ erased class CanThrow [- E <: Exception ]
8
+
9
+ @ experimental
10
+ object unsafeExceptions :
11
+ given canThrowAny : CanThrow [Exception ] = ???
You can’t perform that action at this time.
0 commit comments