@@ -19,6 +19,7 @@ import util.SourceFile
1919import TypeComparer .necessarySubType
2020
2121import scala .annotation .internal .sharable
22+ import dotty .tools .dotc .util .Spans .{NoSpan , Span }
2223
2324object ProtoTypes {
2425
@@ -165,7 +166,7 @@ object ProtoTypes {
165166 *
166167 * [ ].name: proto
167168 */
168- abstract case class SelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean )
169+ abstract case class SelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean , nameSpan : Span )
169170 extends CachedProxyType with ProtoType with ValueTypeOrProto {
170171
171172 /** Is the set of members of this type unknown, in the sense that we
@@ -230,24 +231,24 @@ object ProtoTypes {
230231
231232 def underlying (using Context ): Type = WildcardType
232233
233- def derivedSelectionProto (name : Name , memberProto : Type , compat : Compatibility )(using Context ): SelectionProto =
234- if ((name eq this .name) && (memberProto eq this .memberProto) && (compat eq this .compat)) this
235- else SelectionProto (name, memberProto, compat, privateOK)
234+ def derivedSelectionProto (name : Name , memberProto : Type , compat : Compatibility , nameSpan : Span )(using Context ): SelectionProto =
235+ if ((name eq this .name) && (memberProto eq this .memberProto) && (compat eq this .compat) && (nameSpan == this .nameSpan) ) this
236+ else SelectionProto (name, memberProto, compat, privateOK, nameSpan )
236237
237238 override def isErroneous (using Context ): Boolean =
238239 memberProto.isErroneous
239240
240241 override def unusableForInference (using Context ): Boolean =
241242 memberProto.unusableForInference
242243
243- def map (tm : TypeMap )(using Context ): SelectionProto = derivedSelectionProto(name, tm(memberProto), compat)
244+ def map (tm : TypeMap )(using Context ): SelectionProto = derivedSelectionProto(name, tm(memberProto), compat, nameSpan )
244245 def fold [T ](x : T , ta : TypeAccumulator [T ])(using Context ): T = ta(x, memberProto)
245246
246247 override def deepenProto (using Context ): SelectionProto =
247- derivedSelectionProto(name, memberProto.deepenProto, compat)
248+ derivedSelectionProto(name, memberProto.deepenProto, compat, nameSpan )
248249
249250 override def deepenProtoTrans (using Context ): SelectionProto =
250- derivedSelectionProto(name, memberProto.deepenProtoTrans, compat)
251+ derivedSelectionProto(name, memberProto.deepenProtoTrans, compat, nameSpan )
251252
252253 override def computeHash (bs : Hashable .Binders ): Int = {
253254 val delta = (if (compat eq NoViewsAllowed ) 1 else 0 ) | (if (privateOK) 2 else 0 )
@@ -268,24 +269,24 @@ object ProtoTypes {
268269 }
269270 }
270271
271- class CachedSelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean )
272- extends SelectionProto (name, memberProto, compat, privateOK)
272+ class CachedSelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean , nameSpan : Span )
273+ extends SelectionProto (name, memberProto, compat, privateOK, nameSpan )
273274
274275 object SelectionProto {
275- def apply (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean )(using Context ): SelectionProto = {
276- val selproto = new CachedSelectionProto (name, memberProto, compat, privateOK)
276+ def apply (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean , nameSpan : Span )(using Context ): SelectionProto = {
277+ val selproto = new CachedSelectionProto (name, memberProto, compat, privateOK, nameSpan )
277278 if (compat eq NoViewsAllowed ) unique(selproto) else selproto
278279 }
279280 }
280281
281282 /** Create a selection proto-type, but only one level deep;
282283 * treat constructors specially
283284 */
284- def shallowSelectionProto (name : Name , tp : Type , typer : Typer )(using Context ): TermType =
285+ def shallowSelectionProto (name : Name , tp : Type , typer : Typer , nameSpan : Span )(using Context ): TermType =
285286 if (name.isConstructorName) WildcardType
286287 else tp match
287- case tp : UnapplyFunProto => new UnapplySelectionProto (name)
288- case tp => SelectionProto (name, IgnoredProto (tp), typer, privateOK = true )
288+ case tp : UnapplyFunProto => new UnapplySelectionProto (name, nameSpan )
289+ case tp => SelectionProto (name, IgnoredProto (tp), typer, privateOK = true , nameSpan )
289290
290291 /** A prototype for expressions [] that are in some unspecified selection operation
291292 *
@@ -295,12 +296,12 @@ object ProtoTypes {
295296 * operation is further selection. In this case, the expression need not be a value.
296297 * @see checkValue
297298 */
298- @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true )
299+ @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true , NoSpan )
299300
300- @ sharable object SingletonTypeProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true )
301+ @ sharable object SingletonTypeProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true , NoSpan )
301302
302303 /** A prototype for selections in pattern constructors */
303- class UnapplySelectionProto (name : Name ) extends SelectionProto (name, WildcardType , NoViewsAllowed , true )
304+ class UnapplySelectionProto (name : Name , nameSpan : Span ) extends SelectionProto (name, WildcardType , NoViewsAllowed , true , nameSpan )
304305
305306 trait ApplyingProto extends ProtoType // common trait of ViewProto and FunProto
306307 trait FunOrPolyProto extends ProtoType : // common trait of PolyProto and FunProto
@@ -599,7 +600,7 @@ object ProtoTypes {
599600 def isMatchedBy (tp : Type , keepConstraint : Boolean )(using Context ): Boolean =
600601 ctx.typer.isApplicableType(tp, argType :: Nil , resultType) || {
601602 resType match {
602- case selProto @ SelectionProto (selName : TermName , mbrType, _, _) =>
603+ case selProto @ SelectionProto (selName : TermName , mbrType, _, _, _ ) =>
603604 ctx.typer.hasExtensionMethodNamed(tp, selName, argType, mbrType)
604605 // .reporting(i"has ext $tp $name $argType $mbrType: $result")
605606 case _ =>
@@ -921,7 +922,7 @@ object ProtoTypes {
921922 }
922923 approxOr
923924 case tp : SelectionProto =>
924- tp.derivedSelectionProto(tp.name, wildApprox(tp.memberProto, theMap, seen, internal), NoViewsAllowed )
925+ tp.derivedSelectionProto(tp.name, wildApprox(tp.memberProto, theMap, seen, internal), NoViewsAllowed , tp.nameSpan )
925926 case tp : ViewProto =>
926927 tp.derivedViewProto(
927928 wildApprox(tp.argType, theMap, seen, internal),
0 commit comments