Skip to content

Commit d4cbc6a

Browse files
committed
Revert "Optimise SpaceEngine.signature for synthetic unapplies"
This reverts commit 6be6e3a.
1 parent 4b0eebf commit d4cbc6a

File tree

2 files changed

+5
-29
lines changed

2 files changed

+5
-29
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4636,7 +4636,6 @@ object Types extends TypeUtils {
46364636
type BT <: LambdaType
46374637
def paramNum: Int
46384638
def paramName: binder.ThisName = binder.paramNames(paramNum)
4639-
def paramInfo: binder.PInfo = binder.paramInfos(paramNum)
46404639

46414640
override def underlying(using Context): Type = {
46424641
// TODO: update paramInfos's type to nullable

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package patmat
55

66
import core.*, Constants.*, Contexts.*, Decorators.*, Flags.*, Names.*, NameOps.*, StdNames.*, Symbols.*, Types.*
77
import ast.*, tpd.*
8-
import config.Printers.exhaustivity
8+
import config.Printers.*
99
import printing.{ Printer, * }, Texts.*
1010
import reporting.*
1111
import typer.*, Applications.*, Inferencing.*, ProtoTypes.*
@@ -531,37 +531,14 @@ object SpaceEngine {
531531
val mt: MethodType = unapp.widen match {
532532
case mt: MethodType => mt
533533
case pt: PolyType =>
534-
scrutineeTp match
535-
case AppliedType(tycon, targs)
536-
if unappSym.is(Synthetic)
537-
&& (pt.resultType.asInstanceOf[MethodType].paramInfos.head.typeConstructor eq tycon) =>
538-
// Special case synthetic unapply/unapplySeq's
539-
// Provided the shapes of the types match:
540-
// the scrutinee type being unapplied and
541-
// the unapply parameter type
542-
pt.instantiate(targs).asInstanceOf[MethodType]
543-
case _ =>
544-
val locked = ctx.typerState.ownedVars
545534
val tvars = constrained(pt)
546535
val mt = pt.instantiate(tvars).asInstanceOf[MethodType]
547-
val unapplyArgType = mt.paramInfos.head
548-
scrutineeTp <:< unapplyArgType
536+
scrutineeTp <:< mt.paramInfos(0)
549537
// force type inference to infer a narrower type: could be singleton
550538
// see tests/patmat/i4227.scala
551-
unapplyArgType <:< scrutineeTp
552-
maximizeType(unapplyArgType, Spans.NoSpan)
553-
if !(ctx.typerState.ownedVars -- locked).isEmpty then
554-
// constraining can create type vars out of wildcard types
555-
// (in legalBound, by using a LevelAvoidMap)
556-
// maximise will only do one pass at maximising the type vars in the target type
557-
// which means we can maximise to types that include other type vars
558-
// this fails TreeChecker's "non-empty constraint at end of $fusedPhase" check
559-
// e.g. run-macros/string-context-implicits
560-
// I can't prove that a second call won't also create type vars,
561-
// but I'd rather have an unassigned new-new type var, than an infinite loop.
562-
// After all, there's nothing strictly "wrong" with unassigned type vars,
563-
// it just fails TreeChecker's linting.
564-
maximizeType(unapplyArgType, Spans.NoSpan)
539+
mt.paramInfos(0) <:< scrutineeTp
540+
instantiateSelected(mt, tvars)
541+
isFullyDefined(mt, ForceDegree.all)
565542
mt
566543
}
567544

0 commit comments

Comments
 (0)