@@ -21,6 +21,7 @@ import dotty.tools.dotc.core.Flags.Transparent
2121import dotty .tools .dotc .config .{ Feature , SourceVersion }
2222
2323import scala .annotation .internal .sharable
24+ import dotty .tools .dotc .util .Spans .{NoSpan , Span }
2425
2526object ProtoTypes {
2627
@@ -180,7 +181,7 @@ object ProtoTypes {
180181 *
181182 * [ ].name: proto
182183 */
183- abstract case class SelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean )
184+ abstract case class SelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean , nameSpan : Span )
184185 extends CachedProxyType with ProtoType with ValueTypeOrProto {
185186
186187 /** Is the set of members of this type unknown, in the sense that we
@@ -243,24 +244,24 @@ object ProtoTypes {
243244
244245 def underlying (using Context ): Type = WildcardType
245246
246- def derivedSelectionProto (name : Name , memberProto : Type , compat : Compatibility )(using Context ): SelectionProto =
247- if ((name eq this .name) && (memberProto eq this .memberProto) && (compat eq this .compat)) this
248- else SelectionProto (name, memberProto, compat, privateOK)
247+ def derivedSelectionProto (name : Name , memberProto : Type , compat : Compatibility , nameSpan : Span )(using Context ): SelectionProto =
248+ if ((name eq this .name) && (memberProto eq this .memberProto) && (compat eq this .compat) && (nameSpan == this .nameSpan) ) this
249+ else SelectionProto (name, memberProto, compat, privateOK, nameSpan )
249250
250251 override def isErroneous (using Context ): Boolean =
251252 memberProto.isErroneous
252253
253254 override def unusableForInference (using Context ): Boolean =
254255 memberProto.unusableForInference
255256
256- def map (tm : TypeMap )(using Context ): SelectionProto = derivedSelectionProto(name, tm(memberProto), compat)
257+ def map (tm : TypeMap )(using Context ): SelectionProto = derivedSelectionProto(name, tm(memberProto), compat, nameSpan )
257258 def fold [T ](x : T , ta : TypeAccumulator [T ])(using Context ): T = ta(x, memberProto)
258259
259260 override def deepenProto (using Context ): SelectionProto =
260- derivedSelectionProto(name, memberProto.deepenProto, compat)
261+ derivedSelectionProto(name, memberProto.deepenProto, compat, nameSpan )
261262
262263 override def deepenProtoTrans (using Context ): SelectionProto =
263- derivedSelectionProto(name, memberProto.deepenProtoTrans, compat)
264+ derivedSelectionProto(name, memberProto.deepenProtoTrans, compat, nameSpan )
264265
265266 override def computeHash (bs : Hashable .Binders ): Int = {
266267 val delta = (if (compat eq NoViewsAllowed ) 1 else 0 ) | (if (privateOK) 2 else 0 )
@@ -281,24 +282,24 @@ object ProtoTypes {
281282 }
282283 }
283284
284- class CachedSelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean )
285- extends SelectionProto (name, memberProto, compat, privateOK)
285+ class CachedSelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean , nameSpan : Span )
286+ extends SelectionProto (name, memberProto, compat, privateOK, nameSpan )
286287
287288 object SelectionProto {
288- def apply (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean )(using Context ): SelectionProto = {
289- val selproto = new CachedSelectionProto (name, memberProto, compat, privateOK)
289+ def apply (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean , nameSpan : Span )(using Context ): SelectionProto = {
290+ val selproto = new CachedSelectionProto (name, memberProto, compat, privateOK, nameSpan )
290291 if (compat eq NoViewsAllowed ) unique(selproto) else selproto
291292 }
292293 }
293294
294295 /** Create a selection proto-type, but only one level deep;
295296 * treat constructors specially
296297 */
297- def shallowSelectionProto (name : Name , tp : Type , typer : Typer )(using Context ): TermType =
298+ def shallowSelectionProto (name : Name , tp : Type , typer : Typer , nameSpan : Span )(using Context ): TermType =
298299 if (name.isConstructorName) WildcardType
299300 else tp match
300- case tp : UnapplyFunProto => new UnapplySelectionProto (name)
301- case tp => SelectionProto (name, IgnoredProto (tp), typer, privateOK = true )
301+ case tp : UnapplyFunProto => new UnapplySelectionProto (name, nameSpan )
302+ case tp => SelectionProto (name, IgnoredProto (tp), typer, privateOK = true , nameSpan )
302303
303304 /** A prototype for expressions [] that are in some unspecified selection operation
304305 *
@@ -308,12 +309,12 @@ object ProtoTypes {
308309 * operation is further selection. In this case, the expression need not be a value.
309310 * @see checkValue
310311 */
311- @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true )
312+ @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true , NoSpan )
312313
313- @ sharable object SingletonTypeProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true )
314+ @ sharable object SingletonTypeProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true , NoSpan )
314315
315316 /** A prototype for selections in pattern constructors */
316- class UnapplySelectionProto (name : Name ) extends SelectionProto (name, WildcardType , NoViewsAllowed , true )
317+ class UnapplySelectionProto (name : Name , nameSpan : Span ) extends SelectionProto (name, WildcardType , NoViewsAllowed , true , nameSpan )
317318
318319 trait ApplyingProto extends ProtoType // common trait of ViewProto and FunProto
319320 trait FunOrPolyProto extends ProtoType : // common trait of PolyProto and FunProto
@@ -612,7 +613,7 @@ object ProtoTypes {
612613 def isMatchedBy (tp : Type , keepConstraint : Boolean )(using Context ): Boolean =
613614 ctx.typer.isApplicableType(tp, argType :: Nil , resultType) || {
614615 resType match {
615- case selProto @ SelectionProto (selName : TermName , mbrType, _, _) =>
616+ case selProto @ SelectionProto (selName : TermName , mbrType, _, _, _ ) =>
616617 ctx.typer.hasExtensionMethodNamed(tp, selName, argType, mbrType)
617618 // .reporting(i"has ext $tp $name $argType $mbrType: $result")
618619 case _ =>
@@ -934,7 +935,7 @@ object ProtoTypes {
934935 }
935936 approxOr
936937 case tp : SelectionProto =>
937- tp.derivedSelectionProto(tp.name, wildApprox(tp.memberProto, theMap, seen, internal), NoViewsAllowed )
938+ tp.derivedSelectionProto(tp.name, wildApprox(tp.memberProto, theMap, seen, internal), NoViewsAllowed , tp.nameSpan )
938939 case tp : ViewProto =>
939940 tp.derivedViewProto(
940941 wildApprox(tp.argType, theMap, seen, internal),
0 commit comments