@@ -45,32 +45,29 @@ class Definitions {
45
45
ctx.newSymbol(owner, name, flags | Permanent , info)
46
46
47
47
private def newClassSymbol (owner : Symbol , name : TypeName , flags : FlagSet , infoFn : ClassSymbol => Type ) =
48
- ctx.newClassSymbol(owner, name, flags | Permanent , infoFn).entered
48
+ ctx.newClassSymbol(owner, name, flags | Permanent , infoFn)
49
49
50
- private def newCompleteClassSymbol (owner : Symbol , name : TypeName , flags : FlagSet , parents : List [TypeRef ], decls : Scope = newScope) =
50
+ private def enterCompleteClassSymbol (owner : Symbol , name : TypeName , flags : FlagSet , parents : List [TypeRef ], decls : Scope = newScope) =
51
51
ctx.newCompleteClassSymbol(owner, name, flags | Permanent , parents, decls).entered
52
52
53
- private def newTopClassSymbol (name : TypeName , flags : FlagSet , parents : List [TypeRef ]) =
54
- completeClass(newCompleteClassSymbol(ScalaPackageClass , name, flags, parents))
55
-
56
- private def newTypeField (cls : ClassSymbol , name : TypeName , flags : FlagSet , scope : MutableScope ) =
53
+ private def enterTypeField (cls : ClassSymbol , name : TypeName , flags : FlagSet , scope : MutableScope ) =
57
54
scope.enter(newSymbol(cls, name, flags, TypeBounds .empty))
58
55
59
- private def newTypeParam (cls : ClassSymbol , name : TypeName , flags : FlagSet , scope : MutableScope ) =
60
- newTypeField (cls, name, flags | ClassTypeParamCreationFlags , scope)
56
+ private def enterTypeParam (cls : ClassSymbol , name : TypeName , flags : FlagSet , scope : MutableScope ) =
57
+ enterTypeField (cls, name, flags | ClassTypeParamCreationFlags , scope)
61
58
62
- private def newSyntheticTypeParam (cls : ClassSymbol , scope : MutableScope , paramFlags : FlagSet , suffix : String = " T0" ) =
63
- newTypeParam (cls, suffix.toTypeName.expandedName(cls), ExpandedName | paramFlags, scope)
59
+ private def enterSyntheticTypeParam (cls : ClassSymbol , paramFlags : FlagSet , scope : MutableScope , suffix : String = " T0" ) =
60
+ enterTypeParam (cls, suffix.toTypeName.expandedName(cls), ExpandedName | paramFlags, scope)
64
61
65
62
// NOTE: Ideally we would write `parentConstrs: => Type*` but SIP-24 is only
66
63
// implemented in Dotty and not in Scala 2.
67
64
// See <http://docs.scala-lang.org/sips/pending/repeated-byname.html>.
68
- private def specialPolyClass (name : TypeName , paramFlags : FlagSet , parentConstrs : => Seq [Type ]): ClassSymbol = {
65
+ private def enterSpecialPolyClass (name : TypeName , paramFlags : FlagSet , parentConstrs : => Seq [Type ]): ClassSymbol = {
69
66
val completer = new LazyType {
70
67
def complete (denot : SymDenotation )(implicit ctx : Context ): Unit = {
71
68
val cls = denot.asClass.classSymbol
72
69
val paramDecls = newScope
73
- val typeParam = newSyntheticTypeParam (cls, paramDecls, paramFlags )
70
+ val typeParam = enterSyntheticTypeParam (cls, paramFlags, paramDecls )
74
71
def instantiate (tpe : Type ) =
75
72
if (tpe.typeParams.nonEmpty) tpe.appliedTo(typeParam.typeRef)
76
73
else tpe
@@ -83,27 +80,30 @@ class Definitions {
83
80
}
84
81
85
82
private def newMethod (cls : ClassSymbol , name : TermName , info : Type , flags : FlagSet = EmptyFlags ): TermSymbol =
86
- newSymbol(cls, name.encode, flags | Method , info).entered.asTerm
83
+ newSymbol(cls, name.encode, flags | Method , info).asTerm
84
+
85
+ private def enterMethod (cls : ClassSymbol , name : TermName , info : Type , flags : FlagSet = EmptyFlags ): TermSymbol =
86
+ newMethod(cls, name, info, flags).entered
87
87
88
- private def newAliasType (name : TypeName , tpe : Type , flags : FlagSet = EmptyFlags ): TypeSymbol = {
88
+ private def enterAliasType (name : TypeName , tpe : Type , flags : FlagSet = EmptyFlags ): TypeSymbol = {
89
89
val sym = newSymbol(ScalaPackageClass , name, flags, TypeAlias (tpe))
90
90
ScalaPackageClass .currentPackageDecls.enter(sym)
91
91
sym
92
92
}
93
93
94
- private def newPolyMethod (cls : ClassSymbol , name : TermName , typeParamCount : Int ,
94
+ private def enterPolyMethod (cls : ClassSymbol , name : TermName , typeParamCount : Int ,
95
95
resultTypeFn : PolyType => Type , flags : FlagSet = EmptyFlags ) = {
96
96
val tparamNames = tpnme.syntheticTypeParamNames(typeParamCount)
97
97
val tparamBounds = tparamNames map (_ => TypeBounds .empty)
98
98
val ptype = PolyType (tparamNames)(_ => tparamBounds, resultTypeFn)
99
- newMethod (cls, name, ptype, flags)
99
+ enterMethod (cls, name, ptype, flags)
100
100
}
101
101
102
- private def newT1ParameterlessMethod (cls : ClassSymbol , name : TermName , resultTypeFn : PolyType => Type , flags : FlagSet ) =
103
- newPolyMethod (cls, name, 1 , resultTypeFn, flags)
102
+ private def enterT1ParameterlessMethod (cls : ClassSymbol , name : TermName , resultTypeFn : PolyType => Type , flags : FlagSet ) =
103
+ enterPolyMethod (cls, name, 1 , resultTypeFn, flags)
104
104
105
- private def newT1EmptyParamsMethod (cls : ClassSymbol , name : TermName , resultTypeFn : PolyType => Type , flags : FlagSet ) =
106
- newPolyMethod (cls, name, 1 , pt => MethodType (Nil , resultTypeFn(pt)), flags)
105
+ private def enterT1EmptyParamsMethod (cls : ClassSymbol , name : TermName , resultTypeFn : PolyType => Type , flags : FlagSet ) =
106
+ enterPolyMethod (cls, name, 1 , pt => MethodType (Nil , resultTypeFn(pt)), flags)
107
107
108
108
private def mkArityArray (name : String , arity : Int , countFrom : Int ): Array [TypeRef ] = {
109
109
val arr = new Array [TypeRef ](arity + 1 )
@@ -172,20 +172,20 @@ class Definitions {
172
172
* def getClass: java.lang.Class[T] = ???
173
173
* }
174
174
*/
175
- lazy val AnyClass : ClassSymbol = completeClass(newCompleteClassSymbol (ScalaPackageClass , tpnme.Any , Abstract , Nil ))
175
+ lazy val AnyClass : ClassSymbol = completeClass(enterCompleteClassSymbol (ScalaPackageClass , tpnme.Any , Abstract , Nil ))
176
176
def AnyType = AnyClass .typeRef
177
- lazy val AnyValClass : ClassSymbol = completeClass(newCompleteClassSymbol (ScalaPackageClass , tpnme.AnyVal , Abstract , List (AnyClass .typeRef)))
177
+ lazy val AnyValClass : ClassSymbol = completeClass(enterCompleteClassSymbol (ScalaPackageClass , tpnme.AnyVal , Abstract , List (AnyClass .typeRef)))
178
178
def AnyValType = AnyValClass .typeRef
179
179
180
- lazy val Any_== = newMethod (AnyClass , nme.EQ , methOfAny(BooleanType ), Final )
181
- lazy val Any_!= = newMethod (AnyClass , nme.NE , methOfAny(BooleanType ), Final )
182
- lazy val Any_equals = newMethod (AnyClass , nme.equals_, methOfAny(BooleanType ))
183
- lazy val Any_hashCode = newMethod (AnyClass , nme.hashCode_, MethodType (Nil , IntType ))
184
- lazy val Any_toString = newMethod (AnyClass , nme.toString_, MethodType (Nil , StringType ))
185
- lazy val Any_## = newMethod (AnyClass , nme.HASHHASH , ExprType (IntType ), Final )
186
- lazy val Any_getClass = newMethod (AnyClass , nme.getClass_, MethodType (Nil , ClassClass .typeRef.appliedTo(TypeBounds .empty)), Final )
187
- lazy val Any_isInstanceOf = newT1ParameterlessMethod (AnyClass , nme.isInstanceOf_, _ => BooleanType , Final )
188
- lazy val Any_asInstanceOf = newT1ParameterlessMethod (AnyClass , nme.asInstanceOf_, PolyParam (_, 0 ), Final )
180
+ lazy val Any_== = enterMethod (AnyClass , nme.EQ , methOfAny(BooleanType ), Final )
181
+ lazy val Any_!= = enterMethod (AnyClass , nme.NE , methOfAny(BooleanType ), Final )
182
+ lazy val Any_equals = enterMethod (AnyClass , nme.equals_, methOfAny(BooleanType ))
183
+ lazy val Any_hashCode = enterMethod (AnyClass , nme.hashCode_, MethodType (Nil , IntType ))
184
+ lazy val Any_toString = enterMethod (AnyClass , nme.toString_, MethodType (Nil , StringType ))
185
+ lazy val Any_## = enterMethod (AnyClass , nme.HASHHASH , ExprType (IntType ), Final )
186
+ lazy val Any_getClass = enterMethod (AnyClass , nme.getClass_, MethodType (Nil , ClassClass .typeRef.appliedTo(TypeBounds .empty)), Final )
187
+ lazy val Any_isInstanceOf = enterT1ParameterlessMethod (AnyClass , nme.isInstanceOf_, _ => BooleanType , Final )
188
+ lazy val Any_asInstanceOf = enterT1ParameterlessMethod (AnyClass , nme.asInstanceOf_, PolyParam (_, 0 ), Final )
189
189
190
190
def AnyMethods = List (Any_== , Any_!= , Any_equals , Any_hashCode ,
191
191
Any_toString , Any_## , Any_getClass , Any_isInstanceOf , Any_asInstanceOf )
@@ -205,37 +205,37 @@ class Definitions {
205
205
}
206
206
def ObjectType = ObjectClass .typeRef
207
207
208
- lazy val AnyRefAlias : TypeSymbol = newAliasType (tpnme.AnyRef , ObjectType )
208
+ lazy val AnyRefAlias : TypeSymbol = enterAliasType (tpnme.AnyRef , ObjectType )
209
209
def AnyRefType = AnyRefAlias .typeRef
210
210
211
- lazy val Object_eq = newMethod (ObjectClass , nme.eq, methOfAnyRef(BooleanType ), Final )
212
- lazy val Object_ne = newMethod (ObjectClass , nme.ne, methOfAnyRef(BooleanType ), Final )
213
- lazy val Object_synchronized = newPolyMethod (ObjectClass , nme.synchronized_, 1 ,
211
+ lazy val Object_eq = enterMethod (ObjectClass , nme.eq, methOfAnyRef(BooleanType ), Final )
212
+ lazy val Object_ne = enterMethod (ObjectClass , nme.ne, methOfAnyRef(BooleanType ), Final )
213
+ lazy val Object_synchronized = enterPolyMethod (ObjectClass , nme.synchronized_, 1 ,
214
214
pt => MethodType (List (PolyParam (pt, 0 )), PolyParam (pt, 0 )), Final )
215
- lazy val Object_clone = newMethod (ObjectClass , nme.clone_, MethodType (Nil , ObjectType ), Protected )
216
- lazy val Object_finalize = newMethod (ObjectClass , nme.finalize_, MethodType (Nil , UnitType ), Protected )
217
- lazy val Object_notify = newMethod (ObjectClass , nme.notify_, MethodType (Nil , UnitType ))
218
- lazy val Object_notifyAll = newMethod (ObjectClass , nme.notifyAll_, MethodType (Nil , UnitType ))
219
- lazy val Object_wait = newMethod (ObjectClass , nme.wait_, MethodType (Nil , UnitType ))
220
- lazy val Object_waitL = newMethod (ObjectClass , nme.wait_, MethodType (LongType :: Nil , UnitType ))
221
- lazy val Object_waitLI = newMethod (ObjectClass , nme.wait_, MethodType (LongType :: IntType :: Nil , UnitType ))
215
+ lazy val Object_clone = enterMethod (ObjectClass , nme.clone_, MethodType (Nil , ObjectType ), Protected )
216
+ lazy val Object_finalize = enterMethod (ObjectClass , nme.finalize_, MethodType (Nil , UnitType ), Protected )
217
+ lazy val Object_notify = enterMethod (ObjectClass , nme.notify_, MethodType (Nil , UnitType ))
218
+ lazy val Object_notifyAll = enterMethod (ObjectClass , nme.notifyAll_, MethodType (Nil , UnitType ))
219
+ lazy val Object_wait = enterMethod (ObjectClass , nme.wait_, MethodType (Nil , UnitType ))
220
+ lazy val Object_waitL = enterMethod (ObjectClass , nme.wait_, MethodType (LongType :: Nil , UnitType ))
221
+ lazy val Object_waitLI = enterMethod (ObjectClass , nme.wait_, MethodType (LongType :: IntType :: Nil , UnitType ))
222
222
223
223
def ObjectMethods = List (Object_eq , Object_ne , Object_synchronized , Object_clone ,
224
224
Object_finalize , Object_notify , Object_notifyAll , Object_wait , Object_waitL , Object_waitLI )
225
225
226
226
/** Dummy method needed by elimByName */
227
- lazy val dummyApply = newPolyMethod (
227
+ lazy val dummyApply = enterPolyMethod (
228
228
OpsPackageClass , nme.dummyApply, 1 ,
229
229
pt => MethodType (List (FunctionOf (Nil , PolyParam (pt, 0 ))), PolyParam (pt, 0 )))
230
230
231
231
/** Method representing a throw */
232
- lazy val throwMethod = newMethod (OpsPackageClass , nme.THROWkw ,
232
+ lazy val throwMethod = enterMethod (OpsPackageClass , nme.THROWkw ,
233
233
MethodType (List (ThrowableType ), NothingType ))
234
234
235
- lazy val NothingClass : ClassSymbol = newCompleteClassSymbol (
235
+ lazy val NothingClass : ClassSymbol = enterCompleteClassSymbol (
236
236
ScalaPackageClass , tpnme.Nothing , AbstractFinal , List (AnyClass .typeRef))
237
237
def NothingType = NothingClass .typeRef
238
- lazy val NullClass : ClassSymbol = newCompleteClassSymbol (
238
+ lazy val NullClass : ClassSymbol = enterCompleteClassSymbol (
239
239
ScalaPackageClass , tpnme.Null , AbstractFinal , List (ObjectClass .typeRef))
240
240
def NullType = NullClass .typeRef
241
241
@@ -281,7 +281,7 @@ class Definitions {
281
281
lazy val SingletonClass : ClassSymbol =
282
282
// needed as a synthetic class because Scala 2.x refers to it in classfiles
283
283
// but does not define it as an explicit class.
284
- newCompleteClassSymbol (
284
+ enterCompleteClassSymbol (
285
285
ScalaPackageClass , tpnme.Singleton , PureInterfaceCreationFlags | Final ,
286
286
List (AnyClass .typeRef), EmptyScope )
287
287
@@ -387,17 +387,17 @@ class Definitions {
387
387
lazy val BoxedDoubleModule = ctx.requiredModule(" java.lang.Double" )
388
388
lazy val BoxedUnitModule = ctx.requiredModule(" java.lang.Void" )
389
389
390
- lazy val ByNameParamClass2x = specialPolyClass (tpnme.BYNAME_PARAM_CLASS , Covariant , Seq (AnyType ))
391
- lazy val EqualsPatternClass = specialPolyClass (tpnme.EQUALS_PATTERN , EmptyFlags , Seq (AnyType ))
390
+ lazy val ByNameParamClass2x = enterSpecialPolyClass (tpnme.BYNAME_PARAM_CLASS , Covariant , Seq (AnyType ))
391
+ lazy val EqualsPatternClass = enterSpecialPolyClass (tpnme.EQUALS_PATTERN , EmptyFlags , Seq (AnyType ))
392
392
393
- lazy val RepeatedParamClass = specialPolyClass (tpnme.REPEATED_PARAM_CLASS , Covariant , Seq (ObjectType , SeqType ))
393
+ lazy val RepeatedParamClass = enterSpecialPolyClass (tpnme.REPEATED_PARAM_CLASS , Covariant , Seq (ObjectType , SeqType ))
394
394
395
395
// fundamental classes
396
396
lazy val StringClass = ctx.requiredClass(" java.lang.String" )
397
397
def StringType : Type = StringClass .typeRef
398
398
lazy val StringModule = StringClass .linkedClass
399
399
400
- lazy val String_+ = newMethod (StringClass , nme.raw.PLUS , methOfAny(StringType ), Final )
400
+ lazy val String_+ = enterMethod (StringClass , nme.raw.PLUS , methOfAny(StringType ), Final )
401
401
lazy val String_valueOf_Object = StringModule .info.member(nme.valueOf).suchThat(_.info.firstParamTypes match {
402
402
case List (pt) => (pt isRef AnyClass ) || (pt isRef ObjectClass )
403
403
case _ => false
0 commit comments