@@ -79,16 +79,16 @@ object Checking {
79
79
HKTypeLambda .fromParams(tparams, bound).appliedTo(args)
80
80
if (boundsCheck) checkBounds(orderedArgs, bounds, instantiate)
81
81
82
- def checkWildcardApply (tp : Type , pos : SourcePosition ): Unit = tp match {
82
+ def checkWildcardApply (tp : Type ): Unit = tp match {
83
83
case tp @ AppliedType (tycon, args) =>
84
84
if (tycon.isLambdaSub && args.exists(_.isInstanceOf [TypeBounds ]))
85
85
ctx.errorOrMigrationWarning(
86
86
ex " unreducible application of higher-kinded type $tycon to wildcard arguments " ,
87
- pos )
87
+ tree.sourcePos )
88
88
case _ =>
89
89
}
90
90
def checkValidIfApply (implicit ctx : Context ): Unit =
91
- checkWildcardApply(tycon.tpe.appliedTo(args.map(_.tpe)), tree.sourcePos )
91
+ checkWildcardApply(tycon.tpe.appliedTo(args.map(_.tpe)))
92
92
checkValidIfApply(ctx.addMode(Mode .AllowLambdaWildcardApply ))
93
93
}
94
94
@@ -118,28 +118,28 @@ object Checking {
118
118
/** Check that `tp` refers to a nonAbstract class
119
119
* and that the instance conforms to the self type of the created class.
120
120
*/
121
- def checkInstantiable (tp : Type , pos : SourcePosition )(implicit ctx : Context ): Unit =
121
+ def checkInstantiable (tp : Type , posd : Positioned )(implicit ctx : Context ): Unit =
122
122
tp.underlyingClassRef(refinementOK = false ) match {
123
123
case tref : TypeRef =>
124
124
val cls = tref.symbol
125
125
if (cls.is(AbstractOrTrait ))
126
- ctx.error(CantInstantiateAbstractClassOrTrait (cls, isTrait = cls.is(Trait )), pos )
126
+ ctx.error(CantInstantiateAbstractClassOrTrait (cls, isTrait = cls.is(Trait )), posd.sourcePos )
127
127
if (! cls.is(Module )) {
128
128
// Create a synthetic singleton type instance, and check whether
129
129
// it conforms to the self type of the class as seen from that instance.
130
130
val stp = SkolemType (tp)
131
131
val selfType = cls.asClass.givenSelfType.asSeenFrom(stp, cls)
132
132
if (selfType.exists && ! (stp <:< selfType))
133
- ctx.error(DoesNotConformToSelfTypeCantBeInstantiated (tp, selfType), pos )
133
+ ctx.error(DoesNotConformToSelfTypeCantBeInstantiated (tp, selfType), posd.sourcePos )
134
134
}
135
135
case _ =>
136
136
}
137
137
138
138
/** Check that type `tp` is realizable. */
139
- def checkRealizable (tp : Type , pos : SourcePosition , what : String = " path" )(implicit ctx : Context ): Unit = {
139
+ def checkRealizable (tp : Type , posd : Positioned , what : String = " path" )(implicit ctx : Context ): Unit = {
140
140
val rstatus = realizability(tp)
141
141
if (rstatus ne Realizable )
142
- ctx.errorOrMigrationWarning(em " $tp is not a legal $what\n since it ${rstatus.msg}" , pos )
142
+ ctx.errorOrMigrationWarning(em " $tp is not a legal $what\n since it ${rstatus.msg}" , posd.sourcePos )
143
143
}
144
144
145
145
/** A type map which checks that the only cycles in a type are F-bounds
@@ -332,7 +332,7 @@ object Checking {
332
332
* unless a type with the same name aleadry appears in `decls`.
333
333
* @return true iff no cycles were detected
334
334
*/
335
- def checkNonCyclicInherited (joint : Type , parents : List [Type ], decls : Scope , pos : SourcePosition )(implicit ctx : Context ): Unit = {
335
+ def checkNonCyclicInherited (joint : Type , parents : List [Type ], decls : Scope , posd : Positioned )(implicit ctx : Context ): Unit = {
336
336
def qualifies (sym : Symbol ) = sym.name.isTypeName && ! sym.is(Private )
337
337
val abstractTypeNames =
338
338
for (parent <- parents; mbr <- parent.abstractTypeMembers if qualifies(mbr.symbol))
@@ -350,7 +350,7 @@ object Checking {
350
350
}
351
351
catch {
352
352
case ex : RecursionOverflow =>
353
- ctx.error(em " cyclic reference involving type $name" , pos )
353
+ ctx.error(em " cyclic reference involving type $name" , posd.sourcePos )
354
354
false
355
355
}
356
356
}
@@ -562,8 +562,8 @@ trait Checking {
562
562
def checkNonCyclic (sym : Symbol , info : TypeBounds , reportErrors : Boolean )(implicit ctx : Context ): Type =
563
563
Checking .checkNonCyclic(sym, info, reportErrors)
564
564
565
- def checkNonCyclicInherited (joint : Type , parents : List [Type ], decls : Scope , pos : SourcePosition )(implicit ctx : Context ): Unit =
566
- Checking .checkNonCyclicInherited(joint, parents, decls, pos )
565
+ def checkNonCyclicInherited (joint : Type , parents : List [Type ], decls : Scope , posd : Positioned )(implicit ctx : Context ): Unit =
566
+ Checking .checkNonCyclicInherited(joint, parents, decls, posd )
567
567
568
568
/** Check that Java statics and packages can only be used in selections.
569
569
*/
@@ -578,8 +578,8 @@ trait Checking {
578
578
}
579
579
580
580
/** Check that type `tp` is stable. */
581
- def checkStable (tp : Type , pos : SourcePosition )(implicit ctx : Context ): Unit =
582
- if (! tp.isStable) ctx.error(ex " $tp is not stable " , pos )
581
+ def checkStable (tp : Type , posd : Positioned )(implicit ctx : Context ): Unit =
582
+ if (! tp.isStable) ctx.error(ex " $tp is not stable " , posd.sourcePos )
583
583
584
584
/** Check that all type members of `tp` have realizable bounds */
585
585
def checkRealizableBounds (cls : Symbol , pos : SourcePosition )(implicit ctx : Context ): Unit = {
@@ -594,14 +594,14 @@ trait Checking {
594
594
* check that class prefix is stable.
595
595
* @return `tp` itself if it is a class or trait ref, ObjectType if not.
596
596
*/
597
- def checkClassType (tp : Type , pos : SourcePosition , traitReq : Boolean , stablePrefixReq : Boolean )(implicit ctx : Context ): Type =
597
+ def checkClassType (tp : Type , posd : Positioned , traitReq : Boolean , stablePrefixReq : Boolean )(implicit ctx : Context ): Type =
598
598
tp.underlyingClassRef(refinementOK = false ) match {
599
599
case tref : TypeRef =>
600
- if (traitReq && ! (tref.symbol is Trait )) ctx.error(TraitIsExpected (tref.symbol), pos )
601
- if (stablePrefixReq && ctx.phase <= ctx.refchecksPhase) checkStable(tref.prefix, pos )
600
+ if (traitReq && ! (tref.symbol is Trait )) ctx.error(TraitIsExpected (tref.symbol), posd.sourcePos )
601
+ if (stablePrefixReq && ctx.phase <= ctx.refchecksPhase) checkStable(tref.prefix, posd )
602
602
tp
603
603
case _ =>
604
- ctx.error(ex " $tp is not a class type " , pos )
604
+ ctx.error(ex " $tp is not a class type " , posd.sourcePos )
605
605
defn.ObjectType
606
606
}
607
607
@@ -634,7 +634,7 @@ trait Checking {
634
634
* - it is defined in Predef
635
635
* - it is the scala.reflect.Selectable.reflectiveSelectable conversion
636
636
*/
637
- def checkImplicitConversionUseOK (sym : Symbol , pos : SourcePosition )(implicit ctx : Context ): Unit = {
637
+ def checkImplicitConversionUseOK (sym : Symbol , posd : Positioned )(implicit ctx : Context ): Unit = {
638
638
val conversionOK =
639
639
! sym.exists ||
640
640
sym.is(Synthetic ) ||
@@ -643,7 +643,7 @@ trait Checking {
643
643
sym.name == nme.reflectiveSelectable && sym.maybeOwner.maybeOwner.maybeOwner == defn.ScalaPackageClass
644
644
if (! conversionOK)
645
645
checkFeature(defn.LanguageModuleClass , nme.implicitConversions,
646
- i " Use of implicit conversion ${sym.showLocated}" , NoSymbol , pos )
646
+ i " Use of implicit conversion ${sym.showLocated}" , NoSymbol , posd.sourcePos )
647
647
}
648
648
649
649
/** Issue a feature warning if feature is not enabled */
@@ -890,14 +890,14 @@ trait Checking {
890
890
}
891
891
892
892
/** Check that we are in an inline context (inside an inline method or in inline code) */
893
- def checkInInlineContext (what : String , pos : SourcePosition )(implicit ctx : Context ): Unit =
893
+ def checkInInlineContext (what : String , posd : Positioned )(implicit ctx : Context ): Unit =
894
894
if (! ctx.inInlineMethod && ! ctx.isInlineContext) {
895
895
val inInlineUnapply = ctx.owner.ownersIterator.exists(owner =>
896
896
owner.name == nme.unapply && owner.is(Inline ) && owner.is(Method ))
897
897
val msg =
898
898
if (inInlineUnapply) " cannot be used in an inline unapply"
899
899
else " can only be used in an inline method"
900
- ctx.error(em " $what $msg" , pos )
900
+ ctx.error(em " $what $msg" , posd.sourcePos )
901
901
}
902
902
903
903
/** Check that all case classes that extend `scala.Enum` are `enum` cases */
@@ -994,12 +994,12 @@ trait ReChecking extends Checking {
994
994
trait NoChecking extends ReChecking {
995
995
import tpd ._
996
996
override def checkNonCyclic (sym : Symbol , info : TypeBounds , reportErrors : Boolean )(implicit ctx : Context ): Type = info
997
- override def checkNonCyclicInherited (joint : Type , parents : List [Type ], decls : Scope , pos : SourcePosition )(implicit ctx : Context ): Unit = ()
997
+ override def checkNonCyclicInherited (joint : Type , parents : List [Type ], decls : Scope , posd : Positioned )(implicit ctx : Context ): Unit = ()
998
998
override def checkValue (tree : Tree , proto : Type )(implicit ctx : Context ): tree.type = tree
999
- override def checkStable (tp : Type , pos : SourcePosition )(implicit ctx : Context ): Unit = ()
1000
- override def checkClassType (tp : Type , pos : SourcePosition , traitReq : Boolean , stablePrefixReq : Boolean )(implicit ctx : Context ): Type = tp
999
+ override def checkStable (tp : Type , posd : Positioned )(implicit ctx : Context ): Unit = ()
1000
+ override def checkClassType (tp : Type , posd : Positioned , traitReq : Boolean , stablePrefixReq : Boolean )(implicit ctx : Context ): Type = tp
1001
1001
override def checkImplicitConversionDefOK (sym : Symbol )(implicit ctx : Context ): Unit = ()
1002
- override def checkImplicitConversionUseOK (sym : Symbol , pos : SourcePosition )(implicit ctx : Context ): Unit = ()
1002
+ override def checkImplicitConversionUseOK (sym : Symbol , posd : Positioned )(implicit ctx : Context ): Unit = ()
1003
1003
override def checkFeasibleParent (tp : Type , pos : SourcePosition , where : => String = " " )(implicit ctx : Context ): Type = tp
1004
1004
override def checkInlineConformant (tree : Tree , isFinal : Boolean , what : => String )(implicit ctx : Context ): Unit = ()
1005
1005
override def checkNoDoubleDeclaration (cls : Symbol )(implicit ctx : Context ): Unit = ()
@@ -1011,6 +1011,6 @@ trait NoChecking extends ReChecking {
1011
1011
override def checkCaseInheritance (parentSym : Symbol , caseCls : ClassSymbol , pos : SourcePosition )(implicit ctx : Context ): Unit = ()
1012
1012
override def checkNoForwardDependencies (vparams : List [ValDef ])(implicit ctx : Context ): Unit = ()
1013
1013
override def checkMembersOK (tp : Type , pos : SourcePosition )(implicit ctx : Context ): Type = tp
1014
- override def checkInInlineContext (what : String , pos : SourcePosition )(implicit ctx : Context ): Unit = ()
1014
+ override def checkInInlineContext (what : String , posd : Positioned )(implicit ctx : Context ): Unit = ()
1015
1015
override def checkFeature (base : ClassSymbol , name : TermName , description : => String , featureUseSite : Symbol , pos : SourcePosition )(implicit ctx : Context ): Unit = ()
1016
1016
}
0 commit comments