Skip to content

Commit 897d7a7

Browse files
committed
Accommodate quasi-constant annotation
1 parent 22b2259 commit 897d7a7

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
136136

137137
/** All term arguments of an application in a single flattened list */
138138
def allArguments(tree: Tree): List[Tree] = unsplice(tree) match {
139+
case Apply(fn, TypeApply(Select(arg, n), _) :: Nil) if n == nme.asInstanceOf_ => allArguments(fn) :+ arg
139140
case Apply(fn, args) => allArguments(fn) ::: args
140141
case TypeApply(fn, _) => allArguments(fn)
141142
case Block(_, expr) => allArguments(expr)

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,8 @@ object Erasure {
562562
report.error(msg, tree.srcPos)
563563
tree.symbol.getAnnotation(defn.CompileTimeOnlyAnnot) match
564564
case Some(annot) =>
565-
val message = annot.argumentConstant(0) match
566-
case Some(c) =>
567-
c.stringValue.toMessage
565+
val message = annot.argumentConstantString(0) match
566+
case Some(c) => c.toMessage
568567
case _ =>
569568
em"""Reference to ${tree.symbol.showLocated} should not have survived,
570569
|it should have been processed and eliminated during expansion of an enclosing macro or term erasure."""

tests/neg/no-unit.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/neg/no-unit.scala:1:8 ----------------------------------------------------------------------------------
2+
1 |val u = Unit // error
3+
| ^^^^
4+
| `Unit` companion object is not allowed in source; instead, use `()` for the unit value

tests/neg/no-unit.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
val u = Unit // error

0 commit comments

Comments
 (0)