Skip to content

Commit 508aebc

Browse files
Kordyjanprolativ
authored andcommitted
Check for types with since annotation
1 parent 4a8f8ef commit 508aebc

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,15 @@ object RefChecks {
986986
report.warning(i"$sym has an unparsable version number: ${ex.getMessage}", pos)
987987
case _ =>
988988

989+
private def checkSinceAnnotInSignature(sym: Symbol, pos: SrcPos)(using Context) =
990+
new TypeTraverser:
991+
def traverse(tp: Type) =
992+
if tp.typeSymbol.hasAnnotation(defn.SinceAnnot) then
993+
checkSinceAnnot(tp.typeSymbol, pos)
994+
else
995+
traverseChildren(tp)
996+
.traverse(sym.info)
997+
989998
/** If @migration is present (indicating that the symbol has changed semantics between versions),
990999
* emit a warning.
9911000
*/
@@ -1272,6 +1281,7 @@ class RefChecks extends MiniPhase { thisPhase =>
12721281
checkDeprecatedOvers(tree)
12731282
checkExperimentalAnnots(tree.symbol)
12741283
checkExperimentalSignature(tree.symbol, tree)
1284+
checkSinceAnnotInSignature(tree.symbol, tree)
12751285
val sym = tree.symbol
12761286
if (sym.exists && sym.owner.isTerm) {
12771287
tree.rhs match {
@@ -1294,6 +1304,7 @@ class RefChecks extends MiniPhase { thisPhase =>
12941304
checkDeprecatedOvers(tree)
12951305
checkExperimentalAnnots(tree.symbol)
12961306
checkExperimentalSignature(tree.symbol, tree)
1307+
checkSinceAnnotInSignature(tree.symbol, tree)
12971308
checkImplicitNotFoundAnnotation.defDef(tree.symbol.denot)
12981309
checkUnaryMethods(tree.symbol)
12991310
tree

tests/neg/since/since_t3.0.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@ import scala.quoted.*
22

33
def useQuotes(using Quotes) =
44
import quotes.reflect.*
5+
56
def useFieldMember(s: Symbol) = s.fieldMember("abc") // error
6-
useFieldMember
7+
def getWildcard: Wildcard = ??? // error
8+
def acceptWildcard(w: Wildcard) = "" // error
9+
def boundByWildcard[T <: Wildcard]: T = ??? // error
10+
11+
(useFieldMember, getWildcard, acceptWildcard) // error

0 commit comments

Comments
 (0)