Skip to content

Commit f63e6ea

Browse files
smartertgodzik
authored andcommitted
Slightly improve the error message after the previous commit
1 parent 10c85b5 commit f63e6ea

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,16 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
467467
else if (tp.symbol hasAnnotation defn.ScalaStaticAnnot)
468468
Ident(tp)
469469
else
470+
// Throw an error here if we detect a skolem to improve the error message in tests/neg/i8623.scala
471+
def checkNoSkolemInPrefix(pre: Type): Unit = pre.dealias match
472+
case pre: SkolemType =>
473+
throw TypeError(em"cannot construct a tree referring to $tp because of skolem prefix $pre")
474+
case pre: TermRef => checkNoSkolemInPrefix(pre.prefix)
475+
case _ =>
476+
470477
val pre = tp.prefix
471-
if (pre.isSingleton) followOuterLinks(singleton(pre.dealias, needLoad)).select(tp)
478+
checkNoSkolemInPrefix(tp)
479+
if pre.isSingleton then followOuterLinks(singleton(pre.dealias, needLoad)).select(tp)
472480
else
473481
val res = Select(TypeTree(pre), tp)
474482
if needLoad && !res.symbol.isStatic then

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)