Skip to content

Commit 51ff47a

Browse files
committed
Be even more careful when combining argument and info bounds in computeAsSeenFrom
1 parent afc6ce4 commit 51ff47a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,9 +1121,13 @@ object Denotations {
11211121
else if symbol.isAllOf(ClassTypeParam) then
11221122
val arg = symbol.typeRef.argForParam(pre, widenAbstract = true)
11231123
if arg.exists then
1124+
// take the argument bounds, but intersect with the symbols bounds if
1125+
// this forces nothing and gives a non-empty type.
11241126
val newBounds =
1125-
if symbol.isCompleted && !symbol.info.containsLazyRefs
1126-
then symbol.info.bounds & arg.bounds
1127+
if symbol.isCompleted && !symbol.info.containsLazyRefs then
1128+
val combined @ TypeBounds(lo, hi) = symbol.info.bounds & arg.bounds
1129+
if lo frozen_<:< hi then combined
1130+
else arg.bounds
11271131
else arg.bounds
11281132
derivedSingleDenotation(symbol, newBounds, pre)
11291133
else derived(symbol.info)

tests/pos/i16049.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
trait BatchDiffFunction[T]
2+
3+
abstract class FirstOrderMinimizer[T, DF <: BatchDiffFunction[T]]:
4+
type State = FirstOrderMinimizer.State[T]
5+
6+
object FirstOrderMinimizer:
7+
case class State[+T](x: T)
8+
9+
class OptParams:
10+
def iterations[T](init: T): Iterator[FirstOrderMinimizer[T, BatchDiffFunction[T]]#State] = ???

0 commit comments

Comments
 (0)