@@ -21,6 +21,7 @@ import dotty.tools.dotc.core.Flags.Transparent
21
21
import dotty .tools .dotc .config .{ Feature , SourceVersion }
22
22
23
23
import scala .annotation .internal .sharable
24
+ import dotty .tools .dotc .util .Spans .{NoSpan , Span }
24
25
25
26
object ProtoTypes {
26
27
@@ -180,7 +181,7 @@ object ProtoTypes {
180
181
*
181
182
* [ ].name: proto
182
183
*/
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 )
184
185
extends CachedProxyType with ProtoType with ValueTypeOrProto {
185
186
186
187
/** Is the set of members of this type unknown, in the sense that we
@@ -243,24 +244,24 @@ object ProtoTypes {
243
244
244
245
def underlying (using Context ): Type = WildcardType
245
246
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 )
249
250
250
251
override def isErroneous (using Context ): Boolean =
251
252
memberProto.isErroneous
252
253
253
254
override def unusableForInference (using Context ): Boolean =
254
255
memberProto.unusableForInference
255
256
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 )
257
258
def fold [T ](x : T , ta : TypeAccumulator [T ])(using Context ): T = ta(x, memberProto)
258
259
259
260
override def deepenProto (using Context ): SelectionProto =
260
- derivedSelectionProto(name, memberProto.deepenProto, compat)
261
+ derivedSelectionProto(name, memberProto.deepenProto, compat, nameSpan )
261
262
262
263
override def deepenProtoTrans (using Context ): SelectionProto =
263
- derivedSelectionProto(name, memberProto.deepenProtoTrans, compat)
264
+ derivedSelectionProto(name, memberProto.deepenProtoTrans, compat, nameSpan )
264
265
265
266
override def computeHash (bs : Hashable .Binders ): Int = {
266
267
val delta = (if (compat eq NoViewsAllowed ) 1 else 0 ) | (if (privateOK) 2 else 0 )
@@ -281,24 +282,24 @@ object ProtoTypes {
281
282
}
282
283
}
283
284
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 )
286
287
287
288
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 )
290
291
if (compat eq NoViewsAllowed ) unique(selproto) else selproto
291
292
}
292
293
}
293
294
294
295
/** Create a selection proto-type, but only one level deep;
295
296
* treat constructors specially
296
297
*/
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 =
298
299
if (name.isConstructorName) WildcardType
299
300
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 )
302
303
303
304
/** A prototype for expressions [] that are in some unspecified selection operation
304
305
*
@@ -308,12 +309,12 @@ object ProtoTypes {
308
309
* operation is further selection. In this case, the expression need not be a value.
309
310
* @see checkValue
310
311
*/
311
- @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true )
312
+ @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true , NoSpan )
312
313
313
- @ sharable object SingletonTypeProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true )
314
+ @ sharable object SingletonTypeProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true , NoSpan )
314
315
315
316
/** 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 )
317
318
318
319
trait ApplyingProto extends ProtoType // common trait of ViewProto and FunProto
319
320
trait FunOrPolyProto extends ProtoType : // common trait of PolyProto and FunProto
@@ -612,7 +613,7 @@ object ProtoTypes {
612
613
def isMatchedBy (tp : Type , keepConstraint : Boolean )(using Context ): Boolean =
613
614
ctx.typer.isApplicableType(tp, argType :: Nil , resultType) || {
614
615
resType match {
615
- case selProto @ SelectionProto (selName : TermName , mbrType, _, _) =>
616
+ case selProto @ SelectionProto (selName : TermName , mbrType, _, _, _ ) =>
616
617
ctx.typer.hasExtensionMethodNamed(tp, selName, argType, mbrType)
617
618
// .reporting(i"has ext $tp $name $argType $mbrType: $result")
618
619
case _ =>
@@ -934,7 +935,7 @@ object ProtoTypes {
934
935
}
935
936
approxOr
936
937
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 )
938
939
case tp : ViewProto =>
939
940
tp.derivedViewProto(
940
941
wildApprox(tp.argType, theMap, seen, internal),
0 commit comments