Skip to content

Commit c8eb6cd

Browse files
committed
Fix experimental in signature check
1 parent 112bea7 commit c8eb6cd

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import ContextFunctionResults.annotateContextResults
1515
import config.Printers.typr
1616
import reporting._
1717

18-
1918
object PostTyper {
2019
val name: String = "posttyper"
2120
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,16 @@ object RefChecks {
978978
then
979979
Feature.checkExperimentalDef(sym, pos)
980980

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+
981991
private def checkExperimentalAnnots(sym: Symbol)(using Context): Unit =
982992
for annot <- sym.annotations if annot.symbol.isExperimental do
983993
Feature.checkExperimentalDef(annot.symbol, annot.tree)
@@ -1220,6 +1230,7 @@ class RefChecks extends MiniPhase { thisPhase =>
12201230
checkNoPrivateOverrides(tree)
12211231
checkDeprecatedOvers(tree)
12221232
checkExperimentalAnnots(tree.symbol)
1233+
checkExperimentalTypes(tree.symbol.info, tree)
12231234
val sym = tree.symbol
12241235
if (sym.exists && sym.owner.isTerm) {
12251236
tree.rhs match {
@@ -1241,6 +1252,7 @@ class RefChecks extends MiniPhase { thisPhase =>
12411252
checkNoPrivateOverrides(tree)
12421253
checkDeprecatedOvers(tree)
12431254
checkExperimentalAnnots(tree.symbol)
1255+
checkExperimentalTypes(tree.symbol.info, tree)
12441256
checkImplicitNotFoundAnnotation.defDef(tree.symbol.denot)
12451257
tree
12461258
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ type Y = Int // error
1515
@experimental
1616
opaque type Z = Int // error
1717

18+
type W = Z // error
19+
1820
def test(
1921
p1: A, // error
20-
p2: List[A], // FIXME ERROR
22+
p2: List[A], // error
2123
p3: X, // error
2224
p4: Y, // error
2325
p5: Z, // error

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.annotation.experimental
44
class A
55

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

99
object Extractor2:
1010
@experimental // error

0 commit comments

Comments
 (0)