Skip to content

Commit 87b7ba8

Browse files
committed
Fixes after rebase
1 parent 9524e02 commit 87b7ba8

12 files changed

+48
-146
lines changed

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
266266
ctx
267267
super.transform(tree)(using gadtCtx)
268268
case tree: Ident if !tree.isType =>
269-
Experimental.checkExperimental(tree)
270269
if tree.symbol.is(Inline) && !Inliner.inInlineMethod then
271270
ctx.compilationUnit.needsInlining = true
272271
checkNoConstructorProxy(tree)
@@ -275,7 +274,6 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
275274
case _ => tree
276275
}
277276
case tree @ Select(qual, name) =>
278-
Experimental.checkExperimental(tree)
279277
if tree.symbol.is(Inline) then
280278
ctx.compilationUnit.needsInlining = true
281279
if (name.isTypeName) {
@@ -394,7 +392,6 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
394392
Checking.checkRealizable(ref.tpe, ref.srcPos)
395393
super.transform(tree)
396394
case tree: TypeTree =>
397-
Experimental.checkExperimental(tree)
398395
tree.withType(
399396
tree.tpe match {
400397
case AnnotatedType(tpe, annot) => AnnotatedType(tpe, transformAnnot(annot))

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import reporting._
2424
import scala.util.matching.Regex._
2525
import Constants.Constant
2626
import NullOpsDecorator._
27+
import dotty.tools.dotc.config.Feature
2728

2829
object RefChecks {
2930
import tpd._
@@ -927,6 +928,7 @@ object RefChecks {
927928
// arbitrarily choose one as more important than the other.
928929
private def checkUndesiredProperties(sym: Symbol, pos: SrcPos)(using Context): Unit =
929930
checkDeprecated(sym, pos)
931+
checkExperimental(sym, pos)
930932

931933
val xMigrationValue = ctx.settings.Xmigration.value
932934
if xMigrationValue != NoScalaVersion then
@@ -967,6 +969,25 @@ object RefChecks {
967969
val since = annot.argumentConstant(1).map(" since " + _.stringValue).getOrElse("")
968970
report.deprecationWarning(s"${sym.showLocated} is deprecated${since}${msg}", pos)
969971

972+
private def checkExperimental(sym: Symbol, pos: SrcPos)(using Context): Unit =
973+
if sym.isExperimental
974+
&& !sym.isConstructor // already reported on the class
975+
&& !ctx.owner.isExperimental // already reported on the @experimental of the owner
976+
&& !sym.is(ModuleClass) // already reported on the module
977+
&& (sym.span.exists || sym != defn.ExperimentalAnnot) // already reported on inferred annotations
978+
then
979+
Feature.checkExperimentalDef(sym, pos)
980+
981+
private def checkExperimentalTypes(tpe: Type, pos: SrcPos)(using Context): Unit =
982+
val checker = new TypeTraverser:
983+
def traverse(tp: Type): Unit =
984+
if tp.typeSymbol.isExperimental then
985+
Feature.checkExperimentalDef(tp.typeSymbol, pos)
986+
else
987+
traverseChildren(tp)
988+
if !pos.span.isSynthetic then // avoid double errors
989+
checker.traverse(tpe)
990+
970991
/** If @migration is present (indicating that the symbol has changed semantics between versions),
971992
* emit a warning.
972993
*/
@@ -1281,6 +1302,11 @@ class RefChecks extends MiniPhase { thisPhase =>
12811302
}
12821303
tree
12831304
}
1305+
1306+
override def transformTypeTree(tree: TypeTree)(using Context): TypeTree = {
1307+
checkUndesiredProperties(tree.symbol, tree.srcPos)
1308+
tree
1309+
}
12841310
}
12851311

12861312
/* todo: rewrite and re-enable

compiler/src/dotty/tools/dotc/util/Experimental.scala

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,6 @@ import dotty.tools.dotc.transform.SymUtils._
1313
object Experimental:
1414
import tpd._
1515

16-
def checkExperimental(tree: Tree)(using Context): Unit =
17-
if tree.symbol.isExperimental
18-
&& !tree.symbol.isConstructor // already reported on the class
19-
&& !ctx.owner.isExperimental // already reported on the @experimental of the owner
20-
&& !tree.symbol.is(ModuleClass) // already reported on the module
21-
&& (tree.span.exists || tree.symbol != defn.ExperimentalAnnot) // already reported on inferred annotations
22-
then
23-
Feature.checkExperimentalDef(tree.symbol, tree)
24-
25-
def checkExperimentalTypes(tree: Tree)(using Context): Unit =
26-
val checker = new TypeTraverser:
27-
def traverse(tp: Type): Unit =
28-
if tp.typeSymbol.isExperimental then
29-
Feature.checkExperimentalDef(tp.typeSymbol, tree)
30-
else
31-
traverseChildren(tp)
32-
if !tree.span.isSynthetic then // avoid double errors
33-
checker.traverse(tree.tpe)
34-
3516
def annotateExperimental(sym: Symbol)(using Context): Unit =
3617
if sym.is(Enum) && sym.hasAnnotation(defn.ExperimentalAnnot) then
3718
// Add @experimental annotation to enum class definitions

tests/neg-custom-args/no-experimental/experimentalAnnotation.scala

Lines changed: 0 additions & 103 deletions
This file was deleted.

tests/neg-custom-args/no-experimental/experimentalEnum.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import scala.annotation.experimental
22

3-
@experimental // error
3+
@experimental // FIXME ERROR
44
enum E: // error
55
case A
66
case B // error
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
class MyExperimentalAnnot extends scala.annotation.experimental // error
1+
class MyExperimentalAnnot // error
2+
extends scala.annotation.experimental // error

tests/neg-custom-args/no-experimental/experimentalOverride.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import scala.annotation.experimental
22

3-
@experimental // error
3+
@experimental // FIXME ERROR
44
class A:
55
def f() = 1
66

7-
@experimental // error
7+
@experimental // FIXME ERROR
88
class B extends A:
99
override def f() = 2
1010

1111
class C:
12-
@experimental // error
12+
@experimental // FIXME ERROR
1313
def f() = 1
1414

1515
class D extends C:
1616
override def f() = 2
1717

1818
trait A2:
19-
@experimental // error
19+
@experimental // FIXME ERROR
2020
def f(): Int
2121

2222
trait B2:

tests/neg-custom-args/no-experimental/experimentalSam.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import scala.annotation.experimental
22

3-
@experimental // error
3+
@experimental // FIXME ERROR
44
trait ExpSAM {
55
def foo(x: Int): Int
66
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import scala.annotation.experimental
22

3-
@experimental // error
3+
@experimental // FIXME ERROR
44
val x = ()
55

6-
@experimental // error
6+
@experimental // FIXME ERROR
77
def f() = ()
88

9-
@experimental // error
9+
@experimental // FIXME ERROR
1010
object X:
1111
def fx() = 1
1212

1313
def test: Unit =
1414
f() // error
1515
x // error
1616
X.fx() // error
17-
import X.fx // error
17+
import X.fx
1818
fx() // error
1919
()

tests/neg-custom-args/no-experimental/experimentalType.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import scala.annotation.experimental
22

3-
@experimental // error
3+
@experimental // FIXME ERROR
44
class A
55

6-
@experimental // error
6+
@experimental // FIXME ERROR
77
class B extends A
88

9-
@experimental // error
9+
@experimental // FIXME ERROR
1010
type X
1111

12-
@experimental // error
12+
@experimental // FIXME ERROR
1313
type Y = Int
1414

15-
@experimental // error
15+
@experimental // FIXME ERROR
1616
opaque type Z = Int
1717

1818
def test(
1919
p1: A, // error
20-
p2: List[A], // error
20+
p2: List[A], // FIXME ERROR
2121
p3: X, // error
2222
p4: Y, // error
2323
p5: Z, // error

tests/neg-custom-args/no-experimental/experimentalUnapply.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import scala.annotation.experimental
22

3-
@experimental // error
3+
@experimental // FIXME ERROR
44
class A
55

66
object Extractor1:
7-
def unapply(s: Any): Option[A] = ??? // error
7+
def unapply(s: Any): Option[A] = ??? // FIXME ERROR
88

99
object Extractor2:
10-
@experimental // error
10+
@experimental // FIXME ERROR
1111
def unapply(s: Any): Option[Int] = ???
1212

1313
def test: Unit =

tests/neg-custom-args/no-experimental/experimentalnline.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import scala.annotation.experimental
22

3-
@experimental // error
3+
@experimental // FIXME ERROR
44
inline def g() = ()
55

66
def test: Unit =

0 commit comments

Comments
 (0)