Skip to content

Commit 4624695

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

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ 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, args) => allArguments(fn) ::: args
139+
case Apply(fn, args) => allArguments(fn) ::: args.flatMap(allArguments)
140+
case TypeApply(Select(fn, n), _) if n == nme.asInstanceOf_ => fn :: Nil
140141
case TypeApply(fn, _) => allArguments(fn)
141142
case Block(_, expr) => allArguments(expr)
142143
case _ => Nil

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:2:8 ----------------------------------------------------------------------------------
2+
2 |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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
val u = Unit // error

0 commit comments

Comments
 (0)