Skip to content
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
16 changes: 4 additions & 12 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2598,22 +2598,14 @@ object Types extends TypeUtils {
case _ => true
}

/** Reduce a type ref P # X, where X is a type alias and P is a refined type or
* a class type. If P is a refined type `T { X = U; ... }`, reduce P to U,
* provided U does not refer with a RecThis to the same refined type. If P is a
* class type, reduce it to the dealiasd version of P # X. This means that at typer
* we create projections only for inner classes with class prefixes, since projections
* of P # X where X is an abstract type are handled by skolemization. At later phases
* these projections might arise, though.
/** Reduce a type-ref `T { X = U; ... } # X` to `U`
* provided `U` does not refer with a RecThis to the
* refinement type `T { X = U; ... }`
*/
def reduceProjection(using Context): Type =
if (isType) {
val reduced = prefix.lookupRefined(name)
if reduced.exists then reduced
else prefix.stripTypeVar match
case pre: (AppliedType | TypeRef)
if prefix.dealias.typeSymbol.isClass && this.symbol.isAliasType => dealias
case _ => this
if reduced.exists then reduced else this
}
else this

Expand Down
26 changes: 0 additions & 26 deletions tests/pos/i19892.scala

This file was deleted.

3 changes: 3 additions & 0 deletions tests/run/i21576.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public SubFlow(SubFlowDef<Flow1<In>>,SubFlowDef<Flow2<java.lang.Object>>)
public SubFlowDef<Flow1<In>> SubFlow.delegate1()
public SubFlowDef<Flow2<java.lang.Object>> SubFlow.delegate2()
31 changes: 31 additions & 0 deletions tests/run/i21576.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// scalajs: --skip
import scala.annotation.unchecked.uncheckedVariance

trait SubFlowDef[+F[+_]]
final class Flow1[-In]{
type Repr[+O] = Flow1[In @uncheckedVariance]
}
final class Flow2[+Out]{
type Repr[+O] = Flow2[O]
}
class SubFlow[In, Out](
val delegate1: SubFlowDef[Flow1[In]#Repr],
val delegate2: SubFlowDef[Flow2[Out]#Repr]
)

object Test {
def main(args: Array[String]): Unit = {
classOf[SubFlow[?, ?]]
.getConstructors()
.map(_.toGenericString())
.sorted
.foreach(println)

classOf[SubFlow[?, ?]]
.getMethods()
.filter(_.getName().startsWith("delegate"))
.map(_.toGenericString())
.sorted
.foreach(println)
}
}
Loading