Skip to content

Commit c6dec50

Browse files
committed
Fix scala#2412: Local error causes spurious errors to be reported
`FunProto#typedArgs` was using the implicit Context from the `FunProto` constructor, and thus errors weren't stored in the proper context.
1 parent 4ecb1f7 commit c6dec50

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
13421342
if (isDetermined(alts2)) alts2
13431343
else {
13441344
pretypeArgs(alts2, pt)
1345-
narrowByTrees(alts2, pt.typedArgs, resultType)
1345+
narrowByTrees(alts2, pt.typedArgs(ctx.addMode(Mode.ImplicitsEnabled)), resultType)
13461346
}
13471347
}
13481348

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ object ProtoTypes {
227227
/** The typed arguments. This takes any arguments already typed using
228228
* `typedArg` into account.
229229
*/
230-
def typedArgs: List[Tree] = {
230+
def typedArgs(implicit ctx: Context): List[Tree] = {
231231
if (myTypedArgs.size != args.length)
232232
myTypedArgs = args.mapconserve(cacheTypedArg(_, typer.typed(_)))
233233
myTypedArgs
@@ -294,7 +294,7 @@ object ProtoTypes {
294294
* [](args): resultType, where args are known to be typed
295295
*/
296296
class FunProtoTyped(args: List[tpd.Tree], resultType: Type, typer: Typer)(implicit ctx: Context) extends FunProto(args, resultType, typer)(ctx) {
297-
override def typedArgs = args
297+
override def typedArgs(implicit ctx: Context) = args
298298
}
299299

300300
/** A prototype for implicitly inferred views:

tests/pos/i2412.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Test {
2+
def test(foo: List[String]): Unit = {
3+
foo.filter(f => {
4+
iDontExist // error: not found
5+
true
6+
})
7+
}
8+
}

0 commit comments

Comments
 (0)