Skip to content

Commit 3ce184f

Browse files
authored
Merge pull request #2875 from dotty-staging/fix-#2871
Fix #2871: Recognize more types as structural selections
2 parents b3dd94f + a5d4098 commit 3ce184f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,8 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
659659
rname == tree.name || hasRefinement(parent)
660660
case tp: TypeProxy =>
661661
hasRefinement(tp.underlying)
662-
case tp: OrType =>
662+
case tp: AndOrType =>
663663
hasRefinement(tp.tp1) || hasRefinement(tp.tp2)
664-
case tp: AndType =>
665-
hasRefinement(tp.tp1) && hasRefinement(tp.tp2)
666664
case _ =>
667665
false
668666
}

tests/neg/i2871.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Cont[A0](x0: A0) { type A = A0; val x: A = x0 }
2+
object Test {
3+
val c: { type A; val x: A } & { type A = Int } = new Cont(1)
4+
println(c.x : Int) // error: not an instance of Selectable
5+
}

0 commit comments

Comments
 (0)