File tree Expand file tree Collapse file tree 7 files changed +31
-6
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 7 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -1778,7 +1778,7 @@ import transform.SymUtils._
1778
1778
|To convert to a function value, you need to explicitly write ${hl(" () => x" )}"""
1779
1779
}
1780
1780
1781
- class MissingEmptyArgumentList (method : Symbol )(using Context )
1781
+ class MissingEmptyArgumentList (method : String )(using Context )
1782
1782
extends SyntaxMsg (MissingEmptyArgumentListID ) {
1783
1783
def msg = em " $method must be called with ${hl(" ()" )} argument "
1784
1784
def explain = {
Original file line number Diff line number Diff line change @@ -373,7 +373,7 @@ trait Applications extends Compatibility {
373
373
def success : Boolean = ok
374
374
375
375
protected def methodType : MethodType = methType.asInstanceOf [MethodType ]
376
- private def methString : String = i " ${methRef.symbol }: ${methType.show}"
376
+ private def methString : String = i " ${err.refStr(methRef) }: ${methType.show}"
377
377
378
378
/** Re-order arguments to correctly align named arguments */
379
379
def reorder [T >: Untyped ](args : List [Trees .Tree [T ]]): List [Trees .Tree [T ]] = {
Original file line number Diff line number Diff line change @@ -84,7 +84,13 @@ object ErrorReporting {
84
84
else anonymousTypeMemberStr(denot.info)
85
85
86
86
def refStr (tp : Type ): String = tp match {
87
- case tp : NamedType => denotStr(tp.denot)
87
+ case tp : NamedType =>
88
+ if tp.denot.symbol.exists then tp.denot.symbol.showLocated
89
+ else
90
+ val kind = tp.info match
91
+ case _ : MethodOrPoly | _ : ExprType => " method"
92
+ case _ => if tp.isType then " type" else " value"
93
+ s " $kind ${tp.name}"
88
94
case _ => anonymousTypeMemberStr(tp)
89
95
}
90
96
Original file line number Diff line number Diff line change @@ -2951,7 +2951,7 @@ class Typer extends Namer
2951
2951
def readaptSimplified (tree : Tree )(using Context ) = readapt(simplify(tree, pt, locked))
2952
2952
2953
2953
def missingArgs (mt : MethodType ) = {
2954
- val meth = methPart(tree).symbol
2954
+ val meth = err.exprStr( methPart(tree))
2955
2955
if (mt.paramNames.length == 0 ) report.error(MissingEmptyArgumentList (meth), tree.srcPos)
2956
2956
else report.error(em " missing arguments for $meth" , tree.srcPos)
2957
2957
tree.withType(mt.resultType)
@@ -3221,7 +3221,7 @@ class Typer extends Namer
3221
3221
def isAutoApplied (sym : Symbol ): Boolean =
3222
3222
sym.isConstructor
3223
3223
|| sym.matchNullaryLoosely
3224
- || warnOnMigration(MissingEmptyArgumentList (sym), tree.srcPos)
3224
+ || warnOnMigration(MissingEmptyArgumentList (sym.show ), tree.srcPos)
3225
3225
&& { patch(tree.span.endPos, " ()" ); true }
3226
3226
3227
3227
// Reasons NOT to eta expand:
Original file line number Diff line number Diff line change 1
1
-- Error: tests/neg/i2033.scala:7:30 -----------------------------------------------------------------------------------
2
2
7 | val arr = bos toByteArray () // error
3
3
| ^^
4
- |can't supply unit value with infix notation because nullary method toByteArray: (): Array[Byte] takes no arguments; use dotted invocation instead: (...).toByteArray()
4
+ |can't supply unit value with infix notation because nullary method toByteArray in class ByteArrayOutputStream : (): Array[Byte] takes no arguments; use dotted invocation instead: (...).toByteArray()
5
5
-- [E007] Type Mismatch Error: tests/neg/i2033.scala:20:35 -------------------------------------------------------------
6
6
20 | val out = new ObjectOutputStream(println) // error
7
7
| ^^^^^^^
Original file line number Diff line number Diff line change
1
+ -- [E100] Syntax Error: tests/neg/i9436.scala:8:12 ---------------------------------------------------------------------
2
+ 8 | println(x.f1) // error
3
+ | ^^^^
4
+ | method f1 must be called with () argument
5
+
6
+ longer explanation available when compiling with `-explain`
7
+ -- Error: tests/neg/i9436.scala:9:14 -----------------------------------------------------------------------------------
8
+ 9 | println(x.f2(1)) // error
9
+ | ^^^^^^^
10
+ | missing argument for parameter y of method f2: (x: Int, y: Int): Int
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
+ def f1 () = 23
6
+ def f2 (x : Int , y : Int ) = x + y
7
+
8
+ println(x.f1) // error
9
+ println(x.f2(1 )) // error
You can’t perform that action at this time.
0 commit comments