Skip to content

Commit b90c324

Browse files
authored
Merge pull request #2748 from dotty-staging/fix-#2697
Fix #2697: Align avoid and checkNoLeaks logic
2 parents 243e439 + 0b8a353 commit b90c324

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ trait TypeAssigner {
5656
// TODO: measure the cost of using `existsPart`, and if necessary replace it
5757
// by a `TypeAccumulator` where we have set `stopAtStatic = true`.
5858
tp existsPart {
59-
case tp: NamedType => forbidden contains tp.symbol
60-
case tp: ThisType => forbidden contains tp.cls
59+
case tp: TermRef => forbidden.contains(tp.symbol) || toAvoid(tp.underlying)
60+
case tp: TypeRef => forbidden.contains(tp.symbol)
61+
case tp: ThisType => forbidden.contains(tp.cls)
6162
case _ => false
6263
}
6364
def apply(tp: Type): Type = tp match {

tests/pos/i2697.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object Foo {
2+
def bar = {
3+
val data = Map.empty[String, String]
4+
val list = List.empty[Map[String, String]]
5+
list.map(_ ++ data)
6+
}
7+
}

0 commit comments

Comments
 (0)