Skip to content

Commit

Permalink
Fix checkConforms test in Recheck
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Aug 13, 2021
1 parent 72961a8 commit 78d40de
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions compiler/src/dotty/tools/dotc/transform/Recheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class Recheck extends Phase, IdentityDenotTransformer:
def run(using Context): Unit =
val unit = ctx.compilationUnit
//println(i"recheck types of $unit")
newRechecker().check()
newRechecker().checkUnit(unit)

def newRechecker()(using Context): Rechecker

Expand Down Expand Up @@ -248,7 +248,7 @@ abstract class Recheck extends Phase, IdentityDenotTransformer:
* @param locked the set of type variables of the current typer state that cannot be interpolated
* at the present time
*/
def recheck(tree: Tree, pt: Type = WildcardType)(using Context): Type = trace(i"rechecking $tree, ${tree.getClass} with $pt", recheckr, show = true) {
def recheck(tree: Tree, pt: Type = WildcardType)(using Context): Type = trace(i"rechecking $tree with pt = $pt", recheckr, show = true) {

def recheckNamed(tree: NameTree, pt: Type)(using Context): Type =
val sym = tree.symbol
Expand Down Expand Up @@ -305,17 +305,16 @@ abstract class Recheck extends Phase, IdentityDenotTransformer:
def checkConforms(tpe: Type, pt: Type, tree: Tree)(using Context): Unit = tree match
case _: DefTree | EmptyTree | _: TypeTree =>
case _ =>
val actual = tree.tpe.widenExpr
val actual = tpe.widenExpr
val expected = pt.widenExpr
val isCompatible =
actual <:< expected
|| expected.isRepeatedParam
&& actual <:< expected.translateFromRepeated(toArray = tree.tpe.isRef(defn.ArrayClass))
if !isCompatible then
err.typeMismatch(tree, pt)
err.typeMismatch(tree.withType(tpe), pt)

def check()(using Context): Unit =
val unit = ictx.compilationUnit
def checkUnit(unit: CompilationUnit)(using Context): Unit =
recheck(unit.tpdTree)

end Rechecker
Expand Down

0 comments on commit 78d40de

Please sign in to comment.