File tree 3 files changed +23
-2
lines changed
compiler/src/dotty/tools/dotc/reporting
3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -1279,12 +1279,20 @@ import ast.tpd
1279
1279
1280
1280
class MethodDoesNotTakeParameters (tree : tpd.Tree )(using Context )
1281
1281
extends TypeMsg (MethodDoesNotTakeParametersId ) {
1282
- def methodSymbol : Symbol = tpd.methPart(tree).symbol
1282
+ def methodSymbol : Symbol =
1283
+ def recur (t : tpd.Tree ): Symbol =
1284
+ val sym = tpd.methPart(t).symbol
1285
+ if sym == defn.Any_typeCast then
1286
+ t match
1287
+ case TypeApply (Select (qual, _), _) => recur(qual)
1288
+ case _ => sym
1289
+ else sym
1290
+ recur(tree)
1283
1291
1284
1292
def msg = {
1285
1293
val more = if (tree.isInstanceOf [tpd.Apply ]) " more" else " "
1286
1294
val meth = methodSymbol
1287
- val methStr = if (meth.exists) methodSymbol .showLocated else " expression"
1295
+ val methStr = if (meth.exists) meth .showLocated else " expression"
1288
1296
em " $methStr does not take $more parameters "
1289
1297
}
1290
1298
Original file line number Diff line number Diff line change
1
+ -- [E050] Type Error: tests/neg/i9437.scala:7:10 -----------------------------------------------------------------------
2
+ 7 | println(x.f1()) // error
3
+ | ^^^^
4
+ | method selectDynamic in trait Selectable does not take parameters
5
+
6
+ longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change
1
+ class Bag extends reflect.Selectable
2
+
3
+ @ main def Test =
4
+ val x = new Bag :
5
+ val f1 = 23
6
+
7
+ println(x.f1()) // error
You can’t perform that action at this time.
0 commit comments