Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3717,16 +3717,8 @@ object Types {
case _ =>
NoType
}
def isInstantiatable(tp: Type)(implicit ctx: Context): Boolean = zeroParamClass(tp) match {
case cinfo: ClassInfo =>
val tref = tp.narrow
val selfType = cinfo.selfType.asSeenFrom(tref, cinfo.cls)
tref <:< selfType
case _ =>
false
}
def unapply(tp: Type)(implicit ctx: Context): Option[SingleDenotation] =
if (isInstantiatable(tp)) {
if (zeroParamClass(tp).exists) {
val absMems = tp.abstractTermMembers
// println(s"absMems: ${absMems map (_.show) mkString ", "}")
if (absMems.size == 1)
Expand Down
8 changes: 8 additions & 0 deletions tests/pos/i2732.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
object Foo {
// Example 1
val fun: java.util.function.Function[String, _ <: String] = x => x

// Example 2
val map = new java.util.HashMap[String, String]
map.computeIfAbsent("hello", foo => "world")
}