Skip to content

Commit 1ca9413

Browse files
committed
remove moved part.
1 parent 89b45ea commit 1ca9413

2 files changed

Lines changed: 10 additions & 39 deletions

File tree

core/shared/src/main/scala/com/github/rssh/appcontext/AppContext.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,27 @@ object AppContext {
101101

102102
/**
103103
* Put component to cache, replacing old if needed
104-
* @param value
104+
*
105+
* @param value
105106
* @tparam T
106107
*/
107-
inline def put[T](value: T): Unit =
108-
c.put(cacheKey[T], value)
108+
inline def put[T](value: T): Option[T] =
109+
c.put(cacheKey[T], value).map(_.asInstanceOf[T])
109110

110111
/**
111112
* Modify component in cache.
112113
* @param f - function to remap
113114
* @tparam T - component type
114-
*/
115+
*/
115116
inline def modify[T](f: Option[T] => Option[T]): Unit =
116-
c.updateWith(cacheKey[T])(v => f(v.asInstanceOf[Option[T]]))
117+
val _unused = c.updateWith(cacheKey[T])(v => f(v.asInstanceOf[Option[T]]))
117118

118119
/**
119120
* Remove component from cache.
120121
* @tparam T - component type
121122
*/
122-
inline def remove[T]: Unit =
123-
c.remove(cacheKey[T])
123+
inline def remove[T]: Option[T] =
124+
c.remove(cacheKey[T]).map(_.asInstanceOf[T])
124125

125126

126127
}

core/shared/src/main/scala/com/github/rssh/appcontext/AppContextProviders.scala

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -68,40 +68,10 @@ object AppContextProviders {
6868
}
6969
retval
7070
}
71-
72-
71+
7372
inline def checkAllAreNeeded[Xs<:NonEmptyTuple](using p: AppContextProviders[Xs]): Boolean =
7473
${ TupleMacroses.checkAllAreNeeded[[X]=>>AppContextProvider[X],[X<:NonEmptyTuple]=>>AppContextProviders[X],Xs]('p) }
75-
// ${ checkAllAreNeededImpl[Xs]('p) }
76-
77-
// not used,
78-
private def checkAllAreNeededImpl[T<:NonEmptyTuple:Type](p: Expr[AppContextProviders[T]])(using Quotes): Expr[Boolean] = {
79-
import quotes.reflect.*
80-
val tupleType = TypeRepr.of[T]
81-
val tupleTypes = TupleMacroses.extractTupleTypes(tupleType)
82-
val fromProvidersSymbol = Symbol.requiredMethod("com.github.rssh.appcontext.AppContextProvider.fromProviders")
83-
var retval = true
84-
for{ t <- tupleTypes } {
85-
val tProvider = TypeRepr.of[AppContextProvider].appliedTo(t)
86-
Implicits.search(tProvider) match
87-
case failure: ImplicitSearchFailure =>
88-
// impossible, it will be success.
89-
report.error(s"Cannot find ${tProvider.show}: ${failure.explanation}")
90-
case success: ImplicitSearchSuccess =>
91-
// if this is 'this ?
92-
success.tree match
93-
case Apply(TypeApply(fun, targs), args@List(p1,ti)) if (fun.symbol == fromProvidersSymbol) =>
94-
if !(p1.tpe =:= p.asTerm.tpe) then
95-
report.error(s"Provider for ${t.show} in ${p.show} is not necessory: ${success.tree.show} provider will be used")
96-
retval = false
97-
case _ =>
98-
report.error(s"Provider for ${t.show} is not needed in ${p.show}, it will be resolved as: ${success.tree.show}")
99-
retval = false
100-
}
101-
Expr(retval)
102-
}
103-
104-
74+
10575

10676
}
10777

0 commit comments

Comments
 (0)