File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -1989,9 +1989,11 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1989
1989
1990
1990
def qualifies (m : SingleDenotation ): Boolean =
1991
1991
val info1 = m.info.widenExpr
1992
- isSubInfo(info1, tp2.refinedInfo.widenExpr, m.symbol.info.orElse(info1))
1993
- || matchAbstractTypeMember(m.info)
1994
- || (tp1.isStable && isSubType(TermRef (tp1, m.symbol), tp2.refinedInfo))
1992
+ m.symbol.hasTargetName(m.symbol.name) && (
1993
+ isSubInfo(info1, tp2.refinedInfo.widenExpr, m.symbol.info.orElse(info1))
1994
+ || matchAbstractTypeMember(m.info)
1995
+ || (tp1.isStable && isSubType(TermRef (tp1, m.symbol), tp2.refinedInfo))
1996
+ )
1995
1997
1996
1998
tp1.member(name) match // inlined hasAltWith for performance
1997
1999
case mbr : SingleDenotation => qualifies(mbr)
Original file line number Diff line number Diff line change
1
+ -- [E007] Type Mismatch Error: tests/neg/i18922.scala:11:27 ------------------------------------------------------------
2
+ 11 |def test = doClose(Resource()) // error
3
+ | ^^^^^^^^^^
4
+ | Found: Resource
5
+ | Required: Object{def close(): Unit}
6
+ |
7
+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change
1
+ import scala .annotation .targetName
2
+
3
+ def doClose (closable : { def close (): Unit }): Unit =
4
+ import reflect .Selectable .reflectiveSelectable
5
+ closable.close()
6
+
7
+ class Resource :
8
+ @ targetName(" foo" )
9
+ def close (): Unit = ???
10
+
11
+ def test = doClose(Resource ()) // error
You can’t perform that action at this time.
0 commit comments