Skip to content

Backport "Be even more careful when combining argument and info in computeAsSeenFrom" #16101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/i16049.scala
Original file line number Diff line number Diff line change
@@ -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] = ???
9 changes: 9 additions & 0 deletions tests/pos/i16076.scala
Original file line number Diff line number Diff line change
@@ -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())