File tree 3 files changed +12
-11
lines changed
compiler/src/dotty/tools/dotc
3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -773,7 +773,10 @@ object SymDenotations {
773
773
def isSkolem : Boolean = name == nme.SKOLEM
774
774
775
775
def isInlineMethod (implicit ctx : Context ): Boolean =
776
- is(InlineMethod , butNot = AccessorOrSynthetic )
776
+ is(InlineMethod , butNot = AccessorOrSynthetic ) &&
777
+ name != nme.unapply // unapply methods do not count as inline methods
778
+ // we need an inline flag on them only do that
779
+ // reduceProjection gets access to their rhs
777
780
778
781
/** An erased value or an inline method, excluding @forceInline annotated methods.
779
782
* The latter have to be kept around to get to parity with Scala.
Original file line number Diff line number Diff line change @@ -981,14 +981,6 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
981
981
else trySelectUnapply(qual1)(_ => notAnExtractor(sel))
982
982
}
983
983
984
- /* Can probably be dropped. The idea is that inline unapply methods are available
985
- * for inspection in the Inliner's reduceMatch method, but are never inlined
986
- * when called from normal code.
987
-
988
- if (unapplyFn.symbol.isInlineMethod)
989
- checkInInlineContext("implementation restriction: call to inline unapply", tree.pos)
990
- */
991
-
992
984
/** Add a `Bind` node for each `bound` symbol in a type application `unapp` */
993
985
def addBinders (unapp : Tree , bound : List [Symbol ]) = unapp match {
994
986
case TypeApply (fn, args) =>
Original file line number Diff line number Diff line change @@ -890,8 +890,14 @@ trait Checking {
890
890
891
891
/** Check that we are in an inline context (inside an inline method or in inline code) */
892
892
def checkInInlineContext (what : String , pos : Position )(implicit ctx : Context ): Unit =
893
- if (! ctx.inInlineMethod && ! ctx.isInlineContext)
894
- ctx.error(em " $what can only be used in an inline method " , pos)
893
+ if (! ctx.inInlineMethod && ! ctx.isInlineContext) {
894
+ val inInlineUnapply = ctx.owner.ownersIterator.exists(owner =>
895
+ owner.name == nme.unapply && owner.is(Inline ) && owner.is(Method ))
896
+ val msg =
897
+ if (inInlineUnapply) " cannot be used in an inline unapply"
898
+ else " can only be used in an inline method"
899
+ ctx.error(em " $what $msg" , pos)
900
+ }
895
901
896
902
/** Check that all case classes that extend `scala.Enum` are `enum` cases */
897
903
def checkEnum (cdef : untpd.TypeDef , cls : Symbol , parent : Symbol )(implicit ctx : Context ): Unit = {
You can’t perform that action at this time.
0 commit comments