Skip to content

Fix #8396: Make prefixes of abstract types contribute to implicit scope #8410

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
Mar 4, 2020
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
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,10 @@ trait ImplicitRunInfo {
/** Is `sym` an anchor type for which givens may exist? Anchor types are classes,
* opaque type aliases, and abstract types, but not type parameters
*/
def isAnchor(sym: Symbol) = sym.isClass && !sym.is(Package) || sym.isOpaqueAlias
def isAnchor(sym: Symbol) =
sym.isClass && !sym.is(Package)
|| sym.isOpaqueAlias
|| sym.is(Deferred, butNot = Param)

def anchors(tp: Type): List[Type] = tp match {
case tp: NamedType if isAnchor(tp.symbol) => tp :: Nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ object Test {
def impl(receiver: Expr[StringContext])(using qctx: scala.quoted.QuoteContext) = {
import qctx.tasty.Repeated
receiver match {
case '{ StringContext(${Repeated(parts)}: _*) } => // error
case '{ StringContext(${Repeated(parts)}: _*) } => // now OK
}
}
}
16 changes: 16 additions & 0 deletions tests/run/i8396.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
trait Show[A]:
def show(a: A): String = a.toString

object Prefix:
type AbstractType
type UpperBoundedType <: String
type FullyBoundedType >: String <: String

given A as Show[AbstractType]
given B as Show[UpperBoundedType]
given C as Show[FullyBoundedType]

@main def Test =
summon[Show[Prefix.AbstractType]]
summon[Show[Prefix.UpperBoundedType]]
summon[Show[Prefix.FullyBoundedType]]