File tree 6 files changed +22
-0
lines changed
6 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -857,6 +857,8 @@ class Definitions {
857
857
def TailrecAnnot (implicit ctx : Context ): ClassSymbol = TailrecAnnotType .symbol.asClass
858
858
lazy val TransientParamAnnotType : TypeRef = ctx.requiredClassRef(" scala.annotation.constructorOnly" )
859
859
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
860
862
lazy val SwitchAnnotType : TypeRef = ctx.requiredClassRef(" scala.annotation.switch" )
861
863
def SwitchAnnot (implicit ctx : Context ): ClassSymbol = SwitchAnnotType .symbol.asClass
862
864
lazy val ThrowsAnnotType : TypeRef = ctx.requiredClassRef(" scala.throws" )
Original file line number Diff line number Diff line change @@ -401,6 +401,8 @@ object Checking {
401
401
if (! sym.is(Deferred ))
402
402
fail(NativeMembersMayNotHaveImplementation (sym))
403
403
}
404
+ if (sym.hasAnnotation(defn.CompileTimeOnlyParamAnnot ))
405
+ ctx.migrationWarning(" `@compileTimeOnly(msg)` will be replaced by `scala.compiletime.error(msg)` or `erased`" , sym.sourcePos)
404
406
else if (sym.is(Deferred , butNot = Param ) && ! sym.isType && ! sym.isSelfSym) {
405
407
if (! sym.owner.isClass || sym.owner.is(Module ) || sym.owner.isAnonymousClass)
406
408
fail(OnlyClassesCanHaveDeclaredButUndefinedMembers (sym))
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ class CompilationTests extends ParallelTesting {
173
173
" tests/neg-custom-args/toplevel-samesource/nested/S.scala" ),
174
174
defaultOptions) +
175
175
compileFile(" tests/neg-custom-args/i6300.scala" , allowDeepSubtypes)
176
+ compileFile(" tests/neg-custom-args/i6312.scala" , defaultOptions and " -Xfatal-warnings" and " -migration" )
176
177
}.checkExpectedErrors()
177
178
178
179
@ 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