Skip to content

Commit f38d86c

Browse files
committed
Fix #9735: Tighten opaque types check
We already has a check that opaque type aliases must be fully applied, but that check did not kick in when the opaque type has type parameters.
1 parent 119e1de commit f38d86c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

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

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

tests/neg/i9735.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait Two[A, B]
2+
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+

0 commit comments

Comments
 (0)