@@ -678,29 +678,39 @@ trait Checking {
678
678
val purityLevel = if (isFinal) Idempotent else Pure
679
679
tree.tpe.widenTermRefExpr match {
680
680
case tp : ConstantType if exprPurity(tree) >= purityLevel => // ok
681
- case tp =>
682
- def isCaseClassApply (sym : Symbol ): Boolean =
683
- sym.name == nme.apply && sym.is(Synthetic ) && sym.owner.is(Module ) && sym.owner.companionClass.is(Case )
684
- def isCaseClassNew (sym : Symbol ): Boolean =
685
- sym.isPrimaryConstructor && sym.owner.is(Case ) && sym.owner.isStatic
686
- def isCaseObject (sym : Symbol ): Boolean = {
687
- // TODO add alias to Nil in scala package
688
- sym.is(Case ) && sym.is(Module )
689
- }
690
- val allow =
691
- ctx.erasedTypes ||
692
- ctx.inInlineMethod ||
693
- (tree.symbol.isStatic && isCaseObject(tree.symbol) || isCaseClassApply(tree.symbol)) ||
694
- isCaseClassNew(tree.symbol)
695
- if (! allow) ctx.error(em " $what must be a known value " , tree.pos)
696
- else {
697
- def checkArgs (tree : Tree ): Unit = tree match {
698
- case Apply (fn, args) =>
699
- args.foreach(arg => checkInlineConformant(arg, isFinal, what))
700
- checkArgs(fn)
701
- case _ =>
702
- }
703
- checkArgs(tree)
681
+ case _ =>
682
+ tree match {
683
+ case Typed (expr, _) =>
684
+ checkInlineConformant(expr, isFinal, what)
685
+ case SeqLiteral (elems, _) =>
686
+ elems.foreach(elem => checkInlineConformant(elem, isFinal, what))
687
+ case Apply (fn, List (arg)) if defn.WrapArrayMethods ().contains(fn.symbol) =>
688
+ checkInlineConformant(arg, isFinal, what)
689
+ case _ =>
690
+ def isCaseClassApply (sym : Symbol ): Boolean =
691
+ sym.name == nme.apply && sym.is(Synthetic ) && sym.owner.is(Module ) && sym.owner.companionClass.is(Case )
692
+ def isCaseClassNew (sym : Symbol ): Boolean =
693
+ sym.isPrimaryConstructor && sym.owner.is(Case ) && sym.owner.isStatic
694
+ def isCaseObject (sym : Symbol ): Boolean = {
695
+ // TODO add alias to Nil in scala package
696
+ sym.is(Case ) && sym.is(Module )
697
+ }
698
+ val allow =
699
+ ctx.erasedTypes ||
700
+ ctx.inInlineMethod ||
701
+ (tree.symbol.isStatic && isCaseObject(tree.symbol) || isCaseClassApply(tree.symbol)) ||
702
+ isCaseClassNew(tree.symbol)
703
+
704
+ if (! allow) ctx.error(em " $what must be a known value " , tree.pos)
705
+ else {
706
+ def checkArgs (tree : Tree ): Unit = tree match {
707
+ case Apply (fn, args) =>
708
+ args.foreach(arg => checkInlineConformant(arg, isFinal, what))
709
+ checkArgs(fn)
710
+ case _ =>
711
+ }
712
+ checkArgs(tree)
713
+ }
704
714
}
705
715
}
706
716
}
0 commit comments