@@ -19,6 +19,7 @@ import util.SourceFile
19
19
import TypeComparer .necessarySubType
20
20
21
21
import scala .annotation .internal .sharable
22
+ import dotty .tools .dotc .util .Spans .{NoSpan , Span }
22
23
23
24
object ProtoTypes {
24
25
@@ -165,7 +166,7 @@ object ProtoTypes {
165
166
*
166
167
* [ ].name: proto
167
168
*/
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 )
169
170
extends CachedProxyType with ProtoType with ValueTypeOrProto {
170
171
171
172
/** Is the set of members of this type unknown, in the sense that we
@@ -230,24 +231,24 @@ object ProtoTypes {
230
231
231
232
def underlying (using Context ): Type = WildcardType
232
233
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 )
236
237
237
238
override def isErroneous (using Context ): Boolean =
238
239
memberProto.isErroneous
239
240
240
241
override def unusableForInference (using Context ): Boolean =
241
242
memberProto.unusableForInference
242
243
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 )
244
245
def fold [T ](x : T , ta : TypeAccumulator [T ])(using Context ): T = ta(x, memberProto)
245
246
246
247
override def deepenProto (using Context ): SelectionProto =
247
- derivedSelectionProto(name, memberProto.deepenProto, compat)
248
+ derivedSelectionProto(name, memberProto.deepenProto, compat, nameSpan )
248
249
249
250
override def deepenProtoTrans (using Context ): SelectionProto =
250
- derivedSelectionProto(name, memberProto.deepenProtoTrans, compat)
251
+ derivedSelectionProto(name, memberProto.deepenProtoTrans, compat, nameSpan )
251
252
252
253
override def computeHash (bs : Hashable .Binders ): Int = {
253
254
val delta = (if (compat eq NoViewsAllowed ) 1 else 0 ) | (if (privateOK) 2 else 0 )
@@ -268,24 +269,24 @@ object ProtoTypes {
268
269
}
269
270
}
270
271
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 )
273
274
274
275
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 )
277
278
if (compat eq NoViewsAllowed ) unique(selproto) else selproto
278
279
}
279
280
}
280
281
281
282
/** Create a selection proto-type, but only one level deep;
282
283
* treat constructors specially
283
284
*/
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 =
285
286
if (name.isConstructorName) WildcardType
286
287
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 )
289
290
290
291
/** A prototype for expressions [] that are in some unspecified selection operation
291
292
*
@@ -295,12 +296,12 @@ object ProtoTypes {
295
296
* operation is further selection. In this case, the expression need not be a value.
296
297
* @see checkValue
297
298
*/
298
- @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true )
299
+ @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true , NoSpan )
299
300
300
- @ sharable object SingletonTypeProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true )
301
+ @ sharable object SingletonTypeProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true , NoSpan )
301
302
302
303
/** 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 )
304
305
305
306
trait ApplyingProto extends ProtoType // common trait of ViewProto and FunProto
306
307
trait FunOrPolyProto extends ProtoType : // common trait of PolyProto and FunProto
@@ -599,7 +600,7 @@ object ProtoTypes {
599
600
def isMatchedBy (tp : Type , keepConstraint : Boolean )(using Context ): Boolean =
600
601
ctx.typer.isApplicableType(tp, argType :: Nil , resultType) || {
601
602
resType match {
602
- case selProto @ SelectionProto (selName : TermName , mbrType, _, _) =>
603
+ case selProto @ SelectionProto (selName : TermName , mbrType, _, _, _ ) =>
603
604
ctx.typer.hasExtensionMethodNamed(tp, selName, argType, mbrType)
604
605
// .reporting(i"has ext $tp $name $argType $mbrType: $result")
605
606
case _ =>
@@ -921,7 +922,7 @@ object ProtoTypes {
921
922
}
922
923
approxOr
923
924
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 )
925
926
case tp : ViewProto =>
926
927
tp.derivedViewProto(
927
928
wildApprox(tp.argType, theMap, seen, internal),
0 commit comments