Skip to content

Commit 0666fec

Browse files
committed
Fix safeDealias
Providional type constructors are weird. They are still alias types but their RHS is a possibly parameterized TypeBounds between Nothing and Any. safeDealias should not "dealias" such a type to the upper bound `Any`.
1 parent b6b2d12 commit 0666fec

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

compiler/src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SymDenotations.LazyType
99
import Decorators._
1010
import util.Stats._
1111
import Names._
12-
import Flags.Module
12+
import Flags.{Module, Provisional}
1313
import dotty.tools.dotc.config.Config
1414

1515
object TypeApplications {
@@ -284,7 +284,8 @@ class TypeApplications(val self: Type) extends AnyVal {
284284

285285
/** Dealias type if it can be done without forcing the TypeRef's info */
286286
def safeDealias(using Context): Type = self match {
287-
case self: TypeRef if self.denot.exists && self.symbol.isAliasType =>
287+
case self: TypeRef
288+
if self.denot.exists && self.symbol.isAliasType && !self.symbol.flagsUNSAFE.is(Provisional) =>
288289
self.superType.stripTypeVar.safeDealias
289290
case _ =>
290291
self

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,10 +2035,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
20352035
// If it is an alias type, it would mean the type is cyclic
20362036
// If it is an abstract type, it would mean the type is an irreducible
20372037
// application of a higher-kinded type to a wildcard argument.
2038-
// Either way, the wildcard argument is illegal.
2039-
// The early test here is needed, so that we do not accidentally reduce
2040-
// an application of a Provisional type away so that the type constructor
2041-
// is no longer present on the roght hand side. See neg/i15507.scala.
2038+
// Either way, the wildcard argument is illegal. The early test of
2039+
// `checkNoWildcard` here is needed, so that we do not accidentally reduce
2040+
// an application of a Provisional type away, which would mean that the type constructor
2041+
// is no longer present on the right hand side. See neg/i15507.scala.
20422042
checkedArgs = checkedArgs.mapconserve(checkNoWildcard)
20432043
else if tycon == defn.throwsAlias
20442044
&& checkedArgs.length == 2

0 commit comments

Comments
 (0)