Skip to content

Commit 451a4b5

Browse files
committed
Slightly improve the error message after the previous commit
1 parent 6e4b0a0 commit 451a4b5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
480480
else if tp.symbol.hasAnnotation(defn.ScalaStaticAnnot) then
481481
Ident(tp)
482482
else
483+
// Throw an error here if we detect a skolem to improve the error message in tests/neg/i8623.scala
484+
def checkNoSkolemInPrefix(pre: Type): Unit = pre.dealias match
485+
case pre: SkolemType =>
486+
throw TypeError(em"cannot construct a tree referring to $tp because of skolem prefix $pre")
487+
case pre: TermRef => checkNoSkolemInPrefix(pre.prefix)
488+
case _ =>
489+
483490
val pre = tp.prefix
491+
checkNoSkolemInPrefix(tp)
484492
if pre.isSingleton then followOuterLinks(singleton(pre.dealias, needLoad)).select(tp)
485493
else
486494
val res = Select(TypeTree(pre), tp)

tests/neg/i8623.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| value pos is not a member of ?1.tasty.Tree.
55
| Extension methods were tried, but the search failed with:
66
|
7-
| cannot construct a tree referring to skolem (?1 : QC)
7+
| cannot construct a tree referring to ?1.tasty.type because of skolem prefix (?1 : QC)
88
|
99
| where: ?1 is an unknown value of type QC
1010
|

0 commit comments

Comments
 (0)