Skip to content

Commit b3181e9

Browse files
committed
Add nowarns for scala/bug#12398
1 parent 9dd0a92 commit b3181e9

File tree

6 files changed

+29
-28
lines changed

6 files changed

+29
-28
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ object AnyConstructorMacro {
3333
assert(enclosingClass.exists(_.pos == positionOfMakeCall), "enclosingClass must contain macro call position")
3434

3535
def findExprContainingMake(tree: Tree): Option[Tree] = {
36+
@nowarn("msg=outer reference")
3637
val afterLastBlock = Option {
3738
tree
3839
.filter(_.exists(_.pos == positionOfMakeCall))

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import izumi.distage.model.reflection.universe.StaticDIUniverse
66
import izumi.distage.reflection.ReflectionProviderDefaultImpl
77
import izumi.fundamentals.reflection.{ReflectionUtil, TrivialMacroLogger}
88

9+
import scala.annotation.nowarn
910
import scala.reflect.macros.blackbox
1011

1112
object ClassConstructorMacro {
@@ -16,7 +17,7 @@ object ClassConstructorMacro {
1617
val targetType = ReflectionUtil.norm(c.universe: c.universe.type)(weakTypeOf[T].dealias)
1718
requireConcreteTypeConstructor(c)("ClassConstructor", targetType)
1819

19-
targetType match {
20+
(targetType match {
2021
case t: SingletonTypeApi =>
2122
val functoid = symbolOf[Functoid.type].asClass.module
2223
val term = t match {
@@ -49,7 +50,7 @@ object ClassConstructorMacro {
4950
val res = c.Expr[ClassConstructor[T]](q"{ new ${weakTypeOf[ClassConstructor[T]]}($provider) }")
5051
logger.log(s"Final syntax tree of class for $targetType:\n$res")
5152
res
52-
}
53+
}): @nowarn("msg=outer reference")
5354
}
5455

5556
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import izumi.distage.model.reflection.universe.StaticDIUniverse
77
import izumi.distage.model.reflection.{Provider, ReflectionProvider}
88
import izumi.fundamentals.reflection.ReflectionUtil
99

10-
import scala.annotation.tailrec
10+
import scala.annotation.{nowarn, tailrec}
1111
import scala.reflect.macros.blackbox
1212

1313
abstract class ClassConstructorMacros extends ConstructorMacrosBase {
@@ -115,6 +115,7 @@ abstract class FactoryConstructorMacros extends ConstructorMacrosBase {
115115
val u.Wiring.Factory.FactoryMethod(factoryMethod, productConstructor, _) = factoryMethod0
116116

117117
val (methodArgListDecls, methodArgList) = {
118+
@nowarn("msg=outer reference")
118119
@tailrec def instantiatedMethod(tpe: Type): MethodTypeApi = {
119120
tpe match {
120121
case m: MethodTypeApi => m

distage/distage-core-api/src/main/scala/izumi/distage/model/reflection/macros/FunctoidMacro.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import izumi.distage.model.reflection.universe.StaticDIUniverse.Aux
99
import izumi.distage.reflection.ReflectionProviderDefaultImpl
1010
import izumi.fundamentals.reflection.TrivialMacroLogger
1111

12+
import scala.annotation.nowarn
1213
import scala.reflect.macros.blackbox
1314

1415
/**
@@ -189,12 +190,12 @@ class FunctoidMacro(val c: blackbox.Context) {
189190
}
190191

191192
protected[this] def widenFunctionObject(sig: Type): Type = {
192-
sig match {
193+
(sig match {
193194
case s: SingleTypeApi =>
194195
sig.baseType(s.sym.typeSignature.baseClasses.find(definitions.FunctionClass.seq.contains(_)).get)
195196
case _ =>
196197
sig
197-
}
198+
}): @nowarn("msg=outer reference")
198199
}
199200

200201
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import izumi.distage.model.reflection.ReflectionProvider
66
import izumi.distage.model.reflection.universe.DIUniverse
77
import izumi.fundamentals.reflection.{JSRAnnotationTools, ReflectionUtil}
88

9+
import scala.annotation.nowarn
10+
11+
@nowarn("msg=outer reference")
912
trait ReflectionProviderDefaultImpl extends ReflectionProvider {
1013

1114
import u.u.{Annotation, LiteralApi}

fundamentals/fundamentals-reflection/src/main/scala_2.13/izumi/fundamentals/reflection/JSRAnnotationTools.scala

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package izumi.fundamentals.reflection
22

3+
import scala.annotation.nowarn
34
import scala.reflect.api.Universe
45

56
object JSRAnnotationTools {
@@ -15,31 +16,24 @@ object JSRAnnotationTools {
1516
* The package name is being ignored
1617
*/
1718
def uniqueJSRNameAnno(u: Universe)(annos: List[u.Annotation]): Option[String] = {
18-
val maybeJSR = annos
19-
.collect {
20-
case a: u.AnnotationApi =>
21-
a.tree.children match {
22-
case (select: u.SelectApi) :: (value: u.NamedArgApi) :: Nil =>
23-
(select.children.headOption, value.lhs, value.rhs) match {
24-
case (Some(n: u.NewApi), i: u.IdentApi, v: u.LiteralApi) if v.value.value.isInstanceOf[String] && i.name.toString == "value" =>
25-
n.children match {
26-
case (head: u.TypeTreeApi) :: Nil if head.symbol.name.toString == "Named" =>
27-
Some(v.value.value.asInstanceOf[String])
28-
case _ =>
29-
None
30-
}
19+
@nowarn("msg=outer reference") @nowarn("msg=abstract type pattern")
20+
val maybeJSR = annos.collect {
21+
case a: u.AnnotationApi =>
22+
a.tree.children match {
23+
case (select: u.SelectApi) :: (value: u.NamedArgApi) :: Nil =>
24+
(select.children.headOption, value.lhs, value.rhs) match {
25+
case (Some(u.New(head: u.TypeTreeApi)), _: u.IdentApi, u.Literal(u.Constant(annotationArgument: String))) if {
26+
head.symbol.name.toString == "Named"
27+
} =>
28+
Some(annotationArgument)
3129

32-
case _ =>
33-
None
34-
}
30+
case _ => None
31+
}
3532

36-
case _ =>
37-
None
38-
}
39-
}
40-
.collect {
41-
case Some(name) => name
42-
}
33+
case _ =>
34+
None
35+
}
36+
}.flatten
4337

4438
maybeJSR match {
4539
case unique :: Nil =>

0 commit comments

Comments
 (0)