File tree 3 files changed +43
-7
lines changed
src/compiler/scala/tools/nsc/typechecker
3 files changed +43
-7
lines changed Original file line number Diff line number Diff line change @@ -207,21 +207,24 @@ trait Implicits {
207
207
*/
208
208
class ImplicitInfo (val name : Name , val pre : Type , val sym : Symbol ) {
209
209
private var tpeCache : Type = null
210
- private var isCyclicOrErroneousCache : TriState = TriState .Unknown
210
+ private var isErroneousCache : TriState = TriState .Unknown
211
211
212
212
/** Computes member type of implicit from prefix `pre` (cached). */
213
213
def tpe : Type = {
214
214
if (tpeCache eq null ) tpeCache = pre.memberType(sym)
215
215
tpeCache
216
216
}
217
217
218
- def isCyclicOrErroneous : Boolean = {
219
- if (! isCyclicOrErroneousCache.isKnown) isCyclicOrErroneousCache = computeIsCyclicOrErroneous
220
- isCyclicOrErroneousCache.booleanValue
221
- }
218
+ def isCyclicOrErroneous : Boolean =
219
+ if (sym.hasFlag(LOCKED )) true
220
+ else {
221
+ if (! isErroneousCache.isKnown)
222
+ isErroneousCache = computeErroneous
223
+ isErroneousCache.booleanValue
224
+ }
222
225
223
- private [this ] final def computeIsCyclicOrErroneous =
224
- try sym.hasFlag( LOCKED ) || containsError(tpe)
226
+ private [this ] final def computeErroneous =
227
+ try containsError(tpe)
225
228
catch { case _ : CyclicReference => true }
226
229
227
230
var useCountArg : Int = 0
Original file line number Diff line number Diff line change
1
+ class X [A ](a : A )
2
+ object Test {
3
+ implicit val ImplicitBoolean : Boolean = true
4
+ def local = {
5
+ implicit object X extends X ({ def local2 = implicitly[Boolean ] ; " " })
6
+ implicitly[X [String ]]
7
+ }
8
+ }
Original file line number Diff line number Diff line change
1
+ trait Foo [T ]
2
+
3
+ trait FooSub [T ] extends Foo [T ] {
4
+ type Super = Foo [T ]
5
+ }
6
+
7
+ object FooSub {
8
+ implicit def fooSub [T ](implicit ft : Bar [T ]): FooSub [T ] =
9
+ new FooSub [T ] {}
10
+ }
11
+
12
+ trait Bar [T ]
13
+
14
+ class Quux
15
+
16
+ object Quux {
17
+ implicit val barQuux : Bar [Quux ] = new Bar [Quux ] {}
18
+
19
+ val fooSubQuux = implicitly[FooSub [Quux ]]
20
+ implicit val fooQuux : fooSubQuux.Super = fooSubQuux
21
+ }
22
+
23
+ object Test extends App {
24
+ implicitly[Foo [Quux ]]
25
+ }
You can’t perform that action at this time.
0 commit comments