diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index a35f4d4c20c4..4366515b8ce3 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -1121,9 +1121,13 @@ object Denotations { else if symbol.isAllOf(ClassTypeParam) then val arg = symbol.typeRef.argForParam(pre, widenAbstract = true) if arg.exists then + // take the argument bounds, but intersect with the symbols bounds if + // this forces nothing and gives a non-empty type. val newBounds = - if symbol.isCompleted && !symbol.info.containsLazyRefs - then symbol.info.bounds & arg.bounds + if symbol.isCompleted && !symbol.info.containsLazyRefs then + val combined @ TypeBounds(lo, hi) = symbol.info.bounds & arg.bounds + if lo frozen_<:< hi then combined + else arg.bounds else arg.bounds derivedSingleDenotation(symbol, newBounds, pre) else derived(symbol.info) diff --git a/tests/pos/i16049.scala b/tests/pos/i16049.scala new file mode 100644 index 000000000000..8cb84eb7f217 --- /dev/null +++ b/tests/pos/i16049.scala @@ -0,0 +1,10 @@ +trait BatchDiffFunction[T] + +abstract class FirstOrderMinimizer[T, DF <: BatchDiffFunction[T]]: + type State = FirstOrderMinimizer.State[T] + +object FirstOrderMinimizer: + case class State[+T](x: T) + + class OptParams: + def iterations[T](init: T): Iterator[FirstOrderMinimizer[T, BatchDiffFunction[T]]#State] = ??? \ No newline at end of file diff --git a/tests/pos/i16076.scala b/tests/pos/i16076.scala new file mode 100644 index 000000000000..8347f0094a2c --- /dev/null +++ b/tests/pos/i16076.scala @@ -0,0 +1,9 @@ +trait Column[V] +trait ColumnPath + +trait ColumnFactory[V, C <: Column[V]]: + def apply(columnPath: ColumnPath): C + +object ColumnFactory: + private def apply[V, C <: Column[V]](f: String => C): ColumnFactory[V, C] = + columnPath => f(columnPath.toString())