Skip to content

Commit be7f82f

Browse files
OlivierBlanvillainodersky
authored andcommitted
Fix spacing and add return types
1 parent 45c25ea commit be7f82f

File tree

7 files changed

+41
-39
lines changed

7 files changed

+41
-39
lines changed

compiler/src/dotty/tools/dotc/typer/Deriving.scala

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ trait Deriving { this: Typer =>
3232
private var synthetics = new mutable.ListBuffer[Symbol]
3333

3434
/** the children of `cls` ordered by textual occurrence */
35-
lazy val children = cls.children
35+
lazy val children: List[Symbol] = cls.children
3636

3737
private def shapeError(explanation: => String): Unit =
3838
ctx.error(i"cannot take shape of $cls\n$explanation", codePos)
@@ -115,7 +115,7 @@ trait Deriving { this: Typer =>
115115
/** Create a synthetic symbol owned by current owner */
116116
private def newSymbol(name: Name, info: Type,
117117
pos: Position = ctx.owner.pos,
118-
flags: FlagSet = EmptyFlags)(implicit ctx: Context) =
118+
flags: FlagSet = EmptyFlags)(implicit ctx: Context): Symbol =
119119
ctx.newSymbol(ctx.owner, name, flags | Synthetic, info, coord = pos)
120120

121121
/** Create a synthetic method owned by current owner */
@@ -145,24 +145,24 @@ trait Deriving { this: Typer =>
145145
else add(newMethod(instanceName, info, pos, Implicit))
146146
}
147147

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+
*/
166166
private def processDerivedInstance(derived: untpd.Tree): Unit = {
167167
val originalType = typedAheadType(derived, AnyTypeConstructorProto).tpe
168168
val underlyingType = underlyingClassRef(originalType)
@@ -237,7 +237,7 @@ trait Deriving { this: Typer =>
237237
}
238238

239239
/** Extractor for the `pattern` and `elements` in a `Shaped.Case(pattern, elements)` shape */
240-
private object ShapeCase {
240+
private object ShapeCase {
241241
def unapply(shape: Type): Option[(Type, List[Type])] = shape match {
242242
case AppliedType(fn, pat :: elems :: Nil) if fn.classSymbol == defn.ShapeCaseClass =>
243243
Some((pat, tupleElems(elems)))
@@ -383,7 +383,7 @@ trait Deriving { this: Typer =>
383383
}
384384

385385
/** 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) =
387387
(tparamRefs: List[Type]) => (paramRefss: List[List[tpd.Tree]]) => {
388388
val tparams = tparamRefs.map(_.typeSymbol.asType)
389389
val params = if (paramRefss.isEmpty) Nil else paramRefss.head.map(_.symbol.asTerm)

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ object Implicits {
155155

156156
def valueTypeCandidateKind(tpw: Type): Candidate.Kind = tpw.stripPoly match {
157157
case tpw: MethodType =>
158-
if (tpw.isImplicitMethod) Candidate.Value else Candidate.None
158+
if (tpw.isImplicitMethod) Candidate.Value else Candidate.None
159159
case _ =>
160160
Candidate.Value
161161
}
@@ -195,7 +195,7 @@ object Implicits {
195195
else ref
196196
val refNorm = normalize(refAdjusted, pt)
197197
if (!NoViewsAllowed.isCompatible(refNorm, ptNorm))
198-
ckind = Candidate.None
198+
ckind = Candidate.None
199199
}
200200
ckind
201201
}
@@ -384,10 +384,10 @@ object Implicits {
384384

385385
class NoMatchingImplicits(val expectedType: Type, val argument: Tree, constraint: Constraint = OrderingConstraint.empty) extends SearchFailureType {
386386

387-
/** Replace all type parameters in constraint by their bounds, to make it clearer
388-
* what was expected
389-
*/
390-
override def clarify(tp: Type)(implicit ctx: Context) = {
387+
/** Replace all type parameters in constraint by their bounds, to make it clearer
388+
* what was expected
389+
*/
390+
override def clarify(tp: Type)(implicit ctx: Context): Type = {
391391
val map = new TypeMap {
392392
def apply(t: Type): Type = t match {
393393
case t: TypeParamRef =>

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ class Namer { typer: Typer =>
841841
else if (!cls.is(ChildrenQueried))
842842
addChild(cls, child)
843843
else
844-
ctx.error(em"""children of ${cls} were already queried before $sym was discovered.
844+
ctx.error(em"""children of $cls were already queried before $sym was discovered.
845845
|As a remedy, you could move $sym on the same nesting level as $cls.""",
846846
child.pos)
847847
}
@@ -947,11 +947,11 @@ class Namer { typer: Typer =>
947947
}
948948
}
949949

950-
/* Check parent type tree `parent` for the following well-formedness conditions:
951-
* (1) It must be a class type with a stable prefix (@see checkClassTypeWithStablePrefix)
952-
* (2) If may not derive from itself
953-
* (3) The class is not final
954-
* (4) If the class is sealed, it is defined in the same compilation unit as the current class
950+
/** Check parent type tree `parent` for the following well-formedness conditions:
951+
* (1) It must be a class type with a stable prefix (@see checkClassTypeWithStablePrefix)
952+
* (2) If may not derive from itself
953+
* (3) The class is not final
954+
* (4) If the class is sealed, it is defined in the same compilation unit as the current class
955955
*/
956956
def checkedParentType(parent: untpd.Tree): Type = {
957957
val ptype = parentType(parent)(ctx.superCallContext).dealiasKeepAnnots

docs/docs/internals/syntax.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ true try type val var while with yield
101101

102102
### Soft keywords
103103

104+
```
104105
derives inline opaque
105106
~ * | & + -
107+
```
106108

107109
## Context-free Syntax
108110

library/src-bootstrapped/scala/Tuple.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ object NonEmptyTuple {
473473
}
474474

475475
@showAsInfix
476-
sealed class *:[+H, +T <: Tuple] extends Object with NonEmptyTuple
476+
sealed class *:[+H, +T <: Tuple] extends Object with NonEmptyTuple
477477

478478
object *: {
479479
inline def unapply[H, T <: Tuple](x: H *: T) = (x.head, x.tail)

library/src-bootstrapped/scala/reflect/Generic.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package scala.reflect
22

33
/** A class for mapping between an ADT value and
4-
* the case mirror that represents the value.
5-
*/
4+
* the case mirror that represents the value.
5+
*/
66
abstract class Generic[T] {
77

88
type Shape <: scala.compiletime.Shape

library/src-bootstrapped/scala/reflect/Mirror.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package scala.reflect
22

33
/** A generic representation of a case in an ADT
4-
* @param reflected The common class-speficic part of this mirror
4+
* @param reflected The common class-specific part of this mirror
55
* @param ordinal The ordinal value of the case in the list of the ADT's cases
66
* @param elems The elements of the case
77
*/
@@ -14,5 +14,5 @@ class Mirror(val adtClass: GenericClass, val ordinal: Int, val elems: Product) {
1414
def caseLabel: String = adtClass.label(ordinal)(0)
1515

1616
/** The label of the `n`'th element of the case reflected by this mirror */
17-
def elementLabel(n: Int) = adtClass.label(ordinal)(n + 1)
17+
def elementLabel(n: Int): String = adtClass.label(ordinal)(n + 1)
1818
}

0 commit comments

Comments
 (0)