diff --git a/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala b/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala index 530883f3cabf..dd390fb09ace 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala @@ -351,7 +351,9 @@ class ShortenedTypePrinter( val paramLabelss = label(methodParams) val extLabelss = label(extParams) - val returnType = tpe(gtpe.finalResultType) + val retType = gtpe.finalResultType + val simplified = if (retType.typeSymbol.isAliasType) retType else retType.deepDealiasAndSimplify + val returnType = tpe(simplified) def extensionSignatureString = val extensionSignature = paramssString(extLabelss, extParams) if extParams.nonEmpty then diff --git a/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala b/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala index 5b6522211767..15715143b217 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala @@ -407,13 +407,13 @@ object InteractiveEnrichments extends CommonMtagsEnrichments: case app @ AppliedType(tycon, params) => AppliedType(tycon, params.map(_.deepDealiasAndSimplify)) case aliasingBounds: AliasingBounds => - aliasingBounds.derivedAlias(aliasingBounds.alias.dealias) + aliasingBounds.derivedAlias(aliasingBounds.alias.deepDealiasAndSimplify) case TypeBounds(lo, hi) => TypeBounds(lo.dealias, hi.dealias) case RefinedType(parent, name, refinedInfo) => RefinedType(parent.dealias, name, refinedInfo.deepDealiasAndSimplify) case dealised => dealised - if tpe.isNamedTupleType then dealiased.simplified else dealiased + dealiased.simplified extension[T] (list: List[T]) def get(n: Int): Option[T] = if 0 <= n && n < list.size then Some(list(n)) else None diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala index 0bad5f41348d..a48b0b34b320 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala @@ -94,18 +94,18 @@ class CompletionSuite extends BaseCompletionSuite: |newBuilder[A]: Builder[A, List[A]] |apply[A](elems: A*): List[A] |concat[A](xss: Iterable[A]*): List[A] - |fill[A](n1: Int, n2: Int)(elem: => A): List[List[A] @uncheckedVariance] - |fill[A](n1: Int, n2: Int, n3: Int)(elem: => A): List[List[List[A]] @uncheckedVariance] - |fill[A](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => A): List[List[List[List[A]]] @uncheckedVariance] - |fill[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => A): List[List[List[List[List[A]]]] @uncheckedVariance] + |fill[A](n1: Int, n2: Int)(elem: => A): List[List[A]] + |fill[A](n1: Int, n2: Int, n3: Int)(elem: => A): List[List[List[A]]] + |fill[A](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => A): List[List[List[List[A]]]] + |fill[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => A): List[List[List[List[List[A]]]]] |fill[A](n: Int)(elem: => A): List[A] |iterate[A](start: A, len: Int)(f: A => A): List[A] |range[A: Integral](start: A, end: A): List[A] |range[A: Integral](start: A, end: A, step: A): List[A] - |tabulate[A](n1: Int, n2: Int)(f: (Int, Int) => A): List[List[A] @uncheckedVariance] - |tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => A): List[List[List[A]] @uncheckedVariance] - |tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => A): List[List[List[List[A]]] @uncheckedVariance] - |tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) => A): List[List[List[List[List[A]]]] @uncheckedVariance] + |tabulate[A](n1: Int, n2: Int)(f: (Int, Int) => A): List[List[A]] + |tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => A): List[List[List[A]]] + |tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => A): List[List[List[List[A]]]] + |tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) => A): List[List[List[List[List[A]]]]] |tabulate[A](n: Int)(f: Int => A): List[A] |unapplySeq[A](x: List[A] @uncheckedVariance): UnapplySeqWrapper[A] |unfold[A, S](init: S)(f: S => Option[(A, S)]): List[A] @@ -116,7 +116,7 @@ class CompletionSuite extends BaseCompletionSuite: |ensuring(cond: List.type => Boolean, msg: => Any): List.type |fromSpecific(from: Any)(it: IterableOnce[Nothing]): List[Nothing] |fromSpecific(it: IterableOnce[Nothing]): List[Nothing] - |nn: List.type & List.type + |nn: List.type |runtimeChecked scala.collection.immutable |toFactory(from: Any): Factory[Nothing, List[Nothing]] |formatted(fmtstr: String): String diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionTypeSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionTypeSuite.scala index 46760b5d9465..b74041450cdf 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionTypeSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionTypeSuite.scala @@ -21,3 +21,33 @@ class CompletionTypeSuite extends BaseCompletionSuite: s"""|method[T <: FS](a: T): Nothing |""".stripMargin ) + + @Test def `long-types-match` = + check( + s"""|@main + |def run = + | (1, 2).to@@ + |""".stripMargin, + s"""|toString(): String + |toArray: Array[Object] + |toIArray: IArray[Object] + |toList: List[Int] + |productIterator: Iterator[Any] + |asInstanceOf[X0]: X0 + |isInstanceOf[X0]: Boolean + |""".stripMargin + ) + + @Test def `union-types` = + check( + s"""| + |def itsAUnionType(): Int | String = ??? + | + |def hello = + | its@@ + | + | + |""".stripMargin, + s"""|itsAUnionType(): Int | String + |""".stripMargin + )