Skip to content

Commit 45cc854

Browse files
committed
Allow @Alpha on types
1 parent ed967d7 commit 45cc854

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,15 @@ object SymDenotations {
446446

447447
/** The name given in an `@alpha` annotation if one is present, `name` otherwise */
448448
final def erasedName(implicit ctx: Context): Name =
449-
if (isTerm)
450-
getAnnotation(defn.AlphaAnnot) match {
451-
case Some(ann) =>
452-
ann.arguments match {
453-
case Literal(Constant(str: String)) :: Nil => str.toTermName
454-
case _ => name
455-
}
456-
case _ => name
457-
}
458-
else name
449+
getAnnotation(defn.AlphaAnnot) match {
450+
case Some(ann) =>
451+
ann.arguments match {
452+
case Literal(Constant(str: String)) :: Nil =>
453+
if (isType) str.toTypeName else str.toTermName
454+
case _ => name
455+
}
456+
case _ => name
457+
}
459458

460459
// ----- Tests -------------------------------------------------
461460

tests/run/alpha/Test_2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
public class Test_2 {
55

66
public static void main(String[] args) {
7-
Alpha<String> a = new Beta();
7+
Alpha<String> a = new Bar();
88
assert a.foo() == 1;
99
assert a.bar("a").equals("aa");
1010
Alpha<String> aa = a.append(a);

tests/run/alpha/alpha_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class Alpha[T] {
1111

1212
}
1313

14-
class Beta extends Alpha[String] {
14+
@alpha("Bar") class | extends Alpha[String] {
1515

1616
@alpha("bar") override def foo(x: String) = x ++ x
1717

0 commit comments

Comments
 (0)