From 83b703d51e87684ba995e0774fef17347c3ec0be Mon Sep 17 00:00:00 2001 From: odersky Date: Sun, 24 Jul 2022 10:06:43 +0200 Subject: [PATCH 1/3] Add missing dealias in isContextFunctionRef Fixes #15738 --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- tests/pos/i15738.scala | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i15738.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 1960eb69269a..a57bdd61e19d 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3704,7 +3704,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer missingArgs(wtp) } - def isContextFunctionRef(wtp: Type): Boolean = wtp match { + def isContextFunctionRef(wtp: Type): Boolean = wtp.dealias match { case RefinedType(parent, nme.apply, _) => isContextFunctionRef(parent) // apply refinements indicate a dependent CFT case _ => diff --git a/tests/pos/i15738.scala b/tests/pos/i15738.scala new file mode 100644 index 000000000000..5e8d1319bbdc --- /dev/null +++ b/tests/pos/i15738.scala @@ -0,0 +1,16 @@ +object Test { + trait Transaction + type Transactional[T] = (Transaction) ?=> T + + def ff(x: Int): Transactional[Int] = { + //summon[Transaction] + x + } + + def fff(x: Int): Transactional[Int] = { + //summon[Transaction] + val x1 = ff(x) + x1 + } + +} \ No newline at end of file From e09a1f127f215ff5faa40c2d4ea5b4173d4ac934 Mon Sep 17 00:00:00 2001 From: odersky Date: Sun, 24 Jul 2022 14:13:50 +0200 Subject: [PATCH 2/3] Fix test --- tests/pos/i15738.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/pos/i15738.scala b/tests/pos/i15738.scala index 5e8d1319bbdc..1cc2bb5a9e15 100644 --- a/tests/pos/i15738.scala +++ b/tests/pos/i15738.scala @@ -1,14 +1,14 @@ object Test { trait Transaction - type Transactional[T] = (Transaction) ?=> T + type Transactional[T] = (t: Transaction) ?=> T def ff(x: Int): Transactional[Int] = { - //summon[Transaction] + summon[Transaction] x } def fff(x: Int): Transactional[Int] = { - //summon[Transaction] + summon[Transaction] val x1 = ff(x) x1 } From b5bcb30a7d76de6843d566ef324c44fbd54b83a7 Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 25 Jul 2022 14:16:04 +0200 Subject: [PATCH 3/3] Drop redundant method It turns out the faulty method should not even have existed since it was trying to duplicate functionality defined elsewhere. --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index a57bdd61e19d..a6af5395d3f8 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3704,16 +3704,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer missingArgs(wtp) } - def isContextFunctionRef(wtp: Type): Boolean = wtp.dealias match { - case RefinedType(parent, nme.apply, _) => - isContextFunctionRef(parent) // apply refinements indicate a dependent CFT - case _ => - val underlying = wtp.underlyingClassRef(refinementOK = false) // other refinements are not OK - defn.isContextFunctionClass(underlying.classSymbol) - } - def adaptNoArgsOther(wtp: Type, functionExpected: Boolean): Tree = { - val implicitFun = isContextFunctionRef(wtp) && !untpd.isContextualClosure(tree) + val implicitFun = defn.isContextFunctionType(wtp) && !untpd.isContextualClosure(tree) def caseCompanion = functionExpected && tree.symbol.is(Module) &&