Skip to content

Commit d969cd2

Browse files
joroKr21xuwei-kliorregevDmytroMitin
authored
Backport recently merged PRs (#1353)
* add explicit type for implicit def (#1330) * Concrete return type for `MkFieldLens.mkFieldLens` (#1324) Co-authored-by: Lior Regev <[email protected]> Co-authored-by: Georgi Krastev <[email protected]> * Add support for `Generic` materialized in companion object of nested case class (#1286) Co-authored-by: Georgi Krastev <[email protected]> --------- Co-authored-by: kenji yoshida <[email protected]> Co-authored-by: Lior Regev <[email protected]> Co-authored-by: Lior Regev <[email protected]> Co-authored-by: Dmytro Mitin <[email protected]>
1 parent ac027ca commit d969cd2

File tree

17 files changed

+117
-46
lines changed

17 files changed

+117
-46
lines changed

build.sbt

+26
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,30 @@ val boilerplate = Def.taskDyn {
111111
(Compile / sourceManaged).map(Boilerplate.gen(scalaBinaryVersion.value))
112112
}
113113

114+
lazy val macroAnnotationSettings = Seq(
115+
scalacOptions ++= {
116+
CrossVersion.partialVersion(scalaVersion.value) match {
117+
case Some((2, v)) if v >= 13 => Seq("-Ymacro-annotations")
118+
case _ => Nil
119+
}
120+
},
121+
libraryDependencies ++= {
122+
CrossVersion.partialVersion(scalaVersion.value) match {
123+
case Some((2, v)) if v <= 12 =>
124+
Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full))
125+
case _ => Nil
126+
}
127+
},
128+
)
129+
130+
lazy val coreTestMacros = crossProject(JSPlatform, JVMPlatform, NativePlatform)
131+
.crossType(CrossType.Full)
132+
.settings(moduleName := "core-test-macros")
133+
.settings(commonSettings)
134+
.settings(noPublishSettings)
135+
.configureCross(buildInfoSetup)
136+
.settings(macroAnnotationSettings)
137+
114138
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
115139
.crossType(CrossType.Full)
116140
.configureCross(configureJUnit)
@@ -123,6 +147,8 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
123147
.settings(Compile / sourceManaged := baseDirectory.value.getParentFile / "shared" / "src" / "main" / "managed")
124148
.settings(Compile / sourceGenerators += boilerplate.taskValue)
125149
.settings(mimaSettings)
150+
.dependsOn(coreTestMacros % "test->compile")
151+
.settings(macroAnnotationSettings)
126152

127153
lazy val coreJVM = core.jvm
128154
lazy val coreJS = core.js

core/shared/src/main/scala/shapeless/conversions.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import ops.hlist.Tupler
2222
* Higher ranked function which converts `HLists` to tuples.
2323
*/
2424
object tupled extends Poly1 {
25-
implicit def caseHList[L <: HList](implicit tupler: Tupler[L]) = at[L](tupler(_))
25+
implicit def caseHList[L <: HList](implicit tupler: Tupler[L]): Case.Aux[L, tupler.Out] = at[L](tupler(_))
2626
}
2727

2828
/**
2929
* Higher ranked function which converts products to `HLists`.
3030
*/
3131
object productElements extends Poly1 {
32-
implicit def caseProduct[P](implicit gen: Generic[P]) = at[P](p => gen.to(p))
32+
implicit def caseProduct[P](implicit gen: Generic[P]): Case.Aux[P, gen.Repr] = at[P](p => gen.to(p))
3333
}

core/shared/src/main/scala/shapeless/coproduct.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ object Coproduct extends Dynamic {
130130

131131
def apply[C <: Coproduct] = new MkCoproduct[C]
132132

133-
implicit def cpOps[C <: Coproduct](c: C) = new CoproductOps(c)
133+
implicit def cpOps[C <: Coproduct](c: C): CoproductOps[C] = new CoproductOps(c)
134134

135135
def unsafeMkCoproduct(length: Int, value: Any) =
136136
(0 until length).foldLeft[Coproduct](Inl(value))((accum, _) => Inr(accum))

core/shared/src/main/scala/shapeless/generic.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,12 @@ trait CaseClassMacros extends ReprTypes with CaseClassMacrosVersionSpecifics {
10211021
// case 3: case class
10221022
case tpe if tpe.typeSymbol.asClass.isCaseClass =>
10231023
val companion = patchedCompanionSymbolOf(tpe.typeSymbol)
1024+
val apply = companion.typeSignature.member(TermName("apply"))
10241025
val unapply = companion.typeSignature.member(TermName("unapply"))
10251026
val fields = fieldsOf(tpe)
1026-
(fromApply(fields), if (unapply.isSynthetic) toUnapply(fields) else toGetters(fields))
1027+
val ctor = if (apply == NoSymbol) fromConstructor(fields) else fromApply(fields)
1028+
val dtor = if (unapply.isSynthetic) toUnapply(fields) else toGetters(fields)
1029+
(ctor, dtor)
10271030
// case 4: exactly one matching public apply/unapply
10281031
case HasApplyUnapply(args) =>
10291032
(fromApply(args), toUnapply(args))

core/shared/src/main/scala/shapeless/hmap.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class HMap[R[_, _]](underlying : Map[Any, Any] = Map.empty) extends Poly1 {
3636
def +[K, V](kv : (K, V))(implicit ev : R[K, V]) : HMap[R] = new HMap[R](underlying+kv)
3737
def -[K](k : K) : HMap[R] = new HMap[R](underlying-k)
3838

39-
implicit def caseRel[K, V](implicit ev : R[K, V]) = Case1[this.type, K, V](get(_).get)
39+
implicit def caseRel[K, V](implicit ev : R[K, V]): Case1.Aux[this.type, K, V] = Case1[this.type, K, V](get(_).get)
4040
}
4141

4242
object HMap {

core/shared/src/main/scala/shapeless/lenses.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ object OpticDefns {
159159
def apply[C] = id[C]
160160

161161
object compose extends Poly2 {
162-
implicit def default[A, B, C] = at[Lens[B, C], Lens[A, B]](_ compose _)
162+
implicit def default[A, B, C]: Case.Aux[Lens[B, C], Lens[A, B], Lens[A, C]] = at[Lens[B, C], Lens[A, B]](_ compose _)
163163
}
164164

165165
class RootLens[C] extends Lens[C, C] {
@@ -245,10 +245,10 @@ object MkFieldLens {
245245
implicit def mkFieldLens[A, K, R <: HList, B]
246246
(implicit
247247
mkGen: MkLabelledGenericLens.Aux[A, R],
248-
mkLens: MkRecordSelectLens[R, K]): Aux[A, K, mkLens.Elem] =
248+
mkLens: MkRecordSelectLens.Aux[R, K, B]): Aux[A, K, B] =
249249
new MkFieldLens[A, K] {
250-
type Elem = mkLens.Elem
251-
def apply(): Lens[A, mkLens.Elem] = mkLens() compose mkGen()
250+
type Elem = B
251+
def apply(): Lens[A, B] = mkLens() compose mkGen()
252252
}
253253
}
254254

core/shared/src/main/scala/shapeless/ops/hlists.scala

+12-12
Original file line numberDiff line numberDiff line change
@@ -121,35 +121,35 @@ object hlist {
121121
object NatTRel {
122122
def apply[L1 <: HList, F1[_], L2 <: HList, F2[_]](implicit natTRel: NatTRel[L1, F1, L2, F2]) = natTRel
123123

124-
implicit def hnilNatTRel1[F1[_], F2[_]] = new NatTRel[HNil, F1, HNil, F2] {
124+
implicit def hnilNatTRel1[F1[_], F2[_]]: NatTRel[HNil, F1, HNil, F2] = new NatTRel[HNil, F1, HNil, F2] {
125125
def map(f: F1 ~> F2, fa: HNil): HNil = HNil
126126
}
127127

128-
implicit def hnilNatTRel2[F1[_], H2] = new NatTRel[HNil, F1, HNil, Const[H2]#λ] {
128+
implicit def hnilNatTRel2[F1[_], H2]: NatTRel[HNil, F1, HNil, Const[H2]#λ] = new NatTRel[HNil, F1, HNil, Const[H2]#λ] {
129129
def map(f: F1 ~> Const[H2]#λ, fa: HNil): HNil = HNil
130130
}
131131

132-
implicit def hlistNatTRel1[H, F1[_], F2[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, F2]) =
132+
implicit def hlistNatTRel1[H, F1[_], F2[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, F2]): NatTRel[F1[H] :: T1, F1, F2[H] :: T2, F2] =
133133
new NatTRel[F1[H] :: T1, F1, F2[H] :: T2, F2] {
134134
def map(f: F1 ~> F2, fa: F1[H] :: T1): F2[H] :: T2 = f(fa.head) :: nt.map(f, fa.tail)
135135
}
136136

137-
implicit def hlistNatTRel2[H, F2[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, Id, T2, F2]) =
137+
implicit def hlistNatTRel2[H, F2[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, Id, T2, F2]): NatTRel[H :: T1, Id, F2[H] :: T2, F2] =
138138
new NatTRel[H :: T1, Id, F2[H] :: T2, F2] {
139139
def map(f: Id ~> F2, fa: H :: T1): F2[H] :: T2 = f(fa.head) :: nt.map(f, fa.tail)
140140
}
141141

142-
implicit def hlistNatTRel3[H, F1[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, Id]) =
142+
implicit def hlistNatTRel3[H, F1[_], T1 <: HList, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, Id]): NatTRel[F1[H] :: T1, F1, H :: T2, Id] =
143143
new NatTRel[F1[H] :: T1, F1, H :: T2, Id] {
144144
def map(f: F1 ~> Id, fa: F1[H] :: T1): H :: T2 = f(fa.head) :: nt.map(f, fa.tail)
145145
}
146146

147-
implicit def hlistNatTRel4[H1, F1[_], T1 <: HList, H2, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, Const[H2]#λ]) =
147+
implicit def hlistNatTRel4[H1, F1[_], T1 <: HList, H2, T2 <: HList](implicit nt : NatTRel[T1, F1, T2, Const[H2]#λ]): NatTRel[F1[H1] :: T1, F1, H2 :: T2, Const[H2]#λ] =
148148
new NatTRel[F1[H1] :: T1, F1, H2 :: T2, Const[H2]#λ] {
149149
def map(f: F1 ~> Const[H2]#λ, fa: F1[H1] :: T1): H2 :: T2 = f(fa.head) :: nt.map(f, fa.tail)
150150
}
151151

152-
implicit def hlistNatTRel5[H1, T1 <: HList, H2, T2 <: HList](implicit nt : NatTRel[T1, Id, T2, Const[H2]#λ]) =
152+
implicit def hlistNatTRel5[H1, T1 <: HList, H2, T2 <: HList](implicit nt : NatTRel[T1, Id, T2, Const[H2]#λ]): NatTRel[H1 :: T1, Id, H2 :: T2, Const[H2]#λ] =
153153
new NatTRel[H1 :: T1, Id, H2 :: T2, Const[H2]#λ] {
154154
def map(f: Id ~> Const[H2]#λ, fa: H1 :: T1): H2 :: T2 = f(fa.head) :: nt.map(f, fa.tail)
155155
}
@@ -214,12 +214,12 @@ object hlist {
214214

215215
type Aux[L <: HList, Out0 <: HKernel] = HKernelAux[L] { type Out = Out0 }
216216

217-
implicit def mkHNilHKernel = new HKernelAux[HNil] {
217+
implicit def mkHNilHKernel: Aux[HNil, HNilHKernel] = new HKernelAux[HNil] {
218218
type Out = HNilHKernel
219219
def apply() = HNilHKernel
220220
}
221221

222-
implicit def mkHListHKernel[H, T <: HList, CtOut <: HKernel](implicit ct: HKernelAux.Aux[T, CtOut]) = new HKernelAux[H :: T] {
222+
implicit def mkHListHKernel[H, T <: HList, CtOut <: HKernel](implicit ct: HKernelAux.Aux[T, CtOut]): Aux[H :: T, HConsHKernel[H, CtOut]] = new HKernelAux[H :: T] {
223223
type Out = HConsHKernel[H, CtOut]
224224
def apply() = HConsHKernel[H, CtOut](ct())
225225
}
@@ -2740,7 +2740,7 @@ object hlist {
27402740
type Aux[L <: HList, V, P <: Poly, Out0 <: HList] = RightScanner0[L, V, P] { type Out = Out0 }
27412741
}
27422742

2743-
implicit def hlistRightScanner0[H, H0, T <: HList, P <: Poly, C2Result](implicit ev: Case2.Aux[P, H0, H, C2Result]) =
2743+
implicit def hlistRightScanner0[H, H0, T <: HList, P <: Poly, C2Result](implicit ev: Case2.Aux[P, H0, H, C2Result]): RightScanner0.Aux[H :: T, H0, P, C2Result :: H :: T] =
27442744
new RightScanner0[H :: T, H0, P]{
27452745
type Out = C2Result :: H :: T
27462746

@@ -2845,7 +2845,7 @@ object hlist {
28452845
}
28462846

28472847
implicit def hlistPatch2[M <: Nat, L <: HList, In <: HList, OutL <: HList, OutP <: HList]
2848-
(implicit drop: Drop.Aux[L, M, OutL], prepend: Prepend.Aux[In, OutL, OutP]) =
2848+
(implicit drop: Drop.Aux[L, M, OutL], prepend: Prepend.Aux[In, OutL, OutP]): Patcher.Aux[_0, M, L, In, OutP] =
28492849
new Patcher[_0, M, L, In]{
28502850
type Out = OutP
28512851

@@ -3049,7 +3049,7 @@ object hlist {
30493049
}
30503050

30513051
trait LowPriorityCombinations {
3052-
implicit def combinationHNil[N <: Nat] =
3052+
implicit def combinationHNil[N <: Nat]: Combinations.Aux[N, HNil, HNil] =
30533053
new Combinations[N, HNil] {
30543054
type Out = HNil
30553055
def apply(l: HNil): Out = HNil

core/shared/src/main/scala/shapeless/ops/nat.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ object nat {
140140
object LT extends LT0 {
141141
def apply[A <: Nat, B <: Nat](implicit lt: A < B): LT[A, B] = lt
142142

143-
implicit def lt1[B <: Nat] = new <[_0, Succ[B]] {}
144-
implicit def lt2[A <: Nat, B <: Nat](implicit lt : A < B) = new <[Succ[A], Succ[B]] {}
143+
implicit def lt1[B <: Nat]: _0 < Succ[B] = new <[_0, Succ[B]] {}
144+
implicit def lt2[A <: Nat, B <: Nat](implicit lt : A < B): Succ[A] < Succ[B] = new <[Succ[A], Succ[B]] {}
145145
}
146146

147147
trait LT0 {
148148
type <[A <: Nat, B <: Nat] = LT[A, B]
149149

150-
implicit def lt3[A <: Nat] = new <[A, Succ[A]] {}
150+
implicit def lt3[A <: Nat]: A < Succ[A] = new <[A, Succ[A]] {}
151151
}
152152

153153
/**
@@ -160,15 +160,15 @@ object nat {
160160
object LTEq extends LTEq0 {
161161
def apply[A <: Nat, B <: Nat](implicit lteq: A <= B): LTEq[A, B] = lteq
162162

163-
implicit def ltEq1[A <: Nat] = new <=[A, A] {}
164-
implicit def ltEq2[A <: Nat] = new <=[A, Succ[A]] {}
163+
implicit def ltEq1[A <: Nat]: A <= A = new <=[A, A] {}
164+
implicit def ltEq2[A <: Nat]: A <= Succ[A] = new <=[A, Succ[A]] {}
165165
}
166166

167167
trait LTEq0 {
168168
type <=[A <: Nat, B <: Nat] = LTEq[A, B]
169169

170-
implicit def ltEq3[B <: Nat] = new <=[_0, B] {}
171-
implicit def ltEq4[A <: Nat, B <: Nat](implicit lteq : A <= B) = new <=[Succ[A], Succ[B]] {}
170+
implicit def ltEq3[B <: Nat]: _0 <= B = new <=[_0, B] {}
171+
implicit def ltEq4[A <: Nat, B <: Nat](implicit lteq : A <= B): Succ[A] <= Succ[B] = new <=[Succ[A], Succ[B]] {}
172172
}
173173

174174
/**

core/shared/src/main/scala/shapeless/ops/tuples.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ object tuple {
12431243
(implicit gen: Generic.Aux[T, L],
12441244
genIn: Generic.Aux[InT, InL],
12451245
patch: hl.Patcher.Aux[N, M, L, InL, OutL],
1246-
tp: hl.Tupler[OutL]) =
1246+
tp: hl.Tupler[OutL]): Patcher[N, M, T, InT] { type Out = tp.Out } =
12471247
new Patcher[N, M, T, InT]{
12481248
type Out = tp.Out
12491249

core/shared/src/main/scala/shapeless/poly.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object PolyDefns extends Cases {
7373

7474
object Compose {
7575
implicit def composeCase[C, F <: Poly, G <: Poly, T, U, V]
76-
(implicit unpack: Unpack2[C, Compose, F, G], cG : Case1.Aux[G, T, U], cF : Case1.Aux[F, U, V]) = new Case[C, T :: HNil] {
76+
(implicit unpack: Unpack2[C, Compose, F, G], cG : Case1.Aux[G, T, U], cF : Case1.Aux[F, U, V]): Case.Aux[C, T :: HNil, V] = new Case[C, T :: HNil] {
7777
type Result = V
7878
val value = (t : T :: HNil) => cF(cG.value(t))
7979
}
@@ -170,23 +170,23 @@ object PolyDefns extends Cases {
170170
* Base class for lifting a `Function1` to a `Poly1`
171171
*/
172172
class ->[T, R](f : T => R) extends Poly1 {
173-
implicit def subT[U <: T] = at[U](f)
173+
implicit def subT[U <: T]: Case.Aux[U, R] = at[U](f)
174174
}
175175

176176
trait LowPriorityLiftFunction1 extends Poly1 {
177-
implicit def default[T] = at[T](_ => HNil : HNil)
177+
implicit def default[T]: Case.Aux[T, HNil] = at[T](_ => HNil : HNil)
178178
}
179179

180180
/**
181181
* Base class for lifting a `Function1` to a `Poly1` over the universal domain, yielding an `HList` with the result as
182182
* its only element if the argument is in the original functions domain, `HNil` otherwise.
183183
*/
184184
class >->[T, R](f : T => R) extends LowPriorityLiftFunction1 {
185-
implicit def subT[U <: T] = at[U](f(_) :: HNil)
185+
implicit def subT[U <: T]: Case.Aux[U, R :: HNil] = at[U](f(_) :: HNil)
186186
}
187187

188188
trait LowPriorityLiftU extends Poly {
189-
implicit def default[L <: HList] = new ProductCase[L] {
189+
implicit def default[L <: HList]: ProductCase.Aux[L, HNil] = new ProductCase[L] {
190190
type Result = HNil
191191
val value = (l : L) => HNil
192192
}
@@ -197,7 +197,7 @@ object PolyDefns extends Cases {
197197
* only element if the argument is in the original functions domain, `HNil` otherwise.
198198
*/
199199
class LiftU[P <: Poly](p : P) extends LowPriorityLiftU {
200-
implicit def defined[L <: HList](implicit caseT : Case[P, L]) = new ProductCase[L] {
200+
implicit def defined[L <: HList](implicit caseT : Case[P, L]): ProductCase.Aux[L, caseT.Result :: HNil] = new ProductCase[L] {
201201
type Result = caseT.Result :: HNil
202202
val value = (l : L) => caseT(l) :: HNil
203203
}

core/shared/src/main/scala/shapeless/syntax/std/functions.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ package std
2929
object function {
3030
import ops.function._
3131

32-
implicit def fnHListOps[F, T <: HList, R](t: F)(implicit fnHLister: FnToProduct.Aux[F, T => R]) = new FnHListOps[T => R] {
32+
implicit def fnHListOps[F, T <: HList, R](t: F)(implicit fnHLister: FnToProduct.Aux[F, T => R]): FnHListOps[T => R] = new FnHListOps[T => R] {
3333
def toProduct = fnHLister(t)
3434
}
3535

3636

37-
implicit def fnUnHListOps[F](t : F)(implicit fnUnHLister : FnFromProduct[F]) = new FnUnHListOps[fnUnHLister.Out] {
37+
implicit def fnUnHListOps[F](t : F)(implicit fnUnHLister : FnFromProduct[F]): FnUnHListOps[fnUnHLister.Out] = new FnUnHListOps[fnUnHLister.Out] {
3838
def fromProduct = fnUnHLister(t)
3939
}
4040
}

core/shared/src/main/scala/shapeless/syntax/std/maps.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import shapeless.ops.maps.FromMap
2323
* Conversions between `Map` and `Records`.
2424
*/
2525
object maps {
26-
implicit def mapOps[K, V](m: Map[K, V]) = new MapOps[K, V](m)
26+
implicit def mapOps[K, V](m: Map[K, V]): MapOps[K, V] = new MapOps[K, V](m)
2727
}
2828

2929
final class MapOps[K, V](m: Map[K, V]) {

core/shared/src/main/scala/shapeless/syntax/zipper.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package shapeless
1818
package syntax
1919

2020
object zipper {
21-
implicit def toZipper[L <: HList](l: L) = new HListZipperOps(l)
22-
implicit def toZipper[C, CL <: HList](c : C)(implicit gen : Generic.Aux[C, CL]) = new GenericZipperOps(c)
21+
implicit def toZipper[L <: HList](l: L): HListZipperOps[L] = new HListZipperOps(l)
22+
implicit def toZipper[C, CL <: HList](c : C)(implicit gen : Generic.Aux[C, CL]): GenericZipperOps[C, CL] = new GenericZipperOps(c)
2323
}
2424

2525
/** Enhances values of any type with a representation via `Generic` with a method supporting conversion to a `Zipper`. */

core/shared/src/main/scala/shapeless/typeoperators.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ trait Lub[-A, -B, Out] extends Serializable {
195195
}
196196

197197
object Lub {
198-
implicit def lub[T] = new Lub[T, T, T] {
198+
implicit def lub[T]: Lub[T, T, T] = new Lub[T, T, T] {
199199
def left(a : T): T = a
200200
def right(b : T): T = b
201201
}

core/shared/src/main/scala/shapeless/unwrapped.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait UnwrappedInstances extends LowPriorityUnwrappedInstances {
3434
gen: Generic.Aux[W, Repr],
3535
avh: AnyValHelper.Aux[Repr, UI],
3636
chain: Strict[Unwrapped.Aux[UI, UF]]
37-
) = new Unwrapped[W] {
37+
): Unwrapped.Aux[W, UF] = new Unwrapped[W] {
3838
type U = UF
3939
def unwrap(w: W): U = chain.value.unwrap(avh.unwrap(gen.to(w)))
4040
def wrap(u: U): W = gen.from(avh.wrap(chain.value.wrap(u)))
@@ -47,7 +47,7 @@ trait UnwrappedInstances extends LowPriorityUnwrappedInstances {
4747
}
4848
object AnyValHelper {
4949
type Aux[Repr, U0] = AnyValHelper[Repr] { type U = U0 }
50-
implicit def sizeOneHListHelper[T] =
50+
implicit def sizeOneHListHelper[T]: Aux[T :: HNil, T] =
5151
SizeOneHListHelper.asInstanceOf[AnyValHelper.Aux[T :: HNil, T]]
5252
val SizeOneHListHelper = new AnyValHelper[Any :: HNil] {
5353
type U = Any
@@ -58,11 +58,11 @@ trait UnwrappedInstances extends LowPriorityUnwrappedInstances {
5858

5959
implicit def newtypeUnwrapped[UI, Ops, UF](implicit
6060
chain: Strict[Unwrapped.Aux[UI, UF]]
61-
) = chain.value.asInstanceOf[Unwrapped.Aux[Newtype[UI, Ops], UF]]
61+
): Unwrapped.Aux[Newtype[UI, Ops], UF] = chain.value.asInstanceOf[Unwrapped.Aux[Newtype[UI, Ops], UF]]
6262

6363
implicit def tagUnwrapped[T[UI, TT] <: tag.@@[UI, TT], UI, TT, UF](implicit
6464
chain: Strict[Unwrapped.Aux[UI, UF]]
65-
) = chain.value.asInstanceOf[Unwrapped.Aux[T[UI, TT], UF]]
65+
): Unwrapped.Aux[T[UI, TT], UF] = chain.value.asInstanceOf[Unwrapped.Aux[T[UI, TT], UF]]
6666

6767
}
6868

@@ -73,6 +73,6 @@ trait LowPriorityUnwrappedInstances {
7373
def unwrap(t: Any) = t
7474
def wrap(t: Any) = t
7575
}
76-
implicit def selfUnwrapped[T] =
76+
implicit def selfUnwrapped[T]: Unwrapped.Aux[T,T] =
7777
theSelfUnwrapped.asInstanceOf[Unwrapped.Aux[T, T]]
7878
}

core/shared/src/test/scala/shapeless/generic.scala

+7
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ package GenericTestsAux {
171171
def apply(y: String): Priv = new Priv(y)
172172
def unapply(p: Priv): Some[String] = Some(p.y)
173173
}
174+
175+
object macroAnnotations {
176+
case class A(i: Int, s: String)
177+
178+
@generateGeneric
179+
object A
180+
}
174181
}
175182

176183
class GenericTests {

0 commit comments

Comments
 (0)