@@ -56,10 +56,19 @@ class Definitions {
56
56
private def newSyntheticTypeParam (cls : ClassSymbol , scope : MutableScope , paramFlags : FlagSet , suffix : String = " T0" ) =
57
57
newTypeParam(cls, suffix.toTypeName.expandedName(cls), ExpandedName | paramFlags, scope)
58
58
59
- // NOTE: Ideally we would write `parentConstrs: => Type*` but SIP-24 is only
60
- // implemented in Dotty and not in Scala 2.
61
- // See <http://docs.scala-lang.org/sips/pending/repeated-byname.html>.
62
- private def specialPolyClass (name : TypeName , paramFlags : FlagSet , parentConstrs : => Seq [Type ]): ClassSymbol = {
59
+ /** A class following the template
60
+ *
61
+ * package scala
62
+ * class <name>[<paramFlags> $T0] extends <parents>
63
+ *
64
+ * where <parents> = [constr' | constr <- parentConstrs]
65
+ * <constr'> = constr[$T0] of <constr> has a type parameter
66
+ * = constr otherwise
67
+ */
68
+ private def specialPolyClass (name : TypeName , classFlags : FlagSet , paramFlags : FlagSet , parentConstrs : => Seq [Type ]): ClassSymbol = {
69
+ // NOTE: Ideally we would write `parentConstrs: => Type*` but SIP-24 is only
70
+ // implemented in Dotty and not in Scala 2.
71
+ // See <http://docs.scala-lang.org/sips/pending/repeated-byname.html>.
63
72
val completer = new LazyType {
64
73
def complete (denot : SymDenotation )(implicit ctx : Context ): Unit = {
65
74
val cls = denot.asClass.classSymbol
@@ -73,7 +82,7 @@ class Definitions {
73
82
denot.info = ClassInfo (ScalaPackageClass .thisType, cls, parentRefs, paramDecls)
74
83
}
75
84
}
76
- newClassSymbol(ScalaPackageClass , name, EmptyFlags , completer)
85
+ newClassSymbol(ScalaPackageClass , name, classFlags , completer)
77
86
}
78
87
79
88
private def newMethod (cls : ClassSymbol , name : TermName , info : Type , flags : FlagSet = EmptyFlags ): TermSymbol =
@@ -204,8 +213,8 @@ class Definitions {
204
213
*
205
214
* trait EqClass {
206
215
* /* * Comparison operations between values in the same equality class */
207
- * final def == [T >: this.type <: EqClass](other: T)(implicit ce: Eq[T]): Boolean = this.equals(other)
208
- * final def != [T >: this.type <: EqClass](other: T)(implicit ce: Eq[T]): Boolean = this.equals(other)
216
+ * final def == [T >: this.type <: EqClass[_ ](other: T)(implicit ce: Eq[T]): Boolean = this.equals(other)
217
+ * final def != [T >: this.type <: EqClass[_ ](other: T)(implicit ce: Eq[T]): Boolean = this.equals(other)
209
218
* }
210
219
*
211
220
* The reason we define this here rather than as a source file is that these definitions
@@ -215,13 +224,12 @@ class Definitions {
215
224
* Exception in thread "main" scala.reflect.internal.Types$NoCommonType: lub/glb of incompatible types: => core.this.Names.TypeName and scala.this.Nothing
216
225
*/
217
226
lazy val EqClassClass : ClassSymbol = {
218
- val ecc = newCompleteClassSymbol(
219
- ScalaPackageClass , tpnme.EqClass , PureInterfaceCreationFlags , List (AnyClass .typeRef))
227
+ val ecc = specialPolyClass(tpnme.EqClass , PureInterfaceCreationFlags , Contravariant , List (AnyClass .typeRef))
220
228
val completer = new LazyType {
221
229
override def complete (denot : SymDenotation )(implicit ctx : Context ): Unit = {
222
230
denot.info =
223
231
PolyType (tpnme.syntheticTypeParamNames(1 ))(
224
- pt => List (TypeBounds (ecc.thisType, ecc.typeRef)),
232
+ pt => List (TypeBounds (ecc.thisType, ecc.typeRef.appliedTo( TypeBounds .empty) )),
225
233
pt => MethodType (List (PolyParam (pt, 0 )),
226
234
ImplicitMethodType (List (EqType .appliedTo(PolyParam (pt, 0 ))),
227
235
BooleanType )))
@@ -393,10 +401,10 @@ class Definitions {
393
401
lazy val BoxedDoubleModule = ctx.requiredModule(" java.lang.Double" )
394
402
lazy val BoxedUnitModule = ctx.requiredModule(" java.lang.Void" )
395
403
396
- lazy val ByNameParamClass2x = specialPolyClass(tpnme.BYNAME_PARAM_CLASS , Covariant , Seq (AnyType ))
397
- lazy val EqualsPatternClass = specialPolyClass(tpnme.EQUALS_PATTERN , EmptyFlags , Seq (AnyType ))
404
+ lazy val ByNameParamClass2x = specialPolyClass(tpnme.BYNAME_PARAM_CLASS , EmptyFlags , Covariant , Seq (AnyType ))
405
+ lazy val EqualsPatternClass = specialPolyClass(tpnme.EQUALS_PATTERN , EmptyFlags , EmptyFlags , Seq (AnyType ))
398
406
399
- lazy val RepeatedParamClass = specialPolyClass(tpnme.REPEATED_PARAM_CLASS , Covariant , Seq (ObjectType , SeqType ))
407
+ lazy val RepeatedParamClass = specialPolyClass(tpnme.REPEATED_PARAM_CLASS , EmptyFlags , Covariant , Seq (ObjectType , SeqType ))
400
408
401
409
// fundamental classes
402
410
lazy val StringClass = ctx.requiredClass(" java.lang.String" )
0 commit comments