Skip to content

Commit 9173aba

Browse files
committed
Fix opaque types check
1 parent f38d86c commit 9173aba

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,8 @@ class Namer { typer: Typer =>
888888
val unsafeInfo = if (isDerived) rhsBodyType else abstracted(rhsBodyType)
889889

890890
def opaqueToBounds(info: Type): Type =
891-
if sym.isOpaqueAlias && info.typeParams.nonEmpty then
892-
report.error(em"opaque type alias must be fully applied", rhs.srcPos)
891+
if sym.isOpaqueAlias && info.typeParams.nonEmpty && info.hkResult.typeParams.nonEmpty then
892+
report.error(em"opaque type alias cannot have multiple type parameter lists", rhs.srcPos)
893893
sym.opaqueToBounds(info, rhs1, tparamSyms)
894894

895895
if (isDerived) sym.info = unsafeInfo

tests/neg/i9735.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
trait Two[A, B]
22

3-
opaque type U[A] = [B] =>> Two[A, B] // error: opaque type alias must be fully applied // error: cannot instantiate
4-
opaque type T[A] = [B] =>> String // error: opaque type alias must be fully applied
5-
opaque type S = [B] =>> String // error: opaque type alias must be fully applied
6-
3+
opaque type U[A] = [B] =>> Two[A, B] // error: opaque type alias cannot have multiple type parameter lists // error: cannot instantiate
4+
opaque type T = [A] =>> [B] =>> String // error: opaque type alias cannot have multiple type parameter lists
5+
opaque type S = [B] =>> String // ok
6+
opaque type IArray[+T] = Array[? <: T] // ok
7+
opaque type S2[B] = String // ok

0 commit comments

Comments
 (0)