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._
17781778 |To convert to a function value, you need to explicitly write ${hl(" () => x" )}"""
17791779 }
17801780
1781- class MissingEmptyArgumentList (method : Symbol )(using Context )
1781+ class MissingEmptyArgumentList (method : String )(using Context )
17821782 extends SyntaxMsg (MissingEmptyArgumentListID ) {
17831783 def msg = em " $method must be called with ${hl(" ()" )} argument "
17841784 def explain = {
Original file line number Diff line number Diff line change @@ -373,7 +373,7 @@ trait Applications extends Compatibility {
373373 def success : Boolean = ok
374374
375375 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}"
377377
378378 /** Re-order arguments to correctly align named arguments */
379379 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 {
8484 else anonymousTypeMemberStr(denot.info)
8585
8686 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}"
8894 case _ => anonymousTypeMemberStr(tp)
8995 }
9096
Original file line number Diff line number Diff line change @@ -2951,7 +2951,7 @@ class Typer extends Namer
29512951 def readaptSimplified (tree : Tree )(using Context ) = readapt(simplify(tree, pt, locked))
29522952
29532953 def missingArgs (mt : MethodType ) = {
2954- val meth = methPart(tree).symbol
2954+ val meth = err.exprStr( methPart(tree))
29552955 if (mt.paramNames.length == 0 ) report.error(MissingEmptyArgumentList (meth), tree.srcPos)
29562956 else report.error(em " missing arguments for $meth" , tree.srcPos)
29572957 tree.withType(mt.resultType)
@@ -3221,7 +3221,7 @@ class Typer extends Namer
32213221 def isAutoApplied (sym : Symbol ): Boolean =
32223222 sym.isConstructor
32233223 || sym.matchNullaryLoosely
3224- || warnOnMigration(MissingEmptyArgumentList (sym), tree.srcPos)
3224+ || warnOnMigration(MissingEmptyArgumentList (sym.show ), tree.srcPos)
32253225 && { patch(tree.span.endPos, " ()" ); true }
32263226
32273227 // Reasons NOT to eta expand:
Original file line number Diff line number Diff line change 11-- Error: tests/neg/i2033.scala:7:30 -----------------------------------------------------------------------------------
227 | val arr = bos toByteArray () // error
33 | ^^
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()
55-- [E007] Type Mismatch Error: tests/neg/i2033.scala:20:35 -------------------------------------------------------------
6620 | val out = new ObjectOutputStream(println) // error
77 | ^^^^^^^
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