Skip to content

Commit d25bd16

Browse files
authored
Backport "Be even more careful when combining argument and info in computeAsSeenFrom" (#16101)
Backports #16070
2 parents 8ccb2e3 + cf888c4 commit d25bd16

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-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] = ???

tests/pos/i16076.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Column[V]
2+
trait ColumnPath
3+
4+
trait ColumnFactory[V, C <: Column[V]]:
5+
def apply(columnPath: ColumnPath): C
6+
7+
object ColumnFactory:
8+
private def apply[V, C <: Column[V]](f: String => C): ColumnFactory[V, C] =
9+
columnPath => f(columnPath.toString())

0 commit comments

Comments
 (0)