Skip to content

Commit 4b6d417

Browse files
committed
Make Scala2x a commonFlag and set to all symbols from from Scala 2
In particular fix Scala2x flag
1 parent cfb8459 commit 4b6d417

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

compiler/src/dotty/tools/dotc/core/Flags.scala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,6 @@ object Flags {
339339
/** A super accessor */
340340
final val Scala2SuperAccessor: FlagSet = termFlag(26, "<superaccessor>")
341341

342-
/** An unpickled Scala 2.x class */
343-
final val Scala2x: FlagSet = typeFlag(26, "<scala-2.x>")
344-
345-
final val Scala2xTrait: FlagSet = Scala2x | Trait
346-
347-
final val SuperAccessorOrScala2x: FlagSet = Scala2x.toCommonFlags
348-
349342
/** A method that has default params */
350343
final val DefaultParameterized: FlagSet = termFlag(27, "<defaultparam>")
351344

@@ -394,6 +387,11 @@ object Flags {
394387
/** Symbol is an enum class or enum case (if used with case) */
395388
final val Enum: FlagSet = commonFlag(40, "<enum>")
396389

390+
/** An unpickled Scala 2.x symbol */
391+
final val Scala2x: FlagSet = commonFlag(41, "<scala-2.x>")
392+
393+
final val Scala2xTrait: FlagSet = Scala2x | Trait
394+
397395
/** Labeled with `erased` modifier (erased value) */
398396
final val Erased: FlagSet = termFlag(42, "erased")
399397

@@ -485,7 +483,7 @@ object Flags {
485483
Scala2ExistentialCommon | MutableOrOpaque | Touched | JavaStatic |
486484
CovariantOrOuter | ContravariantOrLabel | CaseAccessor.toCommonFlags |
487485
Extension.toCommonFlags | NonMember | Implicit | Implied | Permanent | Synthetic |
488-
SuperAccessorOrScala2x | Inline
486+
Scala2x | Inline
489487

490488
/** Flags that are not (re)set when completing the denotation, or, if symbol is
491489
* a top-level class or object, when completing the denotation once the class

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
472472
}
473473

474474
def finishSym(sym: Symbol): Symbol = {
475-
if (sym.isClass) {
476-
sym.setFlag(Scala2x)
477-
}
475+
sym.setFlag(Scala2x)
478476
if (!(isRefinementClass(sym) || isUnpickleRoot(sym) || (sym is Scala2Existential))) {
479477
val owner = sym.owner
480478
if (owner.isClass)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2655,7 +2655,7 @@ class Typer extends Namer
26552655
tree.tpe <:< wildApprox(pt)
26562656
readaptSimplified(Inliner.inlineCall(tree, pt))
26572657
}
2658-
else if (tree.symbol.is(Macro, butNot = Inline)) {
2658+
else if (tree.symbol.is(Scala2Macro)) {
26592659
if (ctx.settings.XignoreScala2Macros.value) {
26602660
ctx.warning("Scala 2 macro cannot be used in Dotty. See http://dotty.epfl.ch/docs/reference/dropped-features/macros.html", tree.sourcePos)
26612661
tree

tests/neg/override-scala2-macro.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
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

tests/neg/override-scala2-macro.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Foo extends StringContext {
2+
override inline def f[A >: Any](args: A*): String = ??? // error
3+
}

0 commit comments

Comments
 (0)