8000 Inline Typer.isMonoContext · scala/scala@99a8ba2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 99a8ba2

Browse files
committed
Inline Typer.isMonoContext
Contrary to the comment, it wasn't capturing the the context var at typer initialization, which would not have been correct anyway. The inlining here is motivated by avoiding allocation of lambda in every Typer. Even when we're using this value in eta expansion, SilentResult.filter will actually be inlined to avoid the need for a lambda at all.
1 parent d7c6d7f commit 99a8ba2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,6 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
316316
_checkDead
317317
}
318318

319-
// for use with silent type checking to when we can't have results with undetermined type params
320-
// note that this captures the context var
321-
val isMonoContext = (_: Any) => context.undetparams.isEmpty
322-
323319
def dropExistential(tp: Type): Type = tp match {
324320
case ExistentialType(tparams, tpe) =>
325321
new SubstWildcardMap(tparams).apply(tp)
@@ -3034,7 +3030,11 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
30343030
// We're looking for a method (as indicated by FUNmode in the silent typed below),
30353031
// so let's make sure our expected type is a MethodType
30363032
val methArgs = NoSymbol.newSyntheticValueParams(argpts map { case NoType => WildcardType case tp => tp })
3037-
silent(_.typed(meth, mode.forFunMode, MethodType(methArgs, respt))) filter (isMonoContext) map { methTyped =>
3033+
3034+
val result = silent(_.typed(meth, mode.forFunMode, MethodType(methArgs, respt)))
3035+
// we can't have results with undetermined type params
3036+
val resultMono = result filter (_ => context.undetparams.isEmpty)
3037+
resultMono map { methTyped =>
30383038
// if context.undetparams is not empty, the method was polymorphic,
30393039
// so we need the missing arguments to infer its type. See #871
30403040
val funPt = normalize(methTyped.tpe) baseType FunctionClass(numVparams)

0 commit comments

Comments
 (0)
0