From e4fed5c8e128e74f6b1bc5c59485ec219c9af2ca Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 17 Aug 2021 12:57:47 +0200 Subject: [PATCH] Revert "Merge pull request #12971 from dotty-staging/add-rechecker" This reverts commit 12cb6c5b2be709a776382921f90cf9015e50340a, reversing changes made to 3be078dfd06d0438cfaea44632947b7ec3b676ac. --- compiler/src/dotty/tools/dotc/Compiler.scala | 2 - .../dotty/tools/dotc/config/Printers.scala | 1 - .../tools/dotc/config/ScalaSettings.scala | 1 - .../src/dotty/tools/dotc/core/NamerOps.scala | 20 -- .../src/dotty/tools/dotc/core/Phases.scala | 3 - .../dotty/tools/dotc/core/TypeComparer.scala | 2 - .../tools/dotc/transform/PreRecheck.scala | 21 -- .../dotty/tools/dotc/transform/Recheck.scala | 334 ------------------ .../tools/dotc/typer/RefineTypes.overflow | 0 .../dotty/tools/dotc/typer/TypeAssigner.scala | 18 +- compiler/test/dotc/pos-test-recheck.excludes | 3 - compiler/test/dotc/run-test-recheck.excludes | 0 compiler/test/dotty/tools/TestSources.scala | 4 - .../dotty/tools/dotc/CompilationTests.scala | 21 +- .../tools/vulpix/TestConfiguration.scala | 1 - tests/neg/i6635a.scala | 19 - tests/pos/i6635.scala | 7 +- tests/pos/i6635a.scala | 14 - 18 files changed, 17 insertions(+), 454 deletions(-) delete mode 100644 compiler/src/dotty/tools/dotc/transform/PreRecheck.scala delete mode 100644 compiler/src/dotty/tools/dotc/transform/Recheck.scala delete mode 100644 compiler/src/dotty/tools/dotc/typer/RefineTypes.overflow delete mode 100644 compiler/test/dotc/pos-test-recheck.excludes delete mode 100644 compiler/test/dotc/run-test-recheck.excludes delete mode 100644 tests/neg/i6635a.scala delete mode 100644 tests/pos/i6635a.scala diff --git a/compiler/src/dotty/tools/dotc/Compiler.scala b/compiler/src/dotty/tools/dotc/Compiler.scala index e7e76d16a4f5..a051cba5ba05 100644 --- a/compiler/src/dotty/tools/dotc/Compiler.scala +++ b/compiler/src/dotty/tools/dotc/Compiler.scala @@ -101,8 +101,6 @@ class Compiler { new TupleOptimizations, // Optimize generic operations on tuples new LetOverApply, // Lift blocks from receivers of applications new ArrayConstructors) :: // Intercept creation of (non-generic) arrays and intrinsify. - List(new PreRecheck) :: - List(new TestRecheck) :: List(new Erasure) :: // Rewrite types to JVM model, erasing all type parameters, abstract types and refinements. List(new ElimErasedValueType, // Expand erased value types to their underlying implmementation types new PureStats, // Remove pure stats from blocks diff --git a/compiler/src/dotty/tools/dotc/config/Printers.scala b/compiler/src/dotty/tools/dotc/config/Printers.scala index b71e1e7f188a..8e13e50e59b7 100644 --- a/compiler/src/dotty/tools/dotc/config/Printers.scala +++ b/compiler/src/dotty/tools/dotc/config/Printers.scala @@ -38,7 +38,6 @@ object Printers { val pickling = noPrinter val quotePickling = noPrinter val plugins = noPrinter - val recheckr = noPrinter val refcheck = noPrinter val simplify = noPrinter val staging = noPrinter diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 19675ae5f981..e89c8b97aea8 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -239,7 +239,6 @@ private sealed trait YSettings: val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.") val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects") val YrequireTargetName: Setting[Boolean] = BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation") - val Yrecheck: Setting[Boolean] = BooleanSetting("-Yrecheck", "Run type rechecks (test only)") /** Area-specific debug output */ val YexplainLowlevel: Setting[Boolean] = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.") diff --git a/compiler/src/dotty/tools/dotc/core/NamerOps.scala b/compiler/src/dotty/tools/dotc/core/NamerOps.scala index a5d3e95c8f3e..9444270ccb05 100644 --- a/compiler/src/dotty/tools/dotc/core/NamerOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NamerOps.scala @@ -177,24 +177,4 @@ object NamerOps: cls.registeredCompanion = modcls modcls.registeredCompanion = cls - /** For secondary constructors, make it known in the context that their type parameters - * are aliases of the class type parameters. This is done by (ab?)-using GADT constraints. - * See pos/i941.scala - */ - def linkConstructorParams(sym: Symbol)(using Context): Context = - if sym.isConstructor && !sym.isPrimaryConstructor then - sym.rawParamss match - case (tparams @ (tparam :: _)) :: _ if tparam.isType => - val rhsCtx = ctx.fresh.setFreshGADTBounds - rhsCtx.gadt.addToConstraint(tparams) - tparams.lazyZip(sym.owner.typeParams).foreach { (psym, tparam) => - val tr = tparam.typeRef - rhsCtx.gadt.addBound(psym, tr, isUpper = false) - rhsCtx.gadt.addBound(psym, tr, isUpper = true) - } - rhsCtx - case _ => - ctx - else ctx - end NamerOps diff --git a/compiler/src/dotty/tools/dotc/core/Phases.scala b/compiler/src/dotty/tools/dotc/core/Phases.scala index 0294de01f36e..b1268d7034a9 100644 --- a/compiler/src/dotty/tools/dotc/core/Phases.scala +++ b/compiler/src/dotty/tools/dotc/core/Phases.scala @@ -295,9 +295,6 @@ object Phases { /** If set, implicit search is enabled */ def allowsImplicitSearch: Boolean = false - /** If set equate Skolem types with underlying types */ - def widenSkolems: Boolean = false - /** List of names of phases that should precede this phase */ def runsAfter: Set[String] = Set.empty diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 04463e68c0bd..b568cb2c8af8 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -745,8 +745,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling false } compareClassInfo - case tp2: SkolemType => - ctx.phase.widenSkolems && recur(tp1, tp2.info) || fourthTry case _ => fourthTry } diff --git a/compiler/src/dotty/tools/dotc/transform/PreRecheck.scala b/compiler/src/dotty/tools/dotc/transform/PreRecheck.scala deleted file mode 100644 index ab27bb3bb306..000000000000 --- a/compiler/src/dotty/tools/dotc/transform/PreRecheck.scala +++ /dev/null @@ -1,21 +0,0 @@ -package dotty.tools.dotc -package transform - -import core.Phases.Phase -import core.DenotTransformers.IdentityDenotTransformer -import core.Contexts.{Context, ctx} - -/** A phase that precedes the rechecker and that allows installing - * new types for local symbols. - */ -class PreRecheck extends Phase, IdentityDenotTransformer: - - def phaseName: String = "preRecheck" - - override def isEnabled(using Context) = next.isEnabled - - override def changesBaseTypes: Boolean = true - - def run(using Context): Unit = () - - override def isCheckable = false diff --git a/compiler/src/dotty/tools/dotc/transform/Recheck.scala b/compiler/src/dotty/tools/dotc/transform/Recheck.scala deleted file mode 100644 index 76f89cb65757..000000000000 --- a/compiler/src/dotty/tools/dotc/transform/Recheck.scala +++ /dev/null @@ -1,334 +0,0 @@ -package dotty.tools -package dotc -package transform - -import core.* -import Symbols.*, Contexts.*, Types.*, ContextOps.*, Decorators.*, SymDenotations.* -import Flags.*, SymUtils.*, NameKinds.* -import ast.* -import Phases.Phase -import DenotTransformers.IdentityDenotTransformer -import NamerOps.{methodType, linkConstructorParams} -import NullOpsDecorator.stripNull -import typer.ErrorReporting.err -import typer.ProtoTypes.* -import typer.TypeAssigner.seqLitType -import typer.ConstFold -import config.Printers.recheckr -import util.Property -import StdNames.nme -import reporting.trace - -abstract class Recheck extends Phase, IdentityDenotTransformer: - thisPhase => - - import ast.tpd.* - - def preRecheckPhase = this.prev.asInstanceOf[PreRecheck] - - override def isEnabled(using Context) = ctx.settings.Yrecheck.value - override def changesBaseTypes: Boolean = true - - override def isCheckable = false - // TODO: investigate what goes wrong we Ycheck directly after rechecking. - // One failing test is pos/i583a.scala - - override def widenSkolems = true - - def run(using Context): Unit = - newRechecker().checkUnit(ctx.compilationUnit) - - def newRechecker()(using Context): Rechecker - - class Rechecker(ictx: Context): - val ta = ictx.typeAssigner - - extension (sym: Symbol) def updateInfo(newInfo: Type)(using Context): Unit = - if sym.info ne newInfo then - sym.copySymDenotation().installAfter(thisPhase) // reset - sym.copySymDenotation( - info = newInfo, - initFlags = - if newInfo.isInstanceOf[LazyType] then sym.flags &~ Touched - else sym.flags - ).installAfter(preRecheckPhase) - - /** Hook to be overridden */ - protected def reinfer(tp: Type)(using Context): Type = tp - - def reinferResult(info: Type)(using Context): Type = info match - case info: MethodOrPoly => - info.derivedLambdaType(resType = reinferResult(info.resultType)) - case _ => - reinfer(info) - - def enterDef(stat: Tree)(using Context): Unit = - val sym = stat.symbol - stat match - case stat: ValOrDefDef if stat.tpt.isInstanceOf[InferredTypeTree] => - sym.updateInfo(reinferResult(sym.info)) - case stat: Bind => - sym.updateInfo(reinferResult(sym.info)) - case _ => - - def constFold(tree: Tree, tp: Type)(using Context): Type = - val tree1 = tree.withType(tp) - val tree2 = ConstFold(tree1) - if tree2 ne tree1 then tree2.tpe else tp - - def recheckIdent(tree: Ident)(using Context): Type = - tree.tpe - - /** Keep the symbol of the `select` but re-infer its type */ - def recheckSelect(tree: Select)(using Context): Type = tree match - case Select(qual, name) => - val qualType = recheck(qual).widenIfUnstable - if name.is(OuterSelectName) then tree.tpe - else - //val pre = ta.maybeSkolemizePrefix(qualType, name) - val mbr = qualType.findMember(name, qualType, - excluded = if tree.symbol.is(Private) then EmptyFlags else Private - ).suchThat(tree.symbol ==) - constFold(tree, qualType.select(name, mbr)) - - def recheckBind(tree: Bind, pt: Type)(using Context): Type = tree match - case Bind(name, body) => - enterDef(tree) - recheck(body, pt) - val sym = tree.symbol - if sym.isType then sym.typeRef else sym.info - - def recheckLabeled(tree: Labeled, pt: Type)(using Context): Type = tree match - case Labeled(bind, expr) => - val bindType = recheck(bind, pt) - val exprType = recheck(expr, defn.UnitType) - bindType - - def recheckValDef(tree: ValDef, sym: Symbol)(using Context): Type = - if !tree.rhs.isEmpty then recheck(tree.rhs, tree.symbol.info) - sym.termRef - - def recheckDefDef(tree: DefDef, sym: Symbol)(using Context): Type = - tree.paramss.foreach(_.foreach(enterDef)) - val rhsCtx = linkConstructorParams(sym) - if !tree.rhs.isEmpty && !sym.isInlineMethod && !sym.isEffectivelyErased then - recheck(tree.rhs, tree.symbol.localReturnType)(using rhsCtx) - sym.termRef - - def recheckTypeDef(tree: TypeDef, sym: Symbol)(using Context): Type = - recheck(tree.rhs) - sym.typeRef - - def recheckClassDef(tree: TypeDef, impl: Template, sym: ClassSymbol)(using Context): Type = - recheck(impl.constr) - impl.parentsOrDerived.foreach(recheck(_)) - recheck(impl.self) - recheckStats(impl.body) - sym.typeRef - - // Need to remap Object to FromJavaObject since it got lost in ElimRepeated - private def mapJavaArgs(formals: List[Type])(using Context): List[Type] = - val tm = new TypeMap: - def apply(t: Type) = t match - case t: TypeRef if t.symbol == defn.ObjectClass => defn.FromJavaObjectType - case _ => mapOver(t) - formals.mapConserve(tm) - - def recheckApply(tree: Apply, pt: Type)(using Context): Type = - recheck(tree.fun).widen match - case fntpe: MethodType => - assert(sameLength(fntpe.paramInfos, tree.args)) - val formals = - if tree.symbol.is(JavaDefined) then mapJavaArgs(fntpe.paramInfos) - else fntpe.paramInfos - def recheckArgs(args: List[Tree], formals: List[Type], prefs: List[ParamRef]): List[Type] = args match - case arg :: args1 => - val argType = recheck(arg, formals.head) - val formals1 = - if fntpe.isParamDependent - then formals.tail.map(_.substParam(prefs.head, argType)) - else formals.tail - argType :: recheckArgs(args1, formals1, prefs.tail) - case Nil => - assert(formals.isEmpty) - Nil - val argTypes = recheckArgs(tree.args, formals, fntpe.paramRefs) - constFold(tree, fntpe.instantiate(argTypes)) - - def recheckTypeApply(tree: TypeApply, pt: Type)(using Context): Type = - recheck(tree.fun).widen match - case fntpe: PolyType => - assert(sameLength(fntpe.paramInfos, tree.args)) - val argTypes = tree.args.map(recheck(_)) - constFold(tree, fntpe.instantiate(argTypes)) - - def recheckTyped(tree: Typed)(using Context): Type = - val tptType = recheck(tree.tpt) - recheck(tree.expr, tptType) - tptType - - def recheckAssign(tree: Assign)(using Context): Type = - val lhsType = recheck(tree.lhs) - recheck(tree.rhs, lhsType.widen) - defn.UnitType - - def recheckBlock(stats: List[Tree], expr: Tree, pt: Type)(using Context): Type = - recheckStats(stats) - val exprType = recheck(expr, pt.dropIfProto) - TypeOps.avoid(exprType, localSyms(stats).filterConserve(_.isTerm)) - - def recheckBlock(tree: Block, pt: Type)(using Context): Type = - recheckBlock(tree.stats, tree.expr, pt) - - def recheckInlined(tree: Inlined, pt: Type)(using Context): Type = - recheckBlock(tree.bindings, tree.expansion, pt) - - def recheckIf(tree: If, pt: Type)(using Context): Type = - recheck(tree.cond, defn.BooleanType) - recheck(tree.thenp, pt) | recheck(tree.elsep, pt) - - def recheckClosure(tree: Closure, pt: Type)(using Context): Type = - if tree.tpt.isEmpty then - tree.meth.tpe.widen.toFunctionType(tree.meth.symbol.is(JavaDefined)) - else - recheck(tree.tpt) - - def recheckMatch(tree: Match, pt: Type)(using Context): Type = - val selectorType = recheck(tree.selector) - val casesTypes = tree.cases.map(recheck(_, selectorType.widen, pt)) - TypeComparer.lub(casesTypes) - - def recheck(tree: CaseDef, selType: Type, pt: Type)(using Context): Type = - recheck(tree.pat, selType) - recheck(tree.guard, defn.BooleanType) - recheck(tree.body, pt) - - def recheckReturn(tree: Return)(using Context): Type = - recheck(tree.expr, tree.from.symbol.returnProto) - defn.NothingType - - def recheckWhileDo(tree: WhileDo)(using Context): Type = - recheck(tree.cond, defn.BooleanType) - recheck(tree.body, defn.UnitType) - defn.UnitType - - def recheckTry(tree: Try, pt: Type)(using Context): Type = - val bodyType = recheck(tree.expr, pt) - val casesTypes = tree.cases.map(recheck(_, defn.ThrowableType, pt)) - val finalizerType = recheck(tree.finalizer, defn.UnitType) - TypeComparer.lub(bodyType :: casesTypes) - - def recheckSeqLiteral(tree: SeqLiteral, pt: Type)(using Context): Type = - val elemProto = pt.stripNull.elemType match - case NoType => WildcardType - case bounds: TypeBounds => WildcardType(bounds) - case elemtp => elemtp - val declaredElemType = recheck(tree.elemtpt) - val elemTypes = tree.elems.map(recheck(_, elemProto)) - seqLitType(tree, TypeComparer.lub(declaredElemType :: elemTypes)) - - def recheckTypeTree(tree: TypeTree)(using Context): Type = tree match - case tree: InferredTypeTree => reinfer(tree.tpe) - case _ => tree.tpe - - def recheckAnnotated(tree: Annotated)(using Context): Type = - tree.tpe match - case tp: AnnotatedType => - val argType = recheck(tree.arg) - tp.derivedAnnotatedType(argType, tp.annot) - - def recheckAlternative(tree: Alternative, pt: Type)(using Context): Type = - val altTypes = tree.trees.map(recheck(_, pt)) - TypeComparer.lub(altTypes) - - def recheckPackageDef(tree: PackageDef)(using Context): Type = - recheckStats(tree.stats) - NoType - - def recheckStats(stats: List[Tree])(using Context): Unit = - stats.foreach(enterDef) - stats.foreach(recheck(_)) - - /** Recheck tree without adapting it, returning its new type. - * @param tree the original tree - * @param pt the expected result type - */ - 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 - tree match - case tree: Ident => recheckIdent(tree) - case tree: Select => recheckSelect(tree) - case tree: Bind => recheckBind(tree, pt) - case tree: ValDef => - if tree.isEmpty then NoType - else recheckValDef(tree, sym)(using ctx.localContext(tree, sym)) - case tree: DefDef => - recheckDefDef(tree, sym)(using ctx.localContext(tree, sym)) - case tree: TypeDef => - tree.rhs match - case impl: Template => - recheckClassDef(tree, impl, sym.asClass)(using ctx.localContext(tree, sym)) - case _ => - recheckTypeDef(tree, sym)(using ctx.localContext(tree, sym)) - case tree: Labeled => recheckLabeled(tree, pt) - - def recheckUnnamed(tree: Tree, pt: Type): Type = tree match - case tree: Apply => recheckApply(tree, pt) - case tree: TypeApply => recheckTypeApply(tree, pt) - case _: New | _: This | _: Super | _: Literal => tree.tpe - case tree: Typed => recheckTyped(tree) - case tree: Assign => recheckAssign(tree) - case tree: Block => recheckBlock(tree, pt) - case tree: If => recheckIf(tree, pt) - case tree: Closure => recheckClosure(tree, pt) - case tree: Match => recheckMatch(tree, pt) - case tree: Return => recheckReturn(tree) - case tree: WhileDo => recheckWhileDo(tree) - case tree: Try => recheckTry(tree, pt) - case tree: SeqLiteral => recheckSeqLiteral(tree, pt) - case tree: Inlined => recheckInlined(tree, pt) - case tree: TypeTree => recheckTypeTree(tree) - case tree: Annotated => recheckAnnotated(tree) - case tree: Alternative => recheckAlternative(tree, pt) - case tree: PackageDef => recheckPackageDef(tree) - case tree: Thicket => defn.NothingType - - try - val result = tree match - case tree: NameTree => recheckNamed(tree, pt) - case tree => recheckUnnamed(tree, pt) - checkConforms(result, pt, tree) - result - catch case ex: Exception => - println(i"error while rechecking $tree") - throw ex - } - end recheck - - def checkConforms(tpe: Type, pt: Type, tree: Tree)(using Context): Unit = tree match - case _: DefTree | EmptyTree | _: TypeTree => - case _ => - 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 - println(i"err at ${ctx.phase}") - err.typeMismatch(tree.withType(tpe), pt) - - def checkUnit(unit: CompilationUnit)(using Context): Unit = - recheck(unit.tpdTree) - - end Rechecker -end Recheck - -class TestRecheck extends Recheck: - def phaseName: String = "recheck" - //override def isEnabled(using Context) = ctx.settings.YrefineTypes.value - def newRechecker()(using Context): Rechecker = Rechecker(ctx) - - diff --git a/compiler/src/dotty/tools/dotc/typer/RefineTypes.overflow b/compiler/src/dotty/tools/dotc/typer/RefineTypes.overflow deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index 2a5a9ca284ac..f7e33bd4a5f7 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -17,8 +17,7 @@ import reporting._ import Checking.{checkNoPrivateLeaks, checkNoWildcard} trait TypeAssigner { - import tpd.* - import TypeAssigner.* + import tpd._ /** The qualifying class of a this or super with prefix `qual` (which might be empty). * @param packageOk The qualifier may refer to a package. @@ -436,8 +435,13 @@ trait TypeAssigner { if (cases.isEmpty) tree.withType(expr.tpe) else tree.withType(TypeComparer.lub(expr.tpe :: cases.tpes)) - def assignType(tree: untpd.SeqLiteral, elems: List[Tree], elemtpt: Tree)(using Context): SeqLiteral = - tree.withType(seqLitType(tree, elemtpt.tpe)) + def assignType(tree: untpd.SeqLiteral, elems: List[Tree], elemtpt: Tree)(using Context): SeqLiteral = { + val ownType = tree match { + case tree: untpd.JavaSeqLiteral => defn.ArrayOf(elemtpt.tpe) + case _ => if (ctx.erasedTypes) defn.SeqType else defn.SeqType.appliedTo(elemtpt.tpe) + } + tree.withType(ownType) + } def assignType(tree: untpd.SingletonTypeTree, ref: Tree)(using Context): SingletonTypeTree = tree.withType(ref.tpe) @@ -523,9 +527,5 @@ trait TypeAssigner { tree.withType(pid.symbol.termRef) } -object TypeAssigner extends TypeAssigner: - def seqLitType(tree: untpd.SeqLiteral, elemType: Type)(using Context) = tree match - case tree: untpd.JavaSeqLiteral => defn.ArrayOf(elemType) - case _ => if ctx.erasedTypes then defn.SeqType else defn.SeqType.appliedTo(elemType) - +object TypeAssigner extends TypeAssigner diff --git a/compiler/test/dotc/pos-test-recheck.excludes b/compiler/test/dotc/pos-test-recheck.excludes deleted file mode 100644 index e973b2cd529f..000000000000 --- a/compiler/test/dotc/pos-test-recheck.excludes +++ /dev/null @@ -1,3 +0,0 @@ -# Cannot compensate dealiasing due to false result dependency -i6635a.scala -i6682a.scala diff --git a/compiler/test/dotc/run-test-recheck.excludes b/compiler/test/dotc/run-test-recheck.excludes deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/compiler/test/dotty/tools/TestSources.scala b/compiler/test/dotty/tools/TestSources.scala index 60070bb15af3..4fbf0e9fc5dd 100644 --- a/compiler/test/dotty/tools/TestSources.scala +++ b/compiler/test/dotty/tools/TestSources.scala @@ -11,21 +11,17 @@ object TestSources { def posFromTastyBlacklistFile: String = "compiler/test/dotc/pos-from-tasty.blacklist" def posTestPicklingBlacklistFile: String = "compiler/test/dotc/pos-test-pickling.blacklist" - def posTestRecheckExcludesFile = "compiler/test/dotc/pos-test-recheck.excludes" def posFromTastyBlacklisted: List[String] = loadList(posFromTastyBlacklistFile) def posTestPicklingBlacklisted: List[String] = loadList(posTestPicklingBlacklistFile) - def posTestRecheckExcluded = loadList(posTestRecheckExcludesFile) // run tests lists def runFromTastyBlacklistFile: String = "compiler/test/dotc/run-from-tasty.blacklist" def runTestPicklingBlacklistFile: String = "compiler/test/dotc/run-test-pickling.blacklist" - def runTestRecheckExcludesFile = "compiler/test/dotc/run-test-recheck.excludes" def runFromTastyBlacklisted: List[String] = loadList(runFromTastyBlacklistFile) def runTestPicklingBlacklisted: List[String] = loadList(runTestPicklingBlacklistFile) - def runTestRecheckExcluded = loadList(runTestRecheckExcludesFile) // load lists diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index d06c9f0ca484..d896afa3ea28 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -221,20 +221,9 @@ class CompilationTests { ).checkCompile() } - @Test def recheck: Unit = - given TestGroup = TestGroup("recheck") - aggregateTests( - compileFilesInDir("tests/new", recheckOptions), - compileFilesInDir("tests/pos", recheckOptions, FileFilter.exclude(TestSources.posTestRecheckExcluded)), - compileFilesInDir("tests/run", recheckOptions, FileFilter.exclude(TestSources.runTestRecheckExcluded)) - ).checkCompile() - - - /** This test serves several purposes: - * - being able to compile dotty bootstrapped, - * - making sure that TASTY can link against a compiled version of Dotty, - * - compiling the compiler using the SemanticDB generation - * - compiling the compiler under -Yrecheck mode. + /** The purpose of this test is three-fold, being able to compile dotty + * bootstrapped, and making sure that TASTY can link against a compiled + * version of Dotty, and compiling the compiler using the SemanticDB generation */ @Test def tastyBootstrap: Unit = { implicit val testGroup: TestGroup = TestGroup("tastyBootstrap/tests") @@ -258,7 +247,7 @@ class CompilationTests { Properties.compilerInterface, Properties.scalaLibrary, Properties.scalaAsm, Properties.dottyInterfaces, Properties.jlineTerminal, Properties.jlineReader, ).mkString(File.pathSeparator), - Array("-Ycheck-reentrant", "-Yrecheck", "-language:postfixOps", "-Xsemanticdb") + Array("-Ycheck-reentrant", "-language:postfixOps", "-Xsemanticdb") ) val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-bootstrapped")) @@ -266,7 +255,7 @@ class CompilationTests { val lib = compileList("lib", librarySources, - defaultOptions.and("-Ycheck-reentrant", "-Yrecheck", + defaultOptions.and("-Ycheck-reentrant", "-language:experimental.erasedDefinitions", // support declaration of scala.compiletime.erasedValue // "-source", "future", // TODO: re-enable once we allow : @unchecked in pattern definitions. Right now, lots of narrowing pattern definitions fail. ))(libGroup) diff --git a/compiler/test/dotty/tools/vulpix/TestConfiguration.scala b/compiler/test/dotty/tools/vulpix/TestConfiguration.scala index f2e33ae8ff65..caa7bc911633 100644 --- a/compiler/test/dotty/tools/vulpix/TestConfiguration.scala +++ b/compiler/test/dotty/tools/vulpix/TestConfiguration.scala @@ -79,7 +79,6 @@ object TestConfiguration { ) val picklingWithCompilerOptions = picklingOptions.withClasspath(withCompilerClasspath).withRunClasspath(withCompilerClasspath) - val recheckOptions = defaultOptions.and("-Yrecheck") val scala2CompatMode = defaultOptions.and("-source", "3.0-migration") val explicitUTF8 = defaultOptions and ("-encoding", "UTF8") val explicitUTF16 = defaultOptions and ("-encoding", "UTF16") diff --git a/tests/neg/i6635a.scala b/tests/neg/i6635a.scala deleted file mode 100644 index a79ea4e7c818..000000000000 --- a/tests/neg/i6635a.scala +++ /dev/null @@ -1,19 +0,0 @@ -object Test { - abstract class ExprBase { s => - type A - } - - abstract class Lit extends ExprBase { s => - type A = Int - val n: A - } - - // It would be nice if the following could typecheck. We'd need to apply - // a reasoning like this: - // - // Since there is an argument `e2` of type `Lit & e1.type`, it follows that - // e1.type == e2.type Hence, e1.A == e2.A == Int. This looks similar - // to techniques used in GADTs. - // - def castTestFail2a(e1: ExprBase)(e2: Lit & e1.type)(x: e1.A): Int = x // error: Found: (x : e1.A) Required: Int -} diff --git a/tests/pos/i6635.scala b/tests/pos/i6635.scala index 406eee6251e6..dacd1ef5cd8b 100644 --- a/tests/pos/i6635.scala +++ b/tests/pos/i6635.scala @@ -27,12 +27,11 @@ object Test { def castTest5a(e1: ExprBase)(e2: LitU with e1.type)(x: e2.A): e1.A = x def castTest5b(e1: ExprBase)(e2: LitL with e1.type)(x: e2.A): e1.A = x + //fail: def castTestFail1(e1: ExprBase)(e2: Lit with e1.type)(x: e2.A): e1.A = x // this is like castTest5a/b, but with Lit instead of LitU/LitL - - // The next example fails rechecking. It is repeated in i6635a.scala - // def castTestFail2a(e1: ExprBase)(e2: Lit with e1.type)(x: e1.A): e2.A = x + // the other direction never works: + def castTestFail2a(e1: ExprBase)(e2: Lit with e1.type)(x: e1.A): e2.A = x def castTestFail2b(e1: ExprBase)(e2: LitL with e1.type)(x: e1.A): e2.A = x - def castTestFail2c(e1: ExprBase)(e2: LitU with e1.type)(x: e1.A): e2.A = x // the problem isn't about order of intersections. diff --git a/tests/pos/i6635a.scala b/tests/pos/i6635a.scala deleted file mode 100644 index 9454e03e3a4a..000000000000 --- a/tests/pos/i6635a.scala +++ /dev/null @@ -1,14 +0,0 @@ -object Test { - abstract class ExprBase { s => - type A - } - - abstract class Lit extends ExprBase { s => - type A = Int - val n: A - } - - // Fails recheck since the result type e2.A is converted to Int to avoid - // a false dependency on e2. - def castTestFail2a(e1: ExprBase)(e2: Lit with e1.type)(x: e1.A): e2.A = x -}