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 {
112
112
113
113
/** Are we in a quote in a pattern? */
114
114
val QuotedPattern : Mode = newMode(25 , " QuotedPattern" )
115
+
116
+ /** Are we typechecking the rhs of an extension method? */
117
+ val InExtensionMethod : Mode = newMode(26 , " InExtensionMethod" )
115
118
}
Original file line number Diff line number Diff line change @@ -1353,7 +1353,8 @@ class Namer { typer: Typer =>
1353
1353
def dealiasIfUnit (tp : Type ) = if (tp.isRef(defn.UnitClass )) defn.UnitType else tp
1354
1354
1355
1355
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 )
1357
1358
if (typeParams.nonEmpty) {
1358
1359
// we'll be typing an expression from a polymorphic definition's body,
1359
1360
// 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
1977
1977
}
1978
1978
}
1979
1979
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 )
1981
1982
val rhs1 = PrepareInlineable .dropInlineIfError(sym,
1982
1983
if sym.isScala2Macro then typedScala2MacroBody(ddef.rhs)(using rhsCtx)
1983
1984
else typedExpr(ddef.rhs, tpt1.tpe.widenExpr)(using rhsCtx))
You can’t perform that action at this time.
0 commit comments