Skip to content

Commit 9dd0a92

Browse files
committed
Return older implementations without FatalError
1 parent 3615aec commit 9dd0a92

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

distage/distage-core-api/src/main/scala/izumi/distage/constructors/macros/ConstructorMacros.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ abstract class TraitConstructorMacros extends ConstructorMacrosBase {
7878

7979
def traitConstructorAssertion(targetType: Type): Unit = {
8080
ReflectionUtil
81-
.deepIntersectionTypeMembers(c.universe: c.universe.type)(targetType)
81+
.deepIntersectionTypeMembers[c.universe.type](targetType)
8282
.find(tpe => tpe.typeSymbol.isParameter || tpe.typeSymbol.isFinal)
8383
.foreach {
8484
err =>
@@ -258,7 +258,7 @@ abstract class ConstructorMacrosBase {
258258
constructorParameters: List[List[Tree]],
259259
methodImpls: List[Tree],
260260
): Tree = {
261-
val parents = ReflectionUtil.deepIntersectionTypeMembers(u.u: u.u.type)(targetType)
261+
val parents = ReflectionUtil.deepIntersectionTypeMembers[u.u.type](targetType)
262262
parents match {
263263
case parent :: Nil if parent.typeSymbol.isClass && !parent.typeSymbol.asClass.isTrait =>
264264
if (methodImpls.isEmpty) {

distage/distage-core-api/src/main/scala/izumi/distage/constructors/macros/HasConstructorMacro.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object HasConstructorMacro {
2020
val targetType = ReflectionUtil.norm(c.universe: c.universe.type)(weakTypeOf[T].dealias)
2121
requireConcreteTypeConstructor(c)("HasConstructor", targetType)
2222
val deepIntersection = ReflectionUtil
23-
.deepIntersectionTypeMembers(c.universe: c.universe.type)(targetType)
23+
.deepIntersectionTypeMembers[c.universe.type](targetType)
2424
.filter(_ ne definitions.AnyTpe)
2525

2626
targetType match {

distage/distage-core-api/src/main/scala/izumi/distage/model/reflection/universe/WithDISymbolInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ trait WithDISymbolInfo { this: DIUniverseBase with WithDISafeType =>
8585
SymbolInfo.Static(
8686
name = transformName(tpe.typeSymbol.name.toString),
8787
finalResultType = tpe,
88-
annotations = AnnotationTools.getAllTypeAnnotations(u)(tpe),
88+
annotations = AnnotationTools.getAllTypeAnnotations[u.type](tpe),
8989
isByName = tpe.typeSymbol.isClass && tpe.typeSymbol.asClass == u.definitions.ByNameParamClass,
9090
wasGeneric = tpe.typeSymbol.isParameter,
9191
)

distage/distage-core-api/src/main/scala/izumi/distage/reflection/ReflectionProviderDefaultImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ trait ReflectionProviderDefaultImpl extends ReflectionProvider {
128128
if (tpe.typeSymbol.isStatic) {
129129
None
130130
} else {
131-
val typeRef = ReflectionUtil.toTypeRef(u.u: u.u.type)(tpe)
131+
val typeRef = ReflectionUtil.toTypeRef[u.u.type](tpe)
132132
typeRef
133133
.map(_.pre)
134134
.filterNot(m => m.termSymbol.isModule && m.termSymbol.isStatic)

fundamentals/fundamentals-reflection/src/main/scala/izumi/fundamentals/reflection/AnnotationTools.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
package izumi.fundamentals.reflection
22

3-
import izumi.fundamentals.reflection.ReflectionUtil.stripByName
4-
53
import scala.reflect.api.Universe
64

75
object AnnotationTools {
86

97
def getAllAnnotations(u: Universe)(symb: u.Symbol): List[u.Annotation] = {
10-
val out = symb.annotations ++ getAllTypeAnnotations(u)(symb.typeSignature)
11-
out
8+
symb.annotations ++ getAllTypeAnnotations[u.type](symb.typeSignature)
129
}
1310

14-
def getAllTypeAnnotations(u: Universe)(typ: u.Type): List[u.Annotation] = {
15-
val out = stripByName(u)(typ.finalResultType.dealias) match {
16-
case t: u.AnnotatedTypeApi =>
11+
def getAllTypeAnnotations[U <: Universe with Singleton](typ: U#Type): List[U#Annotation] = {
12+
typ.finalResultType.dealias match {
13+
case t: U#AnnotatedTypeApi =>
1714
t.annotations
1815
case _ =>
1916
Nil
2017
}
21-
out
2218
}
2319

2420
def annotationTypeEq(u: Universe)(tpe: u.Type, ann: u.Annotation): Boolean = {

fundamentals/fundamentals-reflection/src/main/scala/izumi/fundamentals/reflection/ReflectionUtil.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ object ReflectionUtil {
2525
* So we just strip it when we get it.
2626
*/
2727
@tailrec
28-
final def norm0(u: Universe)(x: u.Type): u.Type = {
28+
final def norm0[U <: SingletonUniverse](x: U#Type): U#Type = {
2929
x match {
30-
case r: u.RefinedTypeApi if (r.parents.drop(1) eq Nil) && r.decls.isEmpty => norm0(u)(r.asInstanceOf[u.Type])
31-
case a: u.AnnotatedTypeApi => norm0(u)(a.underlying)
30+
case r: U#RefinedTypeApi if (r.parents.drop(1) eq Nil) && r.decls.isEmpty => norm0[U](r.asInstanceOf[U#Type])
31+
case a: U#AnnotatedTypeApi => norm0[U](a.underlying)
3232
case _ => x
3333
}
3434
}
3535

36-
def toTypeRef(u: Universe)(tpe: u.TypeApi): Option[u.TypeRefApi] = {
36+
def toTypeRef[U <: SingletonUniverse](tpe: U#TypeApi): Option[U#TypeRefApi] = {
3737
tpe match {
38-
case typeRef: u.TypeRefApi =>
38+
case typeRef: U#TypeRefApi =>
3939
Some(typeRef)
4040
case _ =>
4141
None
@@ -100,10 +100,10 @@ object ReflectionUtil {
100100
tpe1.dealias =:= tpe1
101101
}
102102

103-
def deepIntersectionTypeMembers(u: Universe)(targetType: u.Type): List[u.Type] = {
104-
def go(tpe: u.Type): List[u.Type] = {
103+
def deepIntersectionTypeMembers[U <: SingletonUniverse](targetType: U#Type): List[U#Type] = {
104+
def go(tpe: U#Type): List[U#Type] = {
105105
tpe match {
106-
case r: u.RefinedTypeApi => r.parents.flatMap(t => deepIntersectionTypeMembers(u)(norm0(u)(t.dealias)))
106+
case r: U#RefinedTypeApi => r.parents.flatMap(t => deepIntersectionTypeMembers[U](norm0[U](t.dealias): U#Type))
107107
case _ => List(tpe)
108108
}
109109
}

0 commit comments

Comments
 (0)