From e673dd28cab7591d1fce8067b291cfe94fce0bc2 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Wed, 17 Apr 2024 16:41:05 +0200 Subject: [PATCH] Allow erased and non-erased contextual parameters in methods --- .../dotc/transform/ContextFunctionResults.scala | 5 ++--- tests/pos/i20206.scala | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 tests/pos/i20206.scala diff --git a/compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala b/compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala index 80115ca651bb..c31b2673e04a 100644 --- a/compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala +++ b/compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala @@ -4,6 +4,7 @@ package transform import core.* import Contexts.*, Symbols.*, Types.*, Annotations.*, Constants.*, Phases.* +import Decorators.* import StdNames.nme import ast.untpd import ast.tpd.* @@ -115,11 +116,9 @@ object ContextFunctionResults: else tree match case Select(qual, name) => if name == nme.apply then - qual.tpe.nn.dealias match + qual.tpe.nn.widenDealias match case defn.FunctionTypeOfMethod(mt) if mt.isContextualMethod => integrateSelect(qual, n + 1) - case _ if defn.isContextFunctionClass(tree.symbol.maybeOwner) => // for TermRefs - integrateSelect(qual, n + 1) case _ => n > 0 && contextResultCount(tree.symbol) >= n else diff --git a/tests/pos/i20206.scala b/tests/pos/i20206.scala new file mode 100644 index 000000000000..690142140d23 --- /dev/null +++ b/tests/pos/i20206.scala @@ -0,0 +1,15 @@ +//> using options -experimental -Yno-experimental + +import language.experimental.erasedDefinitions + +erased trait A +trait B + +def foo1: A ?=> B ?=> Nothing = ??? +def foo2: (A, B) ?=> Nothing = ??? +def foo3: (B, A) ?=> Nothing = ??? + +def bar: (A, B) ?=> Nothing = + foo1 + foo2 + foo3