Skip to content

Commit 0f09be3

Browse files
Merge pull request #8410 from dotty-staging/fix-#8396
Fix #8396: Make prefixes of abstract types contribute to implicit scope
2 parents 0954a07 + 8a36f1f commit 0f09be3

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,10 @@ trait ImplicitRunInfo {
509509
/** Is `sym` an anchor type for which givens may exist? Anchor types are classes,
510510
* opaque type aliases, and abstract types, but not type parameters
511511
*/
512-
def isAnchor(sym: Symbol) = sym.isClass && !sym.is(Package) || sym.isOpaqueAlias
512+
def isAnchor(sym: Symbol) =
513+
sym.isClass && !sym.is(Package)
514+
|| sym.isOpaqueAlias
515+
|| sym.is(Deferred, butNot = Param)
513516

514517
def anchors(tp: Type): List[Type] = tp match {
515518
case tp: NamedType if isAnchor(tp.symbol) => tp :: Nil

tests/neg/quotedPatterns-4.scala renamed to tests/pos/quotedPatterns-4.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ object Test {
33
def impl(receiver: Expr[StringContext])(using qctx: scala.quoted.QuoteContext) = {
44
import qctx.tasty.Repeated
55
receiver match {
6-
case '{ StringContext(${Repeated(parts)}: _*) } => // error
6+
case '{ StringContext(${Repeated(parts)}: _*) } => // now OK
77
}
88
}
99
}

tests/run/i8396.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
trait Show[A]:
2+
def show(a: A): String = a.toString
3+
4+
object Prefix:
5+
type AbstractType
6+
type UpperBoundedType <: String
7+
type FullyBoundedType >: String <: String
8+
9+
given A as Show[AbstractType]
10+
given B as Show[UpperBoundedType]
11+
given C as Show[FullyBoundedType]
12+
13+
@main def Test =
14+
summon[Show[Prefix.AbstractType]]
15+
summon[Show[Prefix.UpperBoundedType]]
16+
summon[Show[Prefix.FullyBoundedType]]

0 commit comments

Comments
 (0)