File tree 2 files changed +36
-3
lines changed
compiler/src/dotty/tools/dotc/transform
tests/neg-custom-args/fatal-warnings 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,10 @@ class CheckLoopingImplicits extends MiniPhase:
46
46
case Apply (fn, args) =>
47
47
checkNotLooping(fn)
48
48
fn.tpe.widen match
49
- case mt : MethodType =>
49
+ case mt : MethodType
50
+ // Boolean && and || aren't defined with by-name parameters
51
+ // and therefore their type isn't an ExprType, so we exempt them by symbol name
52
+ if t.symbol != defn.Boolean_&& && t.symbol != defn.Boolean_|| =>
50
53
args.lazyZip(mt.paramInfos).foreach { (arg, pinfo) =>
51
54
if ! pinfo.isInstanceOf [ExprType ] then checkNotLooping(arg)
52
55
}
@@ -80,8 +83,8 @@ class CheckLoopingImplicits extends MiniPhase:
80
83
checkNotLooping(t.rhs)
81
84
case _ =>
82
85
83
- if sym.isOneOf(GivenOrImplicit | Lazy ) then
86
+ if sym.isOneOf(GivenOrImplicit | Lazy | ExtensionMethod ) then
84
87
checkNotLooping(mdef.rhs)
85
88
mdef
86
89
end transform
87
- end CheckLoopingImplicits
90
+ end CheckLoopingImplicits
Original file line number Diff line number Diff line change
1
+ opaque type Bytes = Array [Byte ]
2
+ object Bytes :
3
+ extension (self : Bytes )
4
+ def size : Int = (self : Array [Byte ]).size // error
5
+
6
+ //
7
+
8
+ object Module1 :
9
+ opaque type State [S , + A ] = S => (S , A )
10
+ object State :
11
+ extension [S , A ](self : State [S , A ])
12
+ def map [B ](f : A => B ): State [S , B ] =
13
+ s => { val (s2, a) = self(s); (s2, f(a)) }
14
+ object Module2 :
15
+ import Module1 .State
16
+ trait RNG
17
+ opaque type Gen [+ A ] = State [RNG , A ]
18
+ object Gen :
19
+ extension [A ](self : Gen [A ])
20
+ def map [B ](f : A => B ): Gen [B ] =
21
+ self.map(f) // error
22
+
23
+ //
24
+
25
+ class Sym (val owner : Sym )
26
+
27
+ extension (sym : Sym )
28
+ def isSomething : Boolean = false
29
+ def isFoo : Boolean = sym.isSomething && sym.owner.isFoo // was: Infinite loop in function body
30
+ def isBar : Boolean = sym.isSomething || sym.owner.isBar // was: Infinite loop in function body
You can’t perform that action at this time.
0 commit comments