Skip to content

Commit aa99963

Browse files
authored
Merge pull request scala#8976 from joroKr21/macro-annot-error
2 parents cc707c1 + da521e3 commit aa99963

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,19 +1014,16 @@ trait ContextErrors {
10141014
}
10151015

10161016
def MacroAnnotationMustBeStaticError(clazz: Symbol) =
1017-
issueSymbolTypeError(clazz, s"macro annotation must extend scala.annotation.StaticAnnotation")
1017+
issueSymbolTypeError(clazz, "macro annotation must extend scala.annotation.StaticAnnotation")
10181018

10191019
def MacroAnnotationCannotBeInheritedError(clazz: Symbol) =
1020-
issueSymbolTypeError(clazz, s"macro annotation cannot be @Inherited")
1020+
issueSymbolTypeError(clazz, "macro annotation cannot be @Inherited")
10211021

10221022
def MacroAnnotationCannotBeMemberError(clazz: Symbol) =
1023-
issueSymbolTypeError(clazz, s"macro annotation cannot be a member of another class")
1023+
issueSymbolTypeError(clazz, "macro annotation cannot be a member of another class")
10241024

1025-
def MacroAnnotationNotExpandedMessage: String = {
1026-
"macro annotation could not be expanded " + (
1027-
if (!settings.YmacroAnnotations) "(since these are experimental, you must enable them with -Ymacro-annotations)"
1028-
else "(you cannot use a macro annotation in the same compilation run that defines it)")
1029-
}
1025+
def MacroAnnotationNotExpandedMessage: String =
1026+
"macro annotation could not be expanded (since these are experimental, you must enable them with -Ymacro-annotations)"
10301027

10311028
def MacroAnnotationOnlyDefinitionError(ann: Tree) =
10321029
issueNormalTypeError(ann, "macro annotations can only be put on definitions")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Test_2.scala:2: error: macro annotation could not be expanded (since these are experimental, you must enable them with -Ymacro-annotations)
2+
class Test
3+
^
4+
1 error
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// scalac: -Ymacro-annotations
2+
import scala.language.experimental.macros
3+
import scala.reflect.macros.blackbox
4+
import scala.annotation.StaticAnnotation
5+
6+
object Macros {
7+
def annotImpl(c: blackbox.Context)(annottees: c.Expr[Any]*): c.Expr[Any] = ???
8+
}
9+
10+
class annot extends StaticAnnotation {
11+
def macroTransform(annottees: Any*): Any = macro Macros.annotImpl
12+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@annot
2+
class Test

0 commit comments

Comments
 (0)