@@ -2186,7 +2186,7 @@ object Types {
2186
2186
def designator : Designator
2187
2187
protected def designator_= (d : Designator ): Unit
2188
2188
2189
- assert(prefix.isValueType || (prefix eq NoPrefix ), s " invalid prefix $prefix" )
2189
+ assert(NamedType .validPrefix (prefix), s " invalid prefix $prefix" )
2190
2190
2191
2191
private var myName : Name | Null = null
2192
2192
private var lastDenotation : Denotation | Null = null
@@ -2693,7 +2693,7 @@ object Types {
2693
2693
this
2694
2694
2695
2695
/** A reference like this one, but with the given prefix. */
2696
- final def withPrefix (prefix : Type )(using Context ): NamedType = {
2696
+ final def withPrefix (prefix : Type )(using Context ): Type = {
2697
2697
def reload (): NamedType = {
2698
2698
val lastSym = lastSymbol.nn
2699
2699
val allowPrivate = ! lastSym.exists || lastSym.is(Private )
@@ -2706,6 +2706,7 @@ object Types {
2706
2706
NamedType (prefix, name, d)
2707
2707
}
2708
2708
if (prefix eq this .prefix) this
2709
+ else if ! NamedType .validPrefix(prefix) then UnspecifiedErrorType
2709
2710
else if (lastDenotation == null ) NamedType (prefix, designator)
2710
2711
else designator match {
2711
2712
case sym : Symbol =>
@@ -2897,6 +2898,8 @@ object Types {
2897
2898
def apply (prefix : Type , designator : Name , denot : Denotation )(using Context ): NamedType =
2898
2899
if (designator.isTermName) TermRef .apply(prefix, designator.asTermName, denot)
2899
2900
else TypeRef .apply(prefix, designator.asTypeName, denot)
2901
+
2902
+ def validPrefix (prefix : Type ): Boolean = prefix.isValueType || (prefix eq NoPrefix )
2900
2903
}
2901
2904
2902
2905
object TermRef {
0 commit comments