Skip to content

Commit 0b0d2f5

Browse files
Merge pull request #7093 from dotty-staging/fix-#7084
Fix #7084: Drop revealProtoOfExtMethod
2 parents a05678f + 61f15bc commit 0b0d2f5

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,13 +2494,6 @@ class Typer extends Namer
24942494
}
24952495
}
24962496

2497-
/** Reveal ignored parts of prototype when synthesizing the receiver
2498-
* of an extension method. This is necessary for pos/i5773a.scala
2499-
*/
2500-
def revealProtoOfExtMethod(tp: Type)(implicit ctx: Context): Type =
2501-
if (ctx.mode.is(Mode.SynthesizeExtMethodReceiver)) tp.deepenProto
2502-
else tp
2503-
25042497
def adaptNoArgsImplicitMethod(wtp: MethodType): Tree = {
25052498
assert(wtp.isImplicitMethod)
25062499
val tvarsToInstantiate = tvarsInParams(tree, locked).distinct
@@ -2521,7 +2514,7 @@ class Typer extends Namer
25212514
arg.tpe match {
25222515
case failed: AmbiguousImplicits =>
25232516
val pt1 = pt.deepenProto
2524-
if ((pt1 `ne` pt) && resultMatches(wtp, pt1)) implicitArgs(formals, argIndex, pt1)
2517+
if ((pt1 `ne` pt) && constrainResult(tree.symbol, wtp, pt1)) implicitArgs(formals, argIndex, pt1)
25252518
else arg :: implicitArgs(formals1, argIndex + 1, pt1)
25262519
case failed: SearchFailureType if !tree.symbol.hasDefaultParams =>
25272520
// no need to search further, the adapt fails in any case
@@ -2754,9 +2747,6 @@ class Typer extends Namer
27542747
case _ => tp
27552748
}
27562749

2757-
def resultMatches(wtp: Type, pt: Type) =
2758-
constrainResult(tree.symbol, wtp, revealProtoOfExtMethod(pt))
2759-
27602750
def adaptNoArgs(wtp: Type): Tree = {
27612751
val ptNorm = underlyingApplied(pt)
27622752
def functionExpected = defn.isFunctionType(ptNorm)
@@ -2770,7 +2760,7 @@ class Typer extends Namer
27702760
case wtp: ExprType =>
27712761
readaptSimplified(tree.withType(wtp.resultType))
27722762
case wtp: MethodType if wtp.isImplicitMethod &&
2773-
({ resMatch = resultMatches(wtp, pt); resMatch } || !functionExpected) =>
2763+
({ resMatch = constrainResult(tree.symbol, wtp, pt); resMatch } || !functionExpected) =>
27742764
if (resMatch || ctx.mode.is(Mode.ImplicitsEnabled))
27752765
adaptNoArgsImplicitMethod(wtp)
27762766
else {

compiler/test/dotc/pos-from-tasty.blacklist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ t3612.scala
66

77
# Other failure
88
t802.scala
9+
10+
# Matchtype
11+
i7087.scala

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ i939.scala
2121
typelevel0.scala
2222
matchtype.scala
2323
6322.scala
24+
i7087.scala
2425

2526
# Opaque type
2627
i5720.scala

tests/pos/i7084.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
object Test {
2+
3+
type Foo
4+
5+
given A {
6+
def (y: Any) g given Foo: Any = ???
7+
}
8+
9+
def f(x: Any) given Foo: Any = {
10+
val y = x.g
11+
y.g
12+
13+
x.g.g
14+
}
15+
}

tests/pos/i7087.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type Foo
2+
3+
type G[A]
4+
5+
type F[T] = T match {
6+
case G[a] => String
7+
}
8+
9+
given A {
10+
def (tup: T) g[T] given (Foo: F[T]) = ???
11+
}
12+
13+
def f(x: G[Int]) given (Foo: String) = x.g

0 commit comments

Comments
 (0)