Skip to content

Commit a114971

Browse files
dwijnandKordyjan
authored andcommitted
Print full package names, even if they're TermRefs
If you refer to a package by name, e.g. `scala.quoted.Quotes`, the type may have a "quoted" prefix that is a TermRef. Rather than unravel the rest of the prefixes, we print the fully package name. [Cherry-picked c04bb4f]
1 parent 20113f4 commit a114971

26 files changed

+60
-54
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
109109
if (tp.cls.isAnonymousClass) keywordStr("this")
110110
if (tp.cls.is(ModuleClass)) fullNameString(tp.cls.sourceModule)
111111
else super.toTextRef(tp)
112+
case tp: TermRef if !printDebug =>
113+
if tp.symbol.is(Package) then fullNameString(tp.symbol)
114+
else super.toTextRef(tp)
112115
case _ =>
113116
super.toTextRef(tp)
114117
}

compiler/test-resources/repl-macros/i15104c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
scala> import scala.quoted._
22
scala> def macroImpl(using Quotes) = Expr(1)
3-
def macroImpl(using x$1: quoted.Quotes): quoted.Expr[Int]
3+
def macroImpl(using x$1: scala.quoted.Quotes): scala.quoted.Expr[Int]
44
scala> inline def foo = ${ macroImpl }
55
def foo: Int
66
scala> foo

compiler/test-resources/repl-macros/i5551

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
scala> import scala.quoted._
22
scala> def assertImpl(expr: Expr[Boolean])(using q: Quotes) = '{ if !($expr) then throw new AssertionError("failed assertion")}
33
def assertImpl
4-
(expr: quoted.Expr[Boolean])(using q: quoted.Quotes): scala.quoted.Expr[Unit]
4+
(expr: scala.quoted.Expr[Boolean])
5+
(using q: scala.quoted.Quotes): scala.quoted.Expr[Unit]
56
scala> inline def assert(expr: => Boolean): Unit = ${ assertImpl('{expr}) }
67
def assert(expr: => Boolean): Unit
78

compiler/test-resources/repl/i10355

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
scala> import scala.quoted._
22
scala> def foo(expr: Expr[Any])(using Quotes) = expr match { case '{ $x: t } => '{ $x: Any } }
33
def foo
4-
(expr: quoted.Expr[Any])(using x$2: quoted.Quotes): scala.quoted.Expr[Any]
4+
(expr: scala.quoted.Expr[Any])
5+
(using x$2: scala.quoted.Quotes): scala.quoted.Expr[Any]
56
scala> def bar(expr: Expr[Any])(using Quotes) = expr match { case '{ $x: t } => '{ val a: t = ??? ; ???} }
67
def bar
7-
(expr: quoted.Expr[Any])(using x$2: quoted.Quotes): scala.quoted.Expr[Nothing]
8+
(expr: scala.quoted.Expr[Any])
9+
(using x$2: scala.quoted.Quotes): scala.quoted.Expr[Nothing]

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CompletionTest {
3939
code"class Foo { val foo: BigD${m1} }"
4040
.completion(
4141
("BigDecimal", Field, "BigDecimal"),
42-
("BigDecimal", Method, "=> math.BigDecimal.type"),
42+
("BigDecimal", Method, "=> scala.math.BigDecimal.type"),
4343
)
4444
}
4545

staging/test-resources/repl-staging/i6007

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
scala> import scala.quoted._
22
scala> import quoted.staging.{Compiler => StagingCompiler, _}
33
scala> implicit def compiler: StagingCompiler = StagingCompiler.make(getClass.getClassLoader)
4-
def compiler: quoted.staging.Compiler
4+
def compiler: scala.quoted.staging.Compiler
55
scala> def v(using Quotes) = '{ (if true then Some(1) else None).map(v => v+1) }
6-
def v(using x$1: quoted.Quotes): scala.quoted.Expr[Option[Int]]
6+
def v(using x$1: scala.quoted.Quotes): scala.quoted.Expr[Option[Int]]
77
scala> scala.quoted.staging.withQuotes(v.show)
88
val res0: String = (if (true) scala.Some.apply[scala.Int](1) else scala.None).map[scala.Int](((v: scala.Int) => v.+(1)))
99
scala> scala.quoted.staging.run(v)

staging/test-resources/repl-staging/i6263

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
scala> import quoted._
22
scala> import quoted.staging.{Compiler => StagingCompiler, _}
33
scala> implicit def compiler: StagingCompiler = StagingCompiler.make(getClass.getClassLoader)
4-
def compiler: quoted.staging.Compiler
4+
def compiler: scala.quoted.staging.Compiler
55
scala> def fn[T : Type](v : T) = println("ok")
6-
def fn[T](v: T)(implicit evidence$1: quoted.Type[T]): Unit
6+
def fn[T](v: T)(implicit evidence$1: scala.quoted.Type[T]): Unit
77
scala> withQuotes { fn("foo") }
88
ok
99
scala> withQuotes { fn((1,2)) }

tests/neg-custom-args/explain/i16888.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- [E172] Type Error: tests/neg-custom-args/explain/i16888.scala:1:38 --------------------------------------------------
22
1 |def test = summon[scala.quoted.Quotes] // error
33
| ^
4-
| No given instance of type quoted.Quotes was found for parameter x of method summon in object Predef
4+
| No given instance of type scala.quoted.Quotes was found for parameter x of method summon in object Predef
55
|---------------------------------------------------------------------------------------------------------------------
66
| Explanation (enabled by `-explain`)
77
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

tests/neg/i14025.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- [E172] Type Error: tests/neg/i14025.scala:1:88 ----------------------------------------------------------------------
22
1 |val foo = summon[deriving.Mirror.Product { type MirroredType = [X] =>> [Y] =>> (X, Y) }] // error
33
| ^
4-
|No given instance of type deriving.Mirror.Product{type MirroredType[X] = [Y] =>> (X, Y)} was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Product{type MirroredType[X] = [Y] =>> (X, Y)}: type `[X] =>> [Y] =>> (X, Y)` is not a generic product because its subpart `[X] =>> [Y] =>> (X, Y)` is not a supported kind (either `*` or `* -> *`)
4+
|No given instance of type scala.deriving.Mirror.Product{type MirroredType[X] = [Y] =>> (X, Y)} was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Product{type MirroredType[X] = [Y] =>> (X, Y)}: type `[X] =>> [Y] =>> (X, Y)` is not a generic product because its subpart `[X] =>> [Y] =>> (X, Y)` is not a supported kind (either `*` or `* -> *`)
55
-- [E172] Type Error: tests/neg/i14025.scala:2:90 ----------------------------------------------------------------------
66
2 |val bar = summon[deriving.Mirror.Sum { type MirroredType = [X] =>> [Y] =>> List[(X, Y)] }] // error
77
| ^
8-
|No given instance of type deriving.Mirror.Sum{type MirroredType[X] = [Y] =>> List[(X, Y)]} was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Sum{type MirroredType[X] = [Y] =>> List[(X, Y)]}: type `[X] =>> [Y] =>> List[(X, Y)]` is not a generic sum because its subpart `[X] =>> [Y] =>> List[(X, Y)]` is not a supported kind (either `*` or `* -> *`)
8+
|No given instance of type scala.deriving.Mirror.Sum{type MirroredType[X] = [Y] =>> List[(X, Y)]} was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Sum{type MirroredType[X] = [Y] =>> List[(X, Y)]}: type `[X] =>> [Y] =>> List[(X, Y)]` is not a generic sum because its subpart `[X] =>> [Y] =>> List[(X, Y)]` is not a supported kind (either `*` or `* -> *`)

tests/neg/i14127.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- [E172] Type Error: tests/neg/i14127.scala:6:55 ----------------------------------------------------------------------
22
6 | *: Int *: Int *: Int *: Int *: Int *: EmptyTuple)]] // error
33
| ^
4-
|No given instance of type deriving.Mirror.Of[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
5-
| Int, Int, Int)] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
6-
| Int, Int, Int)]:
4+
|No given instance of type scala.deriving.Mirror.Of[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
5+
| Int, Int, Int, Int, Int)] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
6+
| Int, Int, Int, Int, Int)]:
77
| * class *: is not a generic product because it reduces to a tuple with arity 23, expected arity <= 22
88
| * class *: is not a generic sum because it does not have subclasses

tests/neg/i14363.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
|
1010
| One of the following imports might fix the problem:
1111
|
12-
| import math.BigDecimal.int2bigDecimal
13-
| import math.BigInt.int2bigInt
12+
| import scala.math.BigDecimal.int2bigDecimal
13+
| import scala.math.BigInt.int2bigInt
1414
|
1515
|
1616
| longer explanation available when compiling with `-explain`

tests/neg/i14432.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- [E172] Type Error: tests/neg/i14432.scala:13:33 ---------------------------------------------------------------------
22
13 |val mFoo = summon[Mirror.Of[Foo]] // error: no mirror found
33
| ^
4-
|No given instance of type deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[example.Foo]:
4+
|No given instance of type scala.deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[example.Foo]:
55
| * class Foo is not a generic product because the constructor of class Foo is innaccessible from the calling scope.
66
| * class Foo is not a generic sum because it is not a sealed class

tests/neg/i14432a.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- [E172] Type Error: tests/neg/i14432a.scala:14:43 --------------------------------------------------------------------
22
14 | val mFoo = summon[Mirror.Of[example.Foo]] // error: no mirror found
33
| ^
4-
|No given instance of type deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[example.Foo]:
4+
|No given instance of type scala.deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[example.Foo]:
55
| * class Foo is not a generic product because the constructor of class Foo is innaccessible from the calling scope.
66
| * class Foo is not a generic sum because it is not a sealed class

tests/neg/i14432b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- [E172] Type Error: tests/neg/i14432b.scala:15:43 --------------------------------------------------------------------
22
15 | val mFoo = summon[Mirror.Of[example.Foo]] // error: no mirror found
33
| ^
4-
|No given instance of type deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[example.Foo]:
4+
|No given instance of type scala.deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[example.Foo]:
55
| * class Foo is not a generic product because the constructor of class Foo is innaccessible from the calling scope.
66
| * class Foo is not a generic sum because it is not a sealed class

tests/neg/i14432c.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
-- [E172] Type Error: tests/neg/i14432c.scala:16:43 --------------------------------------------------------------------
66
16 | val mFoo = summon[Mirror.Of[example.Foo]] // error: no mirror
77
| ^
8-
|No given instance of type deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[example.Foo]:
8+
|No given instance of type scala.deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[example.Foo]:
99
| * class Foo is not a generic product because the constructor of class Foo is innaccessible from the calling scope.
1010
| * class Foo is not a generic sum because it is not a sealed class

tests/neg/i14432d.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- [E172] Type Error: tests/neg/i14432d.scala:17:45 --------------------------------------------------------------------
22
17 | val mFoo = summon[Mirror.Of[example.Foo]] // error
33
| ^
4-
|No given instance of type deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[example.Foo]:
4+
|No given instance of type scala.deriving.Mirror.Of[example.Foo] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[example.Foo]:
55
| * class Foo is not a generic product because the constructor of class Foo is innaccessible from the calling scope.
66
| * class Foo is not a generic sum because it is not a sealed class

tests/neg/i14564.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
|
1212
| One of the following imports might make progress towards fixing the problem:
1313
|
14-
| import math.Fractional.Implicits.infixFractionalOps
15-
| import math.Integral.Implicits.infixIntegralOps
16-
| import math.Numeric.Implicits.infixNumericOps
14+
| import scala.math.Fractional.Implicits.infixFractionalOps
15+
| import scala.math.Integral.Implicits.infixIntegralOps
16+
| import scala.math.Numeric.Implicits.infixNumericOps
1717
|

tests/neg/i14823.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- [E172] Type Error: tests/neg/i14823.scala:8:50 ----------------------------------------------------------------------
22
8 |val baz = summon[Mirror.Of[SubA[Int] | SubB[Int]]] // error
33
| ^
4-
|No given instance of type deriving.Mirror.Of[SubA[Int] | SubB[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[SubA[Int] | SubB[Int]]:
4+
|No given instance of type scala.deriving.Mirror.Of[SubA[Int] | SubB[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[SubA[Int] | SubB[Int]]:
55
| * type `SubA[Int] | SubB[Int]` is not a generic product because its subpart `SubA[Int] | SubB[Int]` is a top-level union type.
66
| * type `SubA[Int] | SubB[Int]` is not a generic sum because its subpart `SubA[Int] | SubB[Int]` is a top-level union type.

tests/neg/i14823a.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- [E172] Type Error: tests/neg/i14823a.scala:16:48 --------------------------------------------------------------------
22
16 |val foo = summon[Mirror.Of[Box[Int] | Box[Int]]] // error
33
| ^
4-
|No given instance of type deriving.Mirror.Of[Box[Int] | Box[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[Box[Int] | Box[Int]]:
4+
|No given instance of type scala.deriving.Mirror.Of[Box[Int] | Box[Int]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[Box[Int] | Box[Int]]:
55
| * type `Box[Int] | Box[Int]` is not a generic product because its subpart `Box[Int] | Box[Int]` is a top-level union type.
66
| * type `Box[Int] | Box[Int]` is not a generic sum because its subpart `Box[Int] | Box[Int]` is a top-level union type.
77
-- [E172] Type Error: tests/neg/i14823a.scala:17:58 --------------------------------------------------------------------
@@ -13,12 +13,12 @@
1313
-- [E172] Type Error: tests/neg/i14823a.scala:18:63 --------------------------------------------------------------------
1414
18 |def baz = summon[deriving.Mirror.Of[Foo[String] | Foo[String]]] // error
1515
| ^
16-
|No given instance of type deriving.Mirror.Of[Foo[String] | Foo[String]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[Foo[String] | Foo[String]]:
16+
|No given instance of type scala.deriving.Mirror.Of[Foo[String] | Foo[String]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[Foo[String] | Foo[String]]:
1717
| * type `Foo[String] | Foo[String]` is not a generic product because its subpart `Foo[String] | Foo[String]` is a top-level union type.
1818
| * type `Foo[String] | Foo[String]` is not a generic sum because its subpart `Foo[String] | Foo[String]` is a top-level union type.
1919
-- [E172] Type Error: tests/neg/i14823a.scala:20:66 --------------------------------------------------------------------
2020
20 |def qux = summon[deriving.Mirror.Of[Option[Int] | Option[String]]] // error
2121
| ^
22-
|No given instance of type deriving.Mirror.Of[Option[Int] | Option[String]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Of[Option[Int] | Option[String]]:
22+
|No given instance of type scala.deriving.Mirror.Of[Option[Int] | Option[String]] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[Option[Int] | Option[String]]:
2323
| * type `Option[Int] | Option[String]` is not a generic product because its subpart `Option[Int] | Option[String]` is a top-level union type.
2424
| * type `Option[Int] | Option[String]` is not a generic sum because its subpart `Option[Int] | Option[String]` is a top-level union type.

tests/neg/i4986a.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
|Cannot construct a collection of type List[String] with elements of type Int based on a collection of type List[Int]..
55
|I found:
66
|
7-
| collection.BuildFrom.buildFromIterableOps[CC, A0, A]
7+
| scala.collection.BuildFrom.buildFromIterableOps[CC, A0, A]
88
|
9-
|But method buildFromIterableOps in trait BuildFromLowPriority2 does not match type collection.BuildFrom[List[Int], Int, List[String]].
9+
|But method buildFromIterableOps in trait BuildFromLowPriority2 does not match type scala.collection.BuildFrom[List[Int], Int, List[String]].

0 commit comments

Comments
 (0)