Skip to content

Commit 4b74afb

Browse files
Merge pull request #14047 from dotty-staging/fix-#14034
Traverse the types to find experimental references
2 parents dcb123d + a1b7e17 commit 4b74afb

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package jvm
55
import scala.tools.asm
66
import scala.annotation.threadUnsafe
77
import scala.collection.mutable
8-
import scala.collection.generic.Clearable
8+
import scala.collection.mutable.Clearable
99

1010
import dotty.tools.dotc.core.Flags._
1111
import dotty.tools.dotc.core.Contexts._

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,16 @@ class RefChecks extends MiniPhase { thisPhase =>
13391339
}
13401340

13411341
override def transformTypeTree(tree: TypeTree)(using Context): TypeTree = {
1342-
checkExperimental(tree.symbol, tree.srcPos)
1342+
val tpe = tree.tpe
1343+
tpe.foreachPart {
1344+
case TypeRef(_, sym: Symbol) =>
1345+
checkDeprecated(sym, tree.srcPos)
1346+
checkExperimental(sym, tree.srcPos)
1347+
case TermRef(_, sym: Symbol) =>
1348+
checkDeprecated(sym, tree.srcPos)
1349+
checkExperimental(sym, tree.srcPos)
1350+
case _ =>
1351+
}
13431352
tree
13441353
}
13451354

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
@deprecated trait Exp
3+
@deprecated val exp = 1
4+
5+
def test1 = exp // error
6+
def test2(a: Exp) = () // error
7+
8+
type Foo0 = Exp // error
9+
type Foo = Option[Exp] // error
10+
type Bar = Option[exp.type] // error
11+
type Baz = Exp | Int // error
12+
type Quux = [X] =>> X match // error
13+
case Exp => Int
14+
type Quuz[A <: Exp] = Int // error
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import annotation.experimental
2+
3+
@experimental trait Exp
4+
@experimental val exp = 1
5+
6+
type Foo0 = Exp // error
7+
type Foo = Option[Exp] // error
8+
type Bar = Option[exp.type] // error
9+
type Baz = Exp | Int // error
10+
type Quux = [X] =>> X match // error
11+
case Exp => Int
12+
type Quuz[A <: Exp] = Int // error

0 commit comments

Comments
 (0)