Skip to content

Commit e570a90

Browse files
committed
Fix hasMatchingMember handling NoDenotation
1 parent 5d2812a commit e570a90

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
20212021
|| (tp1.isStable && isSubType(TermRef(tp1, m.symbol), tp2.refinedInfo))
20222022

20232023
tp1.member(name) match // inlined hasAltWith for performance
2024-
case mbr: SingleDenotation => qualifies(mbr)
2024+
case mbr: SingleDenotation => mbr.exists && qualifies(mbr)
20252025
case mbr => mbr hasAltWith qualifies
20262026
}
20272027

tests/neg/i17581.check

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- [E007] Type Mismatch Error: tests/neg/i17581.scala:9:6 --------------------------------------------------------------
2+
9 | foo(test) // error // was NoSuchMethodException
3+
| ^^^^
4+
| Found: (test : Test)
5+
| Required: Object{def bar: Any}
6+
|
7+
| longer explanation available when compiling with `-explain`

tests/neg/i17581.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import scala.reflect.Selectable.reflectiveSelectable
2+
3+
class Test
4+
5+
def foo[A <: { def bar: Any }](ob: A) = ob.bar
6+
7+
@main def main =
8+
val test = new Test
9+
foo(test) // error // was NoSuchMethodException

tests/neg/i7812.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
def f(): Any = ???
22
var f: (UndefinedA & UndefinedB) { val x: Int } = ??? // error // error
3-
val a = f // error
3+
val a = f

0 commit comments

Comments
 (0)