diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index fc97a9d88a71..eb66185164e4 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -56,8 +56,9 @@ trait TypeAssigner { // TODO: measure the cost of using `existsPart`, and if necessary replace it // by a `TypeAccumulator` where we have set `stopAtStatic = true`. tp existsPart { - case tp: NamedType => forbidden contains tp.symbol - case tp: ThisType => forbidden contains tp.cls + case tp: TermRef => forbidden.contains(tp.symbol) || toAvoid(tp.underlying) + case tp: TypeRef => forbidden.contains(tp.symbol) + case tp: ThisType => forbidden.contains(tp.cls) case _ => false } def apply(tp: Type): Type = tp match { diff --git a/tests/pos/i2697.scala b/tests/pos/i2697.scala new file mode 100644 index 000000000000..37dded454d80 --- /dev/null +++ b/tests/pos/i2697.scala @@ -0,0 +1,7 @@ +object Foo { + def bar = { + val data = Map.empty[String, String] + val list = List.empty[Map[String, String]] + list.map(_ ++ data) + } +}