Skip to content

Fix #7532: Do not search for ClassTag if abstract types are equal #7533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ class Typer extends Namer
* @pre We are in pattern-matching mode (Mode.Pattern)
*/
def tryWithClassTag(tree: Typed, pt: Type)(implicit ctx: Context): Tree = tree.tpt.tpe.dealias match {
case tref: TypeRef if !tref.symbol.isClass && !ctx.isAfterTyper =>
case tref: TypeRef if !tref.symbol.isClass && !ctx.isAfterTyper && !(tref =:= pt) =>
require(ctx.mode.is(Mode.Pattern))
inferImplicit(defn.ClassTagClass.typeRef.appliedTo(tref),
EmptyTree, tree.tpt.span)(ctx.retractMode(Mode.Pattern)) match {
Expand Down
18 changes: 18 additions & 0 deletions tests/pos/i7532.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

class Tasty {
type Term
type Select <: Term

given scala.reflect.ClassTag[Term] = ???
given scala.reflect.ClassTag[Select] = ???
object Select {
def unapply(x: Select): Boolean = ???
}
}

object Foo {
def impl(given tasty: Tasty): Unit = {
import tasty.{_, given}
val Select() = (??? : Term)
}
}