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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2680,7 +2680,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
val tpt1 = withoutMode(Mode.Pattern):
typed(tree.tpt, AnyTypeConstructorProto)

val tparams = tpt1.tpe.typeParams
val tparams = tpt1.tpe.dealiasKeepAnnotsAndOpaques.typeParams
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been playing with some examples. In all of them, typeParams was able to return the actual typeParams but the top level case (the issue this tries to solve) without the dealiasing. Which means that in the contract of typeParams, it should be able to return the actual params without dealiasing at all. I think it's still worth investigating and fixing such that we don't need the dealiasing here.

if tpt1.tpe.isError then
val args1 = tree.args.mapconserve(typedType(_))
assignType(cpy.AppliedTypeTree(tree)(tpt1, args1), tpt1, args1)
Expand Down
14 changes: 14 additions & 0 deletions tests/pos/i23752.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trait MyOutput[T]
final type MyOutputAlias1[T] = MyOutput[T]
final type MyOutputAlias2 = MyOutput

trait MyType
object MyType {
val value1: MyOutput[MyType] = ???
val value2: MyOutputAlias1[MyType] = ???
val value3: MyOutputAlias2[MyType] = ??? // was COMPILATION ERROR
}

val value1: MyOutput[MyType] = ???
val value2: MyOutputAlias1[MyType] = ???
val value3: MyOutputAlias2[MyType] = ???
7 changes: 7 additions & 0 deletions tests/pos/i23752min.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trait MyOutput[T]
type MyOutputAlias2 = MyOutput

object MyType:
val v: MyOutputAlias2[String] = ??? // was COMPILATION ERROR

@main def Test = ()
Loading