File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -581,6 +581,7 @@ object Flags {
581581 val LazyGiven : FlagSet = Given | Lazy
582582 val InlineOrProxy : FlagSet = Inline | InlineProxy // An inline method or inline argument proxy */
583583 val InlineMethod : FlagSet = Inline | Method
584+ val InlineImplicitMethod : FlagSet = Implicit | InlineMethod
584585 val InlineParam : FlagSet = Inline | Param
585586 val InlineByNameProxy : FlagSet = InlineProxy | Method
586587 val JavaEnumTrait : FlagSet = JavaDefined | Enum // A Java enum trait
Original file line number Diff line number Diff line change @@ -3939,10 +3939,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
39393939
39403940 // Reasons NOT to eta expand:
39413941 // - we reference a constructor
3942+ // - we reference an inline implicit def (see #19862)
39423943 // - we are in a pattern
39433944 // - the current tree is a synthetic apply which is not expandable (eta-expasion would simply undo that)
39443945 if arity >= 0
39453946 && ! tree.symbol.isConstructor
3947+ && ! tree.symbol.isAllOf(InlineImplicitMethod )
39463948 && ! ctx.mode.is(Mode .Pattern )
39473949 && ! (isSyntheticApply(tree) && ! functionExpected)
39483950 then
Original file line number Diff line number Diff line change 1+ import scala .language .implicitConversions
2+
3+ object Test :
4+ implicit inline def uhOh [A ](value : A ): A =
5+ compiletime.error(" Should not have been called" )
6+ def test =
7+ // Compiles because `uhOh` fails to eta-expand and we fallback to `Predef.$conforms[A, A]`
8+ summon[Function1 [Int , Int ]]
You can’t perform that action at this time.
0 commit comments