File tree Expand file tree Collapse file tree 6 files changed +22
-0
lines changed Expand file tree Collapse file tree 6 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -857,6 +857,8 @@ class Definitions {
857857 def TailrecAnnot (implicit ctx : Context ): ClassSymbol = TailrecAnnotType .symbol.asClass
858858 lazy val TransientParamAnnotType : TypeRef = ctx.requiredClassRef(" scala.annotation.constructorOnly" )
859859 def TransientParamAnnot (implicit ctx : Context ): ClassSymbol = TransientParamAnnotType .symbol.asClass
860+ lazy val CompileTimeOnlyAnnotType : TypeRef = ctx.requiredClassRef(" scala.annotation.compileTimeOnly" )
861+ def CompileTimeOnlyParamAnnot (implicit ctx : Context ): ClassSymbol = CompileTimeOnlyAnnotType .symbol.asClass
860862 lazy val SwitchAnnotType : TypeRef = ctx.requiredClassRef(" scala.annotation.switch" )
861863 def SwitchAnnot (implicit ctx : Context ): ClassSymbol = SwitchAnnotType .symbol.asClass
862864 lazy val ThrowsAnnotType : TypeRef = ctx.requiredClassRef(" scala.throws" )
Original file line number Diff line number Diff line change @@ -401,6 +401,8 @@ object Checking {
401401 if (! sym.is(Deferred ))
402402 fail(NativeMembersMayNotHaveImplementation (sym))
403403 }
404+ if (sym.hasAnnotation(defn.CompileTimeOnlyParamAnnot ))
405+ ctx.migrationWarning(" `@compileTimeOnly(msg)` will be replaced by `scala.compiletime.error(msg)` or `erased`" , sym.sourcePos)
404406 else if (sym.is(Deferred , butNot = Param ) && ! sym.isType && ! sym.isSelfSym) {
405407 if (! sym.owner.isClass || sym.owner.is(Module ) || sym.owner.isAnonymousClass)
406408 fail(OnlyClassesCanHaveDeclaredButUndefinedMembers (sym))
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ class CompilationTests extends ParallelTesting {
173173 " tests/neg-custom-args/toplevel-samesource/nested/S.scala" ),
174174 defaultOptions) +
175175 compileFile(" tests/neg-custom-args/i6300.scala" , allowDeepSubtypes)
176+ compileFile(" tests/neg-custom-args/i6312.scala" , defaultOptions and " -Xfatal-warnings" and " -migration" )
176177 }.checkExpectedErrors()
177178
178179 @ Test def fuzzyAll : Unit = {
Original file line number Diff line number Diff line change 1+ class Foo {
2+ inline def foo : Unit = {
3+ @ scala.annotation.compileTimeOnly(" some message" ) val res = ??? // error
4+ res
5+ }
6+ }
Original file line number Diff line number Diff line change 1+ class Foo {
2+ inline def foo : Unit = {
3+ scala.compiletime.error(" some message" )
4+ }
5+ foo // error: some message
6+ }
Original file line number Diff line number Diff line change 1+ class Foo {
2+ inline def foo : Unit = {
3+ scala.compiletime.error(" some message" )
4+ }
5+ }
You can’t perform that action at this time.
0 commit comments