File tree Expand file tree Collapse file tree 3 files changed +29
-6
lines changed
compiler/src/dotty/tools/dotc/transform
neg-custom-args/fatal-warnings Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,13 @@ class CheckLoopingImplicits extends MiniPhase:
20
20
21
21
override def phaseName : String = CheckLoopingImplicits .name
22
22
23
- override def transformDefDef (mdef : DefDef )(using Context ): DefDef =
23
+ override def transformValDef (mdef : ValDef )(using Context ): Tree =
24
+ transform(mdef)
25
+
26
+ override def transformDefDef (mdef : DefDef )(using Context ): Tree =
27
+ transform(mdef)
28
+
29
+ def transform (mdef : ValOrDefDef )(using Context ): Tree =
24
30
val sym = mdef.symbol
25
31
26
32
def checkNotSelfRef (t : RefTree ) =
@@ -70,12 +76,12 @@ class CheckLoopingImplicits extends MiniPhase:
70
76
checkNotLooping(finalizer)
71
77
case SeqLiteral (elems, _) =>
72
78
elems.foreach(checkNotLooping)
73
- case t : ValDef =>
74
- if ! t.symbol.is( Lazy ) then checkNotLooping(t.rhs)
79
+ case t : ValDef =>
80
+ checkNotLooping(t.rhs)
75
81
case _ =>
76
82
77
- if sym.isOneOf(GivenOrImplicit ) then
83
+ if sym.isOneOf(GivenOrImplicit | Lazy ) then
78
84
checkNotLooping(mdef.rhs)
79
85
mdef
80
- end transformDefDef
86
+ end transform
81
87
end CheckLoopingImplicits
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ val x5 =
40
40
41
41
val x6 =
42
42
implicit def barToFoo4 (bar : Bar ): Foo =
43
- lazy val y = bar.toFoo // OK
43
+ lazy val y = bar.toFoo // error
44
44
if false then y else ???
45
45
val foo : Foo = Bar (1 )
46
46
Original file line number Diff line number Diff line change
1
+ class i13011 {
2
+ lazy implicit val simple1 : String = simple1 // error
3
+ def f : Unit = {
4
+ lazy val simple2 : String = simple2 // error
5
+ }
6
+
7
+ lazy val simple3 : String = if true then this .simple3 else " a" // error
8
+
9
+ lazy val simple4 : String = identity(this .simple4) // error
10
+
11
+ lazy val simple5 : String = { // error
12
+ this .simple5
13
+ " aa"
14
+ }
15
+
16
+ lazy val simple6 : Function0 [Any ] = () => this .simple6 // Ok
17
+ }
You can’t perform that action at this time.
0 commit comments