Skip to content

MatchError when using refutable extractor #15650

Closed
@griggt

Description

@griggt

Minimized from the community build failure of erikerlandson/coulomb reported in #15647

Compiler version

3.2.0-RC2
Works in 3.1.3

Minimized code

class Rational

import scala.quoted.*

object meta:
  object rationalTE:
    def unapply(using Quotes)(tr: quotes.reflect.TypeRepr): Option[Rational] = ???

  def foo(using Quotes)(p: quotes.reflect.TypeRepr): Unit =
    val rationalTE(e) = p

Output (click arrow to expand)

exception occurred while typechecking meta.scala
exception occurred while compiling meta.scala
scala.MatchError: Apply(Select(Ident(rationalTE),unapply),List(Ident(x$1))) (of class dotty.tools.dotc.ast.Trees$Apply) while compiling meta.scala
Exception in thread "main" scala.MatchError: Apply(Select(Ident(rationalTE),unapply),List(Ident(x$1))) (of class dotty.tools.dotc.ast.Trees$Apply)
	at dotty.tools.dotc.typer.Checking.fail$1(Checking.scala:821)
	at dotty.tools.dotc.typer.Checking.recur$1(Checking.scala:860)
	at dotty.tools.dotc.typer.Checking.checkIrrefutable(Checking.scala:874)
	at dotty.tools.dotc.typer.Checking.checkIrrefutable$(Checking.scala:776)
	at dotty.tools.dotc.typer.Typer.checkIrrefutable(Typer.scala:117)
	at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:1612)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2873)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1618)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1608)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1618)
	at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1866)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:248)
	at dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:1866)
	at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1874)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1892)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1893)
	at dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1904)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1657)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1664)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:782)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:921)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:809)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:171)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:187)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:189)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:373)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2800)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2825)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1056)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1060)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2867)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.Typer.$anonfun$48(Typer.scala:2295)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:248)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2295)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2835)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2500)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2847)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2851)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2629)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2892)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:43)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:50)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:417)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:50)
	at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:84)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:84)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:234)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1328)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:245)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:253)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:262)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:262)
	at dotty.tools.dotc.Run.compileSources(Run.scala:186)
	at dotty.tools.dotc.Run.compile(Run.scala:170)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.dotc.Driver.process(Driver.scala:195)
	at dotty.tools.dotc.Driver.process(Driver.scala:163)
	at dotty.tools.dotc.Driver.process(Driver.scala:175)
	at dotty.tools.dotc.Driver.main(Driver.scala:205)
	at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions