@@ -32,7 +32,7 @@ trait Deriving { this: Typer =>
32
32
private var synthetics = new mutable.ListBuffer [Symbol ]
33
33
34
34
/** the children of `cls` ordered by textual occurrence */
35
- lazy val children = cls.children
35
+ lazy val children : List [ Symbol ] = cls.children
36
36
37
37
private def shapeError (explanation : => String ): Unit =
38
38
ctx.error(i " cannot take shape of $cls\n $explanation" , codePos)
@@ -115,7 +115,7 @@ trait Deriving { this: Typer =>
115
115
/** Create a synthetic symbol owned by current owner */
116
116
private def newSymbol (name : Name , info : Type ,
117
117
pos : Position = ctx.owner.pos,
118
- flags : FlagSet = EmptyFlags )(implicit ctx : Context ) =
118
+ flags : FlagSet = EmptyFlags )(implicit ctx : Context ): Symbol =
119
119
ctx.newSymbol(ctx.owner, name, flags | Synthetic , info, coord = pos)
120
120
121
121
/** Create a synthetic method owned by current owner */
@@ -145,24 +145,24 @@ trait Deriving { this: Typer =>
145
145
else add(newMethod(instanceName, info, pos, Implicit ))
146
146
}
147
147
148
- /* Check derived type tree `derived` for the following well-formedness conditions:
149
- * (1) It must be a class type with a stable prefix (@see checkClassTypeWithStablePrefix)
150
- * (2) It must have exactly one type parameter
151
- * If it passes the checks, enter a typeclass instance for it in the current scope.
152
- * Given
153
- *
154
- * class C[Ts] .... derives ... D ...
155
- *
156
- * where `T_1, ..., T_n` are the first-kinded type parameters in `Ts`,
157
- * the typeclass instance has the form
158
- *
159
- * implicit def derived$D(implicit ev_1: D[T1 ], ..., ev_n: D[T_n]): D[C[Ts]] = D.derived
160
- *
161
- * See test run/typeclass-derivation2 for examples that spell out what would be generated.
162
- * Note that the name of the derived method containd the name in the derives clause, not
163
- * the underlying class name. This allows one to disambiguate derivations of type classes
164
- * that have the same name but different prefixes through selective aliasing.
165
- */
148
+ /** Check derived type tree `derived` for the following well-formedness conditions:
149
+ * (1) It must be a class type with a stable prefix (@see checkClassTypeWithStablePrefix)
150
+ * (2) It must have exactly one type parameter
151
+ * If it passes the checks, enter a typeclass instance for it in the current scope.
152
+ * Given
153
+ *
154
+ * class C[Ts] .... derives ... D ...
155
+ *
156
+ * where `T_1, ..., T_n` are the first-kinded type parameters in `Ts`,
157
+ * the typeclass instance has the form
158
+ *
159
+ * implicit def derived$D(implicit ev_1: D[T_1 ], ..., ev_n: D[T_n]): D[C[Ts]] = D.derived
160
+ *
161
+ * See test run/typeclass-derivation2 for examples that spell out what would be generated.
162
+ * Note that the name of the derived method containd the name in the derives clause, not
163
+ * the underlying class name. This allows one to disambiguate derivations of type classes
164
+ * that have the same name but different prefixes through selective aliasing.
165
+ */
166
166
private def processDerivedInstance (derived : untpd.Tree ): Unit = {
167
167
val originalType = typedAheadType(derived, AnyTypeConstructorProto ).tpe
168
168
val underlyingType = underlyingClassRef(originalType)
@@ -237,7 +237,7 @@ trait Deriving { this: Typer =>
237
237
}
238
238
239
239
/** Extractor for the `pattern` and `elements` in a `Shaped.Case(pattern, elements)` shape */
240
- private object ShapeCase {
240
+ private object ShapeCase {
241
241
def unapply (shape : Type ): Option [(Type , List [Type ])] = shape match {
242
242
case AppliedType (fn, pat :: elems :: Nil ) if fn.classSymbol == defn.ShapeCaseClass =>
243
243
Some ((pat, tupleElems(elems)))
@@ -383,7 +383,7 @@ trait Deriving { this: Typer =>
383
383
}
384
384
385
385
/** The type class instance definition with symbol `sym` */
386
- private def typeclassInstance (sym : Symbol )(implicit ctx : Context ) =
386
+ private def typeclassInstance (sym : Symbol )(implicit ctx : Context ): List [ Type ] => ( List [ List [tpd. Tree ]] => tpd. Tree ) =
387
387
(tparamRefs : List [Type ]) => (paramRefss : List [List [tpd.Tree ]]) => {
388
388
val tparams = tparamRefs.map(_.typeSymbol.asType)
389
389
val params = if (paramRefss.isEmpty) Nil else paramRefss.head.map(_.symbol.asTerm)
0 commit comments