@@ -18,12 +18,23 @@ import ErrorReporting.{errorType, InfoString}
18
18
import config .Printers ._
19
19
import collection .mutable
20
20
21
- trait Checking {
21
+ trait NoChecking {
22
+ import tpd ._
23
+ def checkBounds (args : List [tpd.Tree ], poly : PolyType , pos : Position )(implicit ctx : Context ): Unit = ()
24
+ def checkStable (tp : Type , pos : Position )(implicit ctx : Context ): Unit = ()
25
+ def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean )(implicit ctx : Context ): Type = tp
26
+ def checkImplicitTptNonEmpty (defTree : untpd.ValOrDefDef )(implicit ctx : Context ): Unit = ()
27
+ def checkImplicitParamsNotSingletons (vparamss : List [List [ValDef ]])(implicit ctx : Context ): Unit = ()
28
+ def checkFeasible (tp : Type , pos : Position , where : => String = " " )(implicit ctx : Context ): Type = tp
29
+ def checkNoDoubleDefs (cls : Symbol )(implicit ctx : Context ): Unit = ()
30
+ }
31
+
32
+ trait Checking extends NoChecking {
22
33
23
34
import tpd ._
24
35
25
36
/** Check that type arguments `args` conform to corresponding bounds in `poly` */
26
- def checkBounds (args : List [tpd.Tree ], poly : PolyType , pos : Position )(implicit ctx : Context ): Unit =
37
+ override def checkBounds (args : List [tpd.Tree ], poly : PolyType , pos : Position )(implicit ctx : Context ): Unit =
27
38
for ((arg, bounds) <- args zip poly.paramBounds) {
28
39
def notConforms (which : String , bound : Type ) =
29
40
ctx.error(i " Type argument ${arg.tpe} does not conform to $which bound $bound" , arg.pos)
@@ -34,14 +45,14 @@ trait Checking {
34
45
/** Check that type `tp` is stable.
35
46
* @return The type itself
36
47
*/
37
- def checkStable (tp : Type , pos : Position )(implicit ctx : Context ): Unit =
48
+ override def checkStable (tp : Type , pos : Position )(implicit ctx : Context ): Unit =
38
49
if (! tp.isStable) ctx.error(i " Prefix of type ${tp.widenIfUnstable} is not stable " , pos)
39
50
40
51
/** Check that `tp` is a class type with a stable prefix. Also, if `isFirst` is
41
52
* false check that `tp` is a trait.
42
53
* @return `tp` itself if it is a class or trait ref, ObjectClass.typeRef if not.
43
54
*/
44
- def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean )(implicit ctx : Context ): Type =
55
+ override def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean )(implicit ctx : Context ): Type =
45
56
tp.underlyingClassRef match {
46
57
case tref : TypeRef =>
47
58
checkStable(tref.prefix, pos)
@@ -53,7 +64,7 @@ trait Checking {
53
64
}
54
65
55
66
/** Check that (return) type of implicit definition is not empty */
56
- def checkImplicitTptNonEmpty (defTree : untpd.ValOrDefDef )(implicit ctx : Context ): Unit = defTree.tpt match {
67
+ override def checkImplicitTptNonEmpty (defTree : untpd.ValOrDefDef )(implicit ctx : Context ): Unit = defTree.tpt match {
57
68
case TypeTree (original) if original.isEmpty =>
58
69
val resStr = if (defTree.isInstanceOf [untpd.DefDef ]) " result " else " "
59
70
ctx.error(i " ${resStr}type of implicit definition needs to be given explicitly " , defTree.pos)
@@ -63,7 +74,7 @@ trait Checking {
63
74
/** Check that a non-implicit parameter making up the first parameter section of an
64
75
* implicit conversion is not a singleton type.
65
76
*/
66
- def checkImplicitParamsNotSingletons (vparamss : List [List [ValDef ]])(implicit ctx : Context ): Unit = vparamss match {
77
+ override def checkImplicitParamsNotSingletons (vparamss : List [List [ValDef ]])(implicit ctx : Context ): Unit = vparamss match {
67
78
case (vparam :: Nil ) :: _ if ! (vparam.symbol is Implicit ) =>
68
79
if (vparam.tpt.tpe.isInstanceOf [SingletonType ])
69
80
ctx.error(s " implicit conversion may not have a parameter of singleton type " , vparam.tpt.pos)
@@ -74,7 +85,7 @@ trait Checking {
74
85
* their lower bound conforms to their upper cound. If a type argument is
75
86
* infeasible, issue and error and continue with upper bound.
76
87
*/
77
- def checkFeasible (tp : Type , pos : Position , where : => String = " " )(implicit ctx : Context ): Type = tp match {
88
+ override def checkFeasible (tp : Type , pos : Position , where : => String = " " )(implicit ctx : Context ): Type = tp match {
78
89
case tp : RefinedType =>
79
90
tp.derivedRefinedType(tp.parent, tp.refinedName, checkFeasible(tp.refinedInfo, pos, where))
80
91
case tp @ TypeBounds (lo, hi) if ! (lo <:< hi) =>
@@ -85,7 +96,7 @@ trait Checking {
85
96
}
86
97
87
98
/** Check that class does not define */
88
- def checkNoDoubleDefs (cls : Symbol )(implicit ctx : Context ): Unit = {
99
+ override def checkNoDoubleDefs (cls : Symbol )(implicit ctx : Context ): Unit = {
89
100
val seen = new mutable.HashMap [Name , List [Symbol ]] {
90
101
override def default (key : Name ) = Nil
91
102
}
0 commit comments