@@ -449,8 +449,7 @@ class Typer extends Namer
449449 }
450450 case qual =>
451451 if (tree.name.isTypeName) checkStable(qual.tpe, qual.sourcePos)
452- val select = Applications .handleMeta(
453- checkValue(assignType(cpy.Select (tree)(qual, tree.name), qual), pt))
452+ val select = checkValue(assignType(cpy.Select (tree)(qual, tree.name), qual), pt)
454453 if (select.tpe ne TryDynamicCallType ) ConstFold (checkStableIdentPattern(select, pt))
455454 else if (pt.isInstanceOf [FunOrPolyProto ] || pt == AssignProto ) select
456455 else typedDynamicSelect(tree, Nil , pt)
@@ -1936,8 +1935,10 @@ class Typer extends Namer
19361935 ctx.warning(" Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ." , tree.sourcePos)
19371936 typed(innerExpr, pt)
19381937 case quoted if quoted.isType =>
1938+ ctx.compilationUnit.needsStaging = true
19391939 typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuoteR ), quoted :: Nil ), pt)(quoteContext).withSpan(tree.span)
19401940 case quoted =>
1941+ ctx.compilationUnit.needsStaging = true
19411942 if (ctx.mode.is(Mode .Pattern ) && level == 0 ) {
19421943 val exprPt = pt.baseType(defn.QuotedExprClass )
19431944 val quotedPt = if (exprPt.exists) exprPt.argTypesHi.head else defn.AnyType
@@ -2012,6 +2013,7 @@ class Typer extends Namer
20122013 ctx.warning(" Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ." , tree.sourcePos)
20132014 typed(innerExpr, pt)
20142015 case expr =>
2016+ ctx.compilationUnit.needsStaging = true
20152017 if (ctx.mode.is(Mode .QuotedPattern ) && level == 1 ) {
20162018 if (isFullyDefined(pt, ForceDegree .all)) {
20172019 def spliceOwner (ctx : Context ): Symbol =
@@ -2024,13 +2026,23 @@ class Typer extends Namer
20242026 tree.withType(UnspecifiedErrorType )
20252027 }
20262028 }
2027- else
2029+ else {
2030+ if (StagingContext .level == 0 ) {
2031+ // Mark the first inline method from the context as a macro
2032+ def markAsMacro (c : Context ): Unit =
2033+ if (c.owner eq c.outer.owner) markAsMacro(c.outer)
2034+ else if (c.owner.isInlineMethod) c.owner.setFlag(Macro )
2035+ else if (! c.outer.owner.is(Package )) markAsMacro(c.outer)
2036+ markAsMacro(ctx)
2037+ }
20282038 typedApply(untpd.Apply (untpd.ref(defn.InternalQuoted_exprSpliceR ), tree.expr), pt)(spliceContext).withSpan(tree.span)
2039+ }
20292040 }
20302041 }
20312042
20322043 /** Translate ${ t: Type[T] }` into type `t.splice` while tracking the quotation level in the context */
20332044 def typedTypSplice (tree : untpd.TypSplice , pt : Type )(implicit ctx : Context ): Tree = track(" typedTypSplice" ) {
2045+ ctx.compilationUnit.needsStaging = true
20342046 checkSpliceOutsideQuote(tree)
20352047 typedSelect(untpd.Select (tree.expr, tpnme.splice), pt)(spliceContext).withSpan(tree.span)
20362048 }
0 commit comments