@@ -2188,7 +2188,7 @@ object Types {
2188
2188
def designator : Designator
2189
2189
protected def designator_= (d : Designator ): Unit
2190
2190
2191
- assert(prefix.isValueType || (prefix eq NoPrefix ), s " invalid prefix $prefix" )
2191
+ assert(NamedType .validPrefix (prefix), s " invalid prefix $prefix" )
2192
2192
2193
2193
private var myName : Name | Null = null
2194
2194
private var lastDenotation : Denotation | Null = null
@@ -2698,7 +2698,7 @@ object Types {
2698
2698
this
2699
2699
2700
2700
/** A reference like this one, but with the given prefix. */
2701
- final def withPrefix (prefix : Type )(using Context ): NamedType = {
2701
+ final def withPrefix (prefix : Type )(using Context ): Type = {
2702
2702
def reload (): NamedType = {
2703
2703
val lastSym = lastSymbol.nn
2704
2704
val allowPrivate = ! lastSym.exists || lastSym.is(Private )
@@ -2711,6 +2711,7 @@ object Types {
2711
2711
NamedType (prefix, name, d)
2712
2712
}
2713
2713
if (prefix eq this .prefix) this
2714
+ else if ! NamedType .validPrefix(prefix) then UnspecifiedErrorType
2714
2715
else if (lastDenotation == null ) NamedType (prefix, designator)
2715
2716
else designator match {
2716
2717
case sym : Symbol =>
@@ -2902,6 +2903,8 @@ object Types {
2902
2903
def apply (prefix : Type , designator : Name , denot : Denotation )(using Context ): NamedType =
2903
2904
if (designator.isTermName) TermRef .apply(prefix, designator.asTermName, denot)
2904
2905
else TypeRef .apply(prefix, designator.asTypeName, denot)
2906
+
2907
+ def validPrefix (prefix : Type ): Boolean = prefix.isValueType || (prefix eq NoPrefix )
2905
2908
}
2906
2909
2907
2910
object TermRef {
0 commit comments