@@ -57,17 +57,30 @@ end TypeError
5757class MalformedType (pre : Type , denot : Denotation , absMembers : Set [Name ])(using Context ) extends TypeError :
5858 def toMessage (using Context ) = em " malformed type: $pre is not a legal prefix for $denot because it contains abstract type member ${if (absMembers.size == 1 ) " " else " s" } ${absMembers.mkString(" , " )}"
5959
60- class MissingType (pre : Type , name : Name )(using Context ) extends TypeError :
61- private def otherReason (pre : Type )(using Context ): String = pre match {
62- case pre : ThisType if pre.cls.givenSelfType.exists =>
63- i " \n or the self type of $pre might not contain all transitive dependencies "
64- case _ => " "
65- }
60+ class MissingType (val pre : Type , val name : Name )(using Context ) extends TypeError :
61+
62+ def reason (using Context ): String =
63+ def missingClassFile =
64+ " The classfile defining the type might be missing from the classpath"
65+ val cls = pre.classSymbol
66+ val givenSelf = cls match
67+ case cls : ClassSymbol => cls.givenSelfType
68+ case _ => NoType
69+ pre match
70+ case pre : ThisType if pre.cls.givenSelfType.exists =>
71+ i """ $missingClassFile
72+ |or the self type of $pre might not contain all transitive dependencies """
73+ case _ if givenSelf.exists && givenSelf.member(name).exists =>
74+ i """ $name exists as a member of the self type $givenSelf of $cls
75+ |but it cannot be called on a receiver whose type does not extend $cls"""
76+ case _ =>
77+ missingClassFile
78+
6679
6780 override def toMessage (using Context ): Message =
6881 if ctx.debug then printStackTrace()
69- em """ cannot resolve reference to type $pre. $name
70- |the classfile defining the type might be missing from the classpath ${otherReason(pre)} """
82+ em """ Cannot resolve reference to type $pre. $name.
83+ | $reason . """
7184end MissingType
7285
7386class RecursionOverflow (val op : String , details : => String , val previous : Throwable , val weight : Int )(using Context )
0 commit comments