File tree Expand file tree Collapse file tree 5 files changed +52
-7
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 5 files changed +52
-7
lines changed Original file line number Diff line number Diff line change @@ -247,11 +247,9 @@ object Implicits:
247247 candidates += Candidate (ref, ckind, level)
248248
249249 if considerExtension then
250- val tryExtension = tryCandidate(extensionOnly = true )
251- companionRefs.foreach(tryExtension)
250+ companionRefs.foreach(tryCandidate(extensionOnly = true ))
252251 if refs.nonEmpty then
253- val tryGiven = tryCandidate(extensionOnly = false )
254- refs.foreach(tryGiven)
252+ refs.foreach(tryCandidate(extensionOnly = false ))
255253 candidates.toList
256254 }
257255 }
@@ -1373,6 +1371,7 @@ trait Implicits:
13731371 if cand1.ref eq cand.ref then
13741372 lazy val wildTp = wildApprox(tp.widenExpr)
13751373 if belowByname && (wildTp <:< wildPt) then
1374+ fullyDefinedType(tp, " by-name implicit parameter" , span)
13761375 false
13771376 else if prev.typeSize > ptSize || prev.coveringSet != ptCoveringSet then
13781377 loop(outer, tp.isByName || belowByname)
Original file line number Diff line number Diff line change @@ -6,9 +6,7 @@ object Test {
66 implicit def case1 [F [_]](implicit t : => TC [F [Any ]]): TC [Tuple2K [[_] =>> Any , F , Any ]] = ???
77 implicit def case2 [A , F [_]](implicit r : TC [F [Any ]]): TC [A ] = ???
88
9- // Disabled because it leads to an infinite loop in implicit search
10- // this is probably the same issue as https://github.com/lampepfl/dotty/issues/9568
11- // implicitly[TC[Int]] // was: error
9+ implicitly[TC [Int ]] // typechecks because we infer F := Nothing (should we avoid inferring Nothing for higher-kinded types?)
1210}
1311
1412object Test1 {
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg/i9568.scala:13:10 ----------------------------------------------------------------------------------
2+ 13 | blaMonad.foo(bla) // error: diverges
3+ | ^
4+ |no implicit argument of type => Monad[([_$3] =>> Any)] was found for parameter ev of method blaMonad in object Test.
5+ |I found:
6+ |
7+ | Test.blaMonad[Nothing, S](Test.blaMonad[F, S])
8+ |
9+ |But method blaMonad in object Test does not match type => Monad[Nothing].
Original file line number Diff line number Diff line change 1+ trait Monad [F [_]] {
2+ def foo [A ](fa : F [A ]): Unit = {}
3+ }
4+
5+ class Bla [F [_], A ]
6+
7+ object Test {
8+ type Id [A ] = A
9+
10+ val bla : Bla [Id , Unit ] = ???
11+ implicit def blaMonad [F [_], S ](implicit ev : => Monad [F ]): Monad [({type L [X ] = Bla [F , X ]})# L ] = ???
12+
13+ blaMonad.foo(bla) // error: diverges
14+ }
Original file line number Diff line number Diff line change 1+ trait Monad [F [_]] {
2+ def foo [A ](fa : F [A ]): Unit = {}
3+ }
4+
5+ class Bla [F [_], A ]
6+
7+ object Test1 {
8+ type Id [A ] = A
9+
10+ val bla : Bla [Id , Unit ] = ???
11+ implicit def blaMonad [F [_]: Monad , S ]: Monad [({type L [X ] = Bla [F , X ]})# L ] = ???
12+ implicit def idMonad : Monad [Id ] = ???
13+
14+ blaMonad.foo(bla) // does not diverge
15+ }
16+
17+ object Test2 {
18+ type Id [A ] = A
19+
20+ val bla : Bla [Id , Unit ] = ???
21+ implicit def blaMonad [F [_], S ](implicit ev : => Monad [F ]): Monad [({type L [X ] = Bla [F , X ]})# L ] = ???
22+ implicit def idMonad : Monad [Id ] = ???
23+
24+ blaMonad.foo(bla) // does not diverge
25+ }
You can’t perform that action at this time.
0 commit comments