@@ -679,12 +679,8 @@ trait Checking {
679679 tree.tpe.widenTermRefExpr match {
680680 case tp : ConstantType if exprPurity(tree) >= purityLevel => // ok
681681 case tp =>
682- def isCaseClassApply (sym : Symbol ): Boolean = {
683- sym.name == nme.apply && (
684- tree.symbol.owner == defn.SomeClass .companionModule.moduleClass ||
685- defn.isTupleClass(tree.symbol.owner.companionClass)
686- )
687- }
682+ def isCaseClassApply (sym : Symbol ): Boolean =
683+ sym.name == nme.apply && sym.isStatic && sym.owner.is(Module ) && sym.owner.companionClass.is(Case )
688684 def isCaseClassNew (sym : Symbol ): Boolean = {
689685 sym.isPrimaryConstructor && (
690686 sym.eq(defn.SomeClass .primaryConstructor) ||
@@ -701,13 +697,15 @@ trait Checking {
701697 isCaseClassApply(tree.symbol) ||
702698 isCaseClassNew(tree.symbol) ||
703699 isCaseObject(tree.symbol)
704- if (! allow) ctx.error(em " $what must be a constant expression " , tree.pos)
705- else tree match {
706- // TODO: add cases for type apply and multiple applies
707- case Apply (_, args) =>
708- for (arg <- args)
709- checkInlineConformant(arg, isFinal, what)
710- case _ =>
700+ if (! allow) ctx.error(em " $what must be a known value " , tree.pos)
701+ else {
702+ def checkArgs (tree : Tree ): Unit = tree match {
703+ case Apply (fn, args) =>
704+ args.foreach(arg => checkInlineConformant(arg, isFinal, what))
705+ checkArgs(fn)
706+ case _ =>
707+ }
708+ checkArgs(tree)
711709 }
712710 }
713711 }
0 commit comments