Skip to content

Commit

Permalink
Fix hasMatchingMember handling NoDenotation
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Jun 14, 2023
1 parent 5d2812a commit 630ed04
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
|| (tp1.isStable && isSubType(TermRef(tp1, m.symbol), tp2.refinedInfo))

tp1.member(name) match // inlined hasAltWith for performance
case mbr: SingleDenotation => qualifies(mbr)
case mbr: SingleDenotation => mbr.exists && qualifies(mbr)
case mbr => mbr hasAltWith qualifies
}

Expand Down
7 changes: 7 additions & 0 deletions tests/neg/i17581.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- [E007] Type Mismatch Error: tests/neg/i17581.scala:9:6 --------------------------------------------------------------
9 | foo(test) // error // was NoSuchMethodException
| ^^^^
| Found: (test : Test)
| Required: Object{def bar: Any}
|
| longer explanation available when compiling with `-explain`
9 changes: 9 additions & 0 deletions tests/neg/i17581.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import scala.reflect.Selectable.reflectiveSelectable

class Test

def foo[A <: { def bar: Any }](ob: A) = ob.bar

@main def main =
val test = new Test
foo(test) // error // was NoSuchMethodException

0 comments on commit 630ed04

Please sign in to comment.