File tree Expand file tree Collapse file tree 6 files changed +12
-6
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 6 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -661,9 +661,6 @@ object Flags {
661661 /** Is a default parameter in Scala 2*/
662662 final val DefaultParameter : FlagConjunction = allOf(Param , DefaultParameterized )
663663
664- /** A Scala 2 Macro */
665- final val Scala2Macro : FlagConjunction = allOf(Macro , Scala2x )
666-
667664 /** A trait that does not need to be initialized */
668665 final val NoInitsTrait : FlagConjunction = allOf(Trait , NoInits )
669666
Original file line number Diff line number Diff line change @@ -807,6 +807,9 @@ object SymDenotations {
807807 // we need an inline flag on them only do that
808808 // reduceProjection gets access to their rhs
809809
810+ /** Is this a Scala 2 macro */
811+ final def isScala2Macro (implicit ctx : Context ): Boolean = is(Macro ) && symbol.owner.is(Scala2x )
812+
810813 /** An erased value or an inline method, excluding @forceInline annotated methods.
811814 * The latter have to be kept around to get to parity with Scala.
812815 * This is necessary at least until we have full bootstrap. Right now
Original file line number Diff line number Diff line change @@ -400,10 +400,10 @@ object RefChecks {
400400 overrideError(" is an extension method, cannot override a normal method" )
401401 } else if (other.is(Extension ) && ! member.is(Extension )) { // (1.9.2)
402402 overrideError(" is a normal method, cannot override an extension method" )
403- } else if ((member.isInlineMethod || member.is( Scala2Macro ) ) && other.is(Deferred ) &&
403+ } else if ((member.isInlineMethod || member.isScala2Macro ) && other.is(Deferred ) &&
404404 member.extendedOverriddenSymbols.forall(_.is(Deferred ))) { // (1.10)
405405 overrideError(" is an inline method, must override at least one concrete method" )
406- } else if (other.is( Scala2Macro ) && ! member.is( Scala2Macro ) ) { // (1.11)
406+ } else if (other.isScala2Macro && ! member.isScala2Macro ) { // (1.11)
407407 overrideError(" cannot be used here - only Scala-2 macros can override Scala-2 macros" )
408408 } else if (! compatibleTypes(memberTp(self), otherTp(self)) &&
409409 ! compatibleTypes(memberTp(upwardsSelf), otherTp(upwardsSelf))) {
Original file line number Diff line number Diff line change @@ -2753,7 +2753,7 @@ class Typer extends Namer
27532753 tree.tpe <:< wildApprox(pt)
27542754 readaptSimplified(Inliner .inlineCall(tree, pt))
27552755 }
2756- else if (tree.symbol.is( Macro , butNot = Inline ) ) {
2756+ else if (tree.symbol.isScala2Macro ) {
27572757 if (ctx.settings.XignoreScala2Macros .value) {
27582758 ctx.warning(" Scala 2 macro cannot be used in Dotty. See http://dotty.epfl.ch/docs/reference/dropped-features/macros.html" , tree.sourcePos)
27592759 tree
Original file line number Diff line number Diff line change 1+ <56..56> in override-scala2-macro.scala
2+ error overriding method f in class StringContext of type [A >: Any](args: Seq[A]): String;
3+ method f of type [A >: Any](args: Seq[A]): String cannot be used here - only Scala-2 macros can override Scala-2 macros
Original file line number Diff line number Diff line change 1+ class Foo extends StringContext {
2+ override inline def f [A >: Any ](args : A * ): String = ??? // error
3+ }
You can’t perform that action at this time.
0 commit comments