File tree Expand file tree Collapse file tree 3 files changed +7
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -112,4 +112,7 @@ object Mode {
112112
113113 /** Are we in a quote in a pattern? */
114114 val QuotedPattern : Mode = newMode(25 , " QuotedPattern" )
115+
116+ /** Are we typechecking the rhs of an extension method? */
117+ val InExtensionMethod : Mode = newMode(26 , " InExtensionMethod" )
115118}
Original file line number Diff line number Diff line change @@ -1353,7 +1353,8 @@ class Namer { typer: Typer =>
13531353 def dealiasIfUnit (tp : Type ) = if (tp.isRef(defn.UnitClass )) defn.UnitType else tp
13541354
13551355 var rhsCtx = ctx.fresh.addMode(Mode .InferringReturnType )
1356- if (sym.isInlineMethod) rhsCtx = rhsCtx.addMode(Mode .InlineableBody )
1356+ if sym.isInlineMethod then rhsCtx = rhsCtx.addMode(Mode .InlineableBody )
1357+ if sym.is(ExtensionMethod ) then rhsCtx = rhsCtx.addMode(Mode .InExtensionMethod )
13571358 if (typeParams.nonEmpty) {
13581359 // we'll be typing an expression from a polymorphic definition's body,
13591360 // so we must allow constraining its type parameters
Original file line number Diff line number Diff line change @@ -1977,7 +1977,8 @@ class Typer extends Namer
19771977 }
19781978 }
19791979
1980- if (sym.isInlineMethod) rhsCtx.addMode(Mode .InlineableBody )
1980+ if sym.isInlineMethod then rhsCtx.addMode(Mode .InlineableBody )
1981+ if sym.is(ExtensionMethod ) then rhsCtx.addMode(Mode .InExtensionMethod )
19811982 val rhs1 = PrepareInlineable .dropInlineIfError(sym,
19821983 if sym.isScala2Macro then typedScala2MacroBody(ddef.rhs)(using rhsCtx)
19831984 else typedExpr(ddef.rhs, tpt1.tpe.widenExpr)(using rhsCtx))
You can’t perform that action at this time.
0 commit comments